/* ── Reset & base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: #0b0b0d;
  color: #ece9e4;
  overflow-x: hidden;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ── CSS custom properties ───────────────────────────────────────────── */
:root {
  --bg:               #0b0b0d;
  --bg-elevated:      #0f0f14;
  --surface:          #141419;
  --surface-elevated: #1c1c24;
  --text-primary:     #ece9e4;
  --text-muted:       #898989;
  --text-faint:       #5a5a6a;
  --accent:           #ff4500;
  --accent-warm:      #ff8b60;
  --rule-dark:        rgba(255,255,255,0.08);
  --rule-faint:       rgba(255,255,255,0.04);
}

svg { max-width: 100%; }
.domain { display: none; }
.tick line { display: none; }
.tick text {
  font-family: 'JetBrains Mono', monospace;
  fill: #898989;
  font-size: 10px;
  letter-spacing: 0.04em;
}

/* ── Typography classes ──────────────────────────────────────────────── */
.kicker {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}
.kicker-muted { color: var(--text-faint); }

.serif { font-family: 'Instrument Serif', serif; font-weight: 400; }
.mono  { font-family: 'JetBrains Mono', ui-monospace, monospace; }

.display-xl {
  font-family: 'Instrument Serif', serif;
  font-size: clamp(3rem, 9vw, 7rem);
  line-height: 0.95;
  font-weight: 400;
  letter-spacing: -0.02em;
}
.display-lg {
  font-family: 'Instrument Serif', serif;
  font-size: clamp(2.4rem, 5.5vw, 4.2rem);
  line-height: 1.05;
  font-weight: 400;
  letter-spacing: -0.015em;
}

/* ── Cover ───────────────────────────────────────────────────────────── */
.cover {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 32px clamp(24px, 5vw, 64px) 48px;
  background: var(--bg);
}

.cover-masthead {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--rule-dark);
  border-bottom: 1px solid var(--rule-dark);
  padding: 12px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
  flex-wrap: wrap;
  gap: 12px;
}

.cover-body {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: auto 0;
  padding: 40px 0;
}

.cover-sub {
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-size: clamp(1.2rem, 2vw, 1.55rem);
  color: var(--text-muted);
  max-width: 620px;
  margin: 36px 0 0;
  line-height: 1.55;
}

.cover-stats {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 32px;
  border-top: 1px solid var(--rule-dark);
  padding-top: 28px;
  margin-top: 16px;
  text-align: center;
}
.cover-stat-n {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(1.8rem, 3.2vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 6px;
}
.cover-stat-n.accent { color: var(--accent); }
.cover-stat-n.cue {
  font-size: 1.6rem;
  color: #d4c5b9;
  animation: arrow-breathing 2.5s ease-in-out 0.5s infinite;
}
.cover-stat-l {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-faint);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ── Cover instructions button ──────────────────────────────────────── */
.cover-instructions-btn {
  position: absolute;
  bottom: 60px;
  right: 32px;
  width: 120px;
  height: 120px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  overflow: visible;
  transition: transform 0.3s ease, filter 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  pointer-events: auto;
}

.cover-instructions-btn:hover {
  transform: translateY(-4px);
}

.cover-instructions-btn:hover img {
  filter: drop-shadow(0 12px 32px rgba(0, 0, 0, 0.4));
}

.cover-instructions-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: filter 0.3s ease;
}

#hero-dots {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.6;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse at center, black 40%, transparent 85%);
  mask-image: radial-gradient(ellipse at center, black 40%, transparent 85%);
}

#epilogue-dots {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.5;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse at center, black 40%, transparent 85%);
  mask-image: radial-gradient(ellipse at center, black 40%, transparent 85%);
}

/* ── Chapter card ────────────────────────────────────────────────────── */
.chapter-card {
  background: var(--bg);
  color: var(--text-primary);
  padding: clamp(160px, 20vh, 240px) clamp(24px, 5vw, 64px) clamp(100px, 14vh, 180px);
  margin-bottom: 0;
  position: relative;
  overflow: visible;
  margin-top: 0;
}

.chapter-card::before {
  content: '';
  position: absolute;
  top: -20px;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(to bottom, #0b0b0d 0%, #1a1a1b 50%, #0b0b0d 100%);
}
.chapter-card-inner {
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
  text-align: left;
}
.chapter-eyebrow {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 40px;
}
.chapter-eyebrow-line {
  flex: 1;
  height: 1px;
  background: var(--rule-dark);
}
.chapter-stat {
  margin-top: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  justify-content: flex-start;
}
.chapter-stat-n {
  font-family: 'Inter', sans-serif;
  font-size: clamp(2rem, 4.5vw, 3rem);
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
}
.chapter-stat-l {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 280px;
  line-height: 1.55;
  flex-shrink: 1;
}

/* ── Paper section (cream reading sections) ──────────────────────────── */
.paper-section {
  background: #f6f3ee;
  color: #1a1a1b;
  padding: 20px 0 40px;
}

.prose-block {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 32px;
  font-family: 'Inter', sans-serif;
  font-size: 1.08rem;
  line-height: 1.75;
  color: #1a1a1b;
}
.prose-block strong { color: #1a1a1b; font-weight: 600; }

/* ── Figure frame ────────────────────────────────────────────────────── */
.figure {
  max-width: 1040px;
  margin: 0 auto;
  padding: 56px 32px 72px;
  color: #1a1a1b;
}

.figure-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid rgba(26,26,27,0.2);
  padding-top: 14px;
  margin-bottom: 6px;
}
.figure-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #5f6164;
}
.figure-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: var(--accent);
}
.figure-title {
  font-family: 'Instrument Serif', serif;
  font-size: clamp(1.6rem, 2.6vw, 2.1rem);
  line-height: 1.15;
  margin: 4px 0 12px;
  letter-spacing: -0.01em;
  color: #1a1a1b;
}
.figure-finding {
  font-family: 'Inter', sans-serif;
  font-size: 1.02rem;
  line-height: 1.7;
  max-width: 700px;
  margin: 0 0 36px;
  color: #a0a0a0;
}
/* NYT-style unified note: caption + source combined */
.figure-note {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  line-height: 1.55;
  width: 100%;
  margin: 12px 0 0 0;
  color: #707070;
}
.figure-note strong {
  font-weight: 600;
  color: #7a7a7a;
}
.figure-source-inline {
  display: block;
  font-size: 0.75rem;
  color: #6a6a6a;
  margin-top: 6px;
}
.figure-source {
  margin-top: 24px;
  margin-bottom: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  opacity: 0.55;
  text-transform: uppercase;
  color: #5f6164;
  display: block;
  clear: both;
}

/* Chart mount wrapper — transparent, inherits section background */
.chart-card {
  background: transparent;
  border-radius: 0;
  overflow: visible;
  margin-bottom: 4px;
}

/* ── Override D3-injected light colours for cream paper sections ─────── */

/* SVG text elements D3 sets to near-white */
.paper-section svg text[fill="#e8e6e1"],
.paper-section svg text[fill="#ece9e4"],
.paper-section svg tspan[fill="#e8e6e1"] {
  fill: #1a1a1b !important;
}

/* Axis tick text (#898989 grey — darken slightly for cream legibility) */
.paper-section svg text[fill="#898989"],
.paper-section svg tspan[fill="#898989"] {
  fill: #5f6164 !important;
}

/* D3 HTML chart titles / subtitles (inline style="color: rgb(232,230,225)") */
/* browsers normalize #e8e6e1 → rgb(232, 230, 225) */
.paper-section [style*="color: rgb(232, 230, 225)"],
.paper-section [style*="color: rgb(232,230,225)"] {
  color: #1a1a1b !important;
}

/* Year-toggle pill background only (not border — D3 controls active border) */
.paper-section [data-year-btn] {
  background: rgba(26,26,27,0.07) !important;
}

/* Brighter text inside year pill labels on cream */
.paper-section [data-year-btn] {
  color: #1a1a1b !important;
}

/* RULE STANCES step (step 5) needs more screen time */
.intro-step[data-step="5"] {
  min-height: 160vh;
}

.intro-step[data-step="5"] ~ * {
  visibility: hidden;
}

/* Hide canvas visualization as final step approaches */
.intro-section:has(.intro-step[data-step="5"]:in-viewport) .intro-canvas-wrap {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease-out;
}

/* ── Pull quote ──────────────────────────────────────────────────────── */
.pull-quote {
  max-width: 900px;
  margin: 0 auto;
  padding: 96px 32px;
  text-align: center;
  border-top: 1px solid rgba(26,26,27,0.1);
}
.pull-quote-text {
  font-family: 'Instrument Serif', serif;
  font-size: clamp(1.8rem, 3.6vw, 2.6rem);
  font-style: italic;
  line-height: 1.35;
  color: #1a1a1b;
  letter-spacing: -0.01em;
}
.pull-quote-attr {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: #5f6164;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-top: 24px;
}

/* ── Quote wall ──────────────────────────────────────────────────────── */
/* Quote wall section (2-column layout with reduced contrast) */
section:has(#quote-wall-mount-epilogue) {
  background: #000;
  padding: 56px 32px 72px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  max-width: 1280px;
  margin: 0 auto;
  align-items: start;
}

section:has(#quote-wall-mount-epilogue) .prose-block {
  background: transparent;
  padding: 0;
  max-width: none;
  margin: 0;
  color: #9a9490;
  font-size: 0.95rem;
  line-height: 1.7;
  order: 2;
}

section:has(#quote-wall-mount-epilogue) #quote-wall-mount-epilogue {
  order: 1;
}

.quote-wall-wrap {
  max-width: none;
  margin: 0;
  padding: 0;
  background: transparent;
}
.quote-wall-header {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: #5f6164;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.quote-wall-header .rule-line {
  flex: 1;
  min-width: 40px;
  height: 1px;
  background: var(--rule-dark);
}
.quote-wall-legend {
  display: inline-flex;
  gap: 14px;
}
.qw-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.qw-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}
.quote-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  line-height: 1.8;
}
.quote-tag {
  display: inline-block;
  background: #1f2937;
  color: #ffffff;
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: default;
  transition: all 0.25s cubic-bezier(.2,.7,.2,1);
  border: 1px solid transparent;
  line-height: 1.35;
}
.quote-tag:hover {
  background: var(--accent);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 6px 24px -8px rgba(255,69,0,0.5);
}
.qt-handle {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  opacity: 0.55;
  margin-right: 8px;
}

/* ── Progress rail ───────────────────────────────────────────────────── */
#progress-rail {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 10px;
  border-radius: 999px;
  background: rgba(20,20,25,0.55);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.06);
}
.rail-dot-link {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  position: relative;
}
.rail-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid #3a3a48;
  transition: all 0.3s;
  flex-shrink: 0;
}
.rail-dot.active {
  background: #ff8b60;
  border-color: #ff8b60;
  box-shadow: 0 0 12px rgba(255,139,96,0.6);
}
.rail-label {
  position: absolute;
  right: 100%;
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  pointer-events: none;
  transition: opacity 0.2s, max-width 0.3s ease;
  color: #e8e6e1;
  font-size: 0.7rem;
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
  font-weight: 500;
  margin-right: 8px;
}
.rail-dot-link:hover .rail-label {
  opacity: 1;
  max-width: 70px;
}

/* ── Scroll reveal (enhanced with scale & rotation) ───────────────────── */
[data-reveal] {
  opacity: 0;
  transform: translateY(24px) scale(0.98) rotateZ(-0.5deg);
  transition: opacity 0.9s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}
[data-reveal].revealed {
  opacity: 1;
  transform: translateY(0) scale(1) rotateZ(0deg);
}

/* ── Kicker color inside cream paper sections ────────────────────────── */
.paper-section .kicker { color: var(--accent); }

/* ── Intro section dark override ─────────────────────────────────────── */
.intro-dark-section {
  background: var(--bg);
}

/* ── Footer ──────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--bg);
  padding: 28px 32px 80px;
  margin-top: 80px;
  border-top: 1px solid var(--rule-dark);
  position: relative;
  overflow: hidden;
}

/* Animated dots background for footer */
.site-footer::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(255, 139, 96, 0.08) 1px, transparent 1px);
  background-size: 100px 100px;
  background-position: 0 0;
  animation: drift 25s linear infinite;
  pointer-events: none;
  z-index: 0;
}

.site-footer-inner {
  position: relative;
  z-index: 1;
  max-width: 1040px;
  margin: 0 auto;
}
.site-footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 48px;
  margin-bottom: 60px;
}
.footer-col-title {
  /* uses .kicker class */
  margin-bottom: 10px !important;
}
.footer-col-body {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.7;
}
.footer-col-body strong { color: var(--text-primary); }
.footer-sources {
  list-style: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.9;
}
.footer-bottom {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  padding-top: 0;
}

/* ── Bar chart bars: darken grey fill so visible on cream ────────────── */
/* Adoption chart bars use fill="#898989" — too low contrast on #f6f3ee  */
.paper-section svg rect[fill="#898989"] {
  fill: #3d4045 !important;
}
/* Diverging chart neutral bars (also #898989 grey) */
.paper-section svg rect[fill="#898989"][rx="2"] {
  fill: #3d4045 !important;
}

/* ── Intro step typography — JetBrains Mono kicker + Inter body ──────── */
.intro-eyebrow {
  font-family: 'JetBrains Mono', ui-monospace, monospace !important;
  font-size: 0.7rem !important;
  letter-spacing: 0.22em !important;
  color: var(--accent-warm) !important;
  text-transform: uppercase !important;
  margin-bottom: 1rem !important;
}
.intro-body {
  font-family: 'Inter', sans-serif !important;
  font-size: 1rem !important;
  line-height: 1.75 !important;
  color: var(--text-primary) !important;
  max-width: 340px !important;
}

/* ── D3 chart legend / pill backgrounds in paper sections ────────────── */
/* Dark legend bg from bars.js / explorer.js → transparent */
.paper-section [style*="rgba(20,20,25"],
.paper-section [style*="rgba(20, 20, 25"] {
  background: transparent !important;
}
.paper-section [style*="rgba(28,28,36"],
.paper-section [style*="rgba(28, 28, 36"] {
  background: transparent !important;
}
/* Explorer legend pill area */
.paper-section [style*="background: rgb(20"] {
  background: transparent !important;
}

/* ── Scroll year transition — fade when auto-switching ───────────────── */
[data-year-transitioning] {
  transition: opacity 0.4s ease;
  opacity: 0.6;
}

/* ─────────────────────────────────────────────────────────────────────── */
/* ── ANIMATION SYSTEM: Keyframes & Micro-interactions ──────────────────── */
/* ─────────────────────────────────────────────────────────────────────── */

/* ── Entrance Keyframes ──────────────────────────────────────────────────– */

@keyframes fade-scale-up {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes kicker-reveal {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes section-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes footer-entrance {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes drift {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 80px 80px;
  }
}

/* ── Loading State Keyframes ────────────────────────────────────────────── */

@keyframes skeleton-pulse {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 0.9;
  }
}

@keyframes placeholder-shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* ── Interactive State Keyframes ────────────────────────────────────────– */

@keyframes button-press {
  from {
    transform: scale(1.03);
  }
  to {
    transform: scale(0.98);
  }
}

@keyframes input-focus-glow {
  0% {
    box-shadow: inset 0 0 0 1px rgba(255, 139, 96, 0.2),
                0 0 8px rgba(255, 139, 96, 0.1);
  }
  50% {
    box-shadow: inset 0 0 0 1px rgba(255, 139, 96, 0.3),
                0 0 16px rgba(255, 139, 96, 0.25);
  }
  100% {
    box-shadow: inset 0 0 0 1px rgba(255, 139, 96, 0.2),
                0 0 12px rgba(255, 139, 96, 0.15);
  }
}

@keyframes rail-pulse {
  0%, 100% {
    box-shadow: 0 0 8px rgba(255, 139, 96, 0.4);
  }
  50% {
    box-shadow: 0 0 16px rgba(255, 139, 96, 0.8);
  }
}

/* ── Button & Link Micro-interactions ───────────────────────────────────– */

button,
a.button,
[role="button"],
.button-like {
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

button:hover,
a.button:hover,
[role="button"]:hover,
.button-like:hover {
  transform: scale(1.03);
  border-color: var(--accent-warm);
  color: var(--accent-warm);
  box-shadow: 0 0 16px rgba(255, 139, 96, 0.25);
}

button:active,
a.button:active,
[role="button"]:active,
.button-like:active {
  transform: scale(0.98);
  opacity: 0.85;
}

button:focus-visible,
a.button:focus-visible,
[role="button"]:focus-visible,
.button-like:focus-visible {
  outline: 2px solid var(--accent-warm);
  outline-offset: 3px;
  box-shadow: 0 0 12px rgba(255, 139, 96, 0.4);
}

/* ── Input Focus States ──────────────────────────────────────────────────– */

input:not([type="hidden"]),
textarea,
select {
  transition: all 0.2s ease;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  border-color: var(--accent-warm);
  background: rgba(255, 139, 96, 0.05);
  box-shadow: inset 0 0 0 1px rgba(255, 139, 96, 0.2),
              0 0 12px rgba(255, 139, 96, 0.15);
}

input::placeholder,
textarea::placeholder {
  transition: opacity 0.3s ease;
}

input:focus-visible::placeholder,
textarea:focus-visible::placeholder {
  opacity: 0.3;
}

/* ── Toggle & Switch Animations ─────────────────────────────────────────– */

[role="switch"],
.toggle-button {
  transition: all 0.15s ease;
}

[role="switch"].active,
.toggle-button.active {
  opacity: 1;
  transform: scale(1);
  border-color: var(--accent-warm);
  background: rgba(255, 139, 96, 0.1);
}

[role="switch"]:not(.active),
.toggle-button:not(.active) {
  opacity: 0.6;
  transform: scale(0.95);
}

/* ── Staggered List Reveals (Child Elements) ────────────────────────────– */

.scroll-reveal li:nth-child(1) { transition-delay: 0ms; }
.scroll-reveal li:nth-child(2) { transition-delay: 60ms; }
.scroll-reveal li:nth-child(3) { transition-delay: 120ms; }
.scroll-reveal li:nth-child(4) { transition-delay: 180ms; }
.scroll-reveal li:nth-child(5) { transition-delay: 240ms; }
.scroll-reveal li:nth-child(6) { transition-delay: 300ms; }

.scroll-reveal [data-stagger]:nth-child(1) { transition-delay: 0ms; }
.scroll-reveal [data-stagger]:nth-child(2) { transition-delay: 60ms; }
.scroll-reveal [data-stagger]:nth-child(3) { transition-delay: 120ms; }
.scroll-reveal [data-stagger]:nth-child(4) { transition-delay: 180ms; }
.scroll-reveal [data-stagger]:nth-child(5) { transition-delay: 240ms; }

/* ── Loading States ─────────────────────────────────────────────────────– */

.skeleton {
  background: linear-gradient(
    90deg,
    rgba(236, 233, 228, 0.1),
    rgba(236, 233, 228, 0.2),
    rgba(236, 233, 228, 0.1)
  );
  background-size: 200% 100%;
  animation: skeleton-pulse 2s ease-in-out infinite;
  border-radius: 4px;
}

.skeleton-bar {
  height: 12px;
  margin: 8px 0;
}

.skeleton-text {
  height: 16px;
  width: 60%;
  margin: 12px 0;
}

.placeholder {
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.05),
    transparent
  );
  background-size: 200px 100%;
  animation: placeholder-shimmer 2s infinite;
}

/* ── Section & Navigation Animations ────────────────────────────────────– */

.narrative-section {
  animation: section-fade-in 0.8s ease-out;
}

.section-kicker {
  opacity: 0;
  animation: kicker-reveal 0.6s ease-out forwards;
}

.site-footer {
  animation: footer-entrance 0.8s ease-out;
}

/* ── Progress Rail Enhancements ─────────────────────────────────────────– */

.rail-dot.active {
  animation: rail-pulse 2s ease-in-out infinite;
}

.rail-dot-link:hover .rail-dot:not(.active) {
  border-color: rgba(255, 139, 96, 0.6);
  box-shadow: 0 0 8px rgba(255, 139, 96, 0.2);
  transition: all 0.2s ease;
}

/* ── Utility Animation Classes ──────────────────────────────────────────– */

.reveal {
  animation: fade-scale-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.glow {
  box-shadow: 0 0 16px rgba(255, 139, 96, 0.25);
  transition: box-shadow 0.2s ease;
}

.spring-ease {
  transition-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Epilogue Parallax Container ───────────────────────────────────────── */

#epilogue-parallax-container {
  position: relative;
  background: var(--bg);
  overflow: hidden;
}

/* ── Epilogue Section ──────────────────────────────────────────────────── */

.epilogue-section {
  background: var(--bg);
  padding: 80px clamp(24px, 5vw, 64px) 60px;
  position: relative;
  border-top: 1px solid var(--rule-faint);
  text-align: center;
  overflow: hidden;
}

/* Animated dots background for epilogue */
.epilogue-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(255, 139, 96, 0.15) 1px, transparent 1px);
  background-size: 80px 80px;
  background-position: 0 0, 40px 40px;
  animation: drift 20s linear infinite;
  pointer-events: none;
  z-index: 0;
}

.epilogue-inner {
  position: relative;
  z-index: 1;
}

.epilogue-inner {
  max-width: 900px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.epilogue-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.5rem;
  display: block;
  opacity: 0;
  animation: fade-scale-up 0.8s ease-out 0s forwards;
}

.epilogue-title {
  font-family: 'Instrument Serif', serif;
  font-size: clamp(2.4rem, 6vw, 4rem);
  line-height: 1.2;
  color: #e8e6e1;
  margin-bottom: 1.5rem;
  letter-spacing: -0.015em;
  font-weight: 400;
  opacity: 0;
  animation: fade-scale-up 0.8s ease-out 0.15s forwards;
}

.epilogue-title em {
  color: var(--accent);
  font-style: italic;
}

.epilogue-body {
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: var(--text-muted);
  max-width: 700px;
  margin: 0 auto 2.5rem;
  line-height: 1.7;
  opacity: 0;
  animation: fade-scale-up 0.8s ease-out 0.3s forwards;
}

.epilogue-cta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0;
  opacity: 0;
  animation: fade-scale-up 0.8s ease-out 0.45s forwards;
  cursor: pointer;
  position: relative;
  display: inline-block;
  transition: text-shadow 0.3s ease-out;
}

.epilogue-cta:hover {
  text-shadow: 0 0 12px rgba(255, 139, 96, 0.6), 0 0 24px rgba(255, 139, 96, 0.3);
}

/* Arrow breathing animation for scroll cue */
@keyframes arrow-breathing {
  0%, 100% {
    transform: translateY(0px);
    opacity: 0.7;
  }
  50% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* Microanimation: breathing animation (glow + vertical bounce) */
@keyframes cta-breathing {
  0%, 100% {
    transform: translateY(0px);
    text-shadow: 0 0 8px rgba(255, 139, 96, 0.4);
  }
  50% {
    transform: translateY(-8px);
    text-shadow: 0 0 16px rgba(255, 139, 96, 0.8);
  }
}

.epilogue-cta {
  animation: fade-scale-up 0.8s ease-out 0.45s forwards, cta-breathing 2.5s ease-in-out 1.25s infinite;
}

/* Microanimations: subtle floating effect on epilogue elements */
@keyframes float-subtle {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-2px);
  }
}

/* Chapter entrance animation: slides up with pause */
@keyframes chapter-slide-up {
  0% {
    opacity: 0;
    transform: translateY(40px);
  }
  100% {
    opacity: 1;
    transform: translateY(0px);
  }
}

.chapter-card.reveal-pause {
  animation: chapter-slide-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.epilogue-title {
  animation: fade-scale-up 0.8s ease-out 0.15s forwards, float-subtle 4s ease-in-out 1s infinite;
}

.epilogue-body {
  animation: fade-scale-up 0.8s ease-out 0.3s forwards, float-subtle 5s ease-in-out 1.2s infinite;
}

/* ── Explorer CTA Section ──────────────────────────────────────────────── */

.explorer-cta-section {
  background: var(--bg);
  padding: 4rem clamp(24px, 5vw, 64px) 3rem;
  border-bottom: 1px solid var(--rule-faint);
}

.cta-inner {
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
}

.cta-title {
  font-family: 'Instrument Serif', serif;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  color: #e8e6e1;
  margin-bottom: 1.2rem;
  letter-spacing: -0.01em;
  opacity: 0;
  animation: fade-scale-up 0.6s ease-out forwards;
}

.cta-description {
  font-family: 'Inter', sans-serif;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text-muted);
  max-width: 700px;
  margin: 0 auto;
  opacity: 0;
  animation: fade-scale-up 0.6s ease-out 0.1s forwards;
}

/* ── Interactive Explorer Section (Dark Background) ─────────────────────── */

.paper-section.explorer-section {
  background: var(--bg);
  color: #e8e6e1;
  padding: 60px clamp(24px, 5vw, 64px) 60px;
}

.explorer-section .prose-block {
  color: #e8e6e1;
  padding: 32px;
  margin-top: 0;
  margin-bottom: 200px;
}

.explorer-section .prose-block strong {
  color: #e8e6e1;
}

.explorer-section .figure {
  color: #e8e6e1;
  padding: 0 0 72px 0;
  margin-top: 0;
  margin-bottom: 0;
}

.explorer-section .figure-head {
  border-top-color: rgba(232, 230, 225, 0.15);
}

.explorer-section .figure-num {
  color: #898989;
}

.explorer-section .figure-tag {
  color: var(--accent);
}

.explorer-section .figure-title {
  color: #e8e6e1;
}

.explorer-section .figure-finding {
  color: var(--text-muted);
}

.explorer-section .figure-note {
  color: var(--text-faint);
}

.explorer-section .figure-source-inline {
  color: #5a5a6a;
}

.explorer-section .figure-source {
  color: var(--text-faint);
}

/* Override D3 colors for dark background */
.explorer-section svg text[fill="#1a1a1b"],
.explorer-section svg tspan[fill="#1a1a1b"] {
  fill: #e8e6e1 !important;
}

.explorer-section svg text[fill="#5f6164"],
.explorer-section svg tspan[fill="#5f6164"] {
  fill: #898989 !important;
}

/* ── Methodology & Credits Section ────────────────────────────────── */

/* ════════════════════════════════════════════════════════════════════
   METHODOLOGY & CREDITS SECTION
   Dark theme, serif headers, spring animations
   ════════════════════════════════════════════════════════════════════ */

.methodology-section {
  background: linear-gradient(to bottom, rgba(255, 139, 96, 0.1) 0%, var(--bg) 60%);
  color: var(--text-primary);
  padding: clamp(120px, 15vh, 160px) clamp(24px, 5vw, 64px) clamp(80px, 10vh, 120px);
  margin-top: clamp(80px, 12vh, 120px);
}

.methodology-container {
  max-width: 860px;
  margin: 0 auto;
}

/* ── Scroll Reveal Animation ────────────────────────────────────────── */
.methodology-section [data-reveal] {
  opacity: 0;
  transform: translateY(24px) scale(0.98) rotateZ(-0.5deg);
}

.methodology-section [data-reveal].revealed {
  opacity: 1;
  transform: translateY(0) scale(1) rotateZ(0deg);
}

/* ── Accordion Styles ──────────────────────────────────────────────── */
.accordion-item {
  margin-bottom: clamp(40px, 6vw, 56px);
}

.accordion-button {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 20px 16px;
  text-align: left;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-transform: none;
}

.accordion-button:hover {
  background: rgba(255, 139, 96, 0.1);
  border-color: rgba(255, 139, 96, 0.3);
  box-shadow: 0 0 12px rgba(255, 139, 96, 0.15);
}

.accordion-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.accordion-label {
  font-weight: 400;
}

.accordion-icon {
  font-size: 1.2rem;
  color: var(--accent-warm);
  font-weight: 300;
  transition: color 0.3s ease;
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  opacity: 0;
}

.accordion-content.open {
  max-height: 2000px;
  overflow: visible;
  opacity: 1;
}

.accordion-inner {
  background: transparent;
  border-left: 2px solid var(--accent-warm);
  padding: 32px 32px 32px 28px;
  margin-top: 12px;
}

.methodology-subhead {
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  color: var(--accent-warm);
  margin: 0 0 16px 0;
  text-transform: uppercase;
}

.methodology-subhead:not(:first-child) {
  margin-top: 28px;
}

.accordion-inner p {
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.7;
}

.accordion-inner p:last-of-type {
  margin-bottom: 0;
}

.accordion-inner a {
  color: #ffffff;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.accordion-inner a:hover {
  color: #e8e6e1;
}

.references-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.references-list li {
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.7;
}

.references-list li:last-child {
  margin-bottom: 0;
}

.references-list strong {
  font-weight: 500;
  color: var(--text-primary);
}

.references-list em {
  font-style: italic;
  color: var(--text-muted);
}

/* ── Author Cards ──────────────────────────────────────────────────── */
.author-section {
  display: flex;
  flex-direction: column;
  gap: clamp(32px, 5vw, 48px);
  margin-top: clamp(56px, 8vw, 80px);
  margin-bottom: clamp(40px, 6vw, 64px);
}

.author-card {
  opacity: 0;
  transform: translateY(24px) scale(0.98);
  display: flex;
  flex-direction: row;
  gap: 28px;
  align-items: flex-start;
  padding: 0;
  background: transparent;
}

.author-card {
  animation: fade-scale-up 0.9s cubic-bezier(0.16, 1, 0.3, 1) var(--stagger-delay, 0ms) forwards;
}

.author-image {
  border-radius: 8px;
  margin-bottom: 0;
  background: var(--surface-elevated) !important;
  flex-shrink: 0;
  width: 140px;
  height: 140px;
}

.author-name {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 8px;
  margin-top: 0;
}

.author-bio {
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin: 0;
}

/* ── Partnership Section ────────────────────────────────────────────── */
.partnership-section {
  padding-top: clamp(48px, 8vw, 64px);
  margin-top: clamp(48px, 8vw, 64px);
  margin-bottom: clamp(40px, 6vw, 64px);
}

.partnership-title {
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  color: var(--accent-warm);
  margin: 0 0 16px 0;
  text-transform: uppercase;
}

.partnership-block {
  display: flex;
  gap: 28px;
  align-items: flex-start;
  padding: 24px;
  opacity: 0;
  transform: translateY(16px);
  animation: fade-scale-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.partnership-section.revealed .partnership-block {
  opacity: 1;
  transform: translateY(0);
}

.partnership-logo {
  background: transparent !important;
  border-radius: 0 !important;
  flex-shrink: 0;
  margin-bottom: 0 !important;
}

.partnership-info {
  flex: 1;
  min-width: 0;
}

.partnership-name {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.3;
}

.partnership-desc {
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin: 0;
}

/* ── Credits Section ────────────────────────────────────────────────── */
.credits-block {
  opacity: 0;
  padding-top: 48px;
  margin-top: 64px;
  margin-bottom: clamp(40px, 6vw, 64px);
  transition: opacity 0.6s ease;
}

.credits-block.revealed {
  opacity: 1;
}

.credits-title {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--accent-warm);
  margin: 0 0 32px 0;
  text-transform: uppercase;
}

.credits-block p {
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 0.9;
  margin-bottom: 32px;
}

.credits-block p:last-child {
  margin-bottom: 0;
}

.credits-block strong {
  font-weight: 500;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  display: block;
  margin-bottom: 1px;
}

/* ── Disclaimer Box ────────────────────────────────────────────────── */
.methodology-disclaimer {
  opacity: 0;
  transform: translateX(-8px);
  background: rgba(255, 139, 96, 0.08);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 24px 28px;
  margin-top: 48px;
  transition: all 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.methodology-disclaimer.revealed {
  opacity: 1;
  transform: translateX(0);
}

.methodology-disclaimer p {
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0 0 12px 0;
  line-height: 1.7;
}

.methodology-disclaimer p:last-child {
  margin-bottom: 0;
}

.methodology-disclaimer p:first-child {
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  color: var(--accent-warm);
  margin-bottom: 12px;
  text-transform: uppercase;
}

/* ── Responsive Design ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .methodology-section {
    padding: clamp(60px, 8vh, 100px) clamp(20px, 4vw, 48px);
  }

  .author-card {
    flex-direction: column;
    gap: 16px;
  }

  .author-image {
    width: 100px !important;
    height: 100px !important;
  }

  .partnership-block {
    flex-direction: column;
    gap: 16px;
  }

  .partnership-logo {
    margin-bottom: 8px !important;
  }

  .accordion-button {
    padding: 20px 0;
  }

  .accordion-inner {
    padding: 24px;
  }
}


/* Responsive */
@media (max-width: 768px) {
  .author-section {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .partnership-block {
    flex-direction: column;
    gap: 16px;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .author-section {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}

/* ── Reduced Motion Compliance ──────────────────────────────────────────– */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Scrollbar styling ───────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 139, 96, 0.5);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 139, 96, 0.7);
}

/* Firefox scrollbar */
* {
  scrollbar-color: rgba(255, 139, 96, 0.5) transparent;
  scrollbar-width: thin;
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .figure { padding: 40px 20px 56px; }
  .prose-block { padding: 32px 20px; }
  .pull-quote { padding: 60px 20px; }
  .quote-wall-wrap { padding: 8px 20px 32px; }
  .cover-masthead { font-size: 0.6rem; gap: 8px; }
  #progress-rail { display: none; }
}
