/* 3D sheet rack viewport with HUD overlays. */
.scene { position: relative; aspect-ratio: 5 / 4.4; min-height: 420px; border: 1px solid var(--line-2); border-radius: 20px; overflow: hidden; background: var(--scene-bg); box-shadow: var(--shadow-deep), 0 0 0 1px var(--overlay-1) inset; isolation: isolate; }
.scene__canvas { position: absolute; inset: 0; cursor: grab; touch-action: pan-y; }
.scene__canvas:active { cursor: grabbing; }
.scene__canvas canvas { width: 100% !important; height: 100% !important; }

.scene__hud { position: absolute; z-index: 2; display: flex; flex-wrap: wrap; gap: 8px; pointer-events: none; }
.scene__hud--top { top: 16px; left: 16px; right: 64px; justify-content: space-between; }

.scene-card { position: absolute; z-index: 2; top: 60px; right: 16px; width: 210px; padding: 14px 16px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--glass-2); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: var(--shadow-hud); transition: border-color .3s, transform .3s var(--ease); overflow-wrap: anywhere; }
.scene-card.is-active { border-color: var(--accent-border); }
.scene-card__eyebrow { color: var(--muted); font-family: var(--font-mono); font-size: .64rem; letter-spacing: .14em; text-transform: uppercase; }
.scene-card__loc { margin-top: 2px; font-family: var(--font-mono); font-size: 1.25rem; font-weight: 700; letter-spacing: .02em; color: var(--text); }
.scene-card__material { display: flex; align-items: center; gap: 8px; margin-top: 4px; color: var(--text-2); font-size: .85rem; font-weight: 600; }
.scene-card__stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--line); }
.scene-card__stats dt { color: var(--muted); font-size: .66rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.scene-card__stats dd { margin: 0; font-family: var(--font-mono); font-size: .88rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.scene-card__sync { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--green); font-size: .74rem; font-weight: 600; }

.scene-feed { position: absolute; z-index: 2; left: 16px; bottom: 64px; display: grid; gap: 6px; width: min(340px, calc(100% - 260px)); margin: 0; padding: 0; list-style: none; pointer-events: none; }
.scene-feed li { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; background: var(--glass-3); border: 1px solid var(--line); color: var(--text-2); font-size: .74rem; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); animation: feed-in .5s var(--ease); }
.scene-feed li:nth-child(2) { opacity: .7; }
.scene-feed li:nth-child(3) { opacity: .4; }
.scene-feed b { margin-right: 6px; color: var(--accent); font-family: var(--font-mono); font-weight: 700; }
@keyframes feed-in { from { opacity: 0; transform: translateY(8px); } }

.scene__filters { position: absolute; z-index: 2; left: 16px; right: 16px; bottom: 16px; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.scene__filters::-webkit-scrollbar { display: none; }
.filter-chip { display: inline-flex; align-items: center; gap: 7px; flex: none; min-height: 34px; padding: 6px 12px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--glass-3); color: var(--text-2); font-size: .78rem; font-weight: 600; cursor: pointer; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: all .18s; }
.filter-chip:hover { color: var(--text); border-color: var(--overlay-7); }
.filter-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.scene__hint { position: absolute; z-index: 1; left: 18px; top: 54px; color: var(--overlay-6); font-family: var(--font-mono); font-size: .64rem; letter-spacing: .08em; text-transform: uppercase; pointer-events: none; transition: opacity .6s; }
.scene.is-touched .scene__hint { opacity: 0; }

.scene__fallback { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; padding: 40px; background: repeating-linear-gradient(0deg, var(--overlay-1) 0 2px, transparent 2px 22px), var(--panel); text-align: center; color: var(--text-2); }
.scene__fallback[hidden] { display: none; }

.scene-card--left { right: auto; left: 16px; }
.scene-feed--right { left: auto; right: 16px; bottom: 16px; width: min(380px, calc(100% - 32px)); }
.scene__hint--right { left: auto; right: 18px; }
.scene--bender { aspect-ratio: 5 / 4; container-type: inline-size; }
/* Narrow bender viewports (any screen size): status card becomes a bottom strip so the machine stays visible */
@container (max-width: 720px) {
    .scene--bender .scene-card { top: auto; left: 12px; right: 12px; bottom: 12px; width: auto; padding: 10px 12px; }
    .scene--bender .scene-card__eyebrow, .scene--bender .scene-card__sync { display: none; }
    .scene--bender .scene-card__loc { margin: 0; font-size: 1rem; }
    .scene--bender .scene-card__material { margin: 0; font-size: .78rem; }
    .scene--bender .scene-card__stats { grid-template-columns: repeat(4, auto); justify-content: space-between; margin-top: 8px; padding-top: 8px; }
    .scene--bender .scene-feed { display: none; }
}
.badge--experimental { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }

@media (max-width: 640px) {
    .scene-card--left { left: 12px; right: 12px; bottom: 12px; }
    .scene--bender .scene-feed { display: none; }
    .scene { aspect-ratio: auto; height: 520px; }
    .scene-card { top: auto; left: 12px; right: 12px; bottom: 60px; width: auto; padding: 10px 12px; }
    .scene-card__eyebrow, .scene-card__sync { display: none; }
    .scene-card__loc { margin: 0; font-size: 1rem; }
    .scene-card__material { margin: 0; font-size: .78rem; }
    .scene-card__stats { grid-template-columns: repeat(4, auto); justify-content: space-between; margin-top: 8px; padding-top: 8px; }
    .scene-card__stats dd { font-size: .78rem; }
    .scene-feed { display: none; }
    .scene__hint { display: none; }
}

/* Expand to full screen: the scene takes every gesture (one-finger orbit, pinch, twist) */
.scene__expand { position: absolute; z-index: 4; top: 14px; right: 14px; display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--glass-2); color: var(--text); cursor: pointer; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: border-color .2s, background .2s; }
.scene__expand:hover { border-color: var(--accent); }
.scene__expand svg { width: 18px; height: 18px; }
/* !important: full screen must beat every page's own sizing of its scene (.wh-scene .scene, .fpx-3d .scene, ...). */
.scene.is-expanded { position: fixed !important; inset: 0 !important; z-index: 200; width: 100vw !important; height: 100vh !important; height: 100dvh !important; min-height: 0 !important; max-height: none !important; aspect-ratio: auto !important; border: 0; border-radius: 0 !important; }
.scene.is-expanded .scene__expand { top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); width: 48px; height: 48px; background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.scene.is-expanded .scene__hud--top { top: max(16px, env(safe-area-inset-top)); }
body.scene-open { overflow: hidden; }
body.scene-open .topbar, body.scene-open .sidebar { visibility: hidden; }

.scene__touch-hint, .scene__expanded-hint { position: absolute; z-index: 1; left: 50%; translate: -50% 0; margin: 0; padding: 6px 12px; border-radius: 999px; background: var(--glass-3); color: var(--text-2); font-family: var(--font-mono); font-size: .64rem; letter-spacing: .04em; white-space: nowrap; pointer-events: none; transition: opacity .6s; }
.scene__touch-hint { top: 44%; display: none; }
.scene__expanded-hint { bottom: max(24px, env(safe-area-inset-bottom)); display: none; }
@media (pointer: coarse) {
    .scene__touch-hint { display: block; }
    .scene__hint { display: none; }
}
.scene.is-touched .scene__touch-hint { opacity: 0; }
.scene.is-expanded .scene__touch-hint { display: none; }
.scene.is-expanded .scene__expanded-hint { display: block; animation: hint-fade 4s ease forwards; }
@keyframes hint-fade { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

/* atomshapr additions ------------------------------------------------------------------------- */
.scene--fill { aspect-ratio: auto; height: calc(100vh - var(--header-h) - 220px); min-height: 480px; }
.scene--preview { aspect-ratio: auto; height: 100%; min-height: 360px; border-radius: 14px; }
.scene-card[hidden] { display: none; }
.scene-card__type { margin-top: 4px; color: var(--text-2); font-size: .85rem; font-weight: 600; }
.scene-empty { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; padding: 32px; text-align: center; }
.scene-empty .empty { max-width: 420px; background: var(--glass-2); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.scene-warning { align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 14px; }
.scene-card { pointer-events: auto; }

/* Legend + fly-to (floor-scene-view): every machine, rack and bin, one tap to jump the camera to it. */
.scene__nav { position: absolute; z-index: 3; top: 56px; left: 16px; display: flex; gap: 6px; }
.scene__nav .filter-chip { min-height: 38px; }
.scene__nav [data-legend-toggle][aria-expanded="true"] { border-color: var(--accent-border); color: var(--text); }
.scene-legend { position: absolute; z-index: 3; top: 104px; left: 16px; bottom: 64px; display: flex; flex-direction: column; gap: 8px; width: 250px; padding: 10px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--glass-2); box-shadow: var(--shadow-hud); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); animation: rise .18s var(--ease); }
.scene-legend[hidden] { display: none; }
.scene-legend__search { width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); font-size: .85rem; }
.scene-legend__search::placeholder { color: var(--placeholder); }
.scene-legend__search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.scene-legend__list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.scene-legend__group { margin: 10px 4px 4px; color: var(--muted); font-family: var(--font-mono); font-size: .64rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.scene-legend__group:first-child { margin-top: 2px; }
.scene-legend__item { align-items: baseline; justify-content: space-between; gap: 8px; color: var(--text); font-size: .86rem; font-weight: 650; }
.scene-legend__item small { overflow: hidden; color: var(--muted); font-size: .74rem; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.scene-legend__bin:focus-visible { outline-offset: -2px; }
.scene-legend__rack.is-open > .scene-legend__item { background: var(--overlay-2); }
.scene-legend__rack.is-open > .scene-legend__item[aria-current="true"] { background: var(--accent-soft); }
.scene-legend__bins { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 4px 10px 10px; }
.scene-legend__bin { min-height: 36px; padding: 4px 9px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--bg-2); color: var(--text-2); font-size: .74rem; font-weight: 600; cursor: pointer; transition: border-color .15s, color .15s; }
.scene-legend__bin:hover { border-color: var(--accent-border); color: var(--text); }
.scene-legend__bin[aria-current="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.scene-legend__bins .link-arrow { font-size: .8rem; }
.scene-legend__empty { margin: 12px 6px; color: var(--muted); font-size: .84rem; }
.scene.is-expanded .scene__nav { top: calc(max(16px, env(safe-area-inset-top)) + 40px); }
@media (max-width: 640px) {
    .scene-legend { right: 12px; left: 12px; bottom: auto; max-height: 52%; width: auto; }
    .scene.has-legend .scene-card { display: none; }
}
