:root {
  --ground: #E8EBEE;
  --ink: #12161A;
  --ink-2: #3A424A;
  --hair: rgba(18, 22, 26, .22);
  --hair-2: rgba(18, 22, 26, .10);
  --veil: rgba(232, 235, 238, .92);
  --hue-l: .55; --hue-c: .09;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0F1215; --ink: #E8EBEE; --ink-2: #B3BBC3;
    --hair: rgba(232, 235, 238, .26); --hair-2: rgba(232, 235, 238, .11);
    --veil: rgba(15, 18, 21, .92);
    --hue-l: .78; --hue-c: .11;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0F1215; --ink: #E8EBEE; --ink-2: #B3BBC3;
  --hair: rgba(232, 235, 238, .26); --hair-2: rgba(232, 235, 238, .11);
  --veil: rgba(15, 18, 21, .92);
  --hue-l: .78; --hue-c: .11;
  color-scheme: dark;
}

[hidden] { display: none !important; }
svg[hidden] { display: none; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font: 400 20px/1.55 "Newsreader", Georgia, serif;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 16px; z-index: 10; background: var(--ground); padding: 8px 12px; }

/* ---------- layout: desktop ---------- */
.stage {
  position: fixed; left: 0; top: 0;
  width: calc(100vw - 600px); height: 100vh; height: var(--vh, 100vh);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 1;
}
#ring { display: block; width: min(640px, calc(100vw - 680px), calc(var(--vh, 100vh) - 150px)); aspect-ratio: 1; touch-action: none; cursor: default; }
#ring.grab { cursor: grab; }
#ring.tap { cursor: pointer; }
.text { margin-left: calc(100vw - 600px); width: 520px; padding: 0 0 20vh; position: relative; z-index: 2; }
.step { padding: 22vh 0 0; min-height: 40vh; }
.step + .step:not(:has(h2)) { padding-top: 14vh; min-height: 30vh; }
.hero { padding-top: 18vh; min-height: 92vh; }
.num {
  font: 500 12px/1 "Martian Mono", ui-monospace, monospace; font-stretch: 87.5%;
  letter-spacing: .04em; color: var(--ink-2);
  border-top: 1px solid var(--hair); padding-top: 14px; margin: 0 0 18px;
}
h1, h2 { font-family: "Bricolage Grotesque", system-ui, sans-serif; font-weight: 600; font-stretch: 88%; letter-spacing: -.012em; }
h1 { font-size: clamp(56px, 5vw, 76px); line-height: .98; margin: 0 0 22px; font-variation-settings: "opsz" 96; }
h2 { font-size: 30px; line-height: 1.12; margin: 0 0 18px; font-variation-settings: "opsz" 40; }
.kicker { font: 500 12px/1.4 "Martian Mono", monospace; font-stretch: 87.5%; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); margin: 0 0 18px; }
.dek { font-size: 25px; line-height: 1.38; margin: 0 0 26px; }
p { margin: 0 0 18px; max-width: 34em; }
.hint { font-size: 16px; color: var(--ink-2); }
em { font-style: italic; }
strong { font-weight: 600; }

/* ---------- controls ---------- */
.controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 8px; min-height: 44px; margin-top: 14px; padding: 0 16px; max-width: 660px; }
.readout { font: 400 12px/1.5 "Martian Mono", monospace; font-stretch: 87.5%; color: var(--ink-2); min-height: 18px; text-align: center; margin-top: 6px; font-variant-numeric: tabular-nums; padding: 0 12px; }
button { font: inherit; color: inherit; }
.controls button, .controls .btn, .controls select, .play {
  font: 500 13px/1 "Martian Mono", monospace; font-stretch: 87.5%;
  background: transparent; color: var(--ink);
  border: 1px solid var(--hair); border-radius: 2px;
  min-height: 40px; padding: 0 13px; cursor: pointer;
  transition: background .2s, border-color .2s, color .2s;
}
.controls button:hover, .controls .btn:hover, .controls select:hover, .play:hover { border-color: var(--ink); }
.controls .btn { display: inline-flex; align-items: center; text-decoration: none; }
.controls select { appearance: none; -webkit-appearance: none; padding-right: 26px; background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%); background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.controls button[aria-pressed="true"] { background: var(--ink); color: var(--ground); border-color: var(--ink); }
.controls button:focus-visible, .controls .btn:focus-visible, .controls select:focus-visible, .play:focus-visible, .theme:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.play.big { font-size: 14px; min-height: 48px; padding: 0 20px; border-color: var(--ink); }
.play.big::before, .play::before { content: ""; display: inline-block; width: 0; height: 0; border-left: 7px solid currentColor; border-top: 4.5px solid transparent; border-bottom: 4.5px solid transparent; margin-right: 10px; vertical-align: 1px; }
.controls label { display: flex; align-items: center; gap: 10px; font: 500 13px/1 "Martian Mono", monospace; font-stretch: 87.5%; min-height: 40px; }
.controls input[type=range] { width: 200px; accent-color: var(--ink); }
.controls .sep { width: 100%; height: 0; }

.theme {
  position: fixed; right: 18px; top: 16px; z-index: 5; width: 40px; height: 40px;
  display: grid; place-items: center; background: transparent; border: 1px solid var(--hair); border-radius: 50%; cursor: pointer; color: var(--ink);
}
.theme svg { width: 18px; height: 18px; }

.coda { padding-top: 26vh; }
.links { font-size: 18px; }
.notes { margin-top: 18vh; padding-top: 18px; border-top: 1px solid var(--hair); font-size: 16px; line-height: 1.55; color: var(--ink-2); }
.notes h2 { font-size: 20px; color: var(--ink); }
.byline { margin-top: 28px; }

/* ---------- phone / narrow ---------- */
@media (max-width: 899px) {
  body { font-size: 18px; line-height: 1.5; }
  .stage {
    width: 100%; height: var(--stage-h, 40vh);
    background: var(--ground);
    border-bottom: 1px solid var(--hair);
    justify-content: flex-start; padding-top: 6px; z-index: 3;
  }
  #ring { width: auto; height: calc(var(--stage-h, 40vh) - 122px); max-width: calc(100vw - 32px); }
  .stage::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 22px; background: linear-gradient(var(--ground), transparent); pointer-events: none; }
  .controls { margin-top: 4px; gap: 4px 5px; min-height: 34px; flex-wrap: wrap; justify-content: center; max-width: 100%; padding: 0 8px; }
  .controls button, .controls .btn, .controls select { flex: 0 0 auto; min-height: 33px; padding: 0 8px; font-size: 11.5px; }
  .controls select { padding-right: 24px; }
  .controls .sep { display: none; }
  .controls label { min-height: 33px; font-size: 11.5px; }
  .controls input[type=range] { width: 130px; }
  .readout { margin: 2px 0 0; font-size: 10.5px; min-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .text { margin: 0; width: auto; padding: calc(var(--stage-h, 40vh) + 8px) 16px 18vh; }
  .step { padding-top: 12vh; min-height: 0; }
  .step + .step:not(:has(h2)) { padding-top: 6vh; min-height: 0; }
  .hero { padding-top: 22px; min-height: 0; }
  h1 { font-size: 40px; margin-bottom: 14px; }
  h2 { font-size: 24px; }
  .dek { font-size: 21px; }
  .theme { top: 8px; right: 12px; width: 36px; height: 36px; z-index: 6; }
  .notes { margin-top: 10vh; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
