/* =========================================================
   When does the world cross 2°C — DSC 106 Project 3
   Aesthetic: editorial / dark / scientific climate-graphic
   ========================================================= */

:root {
  --bg: #0e0d0c;
  --bg-soft: #181613;
  --bg-card: #1c1a16;
  --bg-card-hover: #221f1a;
  --line: rgba(255, 240, 220, 0.08);
  --line-strong: rgba(255, 240, 220, 0.18);
  --ink: #f5efe3;
  --ink-soft: #c9c1b1;
  --ink-faint: #80786c;
  --accent: #ff5c2b; /* hot orange — warming */
  --accent-2: #ffb547; /* amber */
  --cool: #5fa8d3; /* cool blue — not crossed */
  --cool-2: #2a4a5f;
  --good: #7ec18e;
  --warn: #ff8d4a;
  --bad: #d4391b;
  --shadow-1: 0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 8px 32px rgba(0, 0, 0, 0.4);

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter Tight", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--accent);
  color: #fff;
}

a {
  color: var(--accent-2);
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}
a:hover {
  color: var(--accent);
}

button {
  font-family: inherit;
}

/* =========================================================
   HERO — editorial climate broadsheet
   ========================================================= */
.hero {
  --warming-stripe: linear-gradient(
    95deg,
    #2d5a73 0 9%,
    #5fa8d3 9% 20%,
    #88b8c4 20% 30%,
    #fde29c 30% 44%,
    #ffaa3d 44% 58%,
    #ff8d4a 58% 70%,
    #ff5c2b 70% 84%,
    #c2261b 84% 94%,
    #7a0a04 94% 100%
  );
  position: relative;
  height: 100vh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(14px, 2.4vh, 64px) clamp(20px, 5vw, 72px);
  border-bottom: 1px solid var(--line-strong);
  overflow: hidden;
  background: linear-gradient(180deg, #08080a 0%, var(--bg) 46%, #120d0a 100%);
  isolation: isolate;
}

/* Faint geographic lat/long grid — ties the masthead to the map */
.hero-gridlines {
  position: absolute;
  inset: -1px;
  pointer-events: none;
  z-index: -2;
  background-image: repeating-linear-gradient(
      90deg,
      transparent 0 calc(7.5vw - 1px),
      rgba(245, 239, 227, 0.05) calc(7.5vw - 1px) 7.5vw
    ),
    repeating-linear-gradient(
      0deg,
      transparent 0 calc(96px - 1px),
      rgba(245, 239, 227, 0.045) calc(96px - 1px) 96px
    );
  mask-image: radial-gradient(
    ellipse 120% 100% at 50% 38%,
    #000 35%,
    transparent 88%
  );
  -webkit-mask-image: radial-gradient(
    ellipse 120% 100% at 50% 38%,
    #000 35%,
    transparent 88%
  );
}

/* Single ember glow rising from the bottom edge (heat horizon) */
.hero-ember {
  position: absolute;
  left: 50%;
  bottom: -34%;
  width: 150%;
  height: 70%;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: -1;
  background: radial-gradient(
    ellipse 50% 60% at 50% 100%,
    rgba(255, 92, 43, 0.22) 0%,
    rgba(212, 57, 27, 0.1) 38%,
    transparent 72%
  );
  filter: blur(8px);
}

.hero-grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: 0.4;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.35'/></svg>");
  mix-blend-mode: overlay;
}

.hero-inner {
  position: relative;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  /* Fill the viewport-height hero so the scroll cue stays pinned at the bottom
     and never drops below the fold as the lead text grows. */
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

/* ---- Masthead ---- */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  /* Reserve room for the fixed °C/°F toggle pinned to the top-right. */
  padding-right: 76px;
}
.masthead-id {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.masthead-stripes {
  width: 46px;
  height: 16px;
  border-radius: 2px;
  background: var(--warming-stripe);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}
.masthead-name {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.masthead-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.masthead-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border: 0;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--line-strong);
  transition: color 0.22s ease, border-color 0.22s ease, gap 0.22s ease;
}
.masthead-link svg {
  transition: transform 0.28s ease;
}
.masthead-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  gap: 11px;
}
.masthead-link:hover svg {
  transform: translate(2px, -2px);
}

.hero-rule {
  height: 1px;
  margin: 18px 0 0;
  background: linear-gradient(
    90deg,
    var(--line-strong),
    var(--line) 60%,
    transparent
  );
}

/* ---- Dateline ---- */
.dateline {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 clamp(20px, 4vh, 44px);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}
/* Collapse the dateline when it has no content so it doesn't eat vertical space */
.dateline:empty {
  display: none;
  margin: 0;
}
.dateline-sep {
  color: var(--accent);
}

/* ---- Headline ---- */
.hero-title {
  margin: clamp(14px, 2.5vh, 36px) 0 0;
  font-family: var(--font-display);
  font-weight: 300;
  font-variation-settings: "opsz" 144;
  /* also cap by viewport height so the headline can't crowd out the scroll cue
     on short screens */
  font-size: clamp(56px, min(13vw, 18vh), 188px);
  line-height: 0.82;
  letter-spacing: -0.045em;
  color: var(--ink);
}
.title-line {
  display: block;
}
.title-line-2 {
  margin-left: clamp(40px, 11vw, 200px);
} /* asymmetric offset */
.title-fire {
  font-style: italic;
  font-weight: 600;
  /* deeper red-orange ember gradient */
  background: linear-gradient(
    95deg,
    #ff7a1a 0%,
    #ff4d12 35%,
    #e62200 70%,
    #b30d00 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding-right: 0.11em;
  /* layered glow around the word, pulsating */
  animation: fire-pulse 2.6s ease-in-out infinite;
}

@keyframes fire-pulse {
  0%,
  100% {
    filter: drop-shadow(0 0 8px rgba(255, 77, 18, 0.4))
      drop-shadow(0 0 20px rgba(230, 34, 0, 0.32))
      drop-shadow(0 2px 32px rgba(255, 60, 20, 0.25));
  }
  50% {
    filter: drop-shadow(0 0 16px rgba(255, 77, 18, 0.7))
      drop-shadow(0 0 40px rgba(230, 34, 0, 0.6))
      drop-shadow(0 2px 56px rgba(255, 60, 20, 0.45));
  }
}

@media (prefers-reduced-motion: reduce) {
  .title-fire {
    animation: none;
    filter: drop-shadow(0 0 10px rgba(255, 77, 18, 0.55))
      drop-shadow(0 0 28px rgba(230, 34, 0, 0.45))
      drop-shadow(0 2px 40px rgba(255, 60, 20, 0.35));
  }
}

/* ---- Lead + byline ---- */
.hero-body {
  display: grid;
  grid-template-columns: minmax(0, 640px) auto;
  align-items: start;
  gap: clamp(28px, 6vw, 88px);
  margin: clamp(16px, 3vh, 52px) 0 0;
}
.hero-lead {
  margin: 0;
  font-size: clamp(17px, 1.5vw, 20px);
  line-height: 1.6;
  color: var(--ink-soft);
  text-wrap: pretty;
}
.hero-lead em {
  color: var(--ink);
  font-style: italic;
}
.hero-lead-note {
  margin-top: 16px;
  font-size: clamp(14px, 1.1vw, 15px);
  color: var(--ink-faint);
}
.hero-lead-note em {
  font-style: normal;
  color: var(--ink-soft);
  font-weight: 500;
}
.dropcap {
  float: left;
  font-family: var(--font-display);
  font-weight: 500;
  font-variation-settings: "opsz" 144;
  font-size: 3.4em;
  line-height: 0.72;
  padding: 6px 12px 0 0;
  color: var(--accent);
}
.hero-byline {
  border-left: 1px solid var(--line-strong);
  padding-left: 22px;
  white-space: nowrap;
}
.byline-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 8px;
}
.byline-names {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 19px;
  color: var(--ink);
  line-height: 1.4;
}

/* ---- Temperature key (legend + divider) ---- */
.hero-scale {
  margin: clamp(18px, 3.2vh, 64px) 0 0;
  max-width: 760px;
}
.scale-bar {
  height: 10px;
  border-radius: 2px;
  background: var(--warming-stripe);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 6px 22px rgba(0, 0, 0, 0.45);
}
.scale-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}
.scale-caption {
  margin: 6px 0 0;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ---- Scroll cue ---- */
.hero-scroll {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  /* push the cue to the bottom of the hero so it's always on-screen */
  margin-top: auto;
  padding-bottom: clamp(40px, 2.5vh, 48px);
}
.scroll-rule {
  width: 72px;
  height: 1px;
  background: var(--ink-faint);
  position: relative;
  overflow: hidden;
}
.scroll-rule::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: scroll-sweep 2.6s ease-in-out infinite;
}
@keyframes scroll-sweep {
  0% {
    transform: translateX(-100%);
  }
  60%,
  100% {
    transform: translateX(100%);
  }
}
.scroll-label {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* While the climate data is still loading: scrolling is locked and the cue
   reads "Loading data…" with a soft pulse. app.js clears `is-loading` when
   the data is ready. */
html.is-loading,
html.is-loading body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
body.scroll-locked {
  position: fixed;
  inset: 0;
  width: 100%;
  overflow: hidden;
  touch-action: none;
}
.is-loading .scroll-label {
  color: var(--accent-2);
  animation: loading-pulse 1.4s ease-in-out infinite;
}
@keyframes loading-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* ---- Load reveal ----
   The entire hero fades in as one piece the moment it renders — a pure CSS
   animation, no JS, no stagger, no waiting on fonts or data. It animates only
   opacity + transform (GPU-composited), so it stays smooth even while the main
   thread is busy loading the climate data. Wrapped in prefers-reduced-motion
   so it's instant for those who ask. */
@media (prefers-reduced-motion: no-preference) {
  .hero-inner {
    /* `backwards` (not `both`) so the resting state is always the visible base
       style — the animation can never leave the hero stuck hidden. */
    animation: hero-in 0.5s ease-out backwards;
  }
}
@keyframes hero-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* =========================================================
   CONTROLS
   ========================================================= */
.controls {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 20px 32px;
  background: rgba(14, 13, 12, 0.92);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}

.controls-row {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 24px 36px;
  align-items: flex-end;
}

.control-group {
  flex: 0 1 auto;
  min-width: 0;
}

.control-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 10px;
}
.control-label-help {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.seg-control {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  gap: 2px;
}

.seg-btn {
  background: transparent;
  border: 0;
  color: var(--ink-soft);
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  position: relative;
}

.seg-btn:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.02);
}

.seg-btn.active {
  background: var(--ink);
  color: var(--bg);
}
.seg-btn.active .seg-desc {
  color: rgba(14, 13, 12, 0.6);
}

.seg-name {
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.01em;
}

.seg-desc {
  font-size: 10px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  text-transform: lowercase;
}

.year-scrubber {
  max-width: 1320px;
  margin: 16px auto 0;
}

.scrubber-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 16px;
}

.play-btn {
  background: var(--accent);
  color: #fff;
  border: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.play-btn:hover {
  background: var(--accent-2);
}
.play-btn:active {
  transform: scale(0.94);
}

.scrubber-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.scrubber-ticks {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-faint);
  padding: 0 2px;
}

#year-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--cool-2),
    var(--accent-2),
    var(--accent)
  );
  outline: none;
}
#year-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--ink);
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), 0 0 0 4px rgba(255, 255, 255, 0.06);
}
#year-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--ink);
  border: 0;
  border-radius: 50%;
  cursor: grab;
}

.year-tick {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--accent-2);
  min-width: 48px;
  text-align: right;
}

/* =========================================================
   VIZ GRID
   ========================================================= */
.viz-grid {
  max-width: 1320px;
  margin: 28px auto;
  padding: 0 32px;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 20px;
}

@media (max-width: 1100px) {
  .viz-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: var(--shadow-1);
  transition: border-color 0.2s;
}

.card:hover {
  border-color: var(--line-strong);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.card-head > div:first-child {
  min-width: 0;
  flex: 1 1 320px;
}
.card-head .map-legend {
  flex: 0 0 auto;
}

.card-head.compact {
  margin-bottom: 12px;
}

.card-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
  line-height: 1.15;
}

.card-head.compact .card-title {
  font-size: 17px;
}

.card-sub {
  font-size: 13px;
  color: var(--ink-faint);
  margin: 0;
  line-height: 1.4;
}

.card-foot {
  display: flex;
  gap: 32px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.foot-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.foot-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-style: italic;
  font-size: 28px;
  color: var(--accent-2);
  letter-spacing: -0.02em;
  line-height: 1;
}

.foot-lbl {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* =========================================================
   MAP
   ========================================================= */
.map-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1.05;
  border-radius: 8px;
  overflow: hidden;
  background: radial-gradient(
      ellipse at center,
      rgba(255, 255, 255, 0.015),
      transparent 70%
    ),
    var(--bg-soft);
}

#map {
  width: 100%;
  height: 100%;
  display: block;
}

.map-overlay-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(14, 13, 12, 0.7);
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  pointer-events: none;
  transition: opacity 0.4s;
}
.map-overlay-msg.hidden {
  opacity: 0;
}

.map-cell {
  cursor: pointer;
  stroke: none;
  shape-rendering: crispEdges;
  transition: filter 0.1s;
}
.map-cell:hover {
  filter: brightness(1.2);
}
.map-cell.never {
  fill: rgba(95, 168, 211, 0.06);
}
.map-cell.selected {
  stroke: var(--ink);
  stroke-width: 2;
}

.coastline {
  fill: none;
  stroke: rgba(255, 245, 225, 0.85);
  stroke-width: 1;
  stroke-linejoin: round;
  pointer-events: none;
}

.graticule {
  fill: none;
  stroke: rgba(255, 240, 220, 0.04);
  stroke-width: 0.3;
  pointer-events: none;
}

.sphere {
  fill: var(--bg-soft);
  stroke: var(--line-strong);
  stroke-width: 0.5;
}

/* Map legend */
.map-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-faint);
  letter-spacing: 0.05em;
}

.legend-bar {
  width: 220px;
  height: 10px;
  border-radius: 2px;
  position: relative;
}

.legend-axis {
  display: flex;
  justify-content: space-between;
  width: 220px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-faint);
}

.legend-never {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.legend-never-swatch {
  width: 12px;
  height: 10px;
  background: rgba(95, 168, 211, 0.12);
  border: 1px solid rgba(95, 168, 211, 0.3);
  border-radius: 2px;
}

/* Tooltip */
.tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(28, 26, 22, 0.96);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink);
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 100;
  white-space: nowrap;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
}
.tooltip.visible {
  opacity: 1;
}
.tooltip.scenario-tooltip {
  width: min(330px, calc(100vw - 24px));
  white-space: normal;
}

.tip-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}
.tip-key {
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.tip-val {
  color: var(--ink);
  font-weight: 500;
  font-family: var(--font-mono);
}
.tip-headline {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  font-size: 18px;
  color: var(--accent-2);
  margin: 4px 0;
}
.scenario-tip-note {
  color: var(--ink-soft);
  margin: 0 0 8px;
}
.scenario-tip-list {
  display: grid;
  gap: 8px;
}
.scenario-tip-row {
  display: grid;
  grid-template-columns: 74px 76px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
}
.scenario-tip-label,
.scenario-tip-short {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
}
.scenario-tip-label {
  color: var(--ink);
  font-weight: 700;
}
.scenario-tip-short {
  color: var(--accent-2);
  text-transform: uppercase;
}
.scenario-tip-text {
  color: var(--ink-soft);
}

/* =========================================================
   SIDE COLUMN
   ========================================================= */
.side-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.side-chart {
  width: 100%;
  height: 200px;
  display: block;
  margin-top: 8px;
}

#cell-chart,
#histogram {
  height: 180px;
}

/* Region chips */
.region-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0 4px;
}

.chip {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 4px 8px;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Chart axes */
.axis text {
  fill: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 10px;
}

.axis line,
.axis path {
  stroke: var(--line);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.gridline {
  stroke: var(--line);
  stroke-dasharray: 2 3;
  shape-rendering: crispEdges;
}

.threshold-line {
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
}

.threshold-label {
  fill: var(--accent);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
}

.scenario-line {
  fill: none;
  stroke-width: 2;
  transition: opacity 0.2s;
}
.scenario-line.dim {
  opacity: 0.3;
}

.scenario-line.ssp126 {
  stroke: var(--good);
}
.scenario-line.ssp245 {
  stroke: var(--accent-2);
}
.scenario-line.ssp585 {
  stroke: var(--bad);
}

.scenario-dot {
  fill: var(--ink);
  stroke: var(--bg-card);
  stroke-width: 2;
}

.scenario-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.cell-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
}
.cell-area {
  fill: var(--accent);
  fill-opacity: 0.12;
}

.hist-bar {
  fill: var(--accent);
  transition: fill 0.15s;
}
.hist-bar:hover {
  fill: var(--accent-2);
}
.hist-bar.below {
  fill: var(--cool);
}

/* =========================================================
   WRITEUP
   ========================================================= */
.writeup {
  scroll-margin-top: 140px;
  background: var(--bg-soft);
  padding: 80px 32px;
  margin-top: 40px;
  border-top: 1px solid var(--line);
}

.writeup-inner {
  max-width: 760px;
  margin: 0 auto;
}

.writeup h2 {
  font-family: var(--font-display);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(36px, 5vw, 56px);
  margin: 0 0 48px;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.writeup-block {
  margin-bottom: 40px;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--line);
}
.writeup-block:last-of-type {
  border-bottom: 0;
}

.writeup-block h3 {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin: 0 0 12px;
}

.writeup-block p {
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 0 0 14px;
}

.writeup-block strong {
  color: var(--ink);
  font-weight: 500;
}

.page-foot {
  padding: 24px 32px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  flex-wrap: wrap;
  gap: 12px;
}

/* =========================================================
   SCROLLYTELLING
   ========================================================= */
.scrolly {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 0;
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 32px;
}

.scroll-graphic {
  grid-column: 1;
  grid-row: 1;
  position: sticky;
  top: 0;
  height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.viz-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 56px 24px 32px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: opacity 0.55s ease, transform 0.55s ease, visibility 0s 0.55s;
  pointer-events: none;
}
.viz-panel.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
  transition: opacity 0.55s ease, transform 0.55s ease, visibility 0s 0s;
}

.full-svg {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: block;
}

.viz-meta {
  position: absolute;
  top: 18px;
  left: 24px;
  right: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  z-index: 2;
}
.viz-label {
  color: var(--ink-soft);
}

.viz-caption {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  padding: 8px 4px 0;
  align-items: center;
}
.caption-key {
  display: inline-block;
  width: 14px;
  height: 10px;
  margin-right: 4px;
  border-radius: 2px;
  vertical-align: middle;
}

.scroll-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  background: var(--bg-soft);
  z-index: 10;
  transition: opacity 0.4s;
}
.scroll-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Scroll steps */
.scroll-steps {
  grid-column: 2;
  grid-row: 1;
  position: relative;
  z-index: 1;
  padding: 50vh 0 50vh;
}

.step {
  min-height: 80vh;
  padding: 0;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.step-stage {
  --scrolly-progress: 0;
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  align-items: center;
  padding: 80px 8px 80px 36px;
  pointer-events: none;
  z-index: 3;
}

.step-stage-inner {
  position: relative;
  width: 100%;
  max-width: 38ch;
  min-height: min(58vh, 460px);
}

.step-copy {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  opacity: 0;
  visibility: hidden;
  transform: translateY(calc(-50% + 10px));
  transition: opacity 0.32s ease, transform 0.32s ease, visibility 0s 0.32s;
}

.step-copy.is-active {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%);
  transition: opacity 0.32s ease, transform 0.32s ease, visibility 0s 0s;
}

.step-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin: 0 0 16px;
}

.step h3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-style: italic;
  font-size: clamp(28px, 3.4vw, 44px);
  letter-spacing: -0.02em;
  line-height: 1.08;
  margin: 0 0 18px;
  color: var(--ink);
}
.step-copy h3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-style: italic;
  font-size: clamp(28px, 3.4vw, 44px);
  letter-spacing: -0.02em;
  line-height: 1.08;
  margin: 0 0 18px;
  color: var(--ink);
}

.step p {
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 0 0 12px;
  max-width: 38ch;
}
.step-copy p:not(.step-eyebrow) {
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 0 0 12px;
  max-width: 38ch;
}

.step em {
  font-style: italic;
  color: var(--ink);
}
.step-copy em {
  font-style: italic;
  color: var(--ink);
}

/* "How to read it" helper note under each step's narrative */
.step .step-howto,
.step-copy .step-howto {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-faint);
  border-left: 2px solid var(--accent-2);
  padding-left: 12px;
  margin: 18px 0 0;
  max-width: 38ch;
}
.step-howto strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin: 0 0 5px;
}
.step-howto em {
  font-style: normal;
  color: var(--ink-soft);
  font-weight: 500;
}

/* Inline defined term: subtle dotted underline */
.term {
  border-bottom: 1px dotted var(--ink-faint);
  color: var(--ink);
  font-style: normal;
  cursor: help;
}

.scrolly-progress {
  position: relative;
  width: min(100%, 34ch);
  height: 3px;
  margin-top: 24px;
  border-radius: 999px;
  background: rgba(255, 240, 220, 0.12);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.step-stage.is-progress-visible .step-copy.is-active .scrolly-progress {
  opacity: 1;
}
.scrolly-progress-fill {
  position: absolute;
  inset: 0;
  transform: scaleX(var(--scrolly-progress));
  transform-origin: left;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
}

/* mobile collapse */
@media (max-width: 900px) {
  .scrolly {
    grid-template-columns: 1fr;
    padding: 0 14px;
  }

  /* Two stacked, non-overlapping zones: a pinned OPAQUE viz on top, and a
     clear reading band underneath. The graphic must be opaque and sit above
     the steps in z-order, otherwise the text scrolls through the chart and
     intercepts touches meant for the visualization. */
  .scroll-graphic {
    grid-column: 1;
    grid-row: 1;
    top: 0;
    height: 56vh;
    height: 56svh;
    z-index: 5;
    background: var(--bg);
    border-bottom: 1px solid var(--line-strong);
    box-shadow: 0 14px 28px -12px rgba(0, 0, 0, 0.75);
  }
  .scroll-steps {
    grid-column: 1;
    grid-row: 2;
    position: relative;
    z-index: 1;
    padding: 0 0 26vh;
  }
  .step-stage {
    grid-column: 1;
    grid-row: 2;
    top: 56vh;
    top: 56svh;
    height: 44vh;
    height: 44svh;
    padding: 28px clamp(14px, 4vw, 42px);
    background: var(--bg);
    border-top: 1px solid var(--line);
  }
  .step-stage-inner {
    max-width: min(100%, 760px);
    min-height: 36vh;
    min-height: 36svh;
  }
  .step {
    /* Sized so the centered text lands in the reading band (below the
       pinned graphic) while its matching chart is active. */
    min-height: 46vh;
    min-height: 46svh;
  }
  .step-copy h3 {
    grid-column: 1;
    font-size: clamp(24px, 8vw, 34px);
  }
  .step-copy p:not(.step-eyebrow) {
    font-size: 14px;
    line-height: 1.48;
  }
  .step-copy {
    display: grid;
    grid-template-columns: minmax(0, 1.18fr) minmax(150px, 0.82fr);
    column-gap: clamp(20px, 6vw, 56px);
    align-items: start;
  }
  .step-copy .step-eyebrow {
    grid-column: 1 / -1;
  }
  .step-copy p:not(.step-eyebrow):not(.step-howto) {
    grid-column: 1;
    max-width: none;
  }
  .step-copy .step-howto {
    grid-column: 2;
    grid-row: 3 / span 2;
    max-width: none;
    margin: 4px 0 0;
  }
  .step-copy .scrolly-progress {
    grid-column: 1 / -1;
  }
  .viz-panel {
    padding: 12px 12px 12px;
  }

  /* On mobile the act-label flows in-column instead of overlaying the chart,
     so a long label can never bleed into the visualization. */
  .viz-meta {
    position: static;
    margin: 0 0 6px;
    flex: 0 0 auto;
  }
  .viz-label {
    white-space: normal;
    line-height: 1.3;
    font-size: 9px;
    letter-spacing: 0.1em;
  }

  /* Hero collapses to a single editorial column */
  .hero-body {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .hero-byline {
    border-left: 0;
    border-top: 1px solid var(--line-strong);
    padding-left: 0;
    padding-top: 18px;
    white-space: normal;
  }
  .title-line-2 {
    margin-left: clamp(24px, 8vw, 80px);
  }
}

@media (orientation: portrait), (max-width: 900px) {
  .scrolly-progress {
    position: absolute;
    top: 50%;
    right: -12px;
    width: 3px;
    height: min(72%, 260px);
    margin-top: 0;
    transform: translateY(-50%);
  }
  .scrolly-progress-fill {
    transform: scaleY(var(--scrolly-progress));
    transform-origin: top;
    background: linear-gradient(180deg, var(--accent-2), var(--accent));
  }
}

@media (max-width: 560px) {
  .masthead-meta {
    display: none;
  }
  .hero-title {
    line-height: 0.86;
  }
}

/* =========================================================
   STRIPES VIZ
   ========================================================= */
.stripe-rect {
  shape-rendering: crispEdges;
}
.stripe-row-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  fill: var(--ink-soft);
}
.stripe-row-label.dim {
  fill: var(--ink-faint);
}
.stripe-axis text {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--ink-faint);
}
.stripe-axis line {
  stroke: var(--line);
}
.stripe-axis path {
  display: none;
}
.stripe-divider-line {
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 1;
  stroke-dasharray: 3 4;
}
.stripe-divider-text {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  fill: var(--ink-faint);
}

/* =========================================================
   RIDGE PLOT
   ========================================================= */
.ridge-path {
  fill-opacity: 0.7;
  stroke-width: 1.2;
  stroke-linejoin: round;
  transition: fill-opacity 0.2s;
}
.ridge-path:hover {
  fill-opacity: 0.95;
}
.ridge-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  fill: var(--ink);
}
.ridge-sublabel {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.05em;
  fill: var(--ink-faint);
}
.ridge-axis text {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--ink-faint);
}
.ridge-axis line {
  stroke: var(--line);
}
.ridge-axis path {
  display: none;
}

/* =========================================================
   BEESWARM
   ========================================================= */
.bee-dot {
  stroke: rgba(0, 0, 0, 0.35);
  stroke-width: 0.4;
  transition: stroke 0.15s;
}
.bee-dot:hover {
  stroke: var(--ink);
  stroke-width: 1.5;
}
.bee-axis text {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--ink-faint);
}
.bee-axis line {
  stroke: var(--line);
}
.bee-axis path {
  display: none;
}
.bee-never-divider {
  stroke: var(--ink-faint);
  stroke-dasharray: 3 4;
  opacity: 0.6;
}
.bee-never-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  fill: var(--ink-faint);
}

/* =========================================================
   FAN CHART
   ========================================================= */
.fan-area-126 {
  fill: var(--good);
  fill-opacity: 0.55;
}
.fan-area-245 {
  fill: var(--accent-2);
  fill-opacity: 0.45;
}
.fan-area-585 {
  fill: var(--bad);
  fill-opacity: 0.4;
}
.fan-line {
  fill: none;
  stroke-width: 2;
}
.fan-line-126 {
  stroke: var(--good);
}
.fan-line-245 {
  stroke: var(--accent-2);
}
.fan-line-585 {
  stroke: var(--bad);
}

.fan-axis text {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--ink-faint);
}
.fan-axis line {
  stroke: var(--line);
}
.fan-axis path {
  display: none;
}

.fan-scenario-label {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.fan-divergence-anno {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 13px;
  fill: var(--ink);
}

/* =========================================================
   SHARED ACT TOOLBAR
   ========================================================= */
/* In-flow control bar inserted above an act's chart, so it reserves layout
   space and never overlaps the visualization. */
.viz-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 18px;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 8px;
  padding: 8px 14px;
  background: rgba(28, 26, 22, 0.72);
  border: 1px solid var(--line);
  border-radius: 10px;
  backdrop-filter: blur(4px);
  position: relative;
  z-index: 3;
}
.vt-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.vt-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.scenario-help-btn {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-soft);
  cursor: help;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
  padding: 0;
  text-transform: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.scenario-help-btn:hover,
.scenario-help-btn:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent-2);
  color: var(--ink);
  outline: none;
}
.vt-seg {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px;
  gap: 2px;
}
.vt-reset {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.vt-reset:hover {
  color: var(--accent);
  border-color: var(--accent);
}
/* Map: cells become clickable for click-to-zoom */
.scroll-map-cells .map-cell {
  cursor: zoom-in;
}

/* =========================================================
   LIFETIME TIMELINE
   ========================================================= */
/* ---- Act V: morphing popup → top control bar ---- */
.lifetime-card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: min(460px, 88%);
  padding: 32px 32px 28px;
  background: var(--bg-card);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-1), 0 24px 60px rgba(0, 0, 0, 0.55);
  text-align: center;
  transition: top 0.7s cubic-bezier(0.66, 0, 0.2, 1),
    left 0.7s cubic-bezier(0.66, 0, 0.2, 1),
    right 0.7s cubic-bezier(0.66, 0, 0.2, 1),
    transform 0.7s cubic-bezier(0.66, 0, 0.2, 1),
    width 0.7s cubic-bezier(0.66, 0, 0.2, 1),
    padding 0.7s cubic-bezier(0.66, 0, 0.2, 1),
    border-radius 0.7s ease, box-shadow 0.7s ease, background 0.7s ease;
}
.lc-question {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.15;
  color: var(--ink);
}
.lc-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}
.lc-label {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
  color: var(--ink);
}
.lc-go {
  background: var(--accent);
  color: #1a0d07;
  border: 0;
  border-radius: 7px;
  padding: 9px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease;
}
.lc-go:hover {
  background: var(--accent-2);
  transform: translateY(-1px);
}
.lc-hint {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}
#panel-lifetime:not(.lifetime-started) .lc-scenarios,
#panel-lifetime:not(.lifetime-started) .lc-reset {
  display: none;
}
.lc-reset {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 7px 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.lc-reset:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Started: card becomes a slim top bar, graph fades in */
#panel-lifetime #lifetime-svg {
  opacity: 0;
  transition: opacity 0.6s ease 0.25s;
  pointer-events: none;
}
#panel-lifetime.lifetime-started #lifetime-svg {
  opacity: 1;
  pointer-events: auto;
}
#panel-lifetime.lifetime-started .lifetime-card {
  top: 44px;
  left: 3%;
  right: 3%;
  transform: none;
  width: auto;
  max-width: none;
  padding: 8px 18px;
  border-radius: 10px;
  /* Two tidy centered rows (controls, then quick-picks) instead of a single
     row whose children wrap into ragged uneven columns. */
  flex-direction: column;
  align-items: center;
  gap: 0;
  box-shadow: var(--shadow-1);
  background: rgba(28, 26, 22, 0.82);
  backdrop-filter: blur(6px);
}
.lifetime-started .lc-question,
.lifetime-started .lc-hint,
.lifetime-started .lc-go {
  display: none;
}
.lifetime-started .lc-controls {
  width: 100%;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px 16px;
  padding: 4px 0;
}
.lifetime-started .lc-scenarios {
  display: inline-flex;
}
/* Keep the scenario picker grouped with its help button rather than shoved to
   the far edge by the popup's margin-left:auto. */
.lifetime-started .lifetime-scenario-toggle {
  margin-left: 0;
}
.lifetime-started .lc-reset {
  display: inline-flex;
  padding: 6px 10px;
  margin-left: 4px;
}
.lifetime-started .lc-label {
  font-size: 14px;
  color: var(--ink-soft);
}
.lifetime-started #birth-year-input {
  width: 74px;
  font-size: 15px;
  padding: 6px 8px;
}
.lifetime-started .seg-btn-mini {
  padding: 5px 8px;
}
/* Second row: the "year people remember" quick-picks, on their own full-width
   line with a hairline divider so the toolbar reads as two intentional rows. */
.lifetime-started .event-year-row {
  width: 100%;
  margin-top: 0;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  justify-content: center;
  align-items: center;
  gap: 6px 8px;
  font-size: 0.68rem;
}
.lifetime-started .event-year-btn {
  padding: 5px 9px;
  border-radius: 7px;
  font-size: 0.66rem;
}

#birth-year-input {
  width: 92px;
  background: var(--bg-card);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 18px;
  letter-spacing: 0.04em;
  padding: 8px 12px;
  border-radius: 6px;
  outline: none;
  text-align: center;
}
#birth-year-input:focus {
  border-color: var(--accent);
}

.lifetime-scenario-toggle {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px;
  gap: 2px;
  margin-left: auto;
}
.seg-btn-mini {
  background: transparent;
  border: 0;
  color: var(--ink-soft);
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  transition: background 0.15s, color 0.15s;
}
.seg-btn-mini:hover {
  color: var(--ink);
}
.seg-btn-mini.active {
  background: var(--ink);
  color: var(--bg);
}

.life-track-fill {
  fill: url(#life-gradient);
}
.life-track-bg {
  fill: rgba(255, 255, 255, 0.04);
}
.life-axis text {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--ink-faint);
}
.life-axis line {
  stroke: var(--line);
}
.life-axis path {
  display: none;
}
.life-milestone-line {
  stroke-width: 1.5;
  stroke-dasharray: 3 3;
}
.life-milestone-dot {
  stroke: var(--bg);
  stroke-width: 2;
}
.life-milestone-text {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
}
.life-age-text {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 20px;
  fill: var(--ink);
}
.life-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  fill: var(--ink-faint);
}
.life-birth-label,
.life-end-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  fill: var(--ink);
}

/* =========================================================
   FINALE DIVIDER
   ========================================================= */
.finale-divider {
  padding: 80px 32px 30px;
  border-top: 1px solid var(--line);
  background: radial-gradient(
      ellipse at 50% 0%,
      rgba(255, 92, 43, 0.1),
      transparent 60%
    ),
    var(--bg);
}
.finale-divider-inner {
  max-width: 1320px;
  margin: 0 auto;
}
.finale-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-2);
}
.finale-divider h2 {
  font-family: var(--font-display);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(34px, 5vw, 56px);
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 12px 0 0;
}

/* Scrolly map */
#scroll-map {
  width: 100%;
  height: 100%;
}
#scroll-map-legend {
  margin-top: 8px;
}
.scroll-map-annotation {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  fill: var(--ink);
}
.scroll-map-anno-bg {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  fill: var(--bg);
  stroke: var(--bg);
  stroke-width: 4;
  paint-order: stroke fill;
}
.scroll-map-anno-line {
  stroke: var(--ink);
  stroke-width: 1.2;
  fill: none;
  opacity: 0.85;
}
.scroll-map-anno-circle {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-dasharray: 2 3;
}

/* =========================================================
   SCROLLY INTERACTIONS (hover / scrub / zoom guides)
   ========================================================= */

/* Act I — stripes scrub */
.stripe-guide {
  stroke: var(--ink);
  stroke-width: 1.5;
  pointer-events: none;
  mix-blend-mode: difference;
}
.stripe-guide-year {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  fill: var(--ink);
  pointer-events: none;
}

/* Act II — map zoom/hover */
.scroll-map-hint {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  fill: var(--ink-faint);
  transition: opacity 0.3s;
}
.scroll-map-hint.dim {
  opacity: 0.25;
}
.map-cell {
  transition: none;
}
.map-cell.cell-hover {
  stroke: var(--ink);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

/* Act III — ridge scrub */
.ridge-scrub-line {
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  pointer-events: none;
}
.ridge-scrub-year {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  fill: var(--ink);
  pointer-events: none;
}
.ridge-scrub-pct {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
}

/* Act IV — beeswarm scrub */
.bee-scrub-line {
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  pointer-events: none;
}
.bee-scrub-label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  fill: var(--ink);
  pointer-events: none;
}
.bee-scrub-readout {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 16px;
  fill: var(--accent-2);
  pointer-events: none;
}
/* While scrubbing, the parent group dims every dot in a single class write;
   dots tagged .bee-lit (already crossed) are restored to full opacity. No
   opacity transition: a scrub can flip thousands of dots at once, and
   animating that many simultaneous tweens is what made dragging janky. */
.bee-dots.scrubbing .bee-dot {
  opacity: 0.12;
}
.bee-dots.scrubbing .bee-dot.bee-lit {
  opacity: 1;
}

/* Act V — fan scrub */
.fan-scrub-line {
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
  pointer-events: none;
}
.fan-scrub-dot {
  stroke: var(--bg);
  stroke-width: 1.5;
  pointer-events: none;
}

/* Act V — lifetime trajectory */
.life-area {
  opacity: 0.5;
  pointer-events: none;
}
.life-line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
  opacity: 0.85;
  pointer-events: none;
}
/* Decorative layers must not steal pointer events from the zoom/hover brush */
.life-threshold-line,
.life-milestone-mark,
.life-milestone-line,
.life-milestone-dot,
.life-milestone-text,
.life-predata {
  pointer-events: none;
}
/* Brush: hide the default handles/selection chrome, keep a subtle wash */
.life-brush .selection {
  fill: rgba(255, 181, 71, 0.14);
  stroke: var(--accent-2);
  stroke-opacity: 0.5;
  shape-rendering: crispEdges;
}
.life-brush .handle {
  fill: var(--accent-2);
  fill-opacity: 0.4;
}
.life-axis-y text {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--ink-faint);
}
.life-axis-y path {
  display: none;
}
.life-threshold-line {
  stroke: var(--ink-faint);
  stroke-width: 1;
  stroke-dasharray: 3 4;
  opacity: 0.5;
}
.life-predata {
  stroke: var(--ink-faint);
  stroke-width: 1.5;
  stroke-dasharray: 3 4;
}
.life-birth-stem {
  stroke: var(--ink);
  stroke-width: 1;
  stroke-dasharray: 2 3;
  opacity: 0.5;
}
.life-scrub-line {
  stroke: var(--accent-2);
  stroke-width: 1.5;
  pointer-events: none;
}
.life-scrub-dot {
  fill: var(--accent-2);
  stroke: var(--bg);
  stroke-width: 2.5;
  pointer-events: none;
}
.life-scrub-badge rect {
  fill: var(--accent-2);
  pointer-events: none;
}
.life-scrub-badge text {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  fill: var(--bg);
  pointer-events: none;
}

@media (max-width: 520px) {
  .scenario-tip-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

/* ============================================================
   Temperature-unit toggle (°C / °F) — fixed, always reachable
   ============================================================ */
.unit-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 50;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 8px;
  background: rgba(20, 18, 15, 0.82);
  border: 1px solid var(--line-strong);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}
.unit-btn {
  background: transparent;
  border: 0;
  color: var(--ink-soft);
  padding: 5px 11px;
  border-radius: 5px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.unit-btn:hover {
  color: var(--ink);
}
.unit-btn.active {
  background: var(--accent);
  color: var(--bg);
}

@media (max-width: 520px) {
  .unit-toggle {
    top: 10px;
    right: 10px;
    padding: 2px;
  }
  .unit-btn {
    padding: 4px 9px;
    font-size: 11px;
  }
}

/* ============================================================
   Loading spinners — unit switch + per-panel recompute
   ============================================================ */
@keyframes vis-spin {
  to {
    transform: rotate(360deg);
  }
}
.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 240, 220, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: vis-spin 0.7s linear infinite;
  flex: none;
}

/* Small status pill that drops in under the °C/°F toggle while converting. */
.unit-loading {
  position: fixed;
  top: 56px;
  right: 14px;
  z-index: 49;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 7px;
  background: rgba(20, 18, 15, 0.9);
  border: 1px solid var(--line-strong);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.unit-loading.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Centered overlay shown while a panel recomputes its layout. */
.panel-loading {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(14, 13, 12, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.panel-loading.visible {
  opacity: 1;
}

/* Historical event buttons inside lifetime card */
.event-year-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1rem;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.event-year-label {
  color: var(--ink-faint);
  margin-right: 0.25rem;
}

.event-year-btn {
  appearance: none;
  border: 1px solid rgba(245, 235, 215, 0.22);
  background: rgba(245, 235, 215, 0.06);
  color: var(--ink);
  border-radius: 10px;
  padding: 0.48rem 0.7rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.event-year-btn:hover,
.event-year-btn:focus-visible {
  background: rgba(245, 235, 215, 0.14);
  border-color: rgba(245, 235, 215, 0.45);
  transform: translateY(-1px);
  outline: none;
}

.event-year-btn.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
