/* ---------- Global ---------- */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
  color: #e5e7eb;
  background: #0f172a;
}

/* Scenario mood backgrounds */
body.scn-ssp126 {
  background: radial-gradient(circle at top, #0f172a 0%, #022c22 40%, #020617 100%);
}

body.scn-ssp245 {
  background: radial-gradient(circle at top, #111827 0%, #020617 60%, #020617 100%);
}

body.scn-ssp370 {
  background: radial-gradient(circle at top, #1f2937 0%, #7c2d12 40%, #020617 100%);
}

body.scn-ssp585 {
  background: radial-gradient(circle at top, #7f1d1d 0%, #450a0a 45%, #020617 100%);
}

/* ---------- Shell ---------- */

header,
footer {
  background: transparent;
  color: #e5e7eb;
  padding: 1rem 1.5rem;
}

header {
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

header h1 {
  margin: 0;
  font-size: 1.7rem;
  letter-spacing: 0.03em;
}

header p {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
  color: #9ca3af;
}

footer {
  text-align: center;
  font-size: 0.8rem;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
}

main {
  max-width: 1100px;
  margin: 1.75rem auto 2.5rem auto;
  padding: 0 1.25rem 2rem;
}

/* ---------- Sections ---------- */

section {
  margin-bottom: 1.75rem;
  background: #f9fafb;
  border-radius: 0.9rem;
  padding: 1.1rem 1.3rem 1.3rem 1.3rem;
  border: 1px solid #e5e7eb;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.2);
  color: #0f172a;
}

#intro {
  background: linear-gradient(135deg, #eff6ff, #f9fafb);
}

section h2 {
  margin-top: 0;
  margin-bottom: 0.4rem;
  font-size: 1.2rem;
}

section p {
  margin: 0.25rem 0;
  font-size: 0.95rem;
  color: #4b5563;
  max-width: 70ch;
}

section ul {
  margin: 0.25rem 0 0.25rem 1.1rem;
  padding: 0;
  font-size: 0.95rem;
  color: #4b5563;
}

/* ---------- Tabs ---------- */

#tab-bar {
  display: flex;
  gap: 0.6rem;
  margin: 1.2rem 0 0.8rem;
}

.tab-btn {
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid #1f2937;
  background: #020617;
  color: #e5e7eb;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.tab-btn:hover {
  background: #0b1120;
}

.tab-btn.active {
  background: #22c55e;
  color: #022c22;
  box-shadow: 0 8px 24px rgba(34, 197, 94, 0.35);
  transform: translateY(-1px);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Slightly different style for write-up block */
.writeup-inner {
  background: #f9fafb;
  border-radius: 0.9rem;
}

/* ---------- Controls ---------- */

#controls {
  background: #f1f5f9;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-top: 0.3rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

label {
  font-weight: 600;
  font-size: 0.85rem;
  color: #334155;
}

select {
  padding: 0.35rem 0.6rem;
  border-radius: 0.6rem;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  font-size: 0.9rem;
  color: #0f172a;
}

.control-help {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 0.6rem;
}

.scenario-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 15px;
}

.pill {
  padding: 4px 12px;
  border-radius: 16px;
  border: 2px solid #90a4ae;
  background-color: #f0f4f8;
  color: #607d8b;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.pill:hover {
  background-color: #607d8b;
  color: #fff;
  transform: scale(1.05);
}

.pill.active {
  background-color: #607d8b;
  color: #fff;
}

/* ---------- Legends / charts ---------- */

.chart-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 6px;
  margin-top: 0;
}

.legend {
  display: flex;
  flex-direction: column;
  background-color: rgba(255, 255, 255, 0.9);
  padding: 6px 10px;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  font-size: 0.75rem;
  color: #1e293b;
  z-index: 10;
}

.legend-item {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}

.legend-item div {
  width: 12px;
  height: 12px;
  margin-right: 6px;
  border-radius: 2px;
}

/* ---------- Charts ---------- */

.viz-section {
  background: #ffffff;
}

.chart-container {
  margin-top: 0.3rem;
  background-color: #f8fafc;
  border-radius: 0.8rem;
  border: 1px solid #e2e8f0;
  padding: 0.4rem 0.7rem 0.4rem 0.7rem;
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
}

/* SVG axes */

.axis path,
.axis line {
  stroke: #cbd5e1;
}

.axis text {
  font-size: 0.7rem;
  fill: #64748b;
}

/* Tooltip */

.tooltip {
  position: absolute;
  pointer-events: none;
  background-color: #ffffff;
  border: 1px solid #cbd5f5;
  padding: 4px 6px;
  border-radius: 0.4rem;
  font-size: 0.75rem;
  color: #0f172a;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.18);
  opacity: 0;
  transition: opacity 0.1s ease-in-out;
}

/* ---------- Scrollytelling layout ---------- */

#scrolly-1 {
  position: relative;
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  background: transparent;
  border-radius: 0.9rem;
  padding: 0;
  border: none;
  box-shadow: none;
}

#explorer > #scrolly-1 {
  background: transparent;
}

#scrolly-text {
  flex: 1;
  max-width: 460px;
}

#scrolly-viz {
  flex: 1;
  position: sticky;
  top: 80px;
}

/* Scroll progress bar */

#scroll-progress {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: #111827;
  overflow: hidden;
  margin-bottom: 0.6rem;
}

#scroll-progress-inner {
  height: 100%;
  width: 0%;
  background: linear-gradient(to right, #22c55e, #3b82f6, #f97316);
  transition: width 0.15s ease-out;
}

.scrolly-intro {
  font-size: 0.85rem;
  color: #6b7280;
  margin-bottom: 0.6rem;
  max-width: 36rem;
}

#scrolly-text .step {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  border-radius: 0.75rem;
  background: #020617;
  border: 1px solid #1f2937;
  color: #e5e7eb;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease,
    background-color 0.2s ease;
  cursor: pointer;
}

#scrolly-text .step h3 {
  margin-top: 0;
  margin-bottom: 0.4rem;
  color: #e5e7eb;
  font-size: 0.98rem;
}

#scrolly-text .step p {
  color: #cbd5f5;
  max-width: none;
  font-size: 0.9rem;
}

#scrolly-text .step.is-active {
  border-color: #3b82f6;
  box-shadow:
    0 0 0 1px rgba(59, 130, 246, 0.6),
    0 10px 30px rgba(15, 23, 42, 0.55);
  transform: translateY(-2px);
}

/* ---------- Scenario insight strip ---------- */

.scenario-insight {
  margin-bottom: 1rem;
  padding: 0.6rem 0.8rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.95);
  color: #e5e7eb;
  font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.scenario-insight strong {
  color: #38bdf8;
}

/* ---------- Map ---------- */

.map-container {
  margin-top: 0.3rem;
  background: radial-gradient(circle at top, #020617 0%, #020617 40%, #020617 100%);
  border-radius: 0.9rem;
  border: 1px solid #1f2937;
  padding: 0.4rem;
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}

.map-container svg {
  display: block;
}

.region-dot {
  fill: #38bdf8;
  stroke: #0f172a;
  stroke-width: 1.2;
  cursor: pointer;
  opacity: 0.9;
}

.region-dot:hover {
  opacity: 1;
}

.region-dot.active-region {
  fill: #f97316;
}

/* Region summary card */

.region-summary-card {
  margin-top: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: 0.75rem;
  background: #020617;
  color: #e5e7eb;
  border: 1px solid #1f2937;
  font-size: 0.86rem;
}

.region-summary-card h3 {
  margin-top: 0;
  margin-bottom: 0.35rem;
  font-size: 0.92rem;
  color: #e5e7eb;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  #scrolly-1 {
    flex-direction: column;
  }

  #scrolly-viz {
    position: static;
    top: auto;
  }

  #scrolly-text {
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  main {
    padding: 0 0.75rem 1.5rem;
  }

  section {
    padding: 0.9rem 0.9rem 1.1rem 0.9rem;
  }

  header h1 {
    font-size: 1.4rem;
  }

  .control-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .map-container {
    max-width: 100%;
  }
}

.autoplay-group {
  margin-top: 1rem;
}

.autoplay-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

#play-pause-btn {
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  border: 1px solid #1f2937;
  background: #0f172a;
  color: #e5e7eb;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

#play-pause-btn:hover {
  background: #1e293b;
  transform: translateY(-1px);
}

#year-slider {
  flex: 1;
}

#year-label {
  font-size: 0.85rem;
  color: #94a3b8;
  min-width: 3rem;
  text-align: right;
}
