/* ══════════════════════════════════════════════════════════════════
   IRAN WAR 2026: A GEOECONOMIC AUTOPSY
   styles.css — Editorial "Document of Record" Theme
   Stepwell Centre for Asian Futures · Ahmedabad University

   Design system: see DESIGN.md
   Typography: Fraunces (display) · Newsreader (body) · Libre Franklin (UI)
   Palette: paper + ink + oxblood crisis accent (replaces viridis)

   Fonts are loaded via <link> in index.html (Fraunces · Newsreader ·
   Libre Franklin).
   ══════════════════════════════════════════════════════════════════ */

/* ─── CSS CUSTOM PROPERTIES ─── */
:root {
  /* Editorial surfaces */
  --paper:        #FBFAF8;
  --surface:      #FFFFFF;
  --inset:        #F4F2EC;
  --rule:         #E4E1DA;
  --rule-strong:  #CFC9BC;

  /* Ink */
  --ink:          #1A1A1A;
  --body:         #2B2B2B;
  --muted:        #6B6B6B;
  --faint:        #9A9488;

  /* Accents */
  --crisis:       #A61B1B;
  --crisis-deep:  #7A1010;
  --crisis-tint:  #F2E4E1;
  --link:         #326891;
  --teal:         #3E6B5E;
  --teal-tint:    #E6EEEA;
  --gold:         #B8860B;

  /* Escalation ramp — replaces viridis (paper tint → deep oxblood).
     Legacy --v* names kept so existing references stay valid. */
  --v0: #F2E4E1;
  --v1: #E7C6C0;
  --v2: #D89E96;
  --v3: #C8756B;
  --v4: #BC4C41;
  --v5: #A61B1B;
  --v6: #94120F;
  --v7: #7A1010;
  --v8: #5E0C0C;
  --v9: #4A0909;

  /* Data-viz categorical (charts recolored in app.js) */
  --data-ink:    #1A1A1A;
  --data-crisis: #A61B1B;
  --data-blue:   #326891;
  --data-gray:   #9A9488;

  /* Legacy surface/text aliases remapped to editorial tokens */
  --bg-base:      var(--paper);
  --bg-surface:   var(--inset);
  --bg-card:      var(--surface);
  --bg-elevated:  var(--inset);
  --border:       var(--rule);
  --border-light: #EEEBE4;

  --text-primary:   var(--ink);
  --text-secondary: var(--muted);
  --text-muted:     var(--faint);
  --text-accent:    var(--crisis);

  /* Typography — Crimson Pro (display/serif) + Work Sans (body/UI/sans) */
  --font-display: 'Crimson Pro', Georgia, 'Times New Roman', serif;
  --font-read:    'Work Sans', system-ui, sans-serif;
  --font-mono:    'Work Sans', system-ui, sans-serif; /* UI/label face (name kept for compat) */
  --font-sans:    'Work Sans', system-ui, sans-serif;

  /* Layout */
  --max-width:    1080px;
  --measure:      680px;
  --section-pad:  96px 24px;
  --card-radius:  3px;
  --nav-h:        56px; /* updated at runtime; sticky offsets key off this */

  /* Phase colors — editorial escalation (calm → crisis → resolution) */
  --phase-outbreak:   var(--faint);
  --phase-closure:    var(--v2);
  --phase-escalation: var(--v3);
  --phase-peak:       var(--crisis);
  --phase-stalemate:  #8A8478;
  --phase-ceasefire1: var(--teal);
  --phase-collapse:   var(--crisis-deep);
  --phase-blockade:   var(--v6);
  --phase-relapse:    var(--v4);
  --phase-resolution: var(--teal);
  --phase-recovery:   #5E8A79;
}

/* ─── DARK MODE ("night mode") — warm charcoal, not neon ─── */
[data-theme="dark"] {
  --paper:        #14120E;
  --surface:      #1B1813;
  --inset:        #201C16;
  --rule:         #332E26;
  --rule-strong:  #463F33;

  --ink:          #F1ECE2;
  --body:         #DAD3C6;
  --muted:        #9E978A;
  --faint:        #6E675B;

  --crisis:       #E06A5E;
  --crisis-deep:  #C24A44;
  --crisis-tint:  #2E1B18;
  --link:         #8FB4D6;
  --teal:         #5E8A79;
  --teal-tint:    #20302A;
  --gold:         #C9A24A;

  --border-light: #29241D;
}

/* ─── RESET & BASE ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Inline line icons (replace emoji) */
.ico {
  width: 12px;
  height: 12px;
  display: inline-block;
  vertical-align: -2px;
  margin-right: 5px;
  color: var(--faint);
  flex-shrink: 0;
}

html {
  scroll-behavior: smooth;
  overflow-x: clip; /* guard: never scroll horizontally when the window shrinks
                       (clip, not hidden — keeps position:sticky working) */
}

body {
  background: var(--paper);
  color: var(--body);
  font-family: var(--font-read);
  font-size: 19px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  transition: background 0.3s ease, color 0.3s ease;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ─── PROGRESS BAR ─── */
#progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  background: linear-gradient(to right, var(--ink), var(--crisis));
  z-index: 1000;
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.1s linear;
}

/* ─── NAVIGATION ─── */
#main-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 900;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rule);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.nav-logo-mark {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.nav-logo-text { display: flex; flex-direction: column; line-height: 1.2; }

.nav-logo-primary {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.nav-logo-secondary {
  font-family: var(--font-sans);
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.nav-divider {
  width: 1px;
  height: 28px;
  background: var(--rule-strong);
  flex-shrink: 0;
}

.nav-project-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
  min-width: 0; /* allow the title to shrink + ellipsize instead of forcing width */
}

.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 2px;
  color: var(--muted);
  transition: color 0.15s ease, background 0.15s ease;
}
.nav-icon-link:hover { color: var(--ink); background: var(--inset); }
.nav-icon-link svg { width: 17px; height: 17px; display: block; }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  padding: 6px 10px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink); }
.theme-toggle svg { width: 14px; height: 14px; }
.theme-toggle .toggle-label { display: inline; }
@media (max-width: 600px) { .theme-toggle .toggle-label { display: none; } }

.nav-phase-pill {
  font-family: var(--font-sans);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.8px;
  padding: 3px 8px;
  border-radius: 2px;
  text-transform: uppercase;
  transition: opacity 0.2s;
}

/* ─── HERO / MASTHEAD ─── */
#hero {
  background: var(--paper);
  padding: calc(var(--nav-h) + 92px) 24px 72px;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--rule);
}

.hero-inner {
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
  text-align: center;
}

.hero-eyebrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  font-family: var(--font-sans);
  text-transform: uppercase;
  margin-bottom: 28px;
}
.hero-eyebrow .eyebrow-primary {
  font-size: 13px;
  font-weight: 600;
  color: var(--crisis);
  letter-spacing: 0.2em;
}
.hero-eyebrow .eyebrow-secondary {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.16em;
}

.hero-title {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-size: clamp(2.4rem, 9vw, 4.5rem);
  font-weight: 600;
  line-height: 1.0;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin-bottom: 24px;
  white-space: nowrap; /* keep "The 2026 Iran War" on a single line */
}

.hero-subtitle {
  font-family: var(--font-read);
  font-size: clamp(19px, 2.4vw, 24px);
  color: var(--muted);
  max-width: 640px;
  line-height: 1.5;
  margin: 0 auto 48px;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 32px;
  max-width: 820px;
  margin: 0 auto;
  padding-top: 40px;
  border-top: 1px solid var(--rule);
  text-align: left;
}

.hero-stat-number {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  font-size: clamp(30px, 4vw, 46px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 8px;
}

.hero-stat-label {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.5;
}

.hero-viridis-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(to right, var(--v0), var(--v3), var(--v5), var(--v7), var(--v9));
}

.hero-byline {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-sans);
  font-size: 13px;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-bottom: 44px;
  text-align: left;
}

.author-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--rule-strong);
  flex-shrink: 0;
}
.author-avatar.is-missing { display: none; }

.byline-meta { display: flex; flex-direction: column; line-height: 1.4; }
.byline-name-line { color: var(--body); }
.byline-dateline { color: var(--muted); font-size: 12px; }

.hero-byline-name {
  font-weight: 600;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.byline-socials { display: inline-flex; gap: 4px; margin-left: 2px; }
.byline-social {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 2px;
  color: var(--muted);
  transition: color 0.15s ease, background 0.15s ease;
}
.byline-social:hover { color: var(--ink); background: var(--inset); }
.byline-social svg { width: 15px; height: 15px; display: block; }

@media (max-width: 520px) {
  .hero-byline { flex-wrap: wrap; justify-content: center; gap: 10px; }
}

.hero-stat-number.hero-stat-peak { color: var(--crisis); }

/* ─── ARTICLE LEDE ─── */
#lede {
  background: var(--paper);
  padding: 88px 24px;
  border-bottom: 1px solid var(--rule);
}

.lede-inner {
  max-width: var(--measure);
  margin: 0 auto;
}

.lede-standfirst {
  font-family: var(--font-read);
  font-size: clamp(22px, 2.8vw, 27px);
  line-height: 1.45;
  color: var(--ink);
  margin-bottom: 32px;
}

.lede-body {
  font-family: var(--font-read);
  font-size: 19px;
  line-height: 1.75;
  color: var(--body);
  margin-bottom: 28px;
}

.lede-body:first-of-type::first-letter {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  float: left;
  font-size: 4.6rem;
  line-height: 0.82;
  padding: 6px 12px 0 0;
}

.pull-quote {
  margin: 40px 0;
  padding: 10px 0;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--rule);
}

.pull-quote p {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(24px, 3.2vw, 32px);
  line-height: 1.28;
  color: var(--ink);
  margin: 12px 0;
}

.pull-quote cite {
  font-family: var(--font-sans);
  font-style: normal;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ─── PHASE LEGEND (sticky nav) ─── */
#phase-legend {
  position: -webkit-sticky;
  position: sticky;
  top: var(--nav-h); /* directly under the main nav */
  z-index: 800;
  background: color-mix(in srgb, var(--inset) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 11px 24px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  transition: box-shadow 0.2s ease;
}

#phase-legend.is-stuck {
  box-shadow: 0 6px 18px rgba(26, 26, 26, 0.07);
}

.phase-legend-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.phase-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 2px;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--rule);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.phase-pill:hover {
  color: var(--ink);
  border-color: var(--ink);
  text-decoration: none;
}

.phase-pill.is-current {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.phase-pill .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 1;
  flex-shrink: 0;
}

/* ─── SECTION WRAPPER ─── */
.section-wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--section-pad);
}

.section-eyebrow {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--crisis);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.section-title {
  font-family: var(--font-display);
  font-size: clamp(28px, 3.4vw, 42px);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.01em;
  margin-bottom: 12px;
  color: var(--ink);
}

.section-subtitle {
  font-family: var(--font-read);
  font-size: 20px;
  color: var(--muted);
  max-width: var(--measure);
  margin-bottom: 44px;
  line-height: 1.6;
}

/* ─── SCROLLYTELLING LAYOUT ─── */
#scrollytelling {
  background: var(--paper);
  border-top: 1px solid var(--rule);
}

.scroll-outer {
  max-width: var(--max-width);
  margin: 0 auto;
}

.scroll-section {
  display: grid;
  grid-template-columns: 55% 45%;
  align-items: start;
  position: relative;
}

/* Sticky map panel */
.sticky-figure {
  position: -webkit-sticky;
  position: sticky;
  top: var(--nav-h); /* Below nav */
  height: calc(100vh - var(--nav-h));
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--rule);
}

#scroll-map-container {
  flex: 1;
  width: 100%;
  min-height: 0;
}

/* Active step info overlay at bottom of map */
.map-step-overlay {
  flex-shrink: 0;
  padding: 14px 18px;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  border-top: 1px solid var(--rule);
  min-height: 72px;
}

.map-step-date {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  color: var(--crisis);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.map-step-headline {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.map-metrics {
  display: flex;
  gap: 16px;
  margin-top: 7px;
}

.map-metric {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.map-metric span {
  color: var(--crisis);
  font-weight: 600;
}

/* Scrolling steps panel */
.scroll-steps {
  padding: 80px 32px 80px 40px;
}

/* First spacer so map is visible before steps */
.scroll-steps::before {
  content: '';
  display: block;
  height: 15vh;
}

.scroll-step {
  min-height: 75vh;
  padding: 32px 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  opacity: 0.28;
  transform: translateX(0);
  transition: opacity 0.5s ease, transform 0.4s ease;
  border-left: 2px solid transparent;
  padding-left: 22px;
  margin-left: -22px;
}

.scroll-step.is-active {
  opacity: 1;
  transform: translateX(2px);
  border-left-color: var(--crisis);
}

.step-phase-date {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.step-headline {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
  color: var(--ink);
}

.step-narrative {
  font-family: var(--font-read);
  font-size: 18px;
  color: var(--body);
  line-height: 1.7;
  max-width: 440px;
}

.step-metrics {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.step-metric-chip {
  font-family: var(--font-sans);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  padding: 5px 11px;
  border-radius: 2px;
  background: var(--surface);
  border: 1px solid var(--rule);
  color: var(--muted);
}

.step-metric-chip strong { color: var(--crisis); font-weight: 600; }

.step-source {
  font-family: var(--font-sans);
  font-size: 10.5px;
  color: var(--faint);
  margin-top: 14px;
}

/* ─── CHART SECTIONS ─── */
.chart-section-bg {
  background: var(--inset);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-top: 2px solid var(--ink);
  border-radius: 0 0 var(--card-radius) var(--card-radius);
  padding: 24px 26px;
  margin-bottom: 28px;
  overflow: hidden;
}

.chart-card-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.2;
  color: var(--ink);
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  gap: 10px;
}

.chart-card-title .icon {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  display: inline-block;
  flex-shrink: 0;
}

.chart-source {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--faint);
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
  line-height: 1.5;
}

.chart-source a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chart-desc {
  font-family: var(--font-read);
  font-size: 17px;
  color: var(--body);
  margin-bottom: 20px;
  line-height: 1.6;
  max-width: var(--measure);
}

/* Two-column chart grid */
.chart-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}

/* Full-width chart wrapper */
.chart-full { width: 100%; position: relative; }
.chart-full canvas { width: 100% !important; }

/* ─── SANDBOX SECTION ─── */
#sandbox {
  background: var(--paper);
  border-top: 1px solid var(--rule);
}

.slider-wrapper {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-top: 2px solid var(--ink);
  border-radius: 0 0 var(--card-radius) var(--card-radius);
  padding: 22px 26px;
  margin-bottom: 28px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.slider-date-label {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.hormuz-badge {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 2px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hormuz-badge.closed   { background: var(--crisis-tint); color: var(--crisis-deep); }
.hormuz-badge.open     { background: var(--teal-tint);   color: var(--teal); }
.hormuz-badge.blockaded{ background: var(--ink);         color: var(--paper); }

/* Range slider */
input[type="range"].crisis-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  background: linear-gradient(to right, var(--v0), var(--v3), var(--v5), var(--v7), var(--v9));
}

input[type="range"].crisis-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--ink);
  box-shadow: 0 0 0 2px var(--crisis);
  cursor: pointer;
}

input[type="range"].crisis-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--ink);
  box-shadow: 0 0 0 2px var(--crisis);
  cursor: pointer;
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-sans);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 8px;
}

/* Stat cards grid */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left-width: 3px;
  border-radius: var(--card-radius);
  padding: 16px 18px;
  overflow: hidden;
}

.stat-card-value {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  font-size: 24px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-card-label {
  font-family: var(--font-sans);
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.4;
}

/* Sandbox split */
.sandbox-split {
  display: grid;
  grid-template-columns: 50% 50%;
  gap: 20px;
  align-items: start;
}

#sandbox-map-container {
  height: 420px;
  border-radius: var(--card-radius);
  overflow: hidden;
  border: 1px solid var(--rule);
}

.sandbox-event-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--crisis);
  border-radius: var(--card-radius);
  padding: 18px;
  margin-top: 12px;
  min-height: 100px;
}

.sandbox-event-headline {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 7px;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.sandbox-event-body {
  font-family: var(--font-read);
  font-size: 16px;
  color: var(--body);
  line-height: 1.6;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}

/* ─── SANKEY SECTION ─── */
.sankey-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.sankey-btn {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 7px 16px;
  border-radius: 2px;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
}

.sankey-btn:hover { border-color: var(--ink); color: var(--ink); }

.sankey-btn.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.sankey-btn.crisis.active {
  background: var(--crisis);
  color: var(--paper);
  border-color: var(--crisis);
}

#sankey-india-svg, #sankey-global-svg {
  width: 100%;
  overflow: visible;
}

/* ─── GEOPOLITICAL TABLE ─── */
.geo-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-read);
  font-size: 16px;
}

.geo-table th {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 14px 10px;
  border-bottom: 2px solid var(--ink);
  text-align: left;
  white-space: nowrap;
}

.geo-table td {
  padding: 16px 14px;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
  line-height: 1.55;
  color: var(--body);
}

.geo-table tr:hover td { background: var(--inset); }

.geo-table .country-cell {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.geo-table .role-badge {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 2px;
  background: var(--inset);
  color: var(--muted);
  white-space: nowrap;
}

.net-badge {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.net-catastrophic { background: var(--crisis-tint); color: var(--crisis-deep); border: 1px solid #E4C2BC; }
.net-severe       { background: #F6EBD6; color: #8A6300; border: 1px solid #E7D6AE; }
.net-mixed        { background: #F2EFDD; color: #7A6A18; border: 1px solid #E1DCC0; }
.net-gain         { background: var(--teal-tint); color: var(--teal); border: 1px solid #CFE0D8; }
.net-exposure     { background: #E4EDF4; color: #2A5673; border: 1px solid #CCDCE8; }
.net-moderate     { background: var(--inset); color: var(--muted); border: 1px solid var(--rule); }

/* ─── FOOTER ─── */
#resolution-footer {
  background: var(--paper);
  border-top: 3px solid var(--ink);
  padding: 72px 24px 56px;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.footer-eyebrow {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--crisis);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.footer-title {
  font-family: var(--font-display);
  font-size: clamp(26px, 3.2vw, 38px);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 40px;
}

.footer-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 28px;
  margin-bottom: 52px;
}

.footer-stat {
  border-left: 3px solid var(--rule-strong);
  padding-left: 18px;
}

.footer-stat-value {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 5px;
}

.footer-stat-delta {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 3px;
}

.footer-stat-label {
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
}

.footer-credits {
  border-top: 1px solid var(--rule);
  padding-top: 28px;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.8;
}

.footer-credits a { color: var(--link); }
.footer-credits a:hover { color: var(--crisis); }

/* Fork & redesign credit */
.footer-redesign {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--rule);
}
.redesign-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--rule-strong);
  flex-shrink: 0;
}
.redesign-avatar.is-missing { display: none; }
.redesign-meta { font-family: var(--font-sans); line-height: 1.5; }
.redesign-role {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--crisis);
}
.redesign-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
}
.redesign-links { font-size: 12.5px; margin-top: 3px; }
.redesign-links a { color: var(--link); }
.redesign-links a:hover { color: var(--crisis); }
.redesign-note { font-size: 12px; color: var(--faint); margin-top: 5px; }

/* ─── LEAFLET OVERRIDES (light / Positron) ─── */
.leaflet-container {
  background: var(--inset) !important;
  font-family: var(--font-read) !important;
}

/* Dark mode: CARTO Dark Matter borders/labels are very dim — lift them a
   touch so country outlines and names stay legible. Markers live in other
   panes and are unaffected. */
[data-theme="dark"] .leaflet-tile {
  filter: brightness(1.45) contrast(1.05);
}

.leaflet-popup-content-wrapper {
  background: var(--surface) !important;
  border: 1px solid var(--rule) !important;
  border-top: 2px solid var(--ink) !important;
  border-radius: 3px !important;
  box-shadow: 0 8px 28px rgba(26,26,26,0.16) !important;
  color: var(--body) !important;
}

.leaflet-popup-tip { background: var(--surface) !important; }

.leaflet-popup-content {
  margin: 14px 16px !important;
  font-family: var(--font-read) !important;
  min-width: 220px !important;
  max-width: 280px !important;
}

.map-popup-date {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  color: var(--crisis);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.map-popup-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
  line-height: 1.25;
}

.map-popup-body {
  font-family: var(--font-read);
  font-size: 14px;
  color: var(--body);
  line-height: 1.6;
  margin-bottom: 8px;
}

.map-popup-source {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--faint);
}

.leaflet-control-zoom a {
  background: var(--surface) !important;
  color: var(--ink) !important;
  border-color: var(--rule) !important;
}

.leaflet-control-attribution {
  background: color-mix(in srgb, var(--paper) 80%, transparent) !important;
  color: var(--faint) !important;
  font-size: 9px !important;
}
.leaflet-control-attribution a { color: var(--muted) !important; }

/* Pulse animation for active marker */
@keyframes markerPulse {
  0%   { transform: scale(1);   opacity: 1; }
  50%  { transform: scale(1.6); opacity: 0.4; }
  100% { transform: scale(1);   opacity: 1; }
}

.active-marker-pulse {
  animation: markerPulse 1.2s ease-in-out infinite;
}

/* ─── CHART.JS CANVAS CONTAINERS ─── */
.canvas-wrap { position: relative; width: 100%; }
.canvas-wrap canvas { display: block !important; }

/* ─── SANKEY SVG STYLES ─── */
.sankey-node rect {
  rx: 1px;
}

.sankey-link {
  /* fill set via inline style in drawSankey() — do NOT set fill here */
  transition: fill-opacity 0.25s;
  cursor: default;
}

.sankey-link:hover { fill-opacity: 0.6 !important; }

.sankey-label {
  font-family: var(--font-sans);
  font-size: 11px;
  fill: var(--body);
  pointer-events: none;
}

.sankey-col-header {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  fill: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sankey-blocked-label {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  fill: var(--crisis);
  letter-spacing: 0.04em;
}

/* ─── LOADING STATE ─── */
.chart-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--faint);
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ─── SECTION-NAV FLOATING BUTTONS (up + down) ─── */
.section-nav {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 850;
}
.section-nav.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.section-nav-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(26, 26, 26, 0.28);
  transition: background 0.2s ease, opacity 0.2s ease;
}
.section-nav-btn:hover { background: var(--crisis); }
.section-nav-btn svg { width: 20px; height: 20px; }
.section-nav-btn.is-disabled { opacity: 0.32; pointer-events: none; }

/* ─── RESPONSIVE ─── */
@media (max-width: 900px) {
  .scroll-section {
    grid-template-columns: 1fr;
  }

  /* Keep the map sticky on mobile so the scrollytelling stays in sync;
     sits below the nav + one-row legend. Kept compact so each step has a
     comfortable reading area beneath it. */
  .sticky-figure {
    position: -webkit-sticky;
    position: sticky;
    top: calc(var(--nav-h) + 40px);
    height: 34vh;
    border-right: none;
    border-bottom: 1px solid var(--rule);
    background: var(--paper);
    z-index: 5;
  }

  .scroll-steps { padding: 20px 24px 56px 30px; }
  .scroll-steps::before { height: 1vh; }
  .scroll-step  {
    min-height: 0;
    /* only override top/bottom so the base padding-left (border-indent) survives */
    padding-top: 28px;
    padding-bottom: 40px;
    justify-content: flex-start;
  }
  .step-headline, .step-narrative, .step-phase-date, .step-metrics, .step-source { padding-right: 6px; }
  .step-narrative { max-width: none; font-size: 17px; }

  .chart-grid-2 { grid-template-columns: 1fr; }
  .stat-cards   { grid-template-columns: repeat(2, 1fr); }
  .sandbox-split { grid-template-columns: 1fr; }
  #sandbox-map-container { height: 300px; }
}

/* Stack the header on narrow screens: logo row + full-width title row */
@media (max-width: 680px) {
  #main-nav {
    height: auto;
    min-height: 52px;
    flex-wrap: wrap;
    align-items: center;
    padding: 8px 16px;
    gap: 6px 10px;
  }
  .nav-divider { display: none; }
  .nav-logo { flex: 0 1 auto; min-width: 0; }
  .nav-logo-text { min-width: 0; }
  .nav-logo-secondary { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .nav-right { margin-left: auto; }
  .nav-project-title {
    order: 5;
    flex-basis: 100%;
    width: 100%;
    white-space: normal;
    font-size: 12px;
    line-height: 1.3;
    padding-top: 6px;
    border-top: 1px solid var(--rule);
    color: var(--muted);
  }
  /* one scrolling row of phase pills instead of several wrapped rows */
  .phase-legend-inner { flex-wrap: nowrap; }
  #phase-legend { padding: 9px 16px; }
}

@media (max-width: 600px) {
  :root { --section-pad: 56px 18px; }
  body { font-size: 18px; }
  .hero-stats { grid-template-columns: 1fr 1fr; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .footer-stats { grid-template-columns: 1fr 1fr; }
  .nav-phase-pill { display: none; }
  .geo-table { font-size: 14px; }
  .geo-table th, .geo-table td { padding: 10px 8px; }
  /* size the buttons, not the flex container — sizing the container squashed
     the two stacked 46px buttons into a 44px box and rendered them as ovals */
  .section-nav { right: 14px; bottom: 14px; }
  .section-nav-btn { width: 44px; height: 44px; }
}

/* ─── CSS SCROLL-DRIVEN REVEAL (Chrome 115+, Safari 26+) ─── */
@supports (animation-timeline: view()) {
  .reveal-on-scroll {
    animation: revealUp linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 60%;
  }

  @keyframes revealUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}

/* Fallback for unsupported browsers — always visible */
@supports not (animation-timeline: view()) {
  .reveal-on-scroll { opacity: 1; transform: none; }
}

/* Reduced motion accessibility */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .scroll-step { opacity: 1 !important; transform: none !important; }
}
