:root {
  --vh: 1vh;
  --bar: 46px;
  --bg: #07080d;
  --ink: #e9e7e1;
  --ink-2: #a9a8a3;
  --ink-3: #6f6f75;
  --plate: rgba(7, 8, 13, 0.72);
  --plate-line: rgba(255, 255, 255, 0.08);
  --line: #f4f1ea;           /* the critical line, the staircase */
  --curve: #f2b54a;          /* Gauss's smooth curve */
  --band: rgba(242, 181, 74, 0.16);
  --band-2: rgba(232, 92, 120, 0.18);
  --hot: #ff6b8b;            /* the stray zero */
  --cool: #6fd3ff;
  --grid: rgba(255, 255, 255, 0.07);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Charter, "Bitstream Charter", Georgia, serif;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", system-ui, sans-serif;
  --to-top-bg: #07080d;
  --to-top-fg: #e9e7e1;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f3f2ee;
  --ink: #16161c;
  --ink-2: #4a4a52;
  --ink-3: #7c7c84;
  --plate: rgba(243, 242, 238, 0.86);
  --plate-line: rgba(0, 0, 0, 0.08);
  --line: #16161c;
  --curve: #b8650a;
  --band: rgba(184, 101, 10, 0.14);
  --band-2: rgba(200, 40, 80, 0.13);
  --hot: #c8224f;
  --cool: #0b6f9c;
  --grid: rgba(0, 0, 0, 0.07);
  --to-top-bg: #f3f2ee;
  --to-top-fg: #16161c;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f2ee; --ink: #16161c; --ink-2: #4a4a52; --ink-3: #7c7c84;
    --plate: rgba(243, 242, 238, 0.86); --plate-line: rgba(0, 0, 0, 0.08);
    --line: #16161c; --curve: #b8650a; --band: rgba(184, 101, 10, 0.14); --band-2: rgba(200, 40, 80, 0.13);
    --hot: #c8224f; --cool: #0b6f9c; --grid: rgba(0, 0, 0, 0.07);
    --to-top-bg: #f3f2ee; --to-top-fg: #16161c;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { 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: 400 1.125rem/1.6 var(--serif);
  font-feature-settings: "onum" 1, "kern" 1;
  overflow-x: hidden;
}
a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); text-underline-offset: 0.18em; }
a:hover { text-decoration-color: currentColor; }
i, em { font-style: italic; }
sup { line-height: 0; }
.skip { position: absolute; left: -9999px; top: 0; z-index: 50; background: var(--ink); color: var(--bg); padding: 0.5rem 1rem; }
.skip:focus { left: 1rem; top: 0.5rem; }
:focus-visible { outline: 2px solid var(--cool); outline-offset: 3px; }

/* ── top bar ───────────────────────────────────────────── */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  height: calc(var(--bar) + var(--browser-safe-top, env(safe-area-inset-top)));
  padding: var(--browser-safe-top, env(safe-area-inset-top)) clamp(0.75rem, 3vw, 1.5rem) 0;
  display: flex; align-items: center; gap: 1.25rem;
  font: 500 0.8125rem/1 var(--sans); letter-spacing: 0.01em;
  color: var(--ink-2);
  background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 88%, transparent), color-mix(in srgb, var(--bg) 0%, transparent));
  transition: background 0.4s;
}
.topbar.solid { background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--plate-line); }
.topbar a { text-decoration: none; }
.topbar .home { color: var(--ink); white-space: nowrap; }
.topnav { display: flex; gap: 1.1rem; overflow-x: auto; scrollbar-width: none; white-space: nowrap; transition: opacity 0.3s; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a:hover { color: var(--ink); }
.topbar.in-story .topnav { opacity: 0; pointer-events: none; }
.spacer { flex: 1; }
.chip.lang { padding: 6px 10px; border: 1px solid var(--plate-line); border-radius: 999px; color: var(--ink-2); white-space: nowrap; }
.chip.lang:hover { color: var(--ink); }
.icon-btn { width: 44px; height: 44px; margin-right: -10px; border: 0; background: none; color: var(--ink-2); display: grid; place-items: center; cursor: pointer; border-radius: 50%; }
.icon-btn:hover { color: var(--ink); }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.icon-btn .i-moon { fill: currentColor; stroke: none; }
:root .i-sun { display: none; }
:root[data-theme="light"] .i-sun { display: block; } :root[data-theme="light"] .i-moon { display: none; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .i-sun { display: block; } :root:not([data-theme="dark"]) .i-moon { display: none; } }

/* ── stage ─────────────────────────────────────────────── */
.stage { position: fixed; inset: 0; z-index: 0; background: var(--bg); overflow: hidden; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#c2 { pointer-events: none; transition: opacity 0.6s; }
#gl { transition: opacity 0.9s; }
.fallback { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hud { position: absolute; inset: 0; pointer-events: none; font: 500 0.75rem/1.3 var(--sans); color: var(--ink-2); }
.hud .tag { position: absolute; transform: translate(-50%, -100%); white-space: nowrap; padding: 2px 6px; border-radius: 3px; background: color-mix(in srgb, var(--bg) 60%, transparent); transition: opacity 0.5s; }
.hud .tag.left { transform: translate(0, -50%); }
.hud .legend { position: absolute; display: flex; gap: 1rem; flex-wrap: wrap; }
.hud .legend span::before { content: ""; display: inline-block; width: 14px; height: 2px; margin-right: 6px; vertical-align: middle; background: currentColor; }
.hud .big { font: 400 clamp(1.4rem, 3vw, 2.2rem)/1.1 var(--serif); color: var(--ink); font-variant-numeric: lining-nums tabular-nums; }

.ctl {
  position: absolute; z-index: 5; display: flex; align-items: center; flex-wrap: wrap; gap: 0.6rem 0.9rem;
  padding: 0.7rem 0.9rem; border-radius: 10px; background: var(--plate); border: 1px solid var(--plate-line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  font: 500 0.8125rem/1.2 var(--sans); color: var(--ink-2);
}
.ctl[hidden] { display: none; }
.ctl label { min-width: 7.5em; font-variant-numeric: tabular-nums; color: var(--ink); }
.ctl input[type=range] { flex: 1 1 10rem; min-width: 8rem; accent-color: var(--curve); height: 28px; }
.btn { font: inherit; color: var(--bg); background: var(--ink); border: 0; border-radius: 999px; padding: 0 1rem; min-height: 36px; cursor: pointer; white-space: nowrap; }
.btn.ghost { background: none; color: var(--ink); border: 1px solid color-mix(in srgb, var(--ink) 30%, transparent); }
#nz-sound { width: 40px; padding: 0; display: grid; place-items: center; }
#nz-sound svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
#nz-sound svg path:first-child { fill: currentColor; stroke: none; }
#nz-sound .w1, #nz-sound .w2 { display: none; }
#nz-sound[data-on] .w1, #nz-sound[data-on] .w2 { display: inline; }
#nz-sound[data-on] .x { display: none; }

/* ── story ─────────────────────────────────────────────── */
main { position: relative; z-index: 2; }
.hero {
  min-height: calc(var(--vh) * 100);
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: calc(var(--bar) + 1.5rem) clamp(1rem, 6vw, 6rem) calc(var(--vh) * 8);
  max-width: 48rem;
}
.kicker { font: 600 0.75rem/1 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2); margin: 0 0 1.1rem; }
h1 { font: 400 clamp(3rem, 8.2vw, 7.2rem)/0.92 var(--serif); letter-spacing: -0.025em; margin: 0 0 1.6rem; text-wrap: balance; }
.dek { font-size: clamp(1.1rem, 1.6vw, 1.32rem); line-height: 1.5; max-width: 34rem; margin: 0 0 1rem; text-wrap: pretty; }
.hero-note { font: 400 0.875rem/1.5 var(--sans); color: var(--ink-2); max-width: 30rem; margin: 0; }
.cue { font: 500 0.6875rem/1 var(--sans); letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-3); margin: 2.5rem 0 0; }
.cue::after { content: ""; display: block; width: 1px; height: 40px; margin-top: 10px; background: linear-gradient(var(--ink-3), transparent); animation: cue 2.4s ease-in-out infinite; transform-origin: top; }
@keyframes cue { 0%, 100% { transform: scaleY(0.3); opacity: 0.4; } 50% { transform: scaleY(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .cue::after { animation: none; } }

.chapter { padding: 0 clamp(1rem, 6vw, 6rem); scroll-margin-top: var(--bar); }
.chapter > h2 {
  max-width: 30rem; margin: 0; padding: calc(var(--vh) * 30) 0 calc(var(--vh) * 8);
  font: 400 clamp(1.9rem, 3.6vw, 2.9rem)/1.05 var(--serif); letter-spacing: -0.015em; text-wrap: balance;
  text-shadow: 0 0 24px var(--bg), 0 0 8px var(--bg);
}
.num { display: block; font: 600 0.75rem/1 var(--sans); letter-spacing: 0.14em; color: var(--ink-3); margin-bottom: 0.9rem; text-shadow: none; }
.step { min-height: calc(var(--vh) * 82); display: flex; align-items: center; max-width: 30rem; scroll-margin-top: var(--bar); }
.step:last-child { min-height: calc(var(--vh) * 100); }
.step > p, .step > .status {
  margin: 0; padding: 1.15rem 1.35rem 1.25rem; border-radius: 12px;
  background: var(--plate); border: 1px solid var(--plate-line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  text-wrap: pretty; hyphens: manual;
}
.status { font-size: 1rem; }
.status-date { margin: 0 0 0.6rem; font: 600 0.75rem/1.3 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--curve); }
.status ol { margin: 0; padding-left: 1.2rem; }
.status li { margin: 0.45rem 0; }
.status b { font-weight: 600; }
.status-src { margin: 0.7rem 0 0; font: 400 0.8125rem/1.4 var(--sans); color: var(--ink-3); }

/* sections that cover the stage */
.wide, .sources { position: relative; background: var(--bg); padding-bottom: 5rem; }
.wide::before { content: ""; position: absolute; left: 0; right: 0; top: -40vh; height: 40vh; background: linear-gradient(transparent, var(--bg)); pointer-events: none; }
.wide > h2 { padding-top: 6rem; padding-bottom: 1.5rem; text-shadow: none; }
.lede { max-width: 38rem; font-size: 1.22rem; margin: 0 0 3rem; }
.ledger { max-width: 52rem; }
.ledger h3 { font: 600 0.75rem/1 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--curve); margin: 3rem 0 0.4rem; padding-bottom: 0.7rem; border-bottom: 1px solid var(--plate-line); }
.ledger h3:nth-of-type(2) { color: var(--hot); }
.ledger h3:nth-of-type(3) { color: var(--cool); }
.ledger dl { margin: 0; display: grid; grid-template-columns: minmax(12rem, 18rem) 1fr; gap: 0; }
.ledger dt, .ledger dd { padding: 1rem 0; border-bottom: 1px solid var(--plate-line); margin: 0; }
.ledger dt { font-weight: 600; padding-right: 2rem; line-height: 1.35; }
.ledger dd { color: var(--ink-2); font-size: 1.02rem; }
.coda { max-width: 38rem; font-size: 1.3rem; line-height: 1.55; margin: 4.5rem 0 0; }
.coda::before { content: ""; display: block; width: 2px; height: 72px; background: linear-gradient(var(--hot), var(--curve), var(--cool)); margin-bottom: 2rem; }

.sources { padding: 4rem clamp(1rem, 6vw, 6rem) 7rem; border-top: 1px solid var(--plate-line); font-size: 0.9375rem; color: var(--ink-2); }
.sources h2 { font: 600 0.75rem/1 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink); margin: 0 0 1.4rem; }
.sources ul { max-width: 46rem; padding-left: 1.1rem; margin: 0; }
.sources li { margin: 0 0 0.8rem; }
.updated { max-width: 46rem; margin: 2rem 0 0; color: var(--ink-3); }

/* ── rail ──────────────────────────────────────────────── */
.rail { position: fixed; right: 14px; top: 50%; transform: translateY(-50%); z-index: 20; display: flex; flex-direction: column; gap: 4px; opacity: 0; transition: opacity 0.6s; }
.rail.on { opacity: 1; }
.rail a { position: relative; display: block; width: 22px; height: 22px; }
.rail a::before { content: ""; position: absolute; left: 8px; top: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); opacity: 0.55; transition: transform 0.3s, opacity 0.3s, background 0.3s; }
.rail a[aria-current="true"]::before { background: var(--ink); opacity: 1; transform: scale(1.35); }
.rail a::after { content: attr(data-label); position: absolute; right: 26px; top: 50%; transform: translateY(-50%); white-space: nowrap; font: 500 0.75rem/1 var(--sans); color: var(--ink); background: var(--plate); padding: 5px 8px; border-radius: 4px; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.rail a:hover::after, .rail a:focus-visible::after { opacity: 1; }

/* ── phone: the stage sits on top, the text below, never over it ── */
@media (max-width: 760px) {
  body { font-size: 1.0625rem; }
  .stage { top: calc(var(--bar) + var(--browser-safe-top, env(safe-area-inset-top))); bottom: auto; height: calc(var(--vh) * 40); border-bottom: 1px solid var(--plate-line); z-index: 3; }
  .stage.covered { visibility: hidden; }
  main { padding-top: calc(var(--vh) * 40 + var(--bar)); }
  .hero { min-height: auto; padding: 1.6rem 1rem 3rem; justify-content: flex-start; }
  h1 { font-size: clamp(2.6rem, 13vw, 3.6rem); margin-bottom: 1.1rem; }
  .cue { display: none; }
  .chapter { padding: 0 1rem; }
  .chapter > h2 { padding: 3rem 0 1.5rem; text-shadow: none; }
  .step { min-height: calc(var(--vh) * 52); align-items: flex-start; padding-top: 0.6rem; }
  .step:last-child { min-height: calc(var(--vh) * 56); }
  .step > p, .step > .status { background: none; border: 0; padding: 0; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .wide { padding-top: 0; z-index: 4; }
  .wide::before { display: none; }
  .wide > h2 { padding-top: 3rem; }
  .ledger dl { grid-template-columns: 1fr; }
  .ledger dt { padding-bottom: 0.2rem; border-bottom: 0; }
  .ledger dd { padding-top: 0; }
  .sources { padding: 3rem 1rem 6rem; z-index: 4; }
  .rail { display: none; }
  .ctl { left: 8px; right: 8px; bottom: 8px; padding: 0.45rem 0.6rem; gap: 0.4rem 0.6rem; }
  .ctl { flex-wrap: nowrap; }
  .ctl label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .ctl input[type=range] { min-width: 0; }
  .btn { padding: 0 0.8rem; }
  .kicker { letter-spacing: 0.1em; }
  .topnav { display: none; }
}
@media print { .stage, .rail, .topbar { display: none; } main { padding: 0; } }

/* the Romanian title is longer */
html[lang^="ro"] h1 { font-size: clamp(2.8rem, 6.4vw, 6rem); }
@media (max-width: 760px) { html[lang^="ro"] h1 { font-size: clamp(2.3rem, 11vw, 3.1rem); } }

/* simple version: a plainer text beside each full one */
html:not(.mode-simple) .simple { display: none !important; }
html.mode-simple .full { display: none !important; }
html.mode-simple .step > p.simple { font-size: 1.22rem; line-height: 1.55; }
.chip.mode { font: inherit; background: none; cursor: pointer; padding: 6px 10px; border: 1px solid var(--plate-line); border-radius: 999px; color: var(--ink-2); white-space: nowrap; min-height: 32px; }
.chip.mode:hover { color: var(--ink); }
html.mode-simple .ledger { display: none; }
.hero .cue { display: none; }
.mode-invite { margin: 1.3rem 0 0; }
.mode-invite .btn { font: 500 0.875rem/1 var(--sans); min-height: 40px; padding: 0 1.1rem; }
.ledger-simple { max-width: 40rem; }
.ledger-simple h3 { font: 600 0.75rem/1 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--curve); margin: 2.4rem 0 0.6rem; }
.ledger-simple h3:nth-of-type(2) { color: var(--hot); }
.ledger-simple h3:nth-of-type(3) { color: var(--cool); }
.ledger-simple ul { margin: 0; padding-left: 1.2rem; }
.ledger-simple li { margin: 0.55rem 0; font-size: 1.15rem; }
html:not(.mode-simple) .ledger-simple { display: none; }
@media (max-width: 760px) { .chip.mode { padding: 5px 9px; font-size: 0.75rem; } .topbar { gap: 0.6rem; } }
@media (max-width: 420px) { .topbar .home { font-size: 0.75rem; } .chip.lang, .chip.mode { padding: 4px 8px; font-size: 0.75rem; } .icon-btn { margin-right: -12px; } }
