/* Zoom — powers of ten. Deep-space HUD, display serif, quiet film chrome. */
:root {
  --bg: #05060d;
  --ink: #f3f2ff;
  --body: rgba(212, 218, 242, 0.8);
  --muted: rgba(170, 178, 214, 0.62);
  --faint: rgba(170, 178, 214, 0.32);
  --amber: #ffb766;
  --amber-2: #ffd29a;
  --cyan: #6fd8ff;
  --magenta: #ff5cb8;
  --serif: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --vh: 100vh;
}
@supports (height: 100svh) { :root { --vh: 100svh; } }

* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
a { color: inherit; }
a:focus-visible, button:focus-visible { outline: 1px solid var(--amber); outline-offset: 5px; border-radius: 2px; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* ---------- stage ---------- */
#gl, #fx {
  position: fixed; left: 0; top: 0; width: 100vw; height: 100vh; height: 100lvh;
  display: block; pointer-events: none;
}
#gl { z-index: 0; background: var(--bg); }
#fx { z-index: 1; }
.frame { position: fixed; inset: 16px; z-index: 2; pointer-events: none; }
.frame i { position: absolute; width: 14px; height: 14px; border-color: rgba(220, 226, 255, 0.28); border-style: solid; border-width: 0; }
.frame i:nth-child(1) { left: 0; top: 0; border-left-width: 1px; border-top-width: 1px; }
.frame i:nth-child(2) { right: 0; top: 0; border-right-width: 1px; border-top-width: 1px; }
.frame i:nth-child(3) { left: 0; bottom: 0; border-left-width: 1px; border-bottom-width: 1px; }
.frame i:nth-child(4) { right: 0; bottom: 0; border-right-width: 1px; border-bottom-width: 1px; }

/* ---------- top bar ---------- */
.top {
  position: fixed; left: 0; right: 0; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 30px 40px 0; pointer-events: none;
}
.top a { pointer-events: auto; text-decoration: none; }
.brand { display: flex; flex-direction: column; gap: 5px; }
.b1 { font: 500 11px/1 var(--mono); letter-spacing: 0.24em; text-transform: uppercase; color: var(--ink); }
.b2 { font: italic 400 16px/1 var(--serif); color: var(--muted); letter-spacing: 0.01em; }

/* ---------- chapter map ---------- */
.map { position: fixed; right: 34px; top: 50%; transform: translateY(-50%); z-index: 10; }
.map ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; align-items: flex-end; }
.map a { display: flex; align-items: center; gap: 10px; padding: 4px 0; text-decoration: none; font: 400 10px/1 var(--mono); letter-spacing: 0.14em; color: var(--faint); }
.map .t { order: 0; text-transform: uppercase; opacity: 0; transform: translateX(8px); transition: opacity 0.35s, transform 0.45s cubic-bezier(.2, .7, .2, 1); white-space: nowrap; color: var(--ink); }
.map .n { order: 1; width: 18px; text-align: right; transition: color 0.3s; }
.map a::after { content: ""; order: 2; width: 18px; height: 1px; background: currentColor; transform-origin: right; transform: scaleX(0.45); transition: transform 0.45s cubic-bezier(.2, .7, .2, 1), background 0.3s; }
.map a:hover .t, .map a:focus-visible .t { opacity: 0.9; transform: none; }
.map a:hover, .map a:focus-visible { color: var(--ink); }
.map a.on { color: var(--amber); }
.map a.on::after { transform: scaleX(1.6); background: var(--amber); }
.map a.on .t { opacity: 1; transform: none; color: var(--amber-2); }
.map a.done { color: rgba(200, 206, 240, 0.5); }

/* ---------- scale readout ---------- */
.scale { position: fixed; right: 40px; bottom: 34px; z-index: 10; width: 250px; pointer-events: none; text-align: right; }
.sc-k { font: 500 10px/1 var(--mono); letter-spacing: 0.26em; text-transform: uppercase; color: var(--faint); }
.sc-v { font: 400 54px/1 var(--serif); color: var(--ink); margin-top: 6px; display: flex; justify-content: flex-end; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums; }
.sc-e { letter-spacing: -0.01em; }
.sc-u { font: italic 400 26px/1 var(--serif); color: var(--muted); }
.sc-s { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; font: 400 10.5px/1.3 var(--mono); letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; }
.sc-a { color: var(--amber-2); text-transform: none; letter-spacing: 0.04em; }
.sc-r { position: relative; height: 16px; margin-top: 12px; }
.sc-t { position: absolute; inset: 0; background-image: linear-gradient(to right, rgba(210, 216, 255, 0.35) 1px, transparent 1px); background-size: calc(100% / 17) 5px; background-repeat: repeat-x; background-position: 0 100%; border-bottom: 1px solid rgba(210, 216, 255, 0.18); }
.sc-t::before, .sc-t::after { position: absolute; top: -2px; font: 400 9px/1 var(--mono); color: var(--faint); letter-spacing: 0.08em; }
.sc-t::before { content: "10\207B\00B9\2070"; left: 0; }
.sc-t::after { content: "10\2077"; right: 0; }
.sc-m { position: absolute; left: 0; bottom: -3px; width: 2px; height: 13px; background: var(--amber); box-shadow: 0 0 10px var(--amber); transform: translateX(0); will-change: transform; }
.stats { position: fixed; left: 40px; bottom: 34px; z-index: 10; font: 400 10px/1 var(--mono); letter-spacing: 0.16em; text-transform: uppercase; color: var(--faint); pointer-events: none; font-variant-numeric: tabular-nums; }
.beat {
  position: fixed; left: 0; right: 0; bottom: 15vh; z-index: 9; margin: 0; text-align: center; pointer-events: none;
  font: italic 400 clamp(28px, 3.4vw, 46px)/1.1 var(--serif); color: var(--ink); opacity: 0;
  text-shadow: 0 0 30px rgba(5, 6, 13, 0.9), 0 0 60px rgba(5, 6, 13, 0.8);
}

/* ---------- chapters ---------- */
#story { position: relative; z-index: 5; }
.ch { position: relative; height: 190vh; }
.pin { position: sticky; top: 0; height: 100vh; height: var(--vh); pointer-events: none; }
.panel {
  position: absolute; left: clamp(28px, 7vw, 132px); top: 50%;
  width: min(31rem, 38vw); transform: translateY(-50%);
  pointer-events: auto; will-change: opacity;
}
.panel::before {
  content: ""; position: absolute; z-index: -1; left: -45%; right: -35%; top: -30%; bottom: -30%;
  background: radial-gradient(closest-side, rgba(5, 6, 13, 0.82), rgba(5, 6, 13, 0.55) 55%, rgba(5, 6, 13, 0));
  pointer-events: none;
}
.kicker {
  display: flex; align-items: center; gap: 12px; margin: 0;
  font: 500 11px/1 var(--mono); letter-spacing: 0.24em; text-transform: uppercase; color: var(--amber);
}
.kicker .num { color: var(--muted); }
.kicker::after { content: ""; width: 56px; height: 1px; background: currentColor; opacity: 0.55; }
h1, h2, .h1like {
  font-family: var(--serif); font-weight: 400; color: var(--ink);
  font-size: clamp(46px, 5.3vw, 88px); line-height: 0.97; letter-spacing: -0.015em;
  margin: 22px 0 22px; text-wrap: balance;
  text-shadow: 0 0 40px rgba(5, 6, 13, 0.8);
}
h1 em, h2 em, .h1like em { font-style: italic; color: var(--amber-2); }
.hero h1, .hero .h1like { font-size: clamp(54px, 6.6vw, 112px); }
.body { margin: 0; font-size: 16.5px; line-height: 1.64; color: var(--body); max-width: 28rem; text-shadow: 0 0 18px rgba(5, 6, 13, 0.9); }
.body code, .body b.bit { font: 500 0.88em var(--mono); color: var(--cyan); background: rgba(111, 216, 255, 0.08); padding: 1px 5px; border-radius: 3px; }
.body b.bit { color: var(--amber-2); background: rgba(255, 183, 102, 0.1); }
.facts { list-style: none; display: flex; flex-wrap: wrap; gap: 18px 34px; margin: 30px 0 0; padding: 22px 0 0; border-top: 1px solid rgba(210, 216, 255, 0.12); }
.facts li { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.facts b { font: 400 30px/1 var(--serif); color: var(--ink); font-weight: 400; white-space: nowrap; }
.facts b.url { font: 400 15px/1.3 var(--mono); color: var(--cyan); white-space: normal; word-break: break-all; }
.facts span { font: 500 9.5px/1.35 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); max-width: 14em; }
.hint { display: flex; align-items: center; gap: 14px; margin: 38px 0 0; font: 500 10.5px/1 var(--mono); letter-spacing: 0.24em; text-transform: uppercase; color: var(--muted); }
.hint-line { position: relative; width: 1px; height: 38px; background: rgba(210, 216, 255, 0.18); overflow: hidden; }
.hint-line::after { content: ""; position: absolute; left: 0; top: 0; width: 1px; height: 14px; background: var(--amber); animation: drip 2.2s cubic-bezier(.5, 0, .3, 1) infinite; }
@keyframes drip { from { transform: translateY(-14px); } to { transform: translateY(38px); } }

/* truth table */
.tt-wrap { position: relative; margin-top: 26px; width: 15rem; }
.tt { border-collapse: collapse; width: 100%; font: 400 13px/1 var(--mono); color: var(--body); position: relative; z-index: 1; }
.tt th { font: 500 9.5px/1 var(--mono); letter-spacing: 0.16em; color: var(--muted); text-align: left; padding: 0 0 10px; border-bottom: 1px solid rgba(210, 216, 255, 0.14); }
.tt td { padding: 8px 0 7px; height: 30px; }
.tt td:last-child, .tt th:last-child { color: var(--amber-2); }
.tt-bar { position: absolute; left: -10px; right: -10px; top: 28px; height: 30px; background: linear-gradient(90deg, rgba(255, 183, 102, 0.16), rgba(255, 183, 102, 0.04)); border-left: 2px solid var(--amber); transform: translateY(0); transition: transform 0.35s cubic-bezier(.2, .7, .2, 1); }

/* loop */
.again-row { gap: 18px; }
.again {
  position: relative; font: 500 10.5px/1 var(--mono); letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--ink); background: rgba(255, 183, 102, 0.08); border: 1px solid rgba(255, 183, 102, 0.45);
  padding: 12px 18px; border-radius: 999px; cursor: pointer; transition: background 0.3s, border-color 0.3s;
}
.again:hover { background: rgba(255, 183, 102, 0.18); border-color: var(--amber); }
.again-bar { display: block; width: 90px; height: 1px; background: var(--amber); transform: scaleX(0); transform-origin: left; opacity: 0.8; }
.nojs { position: fixed; bottom: 20px; left: 20px; right: 20px; z-index: 20; font: 13px var(--mono); color: var(--muted); }

/* ---------- small screens: stage above, text below ---------- */
@media (max-width: 760px), (max-aspect-ratio: 4/5) {
  .top { padding: 18px 20px 0; }
  .b1 { font-size: 9.5px; letter-spacing: 0.2em; }
  .b2 { font-size: 13px; }
  .frame { inset: 10px; }
  .map { right: auto; left: 20px; top: auto; bottom: auto; top: 64px; transform: none; }
  .map ol { flex-direction: row; gap: 5px; }
  .map a { padding: 6px 0; }
  .map .n, .map .t { display: none; }
  .map a::after { width: 12px; height: 2px; transform: scaleX(0.6); transform-origin: center; }
  .map a.on::after { transform: scaleX(1.4); }
  .scale { right: 20px; top: 88px; bottom: auto; width: 150px; }
  .sc-k { display: none; }
  .sc-v { font-size: 30px; margin-top: 0; }
  .sc-u { font-size: 17px; }
  .sc-s { font-size: 8.5px; flex-direction: column; gap: 3px; align-items: flex-end; }
  .sc-r { display: none; }
  .stats { display: none; }
  .panel {
    left: 20px; right: 20px; width: auto; top: auto; bottom: max(26px, env(safe-area-inset-bottom));
    transform: none;
  }
  .panel::before { left: -20px; right: -20px; top: -60px; bottom: -40px; background: linear-gradient(to bottom, rgba(5, 6, 13, 0), rgba(5, 6, 13, 0.86) 70px, rgba(5, 6, 13, 0.94)); }
  h1, h2, .h1like { font-size: clamp(34px, 9.6vw, 48px); margin: 14px 0 12px; }
  .hero h1, .hero .h1like { font-size: clamp(40px, 11.5vw, 56px); }
  .body { font-size: 14.5px; line-height: 1.55; }
  .facts { margin-top: 16px; padding-top: 14px; gap: 12px 22px; }
  .facts b { font-size: 22px; }
  .facts span { font-size: 8.5px; }
  .hint { margin-top: 20px; }
  .hint-line { height: 24px; }
  .tt-wrap { margin-top: 14px; width: 12rem; }
  .tt td { padding: 4px 0 3px; height: 22px; }
  .tt-bar { height: 22px; top: 23px; }
  .beat { bottom: auto; top: 46%; font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  .hint-line::after { animation: none; transform: translateY(12px); }
  .tt-bar, .map .t, .map a::after { transition: none; }
}

/* debug capture mode (?debug): panels pinned in place, scroll is virtual */
.dbg .pin { position: fixed; left: 0; right: 0; top: 0; }
