:root {
  --bg: #0e1410;
  --bg-panel: #141c17;
  --ink: #eef2ee;
  --ink-dim: #a9b6ac;
  --line: #263229;
  --accent: #4fae6a;
  --accent-soft: rgba(79, 174, 106, 0.15);
  --roadless: #3b82f6;
  --near: #d9622b;
  --near-soft: rgba(217, 98, 43, 0.18);
  --near-dot: #facc15;
  --mog: #3fae9e;
  --alt3-lost: #ff4d4d;
  font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  scroll-behavior: smooth;
}

header.hero {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 4vh 6vw;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(217,98,43,0.10), transparent 60%),
    var(--bg);
}

header.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.5em 0;
  max-width: 26ch;
}

/* Wider than a typical reading column (58ch) on purpose -- this intro text is fixed
   and longer than we'd like, so trading some line-length comfort for fewer wrapped
   lines is what keeps the hero from pushing the map too far down the page. */
header.hero p {
  color: var(--ink-dim);
  font-size: clamp(0.95rem, 1.3vw, 1.1rem);
  max-width: 82ch;
  line-height: 1.45;
  margin: 0 0 1.05em 0;
  text-align: justify;
  text-align-last: left;
}

header.hero p small {
  display: inline-block;
  font-size: 0.78em;
  opacity: 0.75;
}

header.hero p a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(79, 174, 106, 0.4);
  text-underline-offset: 2px;
}

header.hero p a:hover {
  color: var(--ink);
  text-decoration-color: currentColor;
}

.hero-stats {
  display: flex;
  gap: 2.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 1rem;
}

.hero-stats .stat { text-align: center; }

.hero-stats .stat .num {
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  font-weight: 700;
  color: var(--near);
  font-variant-numeric: tabular-nums;
}

.hero-stats .stat .label {
  color: var(--ink-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  max-width: 16ch;
  margin: 0 auto;
}

.scroll-cue {
  margin-top: 3rem;
  color: var(--ink-dim);
  font-size: 0.85rem;
  animation: bob 2s ease-in-out infinite;
}

.scroll-hint {
  margin-top: 0.6em;
  color: var(--ink-dim);
  opacity: 0.7;
  font-size: 0.75rem;
}

.hero-buttons {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

.hero-btn {
  display: inline-block;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.7rem 1.4rem;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
}

.hero-btn-muted {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-dim);
}

.hero-btn-muted:hover {
  color: var(--ink);
  border-color: var(--ink-dim);
}

.hero-btn-action {
  background: var(--near);
  color: #ffffff;
}

.hero-btn-action:hover {
  filter: brightness(1.1);
}

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.65);
  padding: 6vh 5vw;
  overflow-y: auto;
}

.modal-backdrop.open { display: block; }

body.modal-open { overflow: hidden; }

.modal {
  position: relative;
  max-width: 860px;
  margin: 0 auto;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 2.2rem 2.4rem;
  text-align: left;
}

.modal h2 {
  margin: 0 0 1em 0;
  font-size: 1.6rem;
}

.modal h3 {
  color: var(--near);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 1.6em 0 0.5em 0;
}

.modal h3:first-of-type { margin-top: 0; }

.modal p {
  color: var(--ink-dim);
  line-height: 1.6;
  margin: 0 0 1em 0;
}

.modal p a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(79, 174, 106, 0.4);
  text-underline-offset: 2px;
}

.modal p a:hover {
  color: var(--ink);
  text-decoration-color: currentColor;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  color: var(--ink-dim);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}

.modal-close:hover { color: var(--ink); }

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

.story {
  position: relative;
  display: grid;
  grid-template-columns: minmax(280px, 34%) 1fr;
}

.story .map-col {
  position: sticky;
  top: 0;
  height: 100vh;
  border-left: 1px solid var(--line);
}

#map {
  width: 100%;
  height: 100%;
  background: var(--bg);
}

.text-col { padding: 0 5vw; }

.step {
  min-height: 92vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 6vh 0;
  border-bottom: 1px solid var(--line);
}

.step:last-child { border-bottom: none; }

.step .kicker {
  color: var(--near);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 0.5em;
}

.step h2 {
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  margin: 0 0 0.5em 0;
  letter-spacing: -0.01em;
}

.step p {
  color: var(--ink-dim);
  line-height: 1.6;
  max-width: 48ch;
  margin: 0 0 1.2em 0;
}

.step-stats-caption {
  color: var(--ink-dim);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5em;
  max-width: 36rem;
}

.stat-filter {
  display: flex;
  align-items: center;
  gap: 0.6em;
  max-width: 36rem;
  margin-bottom: 0.7em;
}

.stat-filter label {
  color: var(--ink-dim);
  font-size: 0.78rem;
}

.stat-filter select {
  background: var(--bg-panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.step-stats {
  max-width: 36rem;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.2rem;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.stat-row.cols-2 { grid-template-columns: repeat(2, 1fr); }

.step-stats .s { text-align: left; }

.step-stats .s .num {
  font-size: 1.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.step-stats .s.roadless .num { color: var(--roadless); }
.step-stats .s.near .num { color: var(--near-dot); }
.step-stats .s.ratio .num { color: var(--ink); }
.step-stats .s.mog .num { color: var(--mog); }
.step-stats .s.mogpct .num { color: var(--mog); }
.step-stats .s.alt3lost .num { color: var(--alt3-lost); }
.step-stats .s.alt3pct .num { color: var(--alt3-lost); }

.step-stats .s .label {
  color: var(--ink-dim);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.15em;
}

.stat-footnote {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
  color: var(--ink-dim);
  font-size: 0.75rem;
}

.legend {
  position: absolute;
  bottom: 14px;
  left: 14px;
  z-index: 500;
  background: rgba(20, 28, 23, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  font-size: 0.75rem;
  color: var(--ink-dim);
  backdrop-filter: blur(4px);
  max-width: 240px;
}

.legend .title {
  color: var(--ink);
  font-weight: 600;
  margin-bottom: 0.4em;
  font-size: 0.78rem;
}

.legend .ramp {
  height: 10px;
  border-radius: 4px;
  background: linear-gradient(90deg, #274a34, #6d9a3f, #c98a2b, #d9622b);
  margin-bottom: 0.3em;
}

.legend .ramp-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
}

.legend .dot-row {
  display: flex;
  align-items: center;
  gap: 0.4em;
  margin-bottom: 0.25em;
}

.legend .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.legend .dot.sq { border-radius: 2px; }

.mode-toggle {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 500;
  background: rgba(20, 28, 23, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  display: flex;
  gap: 2px;
}

.mode-toggle button {
  background: transparent;
  border: none;
  color: var(--ink-dim);
  font-size: 0.75rem;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}

.mode-toggle button.active {
  background: var(--near-soft);
  color: var(--near);
}

.toggle-tip {
  position: absolute;
  top: 58px;
  right: 14px;
  z-index: 500;
  max-width: 210px;
  background: var(--accent);
  color: #0e1410;
  font-size: 0.8rem;
  line-height: 1.4;
  font-weight: 600;
  padding: 0.7rem 1.6rem 0.7rem 0.9rem;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  animation: tip-in 0.3s ease-out;
}

.toggle-tip::before {
  content: "";
  position: absolute;
  top: -7px;
  right: 24px;
  width: 12px;
  height: 12px;
  background: var(--accent);
  transform: rotate(45deg);
}

.toggle-tip.hidden { display: none; }

.toggle-tip-close {
  position: absolute;
  top: 4px;
  right: 6px;
  background: transparent;
  border: none;
  color: #0e1410;
  opacity: 0.6;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.toggle-tip-close:hover { opacity: 1; }

@keyframes tip-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.leaflet-popup-content-wrapper {
  background: var(--bg-panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.leaflet-popup-tip { background: var(--bg-panel); }

.popup h3 { margin: 0 0 0.3em 0; font-size: 0.95rem; }

.popup .sub {
  color: var(--ink-dim);
  font-size: 0.75rem;
  margin-bottom: 0.6em;
}

.popup table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.popup td { padding: 2px 0; }

.popup td.section {
  padding: 0.6em 0 0.2em 0;
  color: var(--ink-dim);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-top: 1px solid var(--line);
}

.popup tr:first-child td.section { border-top: none; padding-top: 0; }

/* Fixed-width columns so a long label (e.g. "Estimated mature & old-growth") wraps
   onto its own line instead of crowding the value column -- without this, the table's
   default column sizing shrinks the value column to fit whatever the longest label in
   the table needs, which is what caused values to run up against their labels. */
.popup td:first-child:not(.section) { width: 62%; padding-right: 0.6em; }

.popup td.v {
  width: 38%;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.popup td.v .subvalue {
  display: block;
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--ink-dim);
  margin-top: 1px;
}

footer {
  text-align: center;
  color: var(--ink-dim);
  font-size: 0.8rem;
  padding: 3rem 5vw 4rem;
  border-top: 1px solid var(--line);
}

footer a { color: var(--ink-dim); }

@media (max-width: 820px) {
  .story { grid-template-columns: 1fr; }
  .story .map-col {
    position: relative;
    height: 60vh;
    order: -1;
    top: 0;
  }
  .step { min-height: auto; padding: 4vh 0; }
}

/* .mode-toggle above (top-right, button-based) is reused as the MOG / Fires switch. */

.stat-section {
  margin-top: 0.7em;
  padding-top: 0.6em;
  border-top: 1px solid var(--line);
}

.stat-section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.stat-section-title {
  color: var(--ink-dim);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4em;
}

.state-label {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 6px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.cursor-coords {
  position: absolute;
  bottom: 14px;
  right: 14px;
  z-index: 500;
  background: rgba(20, 28, 23, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
  font-size: 0.72rem;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(4px);
}

.jump-nav {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 3000;
}

.jump-nav-toggle {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #0e1410;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(79, 174, 106, 0.35);
}

.jump-nav-toggle:hover { filter: brightness(1.1); }

.jump-nav.open .jump-nav-toggle {
  background: rgba(20, 28, 23, 0.92);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: none;
}

.jump-nav-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 170px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  flex-direction: column;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.jump-nav.open .jump-nav-menu { display: flex; }

.jump-nav-menu a {
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 0.82rem;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
}

.jump-nav-menu a:hover {
  background: var(--accent-soft);
  color: var(--ink);
}
