/* ============================================================
   FIVE-MINUTE FIRE  —  a geostationary observatory at night
   ============================================================ */

:root {
  /* ---- DARK THEME (default page palette) ---- */
  --ink:        #0b0a09;
  --ink-1:      #100e0c;
  --ink-2:      #16130f;
  --line:       #2b2620;
  --line-soft:  #1f1b16;
  --bone:       #f1e9db;   /* primary text   ~17:1 */
  --ash:        #a89e8e;   /* secondary text ~7.4:1 */
  --ash-dim:    #9a9182;   /* small labels   ~5.1:1 */

  --ember:      #ff5a1f;   /* fire — constant across themes */
  --flare:      #ff9436;
  --gold:       #ffce6a;
  --whitehot:   #fff2d4;
  --accent:     #ff5a1f;   /* accent TEXT (flips for legibility) */
  --sat:        #74c4d0;   /* satellite/cool accent (flips) */

  --palisades:  #ff7a2e;
  --eaton:      #b98bf0;

  --glow-1:     rgba(255, 90, 31, 0.30);
  --glow-2:     rgba(255, 148, 54, 0.10);
  --panel-shadow: none;

  --serif: "Instrument Serif", Georgia, serif;
  --sans:  "Hanken Grotesk", system-ui, sans-serif;
  --mono:  "IBM Plex Mono", ui-monospace, monospace;

  --maxw: 1180px;
}

/* ---- LIGHT THEME (page chrome) — follows the device, user-overridable ----
   Applied when the OS prefers light (and the user has not forced dark),
   or when the user explicitly picks light via the toggle. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --ink: #f4efe5; --ink-1: #ece4d5; --ink-2: #e4dbc8;
    --line: #d3c8b2; --line-soft: #e3dac8;
    --bone: #221d15; --ash: #585044; --ash-dim: #635a49;
    --accent: #b23a0b; --gold: #8a5d10; --sat: #1a6e7a;
    --glow-1: rgba(255, 90, 31, 0.15); --glow-2: rgba(255, 120, 40, 0.05);
    --panel-shadow: 0 20px 44px -22px rgba(54, 33, 14, 0.45);
  }
}
:root[data-theme="light"] {
  --ink: #f4efe5; --ink-1: #ece4d5; --ink-2: #e4dbc8;
  --line: #d3c8b2; --line-soft: #e3dac8;
  --bone: #221d15; --ash: #585044; --ash-dim: #635a49;
  --accent: #b23a0b; --gold: #8a5d10; --sat: #1a6e7a;
  --glow-1: rgba(255, 90, 31, 0.15); --glow-2: rgba(255, 120, 40, 0.05);
  --panel-shadow: 0 20px 44px -22px rgba(54, 33, 14, 0.45);
}

/* The instrument + cadence panels are physical "screens" — they stay dark
   in every theme, so the glowing-fire map always reads correctly. */
.instrument, .cadence {
  --ink: #0b0a09; --ink-1: #100e0c; --ink-2: #16130f;
  --line: #2b2620; --line-soft: #1f1b16;
  --bone: #f1e9db; --ash: #a89e8e; --ash-dim: #9a9182;
  --accent: #ff5a1f; --gold: #ffce6a; --sat: #74c4d0;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--ink);
  color: var(--bone);
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* selection + scrollbar flavour */
::selection { background: var(--accent); color: #fff8ec; }
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--ink); }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: var(--ash-dim); }

/* ---------- shared atoms ---------- */
.eyebrow, .beat-index, .r-label, .topbar-meta, .wordmark,
.legend-title, .timeline-label, .site-foot {
  font-family: var(--mono);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.beat-index {
  font-size: 0.72rem;
  color: var(--accent);
  margin-bottom: 1.4rem;
}

/* ============================================================
   HERO
   ============================================================ */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding: 0 clamp(1.4rem, 5vw, 5rem);
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}

/* ember glow rising from the horizon */
.hero-glow {
  position: absolute;
  left: 50%; bottom: -52%;
  width: 160%; height: 110%;
  transform: translateX(-50%);
  background:
    radial-gradient(ellipse 50% 50% at 50% 50%,
      var(--glow-1) 0%,
      var(--glow-2) 38%,
      transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* fine film grain */
.hero-grain {
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.4'/%3E%3C/svg%3E");
  opacity: 0.04;
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: 1;
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.6rem 0;
  font-size: 0.7rem;
}
.wordmark { color: var(--bone); letter-spacing: 0.22em; }
.topbar-meta { color: var(--ash-dim); }

.hero-inner {
  position: relative;
  z-index: 2;
  margin: auto 0;
  max-width: 1000px;
  padding: 4rem 0 5rem;
}

.eyebrow {
  font-size: 0.74rem;
  color: var(--sat);
  margin-bottom: 1.8rem;
}

.hero-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.9rem, 8.4vw, 6.4rem);
  line-height: 1.02;
  letter-spacing: -0.012em;
}
.hero-title span { display: block; }
.hero-title em {
  font-style: italic;
  color: var(--accent);
}

.hero-lede {
  margin-top: 2rem;
  max-width: 41rem;
  font-size: clamp(1rem, 1.5vw, 1.2rem);
  color: var(--ash);
}
.hero-lede strong { color: var(--bone); font-weight: 600; }

.hero-foot {
  margin-top: 3.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 2rem 3rem;
  align-items: flex-end;
  justify-content: space-between;
}
.byline-label {
  display: block;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ash-dim);
  margin-bottom: 0.35rem;
}
.byline-names {
  font-size: 0.96rem;
  color: var(--bone);
}
.byline-sub {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.74rem;
  color: var(--ash);
}

.scrollcue {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  color: var(--bone);
  text-decoration: none;
  padding: 0.7rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
  animation: cue-breathe 3.4s ease-in-out infinite;
}
.scrollcue:hover {
  border-color: var(--ember);
  background: rgba(255,90,31,0.07);
  box-shadow: 0 0 22px -4px rgba(255,90,31,0.35);
  animation-play-state: paused;
}
/* the arrow falls and fades, like a repeating "scroll down" hint */
.scrollcue-arrow { animation: cue-fall 1.7s ease-in-out infinite; }
@keyframes cue-fall {
  0%   { transform: translateY(-4px); opacity: 0; }
  25%  { opacity: 1; }
  60%  { opacity: 1; }
  100% { transform: translateY(8px); opacity: 0; }
}
/* a slow ember glow so the cue gently draws the eye without nagging */
@keyframes cue-breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,90,31,0); border-color: var(--line); }
  50%      { box-shadow: 0 0 16px -6px rgba(255,90,31,0.30); border-color: rgba(255,90,31,0.45); }
}

/* staggered load reveal */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  animation: rise 0.9s cubic-bezier(.2,.7,.2,1) forwards;
  animation-delay: var(--d, 0s);
}
@keyframes rise { to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   NARRATIVE BEATS
   ============================================================ */
.beat {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(5rem, 11vw, 9rem) clamp(1.4rem, 5vw, 5rem);
}
.beat-text {
  font-family: var(--serif);
  font-size: clamp(1.7rem, 3.6vw, 2.9rem);
  line-height: 1.32;
  letter-spacing: -0.005em;
  max-width: 22ch;
}
.beat-text strong { color: var(--accent); font-weight: 400; }
.beat-text em { font-style: italic; color: var(--gold); }

.beat-therefore .beat-text { max-width: 26ch; }
.beat-therefore { border-top: 1px solid var(--line-soft); }

/* on-scroll fade */
.fade-up {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.9s ease, transform 0.9s cubic-bezier(.2,.7,.2,1);
}
.fade-up.in { opacity: 1; transform: translateY(0); }

/* ============================================================
   OBSERVATORY
   ============================================================ */
.observatory {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(4rem, 8vw, 7rem) clamp(1.4rem, 5vw, 5rem);
  border-top: 1px solid var(--line-soft);
}
.obs-head { max-width: 50rem; margin-bottom: 2.6rem; }
.obs-head h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2rem, 4.6vw, 3.4rem);
  line-height: 1.1;
  margin-bottom: 1rem;
}
.obs-sub { color: var(--ash); font-size: 1rem; max-width: 44rem; }
.obs-sub strong { color: var(--gold); font-weight: 600; }

/* the instrument panel */
.instrument {
  border: 1px solid var(--line);
  background-color: var(--ink-1);
  background-image: linear-gradient(180deg, var(--ink-2), var(--ink-1));
  border-radius: 4px;
  overflow: hidden;
  box-shadow: var(--panel-shadow);
}

/* readouts row */
.readouts {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1.2fr;
  border-bottom: 1px solid var(--line);
}
.readout {
  padding: 1.1rem 1.3rem;
  border-right: 1px solid var(--line-soft);
}
.readout:last-child { border-right: 0; }
.r-label {
  display: block;
  font-size: 0.62rem;
  color: var(--ash-dim);
  margin-bottom: 0.5rem;
}
.r-value {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--bone);
  font-variant-numeric: tabular-nums;
}
.readout-time .r-value {
  color: var(--sat);
  font-size: 1.25rem;
  white-space: nowrap;
}
.r-value .unit { font-size: 0.82rem; color: var(--ash); margin-left: 0.25rem; }

/* map stage */
.stage {
  position: relative;
  background: var(--ink);
  line-height: 0;
}
#map { display: block; width: 100%; height: auto; }

/* legend card */
.legend {
  position: absolute;
  right: 1rem; bottom: 1rem;
  background: rgba(11,10,9,0.82);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.8rem 0.9rem;
  backdrop-filter: blur(4px);
  line-height: 1.4;
}
.legend-title { font-size: 0.58rem; color: var(--ash); margin-bottom: 0.55rem; }
.legend-scale {
  height: 8px;
  border-radius: 2px;
  background: linear-gradient(90deg,
    #5a1c08 0%, var(--ember) 35%, var(--flare) 62%, var(--gold) 82%, var(--whitehot) 100%);
}
.legend-ends {
  display: flex;
  justify-content: space-between;
  gap: 1.2rem;
  font-family: var(--mono);
  font-size: 0.58rem;
  color: var(--bone);
  margin-top: 0.4rem;
}
.le-end { display: flex; flex-direction: column; line-height: 1.35; }
.le-right { text-align: right; }
.le-end i { font-style: normal; font-size: 0.54rem; color: var(--ash-dim); }
.legend-note {
  font-size: 0.66rem;
  color: var(--ash);
  margin-top: 0.5rem;
  max-width: 15rem;
}

/* tooltip (shared by the map and the cadence chart) */
.map-tooltip,
.viz-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--ink);
  border: 1px solid var(--ember);
  border-radius: 3px;
  padding: 0.5rem 0.65rem;
  font-family: var(--mono);
  font-size: 0.66rem;
  line-height: 1.55;
  color: var(--bone);
  white-space: nowrap;
  transform: translate(-50%, -118%);
  z-index: 5;
}
.map-tooltip b,
.viz-tooltip b { color: var(--gold); font-weight: 500; }
/* the cadence tooltip is a small stacked card (positioned in JS, never clipped) */
.viz-tooltip {
  white-space: normal;
  max-width: 12.5rem;
  text-align: left;
  line-height: 1.45;
  border-color: rgba(255, 90, 31, 0.4);
  box-shadow: 0 8px 24px -10px rgba(0, 0, 0, 0.85);
  transform: none;
}
.viz-tooltip span { display: block; }
.tip-time { color: var(--bone); font-weight: 600; }
.tip-read { color: var(--ash); margin-top: 3px; }
.tip-read b { color: var(--bone); font-weight: 600; }
.tip-miss { color: var(--ash); margin-top: 5px; }
.tip-miss b { color: var(--gold); font-weight: 700; }
.tip-sub { color: var(--ash-dim); font-size: 0.92em; margin-top: 1px; }

/* on-map wind dial — direction needle, speed ring, live numbers */
.wind-hud {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.62rem 0.4rem 0.42rem;
  background: rgba(11, 10, 9, 0.6);
  border: 1px solid var(--line);
  border-radius: 6px;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  pointer-events: none;
  z-index: 4;
}
.wind-dial { width: 44px; height: 44px; flex: none; }
.wind-ring-bg { fill: none; stroke: rgba(116, 196, 208, 0.22); stroke-width: 1.5; }
.wind-ticks text {
  fill: var(--ash-dim);
  font-family: var(--mono);
  font-size: 7px;
  text-anchor: middle;
  dominant-baseline: middle;
}
.wind-needle { transition: transform 0.18s linear; }
.wind-needle line { stroke: var(--sat); stroke-width: 2.4; stroke-linecap: round; }
.wind-needle polygon { fill: var(--sat); }
.wind-nums { font-family: var(--mono); line-height: 1.2; }
.wind-tag {
  font-size: 0.5rem;
  letter-spacing: 0.13em;
  color: var(--ash-dim);
  margin-bottom: 1px;
}
.wind-speed { color: var(--bone); display: flex; align-items: baseline; gap: 2px; }
.wind-speed > span:first-child { font-size: 1.1rem; font-weight: 600; line-height: 1; }
.wind-unit { font-size: 0.56rem; color: var(--ash); }
.wind-sub { font-size: 0.55rem; color: var(--ash); margin-top: 2px; }
.wind-sub b { color: var(--sat); font-weight: 600; }
@media (prefers-reduced-motion: reduce) {
  .wind-needle { transition: none; }
}

/* controls */
.controls {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  padding: 1rem 1.3rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--ink-2);
}
.play-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  color: var(--ink);
  background: var(--ember);
  border: 0;
  padding: 0.65rem 1.3rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.play-btn:hover { background: var(--flare); }
.play-btn:active { transform: scale(0.97); }
.play-icon { font-size: 0.7rem; }

.speed {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  color: var(--ash-dim);
}
.speed-btn {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ash);
  background: transparent;
  border: 1px solid var(--line);
  padding: 0.3rem 0.55rem;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.18s;
}
.speed-btn:hover { color: var(--bone); border-color: var(--ash-dim); }
.speed-btn.is-on {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(255,206,106,0.08);
}

.ghost-btn {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--ash);
  background: transparent;
  border: 1px solid var(--line);
  padding: 0.5rem 0.85rem;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.18s;
}
.ghost-btn:hover { color: var(--bone); border-color: var(--ash-dim); }

/* timeline */
.timeline { padding: 1.1rem 1.3rem 1.4rem; }
.timeline-label {
  font-size: 0.6rem;
  color: var(--ash-dim);
  margin-bottom: 0.5rem;
}
.dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 0.15rem;
  vertical-align: middle;
}
.dot-p { background: var(--palisades); }
.dot-e { background: var(--eaton); }
.dot-w { background: var(--sat); }
#timeline-svg { display: block; width: 100%; height: 132px; cursor: ew-resize; }

/* timeline svg internals (styled here, drawn in JS) */
.tl-axis text { font-family: var(--mono); font-size: 9.5px; fill: var(--ash); }
.tl-axis line, .tl-axis path { stroke: var(--line-soft); }
.tl-ignite { stroke: var(--ash-dim); stroke-dasharray: 2 3; opacity: 0.55; }
.tl-ignite-label { font-family: var(--mono); font-size: 9px; font-weight: 500; fill: var(--ash); }
.tl-wind-line { fill: none; stroke: var(--sat); stroke-width: 1.4; opacity: 0.9; }
.tl-wind-axis { font-family: var(--mono); font-size: 8.5px; fill: var(--sat); opacity: 0.85; }
.tl-playhead { stroke: var(--whitehot); stroke-width: 1.5; }
.tl-playhead-grip { fill: var(--whitehot); }

/* ============================================================
   WRITEUP
   ============================================================ */
.writeup {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(4rem, 9vw, 8rem) clamp(1.4rem, 5vw, 5rem);
  border-top: 1px solid var(--line-soft);
}
.writeup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
}
.writeup-grid article {
  border-top: 2px solid var(--ember);
  padding-top: 1.3rem;
}
.writeup-grid h3 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.7rem;
  margin-bottom: 0.9rem;
}
.writeup-grid p { color: var(--ash); font-size: 0.97rem; }
.writeup-grid em { color: var(--gold); font-style: italic; }

/* ============================================================
   FOOTER
   ============================================================ */
.site-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 2.4rem;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2.4rem clamp(1.4rem, 5vw, 5rem) 3.4rem;
  border-top: 1px solid var(--line);
  font-size: 0.62rem;
  color: var(--ash-dim);
}

/* ============================================================
   THEME TOGGLE  (fixed; follows the device unless overridden)
   ============================================================ */
.theme-toggle {
  position: fixed;
  right: clamp(0.9rem, 2.5vw, 1.8rem);
  bottom: clamp(0.9rem, 2.5vw, 1.8rem);
  z-index: 50;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem;
  line-height: 1;
  color: var(--bone);
  background: var(--ink-1);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 6px 20px -6px rgba(0, 0, 0, 0.55);
  transition: border-color 0.2s, transform 0.15s, background 0.2s;
}
.theme-toggle:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.theme-toggle:active { transform: scale(0.93); }
.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   SCROLLYTELLING — sticky instrument + scroll-driven steps
   ============================================================ */
.scrolly {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: clamp(1.4rem, 3.5vw, 3rem);
  align-items: start;
}
.scrolly-steps { grid-column: 1; grid-row: 1; }
.scrolly-graphic {
  grid-column: 2; grid-row: 1;
  position: sticky;
  top: 4vh;
  align-self: start;
}

/* the steps */
.step {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  opacity: 0.3;
  transition: opacity 0.45s ease;
}
.step:first-child { min-height: 62vh; }
.step:last-child  { min-height: 70vh; }
.step.is-active { opacity: 1; }
.step-badge {
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin-bottom: 0.9rem;
}
.step-text {
  font-family: var(--serif);
  font-size: clamp(1.5rem, 2.1vw, 1.95rem);
  line-height: 1.34;
  color: var(--bone);
}
.step-text strong { color: var(--gold); font-weight: 400; }
.step-cue {
  display: block;
  margin-top: 1rem;
  font-family: var(--sans);
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--ash);
}

/* keyboard hint under the instrument */
.kbd-hint {
  padding: 0.7rem 1.3rem 0.9rem;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  color: var(--ash-dim);
}
kbd {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--ash);
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.05rem 0.32rem;
  margin: 0 0.05rem;
}

/* ============================================================
   MAP ANNOTATIONS
   ============================================================ */
.annos { position: absolute; inset: 0; pointer-events: none; }
.anno {
  position: absolute;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.anno.show { opacity: 1; }

.anno-dot {
  position: absolute;
  left: -5px; top: -5px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--whitehot);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.6);
}
.anno-dot::after {
  content: "";
  position: absolute; inset: -4px;
  border-radius: 50%;
  border: 1px solid currentColor;
  animation: anno-ring 2.4s ease-out infinite;
}
@keyframes anno-ring {
  0%   { transform: scale(0.7); opacity: 0.9; }
  100% { transform: scale(2.6); opacity: 0; }
}

.anno-card {
  position: absolute;
  left: 16px; bottom: 12px;
  width: 12.2rem;
  background: rgba(11,10,9,0.92);
  border: 1px solid var(--line);
  border-left: 2px solid currentColor;
  border-radius: 3px;
  padding: 0.55rem 0.7rem;
  backdrop-filter: blur(4px);
}
.anno.left .anno-card { left: auto; right: 16px; }
.anno-title {
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  color: currentColor;
  margin-bottom: 0.3rem;
}
.anno-body {
  font-size: 0.74rem;
  line-height: 1.5;
  color: var(--bone);
}

/* ============================================================
   EVIDENCE — cadence comparison
   ============================================================ */
.evidence {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(4rem, 9vw, 8rem) clamp(1.4rem, 5vw, 5rem);
  border-top: 1px solid var(--line-soft);
}
.cadence {
  border: 1px solid var(--line);
  background-color: var(--ink-1);
  background-image: linear-gradient(180deg, var(--ink-2), var(--ink-1));
  border-radius: 4px;
  overflow: hidden;
  box-shadow: var(--panel-shadow);
}
.cadence-readouts {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1.6fr;
  border-bottom: 1px solid var(--line);
}
.cadence-plot { position: relative; }
#cadence-svg { display: block; width: 100%; height: 300px; }

.cadence-control {
  padding: 1.3rem 1.5rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--ink-2);
}
.cadence-label {
  display: block;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ash-dim);
  margin-bottom: 0.9rem;
}
#cadence-slider {
  -webkit-appearance: none; appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ember), var(--line));
  outline: none;
  cursor: pointer;
}
/* thumb sized with border-box so its total footprint is exactly 20px in both
   engines — the tick positions below assume a 10px travel inset at each end */
#cadence-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  box-sizing: border-box;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--whitehot);
  border: 3px solid var(--ember);
  cursor: grab;
}
#cadence-slider::-moz-range-thumb {
  box-sizing: border-box;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--whitehot);
  border: 3px solid var(--ember);
  cursor: grab;
}
#cadence-slider:focus-visible { box-shadow: 0 0 0 3px rgba(255,90,31,0.3); }
/* labels are absolutely placed (in JS) at each value's thumb-center position,
   so they line up with the slider handle instead of drifting from it */
.cadence-ticks {
  position: relative;
  height: 1.3em;
  margin-top: 0.6rem;
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.04em;
  color: var(--ash-dim);
}
.cadence-ticks span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}
.cadence-ticks span.on { color: var(--gold); }

.cadence-caption {
  padding: 1.3rem 1.5rem 1.5rem;
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--ash);
}
.cadence-caption strong { color: var(--gold); font-weight: 600; }
.cadence-caption em { color: var(--bone); font-style: normal; }

/* cadence svg internals (styled here, drawn in JS) */
.cd-axis text { font-family: var(--mono); font-size: 9.5px; fill: var(--ash); }
.cd-axis line, .cd-axis path { stroke: var(--line-soft); }
.cd-truth { fill: rgba(255,122,46,0.10); }
.cd-truthline { fill: none; stroke: rgba(255,122,46,0.4); stroke-width: 1; }
.cd-sample { fill: none; stroke: var(--whitehot); stroke-width: 1.8; stroke-linejoin: round; }
.cd-dot { fill: var(--ember); stroke: var(--whitehot); stroke-width: 1; cursor: pointer; transition: r 0.12s ease; }
.cd-peakline { stroke: var(--ash-dim); stroke-dasharray: 2 3; }
.cd-peaklabel { font-family: var(--mono); font-size: 8.5px; fill: var(--ash); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 820px) {
  .readouts { grid-template-columns: 1fr 1fr; }
  .readout:nth-child(2) { border-right: 0; }
  .readout:nth-child(1), .readout:nth-child(2) { border-bottom: 1px solid var(--line-soft); }
  .writeup-grid { grid-template-columns: 1fr; gap: 2.2rem; }
  .legend { right: 0.6rem; bottom: 0.6rem; padding: 0.6rem 0.7rem; }
  .legend-note { display: none; }
}

/* scrollytelling collapses to a single column with a sticky graphic on top.
   The instrument is heavily compacted so the story steps stay visible below it. */
@media (max-width: 960px) {
  .scrolly { display: block; }
  .scrolly-graphic {
    position: sticky;
    top: 0;
    margin: 0 calc(-1 * clamp(1.4rem, 5vw, 5rem));
    padding: 0.4rem clamp(1.4rem, 5vw, 5rem) 0.5rem;
    background: var(--ink);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 14px 22px -10px rgba(0,0,0,0.9);
    z-index: 6;
  }
  .step { min-height: 56vh; }
  .step:first-child { min-height: 28vh; padding-top: 1.2rem; }
  .kbd-hint { display: none; }

  /* annotations and the legend overlap a small map — the steps narrate instead */
  .annos, .legend { display: none; }

  /* compact readouts */
  .readout { padding: 0.5rem 0.7rem; }
  .r-label { font-size: 0.55rem; margin-bottom: 0.28rem; }
  .r-value { font-size: 1.12rem; }
  .readout-time .r-value { font-size: 1rem; }

  /* compact single-row controls */
  .controls { gap: 0.5rem; padding: 0.6rem 0.8rem; }
  .play-btn { padding: 0.5rem 0.95rem; font-size: 0.7rem; }
  .speed { font-size: 0.6rem; gap: 0.3rem; }
  .speed-btn { padding: 0.25rem 0.4rem; }
  .ghost-btn { padding: 0.4rem 0.55rem; font-size: 0.62rem; }

  /* compact timeline */
  .timeline { padding: 0.7rem 0.85rem 0.9rem; }
  .timeline-label { font-size: 0.54rem; }

  .cadence-readouts { grid-template-columns: 1fr 1fr; }
  .cadence-readouts .readout:last-child {
    grid-column: 1 / -1;
    border-right: 0;
    border-top: 1px solid var(--line-soft);
  }
  .cadence-readouts .readout:nth-child(2) { border-right: 0; }
}

@media (max-width: 560px) {
  .hero-foot { flex-direction: column; align-items: flex-start; }
  .step-text { font-size: 1.3rem; }
  #cadence-svg { height: 240px; }
  .cadence-control { padding: 1.1rem 1rem 0.9rem; }
  .cadence-caption { padding: 1.1rem 1rem 1.3rem; font-size: 0.95rem; }
}

@media (prefers-reduced-motion: reduce) {
  /* the scroll cue keeps animating even under reduced motion (by request) */
  .reveal { animation: none; opacity: 1; transform: none; }
  .fade-up { transition: none; opacity: 1; transform: none; }
  .anno-dot::after { animation: none; }
  .step-down { animation: none; }
  html { scroll-behavior: auto; }
}

/* ============================================================
   HERO DATELINE — the fire names, up in the title block
   ============================================================ */
.hero-dateline {
  margin-top: 1.4rem;
  font-family: var(--serif);
  font-size: clamp(1.35rem, 3.1vw, 2.2rem);
  line-height: 1.15;
  color: var(--bone);
}
.hd-pal { font-style: italic; color: var(--palisades); }
.hd-eat { font-style: italic; color: var(--eaton); }
.hd-meta {
  font-family: var(--mono);
  font-size: 0.5em;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ash);
  white-space: nowrap;
}
/* the raw fire-accent colors read fine on the dark page; nudge them darker on
   the light theme so they keep their contrast */
:root[data-theme="light"] .hd-pal,
:root:not([data-theme="dark"]) .hd-pal { color: #c2511a; }
:root[data-theme="light"] .hd-eat,
:root:not([data-theme="dark"]) .hd-eat { color: #7548c8; }

/* ============================================================
   FROM THE GROUND — real fire photographs
   ============================================================ */
.ground {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(4rem, 8vw, 7rem) clamp(1.4rem, 5vw, 5rem);
  border-top: 1px solid var(--line-soft);
}
.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(0.9rem, 2.4vw, 1.5rem);
}
.photo {
  position: relative;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0b0a09;
  box-shadow: var(--panel-shadow);
  cursor: zoom-in;
}
.photo img {
  display: block;
  width: 100%;
  height: clamp(220px, 30vw, 320px);
  object-fit: cover;
  transition: transform 0.7s cubic-bezier(.2,.7,.2,1);
}
.photo:hover img,
.photo:focus-visible img { transform: scale(1.04); }
.photo:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* corner badge that makes the click-to-enlarge affordance explicit */
.ph-zoom {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 1.7rem;
  height: 1.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  color: #f3ece0;
  background: rgba(8,6,5,0.6);
  border: 1px solid rgba(243,236,224,0.35);
  border-radius: 3px;
  backdrop-filter: blur(2px);
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 0.3s ease, transform 0.3s ease, background 0.3s ease;
  pointer-events: none;
}
.photo:hover .ph-zoom,
.photo:focus-visible .ph-zoom { opacity: 1; transform: translateY(0); }

/* ---- lightbox ---- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 3rem);
  background: rgba(6,4,3,0.92);
  backdrop-filter: blur(6px);
  cursor: zoom-out;
  animation: lbFade 0.22s ease;
}
.lightbox[hidden] { display: none; }
@keyframes lbFade { from { opacity: 0; } to { opacity: 1; } }
.lb-figure {
  margin: 0;
  max-width: min(1100px, 94vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  cursor: default;
}
.lb-figure img {
  display: block;
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border: 1px solid var(--line);
}
.lb-cap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.85rem 0.2rem 0;
}
.lb-tag {
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  padding: 0.14rem 0.5rem;
  border-radius: 2px;
}
.lb-tag.ph-pal { background: var(--palisades); color: #1c1004; }
.lb-tag.ph-eat { background: var(--eaton);     color: #170b27; }
.lb-where { font-size: 0.95rem; color: #f3ece0; flex: 1 1 14rem; }
.lb-source {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  color: #ffce6a;
  text-decoration: none;
  border-bottom: 1px solid rgba(255,206,106,0.4);
  white-space: nowrap;
}
.lb-source:hover { border-bottom-color: #ffce6a; }
.lb-close {
  position: fixed;
  top: 1rem;
  right: 1.1rem;
  width: 2.4rem;
  height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #f3ece0;
  background: rgba(20,16,13,0.8);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.lb-close:hover { border-color: var(--accent); transform: scale(1.06); }
@media (prefers-reduced-motion: reduce) {
  .lightbox { animation: none; }
}
.photo figcaption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 2.2rem 1rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  background: linear-gradient(to top, rgba(7,5,4,0.94) 12%, rgba(7,5,4,0.55) 55%, rgba(7,5,4,0));
}
.ph-tag {
  width: fit-content;
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  padding: 0.14rem 0.5rem;
  border-radius: 2px;
}
.ph-pal { background: var(--palisades); color: #1c1004; }
.ph-eat { background: var(--eaton);     color: #170b27; }
.ph-where { font-size: 0.92rem; line-height: 1.35; color: #f3ece0; }
.ph-credit {
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.03em;
  color: rgba(243,236,224,0.62);
}

/* ============================================================
   SCROLLY PROGRESS — rail in the instrument + numbered steps
   ============================================================ */
.scrolly-rail {
  padding: 0.72rem 1.3rem 0.6rem;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.rail-head { display: flex; align-items: baseline; gap: 0.7rem; }
.rail-step {
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--accent);
  white-space: nowrap;
}
.rail-title {
  font-family: var(--serif);
  font-size: 1.02rem;
  line-height: 1;
  color: var(--bone);
}
.rail-track { display: flex; gap: 5px; }
.rail-seg {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--line);
  transition: background 0.45s ease, box-shadow 0.45s ease;
}
.rail-seg.done { background: rgba(255,90,31,0.45); }
.rail-seg.now {
  background: var(--accent);
  box-shadow: 0 0 9px rgba(255,90,31,0.65);
}

/* numbered step ordinal — fills with the accent when the step is the active one */
.step-n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--ash-dim);
  margin-bottom: 1.1rem;
  transition: color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease, transform 0.4s ease;
}
.step.is-active .step-n {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255,90,31,0.12);
  transform: scale(1.05);
}
/* sharpen the active/inactive contrast so the current beat is unmistakable */
.step { opacity: 0.22; transition: opacity 0.45s ease, transform 0.45s ease; transform: translateY(6px); }
.step.is-active { opacity: 1; transform: none; }
.step-down {
  display: block;
  text-align: center;
  margin-top: 2.4rem;
  font-family: var(--mono);
  font-size: 1.1rem;
  color: var(--ash-dim);
  opacity: 0;
  transition: opacity 0.45s ease;
}
.step.is-active .step-down { opacity: 0.6; animation: stepBob 1.8s ease-in-out infinite; }
@keyframes stepBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(5px); }
}

/* ============================================================
   TAKEAWAY CARD — the clear, actionable conclusion
   ============================================================ */
.takeaway-card {
  margin-top: clamp(2.2rem, 5vw, 3.4rem);
  max-width: 56rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: var(--ink-1);
  box-shadow: var(--panel-shadow);
  padding: clamp(1.4rem, 3.2vw, 2.3rem);
}
.tk-kicker {
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--accent);
  margin-bottom: 0.7rem;
}
.tk-headline {
  font-family: var(--serif);
  font-size: clamp(1.3rem, 2.7vw, 1.95rem);
  line-height: 1.18;
  color: var(--bone);
  margin-bottom: 1.4rem;
}
.tk-headline em { font-style: italic; color: var(--gold); }
.tk-points {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.tk-point {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.95rem 1.05rem;
  background: var(--ink-2);
  border: 1px solid var(--line-soft);
}
.tk-num {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  color: var(--gold);
}
.tk-lbl { font-size: 0.87rem; line-height: 1.5; color: var(--ash); }
.tk-lbl b { color: var(--bone); font-weight: 600; }
.tk-action { font-size: 1.02rem; line-height: 1.65; color: var(--ash); }
.tk-action strong { color: var(--bone); font-weight: 600; }
.tk-action-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 2px;
  padding: 0.1rem 0.42rem;
  margin-right: 0.55rem;
  vertical-align: middle;
}

@media (max-width: 700px) {
  .photo-grid { grid-template-columns: 1fr; }
  .tk-points { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .scrolly-rail { padding: 0.5rem clamp(1.4rem, 5vw, 5rem) 0.45rem; }
  .rail-title { font-size: 0.9rem; }
  .step-n { width: 1.9rem; height: 1.9rem; margin-bottom: 0.8rem; }
  .step-down { margin-top: 1.6rem; }
}
