/* ============================================================
   The Cost of Inaction — styles.css
   Two-column scrollytelling: scrolling story (left) + sticky stage (right)
   ============================================================ */

:root {
  --bg: #141714;
  --bg-soft: #1c1f1c;
  --panel: #222421;
  --ink: #E8E4DC;
  --ink-dim: #A09890;
  --accent: #CC2B00;
  --accent-warm: #ffb347;
  --yellow: #F0E830;
  --brush: #828282;
  --line: #383A30;

  /* disaster-type palette is defined in main.js (TYPE_COLORS) and shared
     by the map bubbles, the stacked bars and the legend swatches. */

  --stage-w: 60%;
  --story-w: 40%;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "DM Mono", monospace;
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- Hero (Ledger) ---- */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #191d1a;
}

.hero-content {
  width: min(640px, 90vw);
  display: flex;
  flex-direction: column;
}

.hero-eyebrow {
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: "DM Mono", monospace;
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--yellow);
  margin: 0 0 52px;
}

.hero-eyebrow::before {
  content: '';
  display: block;
  width: 28px;
  height: 1px;
  background: var(--yellow);
  flex-shrink: 0;
}

.hero-h1 {
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(88px, 9.5vw, 148px);
  line-height: 0.92;
  margin: 0;
}

.w-thecost {
  display: block;
  color: #E8E4DC;
}

.w-of {
  display: block;
  font-size: 0.45em;
  color: rgba(232, 228, 220, 0.35);
  letter-spacing: 0.06em;
}

.w-inaction {
  display: block;
  color: #E8E4DC;
  position: relative;
}

.w-inaction::after {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 100%;
  height: 5px;
  background: var(--yellow);
}

.hero-body {
  font-family: "DM Mono", monospace;
  font-size: 13.5px;
  font-weight: 300;
  line-height: 1.75;
  color: rgba(232, 228, 220, 0.5);
  max-width: 380px;
  margin-top: 48px;
  margin-bottom: 0;
}

.hero-scroll-cue {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 64px;
}

.hero-arrow {
  color: var(--yellow);
  font-size: 16px;
  line-height: 1;
}

.hero-scroll-label {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(232, 228, 220, 0.5);
}

.outro {
  padding: 5rem 2rem;
  text-align: center;
  color: var(--ink-dim);
  font-size: 0.85rem;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
}
.outro p { max-width: 700px; margin: 0 auto; }

/* ---------------- Scrolly layout ---------------- */
#scrolly {
  position: relative;
  display: flex;
  background: #191d1a;
}

/* Left scrolling story */
.story {
  flex: 0 0 var(--story-w);
  max-width: var(--story-w);
  padding: 0;
  background: #191d1a;
}

.step {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 80px 72px 80px 80px;
  opacity: 0.25;
  transition: opacity 0.4s ease;
}
.step.is-active { opacity: 1; }
.step[data-step="6"] { justify-content: center; }

/* Chapter heading row */
.step h2 {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 16px;
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(48px, 5vw, 72px);
  font-weight: 400;
  line-height: 1;
  margin: 0 0 28px;
}
.step-num {
  color: var(--yellow);
  font-family: "Bebas Neue", sans-serif;
  font-size: inherit;
}
.step-sep {
  font-family: "DM Mono", monospace;
  font-size: 14px;
  font-weight: 400;
  color: rgba(232, 228, 220, 0.25);
}
.step-title {
  color: #E8E4DC;
  font-family: "Bebas Neue", sans-serif;
  font-size: inherit;
}

/* Body paragraph */
.step p {
  font-family: "DM Mono", monospace;
  font-size: 13.5px;
  font-weight: 300;
  line-height: 1.75;
  color: rgba(232, 228, 220, 0.5);
  max-width: 480px;
  margin: 0 0 24px;
}
.step strong {
  font-weight: 500;
  color: #E8E4DC;
  font-style: normal;
}

/* Caption / source line */
.step .note {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(232, 228, 220, 0.28);
  border-left: 3px solid color-mix(in srgb, var(--yellow) 40%, transparent);
  padding-left: 12px;
  margin: 0;
}

/* Final CTA paragraph */
.step .cta {
  font-family: "DM Mono", monospace;
  font-size: 13.5px;
  font-weight: 300;
  line-height: 1.75;
  color: rgba(232, 228, 220, 0.5);
  max-width: 480px;
  margin: 0 0 24px;
}
.step .cta strong {
  font-weight: 500;
  color: var(--yellow);
}

/* Right sticky stage */
#stage {
  position: sticky;
  top: 0;
  flex: 0 0 var(--stage-w);
  width: var(--stage-w);
  height: 100vh;
  margin: 0;
  align-self: flex-start;
  background: #111614;
  border-left: 1px solid color-mix(in srgb, var(--yellow) 8%, transparent);
  overflow: hidden;
}

/* Each visualization sits in its own absolutely-positioned panel.
   In guided steps (1-5) only one is visible at a time. */
.viz-panel {
  position: absolute;
  inset: 0;
  padding: 4.5rem 2.5rem 2.5rem;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px);
  transition: opacity 0.6s ease, transform 0.6s ease, visibility 0.6s;
}
.viz-panel.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.panel-title {
  font-family: "Bebas Neue", sans-serif;
  font-size: 24px;
  font-weight: 400;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
  color: #E8E4DC;
}
.chart { flex: 1; position: relative; min-height: 0; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }

/* ---------------- Exploration (Step 6) dashboard ----------------
   All three panels visible at once in a grid. */
#stage.explore .viz-panel {
  position: absolute;
  opacity: 1;
  visibility: visible;
  transform: none;
  padding: 2.6rem 1.6rem 1.2rem;
}
#stage.explore #panel-area { inset: 0 0 50% 0; }
#stage.explore #panel-map  { inset: 50% 50% 0 0; border-top: 1px solid var(--line); }
#stage.explore #panel-bar  { inset: 50% 0 0 50%; border-top: 1px solid var(--line); border-left: 1px solid var(--line); padding-bottom: 3.5rem; }

/* Bar chart floor clears the legend strip (~36px) */
#panel-bar { padding-bottom: 3.5rem; }
#stage.explore .panel-title { font-size: 17px; margin-bottom: 0.2rem; }

.explore-banner {
  position: absolute;
  top: 0; left: 0; right: 0;
  background: var(--yellow);
  color: #1a1a1a;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  padding: 0.45rem;
  letter-spacing: 0.02em;
  transform: translateY(-100%);
  transition: transform 0.5s ease;
  z-index: 5;
}
#stage.explore .explore-banner { transform: translateY(0); }



/* ---------------- Axes & marks ---------------- */
.axis path, .axis line { stroke: var(--line); }
.axis text { fill: var(--ink-dim); font-size: 11px; font-family: "DM Mono", monospace; }
.axis-label { fill: var(--ink-dim); font-size: 11px; font-family: "DM Mono", monospace; font-weight: 400; letter-spacing: 0.06em; }
.grid line { stroke: rgba(255,255,255,0.09); }
.grid path { stroke: none; }

.zero-line { stroke: rgba(255,255,255,0.25); stroke-dasharray: 4 4; stroke-width: 1; opacity: 1; }
.area-fill { opacity: 0.85; }
.area-line { fill: none; stroke: var(--yellow); stroke-width: 2; }

.country { fill: #2d2e2b; stroke: #3d3e3a; stroke-width: 0.5; }
.graticule { fill: none; stroke: rgba(255,255,255,0.07); }
.bubble { stroke: #131614; stroke-width: 0.6; fill-opacity: 0.75; cursor: pointer; transition: fill-opacity 0.15s; }
.bubble:hover { fill-opacity: 1; stroke: #fff; stroke-width: 1.2; }

.bar-seg {
  cursor: pointer;
  transition: opacity 0.15s;
}
.bar-seg:hover { opacity: 0.72; }

/* ---------------- Legend — full-width bottom strip in all modes ---------------- */
.legend {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: auto;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.2rem 1.4rem;
  padding: 0.45rem 1.2rem;
  background: rgba(19, 21, 17, 0.94);
  border: none;
  border-top: 1px solid var(--line);
  border-radius: 0;
  font-size: 0.78rem;
  display: none;
  z-index: 4;
  backdrop-filter: blur(6px);
}
.legend.is-visible { display: flex; }
.legend-row { display: flex; align-items: center; gap: 0.5rem; color: var(--ink-dim); }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }

/* ---------------- Tooltip (details-on-demand) ---------------- */
.tooltip {
  position: fixed;
  pointer-events: none;
  background: #fff;
  color: #1a1710;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font-size: 0.82rem;
  line-height: 1.45;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
  opacity: 0;
  transition: opacity 0.12s ease;
  z-index: 50;
  max-width: 240px;
}
.tooltip.is-visible { opacity: 1; }
.tooltip .tt-title { font-weight: 700; margin-bottom: 2px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 1rem; }
.tooltip .tt-key { color: #6b6358; }
.tooltip .tt-val { font-weight: 600; font-variant-numeric: tabular-nums; }

/* brush styling */
.brush .selection { fill: var(--brush); fill-opacity: 0.15; stroke: var(--brush); stroke-width: 1; }
.brush-hint { fill: var(--ink-dim); font-size: 10px; font-family: "DM Mono", monospace; font-style: normal; letter-spacing: 0.08em; }

/* =============== MORE INFO BUTTON =============== */
.btn-more-info {
  display: inline-block;
  margin-top: 2rem;
  padding: 0.75rem 1.4rem;
  background: transparent;
  border: 1px solid rgba(240, 232, 48, 0.6);
  color: var(--yellow);
  font-family: "DM Mono", monospace;
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.35s ease;
  border-radius: 0;
  position: relative;
  overflow: hidden;
}

.btn-more-info::before {
  content: '';
  position: absolute;
  left: -100%;
  top: 0;
  width: 100%;
  height: 100%;
  background: var(--yellow);
  z-index: -1;
  transition: left 0.35s ease;
}

.btn-more-info:hover {
  border-color: var(--yellow);
  color: #1a1a1a;
  transform: translateX(3px);
}

.btn-more-info:hover::before {
  left: 0;
}

.btn-more-info:active {
  transform: translateX(1px);
}

/* =============== MODAL SYSTEM =============== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.94);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 100;
  overflow-y: auto;
  padding: 2rem;
}
.modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  max-width: 900px;
  margin: 0 auto;
  position: relative;
}

.modal-close {
  position: fixed;
  top: 2rem;
  right: 2rem;
  width: 44px;
  height: 44px;
  background: transparent;
  border: 2px solid var(--yellow);
  color: var(--yellow);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 101;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
}
.modal-close:hover {
  background: var(--yellow);
  color: #1a1a1a;
  transform: rotate(90deg);
}

.modal-panel {
  display: none;
}
.modal-panel.is-active {
  display: block;
  animation: slideUp 0.3s ease forwards;
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-panel h2 {
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(32px, 4vw, 52px);
  line-height: 1.2;
  color: var(--yellow);
  margin: 0 0 2rem;
  margin-top: 1rem;
}

.modal-body {
  font-family: "DM Mono", monospace;
  font-size: 13px;
  font-weight: 300;
  line-height: 1.8;
  color: rgba(232, 228, 220, 0.75);
}

.modal-body p {
  margin: 0 0 1.5rem;
  max-width: 800px;
}

.modal-body h3 {
  font-family: "Bebas Neue", sans-serif;
  font-size: 20px;
  font-weight: 400;
  color: rgba(240, 232, 48, 0.95);
  margin: 2.5rem 0 1rem;
  letter-spacing: 0.04em;
}

.modal-body ul {
  margin: 0 0 1.5rem;
  padding-left: 1.8rem;
  list-style: none;
}

.modal-body li {
  margin: 0.6rem 0;
  padding-left: 1rem;
  position: relative;
}

.modal-body li::before {
  content: '\2022';
  position: absolute;
  left: 0;
  color: var(--yellow);
  font-weight: 700;
}

.modal-body strong {
  color: #E8E4DC;
  font-weight: 500;
}

/* Responsive modal */
@media (max-width: 768px) {
  .modal-overlay {
    padding: 5rem 1.5rem 2rem;
  }

  .modal-close {
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    font-size: 24px;
  }

  .modal-panel h2 {
    font-size: clamp(24px, 6vw, 40px);
  }

  .modal-body {
    font-size: 12px;
  }

  .modal-body h3 {
    font-size: 16px;
    margin: 1.8rem 0 0.8rem;
  }
}

/* ---------------- Responsive fallback ---------------- */
@media (max-width: 900px) {
  .hero-content { padding: 0 24px; }

  #scrolly { flex-direction: column; }
  .story, #stage {
    flex-basis: 100%;
    max-width: 100%;
    width: 100%;
  }
  #stage { height: 70vh; top: 30vh; }
  .step { min-height: 80vh; padding: 48px 32px 48px 40px; }
}
