: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;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; color: var(--ink); background: #d8dfd9; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
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(31vw, 34rem); min-height: 28vh; margin: 0 3vw 58vh; 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: Georgia, "Times New Roman", serif; font-size: clamp(1.65rem, 3vw, 2.7rem); line-height: 1.08; text-wrap: balance; }
.chapter p { margin: .75rem 0; font-size: 1rem; line-height: 1.62; }
.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; }
.chart { margin: 1.2rem 0; }
.chart h3, .species h3 { margin: 0 0 .75rem; color: var(--navy); font-size: 1rem; }
.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; }
.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(20rem, calc(100vw - 2rem)); padding: .7rem .85rem; 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-swatch { flex: 0 0 auto; width: .75rem; height: .75rem; border-radius: 50%; border: 2px solid currentColor; background: currentColor; }
.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: 64vh; 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; }
  .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; }
}
