@font-face {
  font-family: "Red Hat Display";
  src: url("fonts/RedHatDisplay-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Red Hat Display";
  src: url("fonts/RedHatDisplay-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #14231d;
  --muted: #52635a;
  --green: #186a4b;
  --navy: #163349;
  --accent: #d5a72b;
  --card: rgba(252, 252, 248, 0.94);
  --border: rgba(20, 35, 29, 0.16);
  --shadow: 0 20px 55px rgba(12, 30, 23, 0.24);
  --content: 42rem;
  --font: "Red Hat Display", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; color: var(--ink); background: #d8dfd9; font-family: var(--font); }
body { overflow-x: hidden; }
a { color: var(--green); text-underline-offset: 0.18em; }
a:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.skip-link { position: fixed; z-index: 20; left: 1rem; top: -5rem; padding: .7rem 1rem; background: white; border-radius: .4rem; }
.skip-link:focus { top: 1rem; }
#map, #map-shade { position: fixed; inset: 0; }
#map { z-index: 0; background: #d8dfd9; }
#map-shade { z-index: 1; pointer-events: none; background: linear-gradient(90deg, rgba(9, 24, 18, .12), transparent 48%, rgba(9, 24, 18, .08)); }
.story { position: relative; z-index: 2; width: 100%; padding: 32vh 0 40vh; }
.chapter { width: min(35vw, 37rem); min-height: 0; margin: 0 3vw 48vh; padding: clamp(1.2rem, 2vw, 1.8rem); border: 1px solid var(--border); border-radius: 1rem; background: var(--card); box-shadow: var(--shadow); backdrop-filter: blur(9px); opacity: .62; transform: translateY(10px); transition: opacity 220ms ease, transform 220ms ease; }
.chapter.is-active { opacity: 1; transform: none; }
.chapter.align-right { margin-left: auto; margin-right: 3vw; }
.chapter.align-center, .chapter.align-full { width: min(31vw, 34rem); margin-left: 3vw; margin-right: auto; }
.chapter-kicker { margin: 0 0 .65rem; color: var(--green); font-size: .75rem; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
.chapter h1, .chapter h2 { margin: 0 0 1rem; color: var(--navy); font-family: var(--font); font-size: clamp(1.65rem, 3vw, 2.7rem); font-weight: 700; line-height: 1.08; text-wrap: balance; }
.chapter p { margin: .75rem 0; font-size: 1rem; line-height: 1.62; }
.chapter-points { display: grid; gap: .7rem; margin: 1.1rem 0 1.25rem; padding: 0; list-style: none; }
.chapter-points li { position: relative; padding-left: 1.35rem; font-size: 1.03rem; line-height: 1.48; }
.chapter-points li::before { content: ""; position: absolute; left: 0; top: .55em; width: .55rem; height: .55rem; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(24,106,75,.11); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: .65rem; margin: 1.25rem 0; }
.stat { min-width: 0; padding: .8rem; border: 1px solid var(--border); border-radius: .7rem; background: rgba(255,255,255,.7); }
.stat.callout { border-color: rgba(213,167,43,.55); background: #fff9df; }
.stat-label { display: block; color: var(--muted); font-size: .72rem; line-height: 1.25; text-transform: uppercase; letter-spacing: .045em; }
.stat-value { display: block; margin-top: .35rem; color: var(--navy); font-size: 1.08rem; font-weight: 750; overflow-wrap: anywhere; }
.stat-detail { display: block; margin-top: .35rem; color: var(--muted); font-size: .78rem; line-height: 1.35; }
.method-note { margin: .85rem 0 0; color: var(--muted); font-size: .8rem; line-height: 1.45; }
.chart { margin: 1.2rem 0; }
.chart h3, .species h3 { margin: 0 0 .75rem; color: var(--navy); font-size: 1rem; }
.species-note { margin: -.35rem 0 .75rem; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.bar-row { display: grid; grid-template-columns: minmax(7.5rem, 1fr) 2fr auto; align-items: center; gap: .55rem; margin: .5rem 0; font-size: .82rem; }
.bar-track { height: .66rem; overflow: hidden; border-radius: 1rem; background: rgba(20,35,29,.1); }
.bar-fill { display: block; height: 100%; min-width: 2px; border-radius: inherit; background: var(--green); }
.bar-value { color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-note { margin: .7rem 0 0; color: var(--muted); font-size: .76rem; line-height: 1.45; }
.media { margin: 1.2rem 0; }
.media img { display: block; width: 100%; max-height: 24rem; object-fit: contain; border-radius: .65rem; background: #f2f3ef; }
.media figcaption { margin-top: .45rem; color: var(--muted); font-size: .78rem; line-height: 1.4; }
.species { margin: 1.2rem 0; overflow-x: auto; }
.species table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.species th, .species td { padding: .5rem .35rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.species th { color: var(--muted); font-size: .7rem; letter-spacing: .04em; text-transform: uppercase; }
.legend { position: fixed; z-index: 4; right: 1rem; bottom: 1rem; max-width: min(16rem, calc(100vw - 2rem)); max-height: min(42vh, 22rem); overflow-y: auto; padding: .65rem .8rem; border: 1px solid var(--border); border-radius: .55rem; background: rgba(252,252,248,.92); box-shadow: 0 8px 24px rgba(12,30,23,.14); font-size: .76rem; }
.legend.dock-left { left: 1rem; right: auto; }
.legend-row { display: flex; gap: .55rem; align-items: center; margin: .28rem 0; }
.legend.is-dense .legend-row { margin: .16rem 0; }
.legend-swatch { flex: 0 0 auto; width: .75rem; height: .75rem; border-radius: 50%; border: 2px solid currentColor; background: currentColor; }
.legend-swatch-gradient { width: 2.6rem; height: .7rem; border-radius: .25rem; border: 1px solid rgba(18, 33, 27, .28); background: #ccc; }
.legend-swatch.is-square { border-radius: .18rem; border-width: 1px; }
.scenario-toggle { position: fixed; z-index: 6; left: 1rem; top: 1rem; display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; padding: .4rem .45rem; border-radius: .6rem; background: rgba(13,42,66,.62); box-shadow: 0 8px 24px rgba(12,30,23,.22); backdrop-filter: blur(3px); }
.scenario-toggle[hidden] { display: none; }
.scenario-toggle-title { color: #fff; font-size: .62rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; opacity: .85; padding: 0 .2rem; }
.scenario-btn { border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.10); color: #fff; border-radius: .4rem; padding: .32rem .6rem; font: inherit; font-size: .74rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.scenario-btn:hover { background: rgba(255,255,255,.22); }
.scenario-btn.is-active { background: #fff; color: #0d2a42; border-color: #fff; }
.status-panel, .diagnostics, .no-script { position: fixed; z-index: 10; left: 50%; top: 1rem; width: min(36rem, calc(100vw - 2rem)); transform: translateX(-50%); padding: .9rem 1rem; border: 1px solid var(--border); border-radius: .65rem; background: rgba(252,252,248,.96); box-shadow: var(--shadow); }
.status-panel span { display: block; margin-top: .2rem; color: var(--muted); font-size: .85rem; }
.status-panel[hidden] { display: none; }
.diagnostics { top: auto; bottom: 1rem; border-left: 5px solid var(--accent); font-size: .83rem; }
.diagnostics.is-fatal { border-left-color: #a33131; }
.diagnostics strong, .diagnostics span { display: block; }
.diagnostics span { margin-top: .25rem; color: var(--muted); }
.maplibregl-ctrl-attrib { font-size: 10px; }

@media (max-width: 760px) {
  #map-shade { background: linear-gradient(0deg, rgba(9,24,18,.12), transparent 55%); }
  .story { padding-top: 42vh; }
  .chapter, .chapter.align-right, .chapter.align-center, .chapter.align-full { width: 90vw; margin-left: auto; margin-right: auto; margin-bottom: 54vh; padding: 1.15rem; }
  .chapter h1, .chapter h2 { font-size: clamp(1.5rem, 7vw, 2.2rem); }
  .legend, .legend.dock-left { left: .5rem; right: .5rem; bottom: .5rem; max-width: none; max-height: 32vh; }
  .bar-row { grid-template-columns: minmax(6rem, 1fr) 1.4fr auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
