/* ═══════════════════════════════════════════════════════════════
   Choose Your Future — main stylesheet
   ═══════════════════════════════════════════════════════════════ */

/* ── Design tokens ────────────────────────────────────────────── */
:root {
  /* SSP scenario colors — match climate.js exactly */
  --color-ssp126:     #1a9850;
  --color-ssp245:     #f6c744;
  --color-ssp370:     #f46d43;
  --color-ssp585:     #d73027;
  --color-historical: #888888;
  --color-accent:     #58a6ff;

  /* Backgrounds */
  --bg-primary:   #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary:  #1c2128;

  /* Borders */
  --border-dim:   #21262d;
  --border-muted: #30363d;

  /* Text */
  --text-primary:   #e6edf3;
  --text-secondary: #8b949e;

  /* Typography */
  --font-serif: 'Lora', Georgia, serif;
  --font-sans:  'Inter', system-ui, -apple-system, sans-serif;
}

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

html {
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  scroll-padding-top: 70px;
}

/* ── Base ─────────────────────────────────────────────────────── */
body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
}

/* ── Header ───────────────────────────────────────────────────── */
#site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-dim);
  padding: 8px 32px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

#header-center {
  text-align: center;
  min-width: 0;
}

.header-spacer {
  flex: 1;
  flex-shrink: 0;
}

#site-title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 2px;
  letter-spacing: -0.01em;
}

#site-subtitle {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

/* ── Section nav dots ─────────────────────────────────────────── */
.section-nav {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-self: end;
}

.section-nav a {
  position: relative;
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border-muted);
  text-decoration: none;
  transition: background 0.2s, transform 0.2s;
}

.section-nav a:hover {
  background: var(--text-secondary);
  transform: scale(1.4);
}

.section-nav a.active {
  background: var(--color-accent);
  transform: scale(1.3);
}

/* CSS tooltip from title attribute */
.section-nav a::after {
  content: attr(title);
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.7rem;
  padding: 4px 9px;
  border-radius: 4px;
  border: 1px solid var(--border-muted);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 10;
}

.section-nav a:hover::after {
  opacity: 1;
}


/* ── Scroll sections ──────────────────────────────────────────── */
.scroll-section {
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 40px;
  border-bottom: 1px solid var(--border-dim);
  scroll-snap-align: start;
}

.scroll-section:last-child {
  border-bottom: none;
}

/* ── Text blocks ──────────────────────────────────────────────── */
.text-block {
  max-width: 680px;
  margin-bottom: 24px;
  text-align: center;
}

.section-num {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: 10px;
}

.text-block h2 {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 18px;
}

.text-block p {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--text-secondary);
}

/* ── Chart blocks ─────────────────────────────────────────────── */
.chart-block {
  width: 100%;
  max-width: 900px;
  min-height: 400px;
  position: relative;
}

#chart-keeling {
  position: relative;
  margin-top: 24px;
  overflow: visible;
}

#chart-historical svg,
#chart-fan svg,
#chart-keeling svg,
#chart-adventure svg {
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border-dim);
}

.axis path,
.axis line {
  stroke: var(--border-muted);
}

/* ── Adventure section: top-aligned (content stays put when panel expands) ── */
#section-adventure {
  justify-content: flex-start;
}

#section-adventure .chart-block {
  max-width: none;
  min-height: 0;
}

#chart-adventure {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 28px;
}

#chart-adventure > svg {
  flex: 0 0 auto;
  overflow: visible;
}

/* Panel and summary: right column */
#adventure-panel,
#adventure-summary {
  flex: 1 1 280px;
  min-width: 260px;
  max-width: none !important;
  margin-top: 0 !important;
  font-family: var(--font-sans) !important;
  padding-top: 4px;
}

/* Collapse the panel when D3 clears it (so summary slots into the same column) */
#adventure-panel:empty {
  display: none;
}

/* Stack choice buttons vertically (D3 sets flex-direction row inline) */
#adventure-panel > div:has(button) {
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  gap: 10px !important;
}

/* Choice buttons: primary CTA treatment */
#adventure-panel button {
  width: 100% !important;
  padding: 15px 18px !important;
  border-radius: 10px !important;
  text-align: left !important;
  line-height: 1.45 !important;
  font-size: 0.95rem !important;
  font-family: var(--font-sans) !important;
  cursor: pointer;
}

/* ── Responsive: quiz phase goes single column on narrow viewports ── */
@media (max-width: 1350px) {
  #section-adventure {
    align-items: center;
  }

  #section-adventure .chart-block {
    max-width: 900px;
  }

  #chart-adventure:not(.phase-2) {
    flex-direction: column;
  }

  #adventure-panel,
  #chart-adventure:not(.phase-2) #adventure-summary {
    width: 100% !important;
    max-width: 900px !important;
    margin-top: 16px !important;
  }
}

/* ── Responsive: phase-2 row collapses to column on very narrow viewports ── */
@media (max-width: 1100px) {
  #chart-adventure.phase-2 {
    flex-direction: column !important;
    align-items: center;
  }

  #chart-adventure.phase-2 #adventure-summary {
    max-height: none;
    max-width: 900px !important;
    width: 100% !important;
  }
}

/* ── Sea level embedded section ───────────────────────────────── */
#section-sealevel {
  min-height: auto;
  padding-bottom: 80px;
}

/* Override chidiebere's 100vh min-height so it flows naturally */
#section-sealevel #content {
  min-height: auto;
  width: 100%;
  max-width: 1200px;
  padding: 0 16px;
}

/* Keep chidiebere tooltip above everything */
#section-sealevel #tooltip {
  z-index: 200;
}

/* ── Hero section ─────────────────────────────────────────────── */
#section-hero {
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 60px 40px 40px;
  text-align: center;
  border-bottom: 1px solid var(--border-dim);
  scroll-snap-align: start;
  overflow: hidden;
}

.hero-eyebrow {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: 8px;
}

.hero-authors {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.hero-title {
  font-family: var(--font-serif);
  font-size: 3.8rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.hero-subtitle {
  font-family: var(--font-sans);
  font-size: 1.2rem;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
  margin-bottom: 32px;
}

.hero-hook {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-style: italic;
  color: var(--text-primary);
  margin-bottom: 56px;
  max-width: 560px;
}

.hero-video-link {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-accent);
  text-decoration: none;
  margin-bottom: 32px;
  transition: opacity 0.15s;
}

.hero-video-link:hover {
  opacity: 0.75;
}

.scroll-cue {
  display: inline-block;
  color: var(--text-secondary);
  font-size: 1.4rem;
  text-decoration: none;
  animation: bounce-y 1.8s ease-in-out infinite;
  transition: color 0.15s;
}

.scroll-cue:hover {
  color: var(--color-accent);
}

@keyframes bounce-y {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(8px); }
}

/* ── SSP fan chart layout ─────────────────────────────────────── */
#fan-layout {
  display: flex;
  flex-direction: row;
  gap: 28px;
  align-items: flex-start;
  width: 100%;
  max-width: 1200px;
}

#fan-chart-col {
  flex: 0 0 auto;
}

#fan-controls {
  display: flex;
  flex-direction: row;
  gap: 10px;
  margin-bottom: 12px;
}

.ssp-btn {
  padding: 6px 16px;
  border-radius: 20px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.18s;
}

.ssp-btn[data-ssp="ssp126"]        { border: 1.5px solid var(--color-ssp126); }
.ssp-btn[data-ssp="ssp126"]:hover  { color: var(--color-ssp126); }
.ssp-btn[data-ssp="ssp126"].active { background: #1a985022; color: var(--color-ssp126); font-weight: 600; }

.ssp-btn[data-ssp="ssp245"]        { border: 1.5px solid var(--color-ssp245); }
.ssp-btn[data-ssp="ssp245"]:hover  { color: var(--color-ssp245); }
.ssp-btn[data-ssp="ssp245"].active { background: #f6c74422; color: var(--color-ssp245); font-weight: 600; }

.ssp-btn[data-ssp="ssp370"]        { border: 1.5px solid var(--color-ssp370); }
.ssp-btn[data-ssp="ssp370"]:hover  { color: var(--color-ssp370); }
.ssp-btn[data-ssp="ssp370"].active { background: #f46d4322; color: var(--color-ssp370); font-weight: 600; }

.ssp-btn[data-ssp="ssp585"]        { border: 1.5px solid var(--color-ssp585); }
.ssp-btn[data-ssp="ssp585"]:hover  { color: var(--color-ssp585); }
.ssp-btn[data-ssp="ssp585"].active { background: #d7302722; color: var(--color-ssp585); font-weight: 600; }

#fan-description {
  flex: 1 1 260px;
  min-width: 240px;
  max-width: 320px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-dim);
  border-radius: 10px;
  padding: 20px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text-secondary);
  position: sticky;
  top: 80px;
  margin-top: 45px;
}

.fan-desc-title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

@media (max-width: 1100px) {
  #fan-layout {
    flex-direction: column;
  }

  #fan-description {
    max-width: 100%;
    position: static;
  }
}

/* ── Adventure Phase 1: questions centered, chart hidden ─────── */
#chart-adventure:not(.phase-2) {
  flex-direction: column !important;
  align-items: center;
}

#chart-adventure:not(.phase-2) > svg {
  display: none;
}

#chart-adventure:not(.phase-2) #adventure-panel {
  max-width: 700px !important;
  width: 100% !important;
}

/* ── Adventure: quiz complete — section scrolls internally so section 05 can't bleed in ── */
#section-adventure.quiz-complete {
  overflow-y: auto;
}

/* ── Adventure Phase 2: summary beside chart (row layout) ──────── */
#chart-adventure.phase-2 {
  flex-direction: row !important;
  align-items: stretch;
  justify-content: center;
}

#chart-adventure.phase-2 > svg {
  display: block;
  flex: 0 0 auto;
}

#chart-adventure.phase-2 #adventure-summary {
  flex: 1 1 320px;
  min-width: 280px;
  max-width: 440px !important;
  margin-top: 0 !important;
  display: flex !important;
  flex-direction: column !important;
}

/* ── Sea level section: description fades to map on scroll ───── */
#section-sealevel {
  height: 100vh;
  min-height: unset;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

#sealevel-header {
  flex: 0 0 auto;
  background: var(--bg-primary);
  text-align: center;
  padding: 28px 40px 16px;
  z-index: 10;
}

#sealevel-header h2 {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 0;
}

#sealevel-phases {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#sealevel-phase1,
#sealevel-phase2 {
  position: absolute;
  inset: 0;
  transition: opacity 0.5s ease;
}

#sealevel-phase1 {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0px 60px 0;
  text-align: center;
  z-index: 2;
}

#sealevel-phase1 p {
  max-width: 680px;
  font-family: var(--font-sans);
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--text-secondary);
}

#sealevel-phase2 {
  opacity: 0.45;
  pointer-events: none;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: 4px 16px 0;
  overflow-y: auto;
  zoom: 0.80;
  transform: scale(0.42);
  transform-origin: center 75%;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

#section-sealevel.phase-2 #sealevel-phase1 {
  opacity: 0;
  pointer-events: none;
}

#section-sealevel.phase-2 #sealevel-phase2 {
  opacity: 1;
  pointer-events: all;
  transform: scale(1) translateY(0);
}

#sealevel-scroll-cue {
  margin-top: 24px;
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  transition: opacity 0.4s ease;
}

#section-sealevel.phase-2 #sealevel-scroll-cue {
  opacity: 0;
  pointer-events: none;
}

#section-sealevel #slider-wrap {
  margin-bottom: 8px;
}

#section-sealevel #legend {
  margin: -6px 0 6px;
  gap: 14px;
}

#section-sealevel .legend-item {
  font-size: 11px;
}


/* ── Section 05 scenario buttons: match SSP colors from section 03 ─ */
#scenario-buttons button[data-scenario="ssp126"]        { border-color: var(--color-ssp126); }
#scenario-buttons button[data-scenario="ssp126"]:hover  { color: var(--color-ssp126); border-color: var(--color-ssp126); }
#scenario-buttons button[data-scenario="ssp126"].active { background: #1a985022; color: var(--color-ssp126); border-color: var(--color-ssp126); }

#scenario-buttons button[data-scenario="ssp245"]        { border-color: var(--color-ssp245); }
#scenario-buttons button[data-scenario="ssp245"]:hover  { color: var(--color-ssp245); border-color: var(--color-ssp245); }
#scenario-buttons button[data-scenario="ssp245"].active { background: #f6c74422; color: var(--color-ssp245); border-color: var(--color-ssp245); }

#scenario-buttons button[data-scenario="ssp370"]        { border-color: var(--color-ssp370); }
#scenario-buttons button[data-scenario="ssp370"]:hover  { color: var(--color-ssp370); border-color: var(--color-ssp370); }
#scenario-buttons button[data-scenario="ssp370"].active { background: #f46d4322; color: var(--color-ssp370); border-color: var(--color-ssp370); }

#scenario-buttons button[data-scenario="ssp585"]        { border-color: var(--color-ssp585); }
#scenario-buttons button[data-scenario="ssp585"]:hover  { color: var(--color-ssp585); border-color: var(--color-ssp585); }
#scenario-buttons button[data-scenario="ssp585"].active { background: #d7302722; color: var(--color-ssp585); border-color: var(--color-ssp585); }

/* ── Section 01: phase transition (text → chart) ─────────────── */
#section-now {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
  overflow: hidden;
  scroll-snap-stop: always;
}

#now-header {
  flex: 0 0 auto;
  background: var(--bg-primary);
  text-align: center;
  padding: 28px 40px 16px;
  z-index: 10;
}

#now-header h2 {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 0;
}

#now-phases {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#now-phase1,
#now-phase2 {
  position: absolute;
  inset: 0;
  transition: opacity 0.5s ease;
}

#now-phase1 {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 32px 60px 0;
  text-align: center;
  z-index: 2;
}
#now-phase1 .text-block {
  max-width: 55vw;
}


#now-scroll-cue {
  margin-top: 8px;
  font-size: 0.95rem;
  letter-spacing: 0.05em;
}

#now-phase2 {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  opacity: 0.45;
  pointer-events: none;
  z-index: 1;
  transform: scale(0.38);
  transform-origin: center 88%;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

#section-now.phase-2 #now-phase1 {
  opacity: 0;
  pointer-events: none;
}

#section-now.phase-2 #now-phase2 {
  opacity: 1;
  pointer-events: all;
  transform: scale(1);
}

/* ── Closing section ──────────────────────────────────────────── */
#section-closing .text-block {
  max-width: 760px;
}

#section-closing .text-block p + p {
  margin-top: 18px;
}

