/* work/_shared/3d-shell.css — chrome shared by every /work/<kit>/3d page.
   One stylesheet (cached once) instead of 26 inline copies. Each page sets --accent.
   Layout: top bar · canvas · side panel (desktop) / bottom sheet (mobile) · instruction strip. */
:root {
  --bg: #0a0c10;
  --panel: rgba(14, 17, 23, 0.9);
  --panel-solid: #12151c;
  --line: #262b35;
  --ink: #eceef2;
  --ink-2: #b8bec9;
  --ink-3: #8b93a1;
  --ok: #7dd3a7;
  --warn: #f5c76b;
  --bad: #f19c8f;
  --accent: #60a5fa;
  --hud-w: 380px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.skip { position: fixed; left: 12px; top: -60px; z-index: 300; background: var(--panel-solid); color: var(--ink);
  padding: 10px 14px; border: 1px solid var(--accent); border-radius: 6px; text-decoration: none; }
.skip:focus { top: 12px; }

#stage3d { position: fixed; inset: 0; z-index: 0; touch-action: none; display: block; width: 100%; height: 100%; }

#loader { position: fixed; inset: 0; z-index: 100; background: #06070a; display: flex; flex-direction: column;
  gap: 14px; align-items: center; justify-content: center; transition: opacity .5s ease; }
#loader.off { opacity: 0; pointer-events: none; }
#loader .loader-text { color: var(--ink-2); font: 500 12px/1 var(--mono); letter-spacing: .22em; text-transform: uppercase; }
#loader .poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .28; filter: blur(6px) saturate(.8); z-index: -1; }
#loader .loader-text, #loader .bar { position: relative; }
#fatal .poster { width: 100%; border-radius: 6px; opacity: .9; }
#loader .bar { width: 160px; height: 2px; background: var(--line); overflow: hidden; }
#loader .bar::after { content: ''; display: block; width: 40%; height: 100%; background: var(--accent);
  animation: load 1.1s ease-in-out infinite; }
@keyframes load { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* top bar */
#topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  padding: 14px 22px; background: linear-gradient(180deg, rgba(6,7,10,.85), rgba(6,7,10,0)); pointer-events: none; }
#topbar a, #topbar button { pointer-events: auto; }
#topbar .back, #topbar .alt { font: 600 12px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; text-decoration: none;
  color: var(--ink); border: 1px solid var(--line); background: rgba(18,21,28,.8); padding: 10px 12px; border-radius: 6px;
  min-height: 40px; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
#topbar .back:hover, #topbar .alt:hover { border-color: var(--accent); color: var(--accent); }
#topbar .title { flex: 1; min-width: 0; }
#topbar .kit { display: block; font: 600 11px/1.2 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--accent); }
#topbar h1 { font-size: 17px; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* side panel / bottom sheet */
#hud { position: fixed; z-index: 15; top: 74px; right: 16px; bottom: 64px; width: var(--hud-w);
  display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line);
  border-top: 2px solid var(--accent); border-radius: 10px; backdrop-filter: blur(10px); overflow: hidden; }
#hud.collapsed #hud-body, #hud.collapsed #hotspots { display: none; }
#hud.collapsed { bottom: auto; }
#hud-toggle { align-self: flex-end; margin: 8px 8px 0; background: none; border: 1px solid var(--line); color: var(--ink-3);
  font: 600 11px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; padding: 7px 9px; border-radius: 5px; cursor: pointer; }
#hud-toggle:hover { color: var(--ink); border-color: var(--ink-3); }
#hud-body { flex: 1; overflow-y: auto; padding: 4px 18px 16px; }
#hotspots { border-top: 1px solid var(--line); padding: 10px 18px 14px; max-height: 34%; overflow-y: auto; }
#hotspots:empty { display: none; }
#howto { display: none; margin: 0 18px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
#howto summary { cursor: pointer; font: 600 11px/1.6 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
#hotspots .hs-title { font: 600 10.5px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 8px; }
#hotspots ul { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
#hotspots button { font: 500 12.5px/1.2 var(--font); color: var(--ink-2); background: rgba(255,255,255,.03);
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 11px; cursor: pointer; min-height: 32px; }
#hotspots button:hover, #hotspots button:focus-visible { color: var(--ink); border-color: var(--accent); }
#hotspots button[aria-pressed="true"] { color: var(--ink); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); }
#hotspots button:disabled { opacity: .45; cursor: default; }

/* HUD content vocabulary shared by all scenes */
.h-eyebrow { font: 600 10.5px/1.3 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); margin: 12px 0 6px; }
.h-title { font-size: 18px; font-weight: 650; line-height: 1.3; margin-bottom: 6px; }
.h-text { color: var(--ink-2); font-size: 14px; margin-bottom: 10px; }
.h-text b, .h-text strong { color: var(--ink); }
.h-quote { border-left: 2px solid var(--accent); padding: 6px 0 6px 12px; color: var(--ink); font-size: 14px; margin: 8px 0 12px; }
.h-meta { font: 500 12px/1.4 var(--mono); color: var(--ink-3); }
.h-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.h-choices { display: grid; gap: 8px; margin: 10px 0 6px; }
.h-btn { font: 500 14px/1.35 var(--font); text-align: left; color: var(--ink); background: rgba(255,255,255,.035);
  border: 1px solid var(--line); border-radius: 8px; padding: 11px 13px; cursor: pointer; min-height: 44px; width: 100%; }
.h-btn:hover:not(:disabled) { border-color: var(--accent); }
.h-btn:disabled { opacity: .5; cursor: default; }
.h-btn.primary { background: var(--accent); color: #0b0d11; border-color: var(--accent); font-weight: 650; text-align: center; }
.h-btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.h-btn.small { width: auto; min-height: 36px; padding: 8px 12px; font-size: 13px; }
.h-btn[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.h-btn .k { display: block; font: 600 10.5px/1.2 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 3px; }
.h-fb { border: 1px solid var(--line); border-left: 3px solid var(--ink-3); border-radius: 6px; padding: 10px 12px; margin: 10px 0; font-size: 14px; color: var(--ink-2); }
.h-fb.ok { border-left-color: var(--ok); }
.h-fb.warn { border-left-color: var(--warn); }
.h-fb.bad { border-left-color: var(--bad); }
.h-fb b { color: var(--ink); }
.h-meter { margin: 8px 0; }
.h-meter .lbl { display: flex; justify-content: space-between; font: 500 12px/1.3 var(--mono); color: var(--ink-3); margin-bottom: 4px; }
.h-meter .lbl b { color: var(--ink); font-weight: 600; }
.h-meter .track { height: 6px; background: rgba(255,255,255,.07); border-radius: 3px; overflow: hidden; }
.h-meter .fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s ease; }
.h-steps { display: flex; gap: 4px; margin: 6px 0 10px; }
.h-steps span { flex: 1; height: 4px; border-radius: 2px; background: rgba(255,255,255,.1); }
.h-steps span.done { background: var(--accent); }
.h-steps span.now { background: color-mix(in srgb, var(--accent) 50%, #fff 0%); outline: 1px solid var(--accent); }
.h-list { list-style: none; display: grid; gap: 6px; margin: 8px 0; }
.h-list li { font-size: 13.5px; color: var(--ink-2); padding-left: 14px; position: relative; }
.h-list li::before { content: ''; position: absolute; left: 0; top: .6em; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); }
.h-list li.ok::before { background: var(--ok); } .h-list li.bad::before { background: var(--bad); } .h-list li.warn::before { background: var(--warn); }
.h-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0; }
.h-table th, .h-table td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.h-table th { font: 600 10.5px/1.2 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.h-field { width: 100%; background: rgba(0,0,0,.25); border: 1px solid var(--line); border-radius: 6px; color: var(--ink);
  font: 14px/1.4 var(--font); padding: 9px 10px; }
label.h-lbl { display: block; font: 600 11px/1.3 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin: 10px 0 5px; }
.tag { display: inline-block; font: 600 10.5px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; padding: 4px 7px; border-radius: 4px;
  border: 1px solid var(--line); color: var(--ink-2); }
.tag.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
.tag.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.tag.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, transparent); }

/* caption + instructions */
#why3d { position: fixed; left: 22px; bottom: 60px; z-index: 12; max-width: min(520px, calc(100vw - var(--hud-w) - 70px)); display: none;
  font-size: 12.5px; font-style: italic; color: var(--ink-3); text-shadow: 0 1px 3px #000; }
.instructions { position: fixed; bottom: 0; left: 0; right: 0; z-index: 14; background: rgba(10,12,16,.88);
  border-top: 1px solid var(--line); padding: 11px 22px; font-size: 13px; line-height: 1.45; color: var(--ink-2); backdrop-filter: blur(8px); }
.instructions strong { color: var(--accent); font: 600 11px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; margin-right: 6px; }

/* toast */
#toast { position: fixed; left: calc((100vw - var(--hud-w)) / 2); bottom: 88px; transform: translate(-50%, 8px); z-index: 60;
  background: rgba(17,20,26,.96); border: 1px solid var(--line); border-left: 3px solid var(--accent); color: var(--ink);
  padding: 11px 16px; font: 500 14px/1.4 var(--font); border-radius: 6px; max-width: min(460px, 90vw);
  opacity: 0; transition: opacity .25s ease, transform .25s ease; pointer-events: none; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#toast[data-tone="bad"] { border-left-color: var(--bad); }
#toast[data-tone="ok"] { border-left-color: var(--ok); }
#toast[data-tone="warn"] { border-left-color: var(--warn); }

/* dialogs */
.dlg-backdrop { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  background: rgba(4,5,7,.62); backdrop-filter: blur(3px); padding: 16px; }
.dlg { position: relative; background: var(--panel-solid); border: 1px solid var(--line); border-top: 3px solid var(--accent);
  color: var(--ink); padding: 26px 28px 24px; width: min(560px, 100%); max-height: 86vh; overflow: auto; border-radius: 10px; }
.dlg.wide { width: min(760px, 100%); }
.dlg:focus { outline: none; }
.dlg-close { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border-radius: 6px; border: 1px solid var(--line);
  background: none; color: var(--ink-2); font-size: 20px; line-height: 1; cursor: pointer; }
.dlg-close:hover { color: var(--ink); border-color: var(--ink-3); }
.dlg h2, .dlg h3 { font-size: 20px; line-height: 1.3; margin: 0 40px 10px 0; }
.dlg p { color: var(--ink-2); margin: 0 0 10px; }
.dlg p b, .dlg p strong { color: var(--ink); }

@media (max-width: 767px) {
  #topbar { padding: 10px 12px; gap: 8px; }
  #topbar h1 { font-size: 14px; }
  #topbar .kit { font-size: 10px; }
  #topbar .back, #topbar .alt { padding: 8px 9px; font-size: 10.5px; min-height: 36px; }
  #hud { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 46vh; border-radius: 12px 12px 0 0; border-left: 0; border-right: 0; }
  #hud.collapsed { max-height: 48px; }
  #hotspots { max-height: 30%; }
  #why3d { display: none !important; }
  .instructions { display: none; }
  #howto { display: block; }
  #toast { left: 50%; bottom: calc(46vh + 12px); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
