@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,300;9..144,400;9..144,500;9..144,700&family=JetBrains+Mono:wght@300;400;500&family=Inter+Tight:ital,wght@0,300;0,400;0,500;0,600;1,400&display=swap');

:root {
  --bg: #f4f6f8;
  --bg-2: #ffffff;
  --ink: #1a2228;
  --ink-dim: #5c6a73;
  --ink-faint: #8b969e;
  --accent: #0683AE;
  --accent-bright: #0578a0;
  --accent-soft: rgba(6, 131, 174, 0.12);
  --line: #dfe4e8;
  --warn: #b8860b;
  --ok: #2a9a6a;
  --gap: #b54545;
  --glass: rgba(255, 255, 255, 0.78);
  --fade: rgba(244, 246, 248, 0.94);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter Tight', sans-serif;
  -webkit-font-smoothing: antialiased;
}
html { scroll-behavior: auto; }
body { line-height: 1.5; overflow-x: hidden; }
a { color: inherit; }

#map {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #e8eef2;
}
.leaflet-container { font-family: 'Inter Tight', sans-serif; background: #e8eef2; }
.leaflet-tile-pane { filter: contrast(0.96) brightness(1.06); }
.leaflet-control-attribution {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: .04em;
  background: rgba(255,255,255,.78) !important;
  color: var(--ink-faint);
  margin: 0 12px 96px 0 !important;
}
.leaflet-control-zoom {
  border: 1px solid var(--line) !important;
  box-shadow: none !important;
  margin-bottom: 110px !important;
  margin-right: 18px !important;
}
.leaflet-control-zoom a {
  background: var(--bg-2) !important;
  color: var(--ink) !important;
  width: 32px; height: 32px; line-height: 32px;
  border-bottom: 1px solid var(--line) !important;
}

.stage-fade {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: min(62vw, 860px);
  z-index: 4;
  pointer-events: none;
  background: linear-gradient(
    to right,
    rgba(244, 246, 248, 0.97) 0%,
    rgba(244, 246, 248, 0.92) 22%,
    rgba(244, 246, 248, 0.72) 42%,
    rgba(244, 246, 248, 0.42) 58%,
    rgba(244, 246, 248, 0.18) 72%,
    rgba(244, 246, 248, 0.06) 86%,
    transparent 100%
  );
  mask-image: linear-gradient(
    to right,
    #000 0%,
    #000 28%,
    rgba(0, 0, 0, 0.82) 48%,
    rgba(0, 0, 0, 0.45) 68%,
    rgba(0, 0, 0, 0.12) 86%,
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(
    to right,
    #000 0%,
    #000 28%,
    rgba(0, 0, 0, 0.82) 48%,
    rgba(0, 0, 0, 0.45) 68%,
    rgba(0, 0, 0, 0.12) 86%,
    transparent 100%
  );
}
.grain {
  position: fixed; inset: 0; z-index: 3; pointer-events: none; opacity: .035;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.9'/></svg>");
}

nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  padding: 20px 36px;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
}
nav::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: min(280px, 48vh);
  z-index: -1;
  pointer-events: none;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  background: linear-gradient(
    to bottom,
    rgba(244, 246, 248, 0.88) 0%,
    rgba(244, 246, 248, 0.55) 28%,
    rgba(244, 246, 248, 0.22) 55%,
    rgba(244, 246, 248, 0.06) 78%,
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    #000 0%,
    #000 18%,
    rgba(0, 0, 0, 0.88) 36%,
    rgba(0, 0, 0, 0.52) 58%,
    rgba(0, 0, 0, 0.18) 78%,
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(
    to bottom,
    #000 0%,
    #000 18%,
    rgba(0, 0, 0, 0.88) 36%,
    rgba(0, 0, 0, 0.52) 58%,
    rgba(0, 0, 0, 0.18) 78%,
    transparent 100%
  );
}
.brand {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--ink); text-decoration: none;
  display: flex; align-items: center; gap: 12px;
}
.brand i {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  display: block;
}
.nav-end { display: flex; align-items: center; gap: 10px; }
.nav-proc {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-dim);
  margin-right: 8px;
}
.icon-btn, .btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 999px;
  cursor: pointer; padding: 9px 14px;
  text-decoration: none; display: inline-flex; align-items: center;
}
.icon-btn:hover, .btn-ghost:hover { border-color: var(--accent); color: var(--accent-bright); background: var(--accent-soft); }
.btn-primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-bright); color: #fff; }
.btn.static { cursor: default; }

.hud {
  position: fixed; top: 88px; right: 36px; z-index: 20;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; color: var(--ink-dim); text-align: right; line-height: 1.75;
  pointer-events: none;
}
.hud .blink {
  display: inline-block; width: 7px; height: 7px; background: var(--accent);
  border-radius: 50%; margin-right: 6px; vertical-align: middle;
  box-shadow: 0 0 0 4px var(--accent-soft);
  animation: blink 1.6s infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.28} }
.hud-year {
  font-family: 'Fraunces', serif; font-weight: 300;
  font-size: clamp(40px, 5.4vw, 76px);
  line-height: .9; letter-spacing: -.04em; color: var(--ink);
  margin: 8px 0 4px;
}
.hud-place { color: var(--accent); letter-spacing: .14em; text-transform: uppercase; }
.hud-impacts { margin-top: 16px; }
.hud-impacts div {
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-dim); margin-top: 6px;
}
.hud-impacts em {
  display: block; font-style: normal; color: var(--ink-faint);
  letter-spacing: .08em; font-size: 9px;
}
.hud-impacts .live { color: var(--accent); }
.hud-impacts .gap { color: var(--gap); }

.legend {
  position: fixed; top: 88px; right: 36px; z-index: 19;
  margin-top: 220px;
  display: flex; flex-direction: column; gap: 6px;
  pointer-events: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-dim); text-align: right;
}
.legend span { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.legend i {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
  box-shadow: 0 0 0 3px rgba(255,255,255,.9);
}

.filters {
  position: fixed; right: 36px; bottom: 118px; z-index: 21;
  left: auto; top: auto;
  display: flex; flex-wrap: wrap; gap: 6px;
  justify-content: flex-end;
  max-width: 42vw;
}
.filters button {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  background: var(--glass); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 12px; cursor: pointer; color: var(--ink-dim);
  backdrop-filter: blur(10px);
}
.filters button.on, .filters button:hover {
  color: var(--accent-bright); border-color: var(--accent); background: #fff;
}

.stage { position: relative; z-index: 10; pointer-events: none; }
.hero, .chapter, .finale { pointer-events: none; }
.hero a, .chapter a, .finale a, .finale .btn { pointer-events: auto; }

.hero {
  min-height: 100vh;
  padding: 150px 40px 180px;
  display: flex; flex-direction: column; justify-content: flex-end;
  max-width: 720px;
}
.eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; letter-spacing: .18em; color: var(--accent);
  text-transform: uppercase; margin-bottom: 26px;
  display: flex; align-items: center; gap: 14px;
}
.eyebrow::before { content: ""; width: 32px; height: 1px; background: var(--accent); }
.hero h1, .chapter h2, .finale h2 {
  font-family: 'Fraunces', serif; font-weight: 300;
  line-height: 1.02; letter-spacing: -.03em;
}
.hero h1 {
  font-size: clamp(40px, 6.4vw, 78px);
  max-width: 16ch;
}
.hero h1 em, .chapter h2 em, .finale h2 em {
  font-style: italic; color: var(--accent); font-weight: 400;
  font-variation-settings: "opsz" 144;
}
.hero-lead, .lead { margin-top: 22px; font-size: 17px; color: var(--ink); max-width: 48ch; line-height: 1.65; }
.body { font-size: 15px; color: var(--ink-dim); line-height: 1.7; max-width: 50ch; margin-top: 14px; }
.hero-meta {
  display: flex; gap: 36px; margin-top: 48px; padding-top: 24px;
  border-top: 1px solid var(--line); flex-wrap: wrap;
}
.hero-meta-item {
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  color: var(--ink-dim); text-transform: uppercase; letter-spacing: .12em;
}
.hero-meta-item strong {
  display: block; color: var(--ink); font-size: 14px;
  font-family: 'Inter Tight', sans-serif; text-transform: none; letter-spacing: 0;
  font-weight: 500; margin-top: 6px;
}
.scroll-hint {
  margin-top: 40px;
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  letter-spacing: .16em; text-transform: uppercase; color: var(--ink-faint);
}

.chapter, .finale {
  min-height: 100vh;
  padding: 120px 40px 200px;
  max-width: 720px;
  display: flex; flex-direction: column; justify-content: center;
  scroll-margin-top: 80px;
}
.kicker {
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  letter-spacing: .18em; text-transform: uppercase; color: var(--ink-dim);
  margin-bottom: 20px; display: flex; align-items: center; gap: 14px;
}
.kicker::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}
.kicker span { color: var(--accent); }
.chapter h2, .finale h2 {
  font-size: clamp(30px, 4.2vw, 52px);
  margin-bottom: 8px;
}
.stats { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 32px; }
.stat-num {
  font-family: 'Fraunces', serif; font-weight: 300; font-size: 38px;
  letter-spacing: -.04em; color: var(--accent); line-height: 1;
}
.stat-label {
  font-family: 'JetBrains Mono', monospace; font-size: 10px;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-dim); margin-top: 8px;
}

.finale-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }
.disclaimer {
  margin-top: 36px; max-width: 52ch;
  font-size: 12px; color: var(--ink-faint); line-height: 1.6;
}

.rail {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 22px 36px 18px;
  background: linear-gradient(
    to top,
    rgba(244, 246, 248, 0.97) 0%,
    rgba(244, 246, 248, 0.82) 38%,
    rgba(244, 246, 248, 0.35) 68%,
    rgba(244, 246, 248, 0.08) 86%,
    transparent 100%
  );
  pointer-events: none;
}
.rail-inner { pointer-events: auto; max-width: 1400px; margin: 0 auto; }
.rail-meta {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-dim);
  margin-bottom: 10px; gap: 12px; flex-wrap: wrap;
}
.rail-meta strong { color: var(--ink); font-weight: 400; }
.slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 2px; background: var(--line); outline: none; cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff;
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff;
}
.ticks {
  display: flex; justify-content: space-between; margin-top: 8px;
  font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--ink-faint);
  letter-spacing: .06em;
}
.ticks button {
  background: none; border: none; color: inherit; cursor: pointer; font: inherit;
  padding: 4px 0; transition: color .2s;
}
.ticks button.on, .ticks button:hover { color: var(--accent); }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 60;
  width: min(420px, 100vw);
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(18px);
  border-left: 1px solid var(--line);
  padding: 24px 24px 40px;
  overflow: auto;
}
.drawer[hidden] { display: none; }
.drawer header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  margin-bottom: 20px;
}
.drawer-kicker {
  font-family: 'JetBrains Mono', monospace; font-size: 10px;
  letter-spacing: .16em; text-transform: uppercase; color: var(--accent);
  margin-bottom: 6px;
}
.drawer h3 {
  font-family: 'Fraunces', serif; font-weight: 400; font-size: 26px;
  letter-spacing: -.02em; line-height: 1.15;
}
.drawer-body { font-size: 14px; color: var(--ink-dim); }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; margin: 18px 0; }
.kv dt {
  font-family: 'JetBrains Mono', monospace; font-size: 10px;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); padding-top: 2px;
}
.kv dd { color: var(--ink); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: .08em;
  text-transform: uppercase; border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 10px; color: var(--ink-dim);
}
.chip.gap { color: var(--gap); border-color: #e8c4c4; }
.chip.pilot { color: var(--accent); border-color: #b7d7e4; }
.chip.ok { color: var(--ok); border-color: #c5e4d4; }

.mk {
  background: transparent; border: 0;
}
.mk-dot {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(26,34,40,.12);
}
.mk-hub {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #fff;
  box-shadow: 0 0 0 6px var(--accent-soft), 0 0 0 1px rgba(6,131,174,.25);
  position: relative;
}
.mk-hub::after {
  content: "";
  position: absolute; inset: -14px;
  border-radius: 50%;
  border: 1px solid rgba(6,131,174,.35);
  animation: ring 2.8s ease-out infinite;
}
.mk.is-dim { opacity: .22; }
.mk.is-gap .mk-dot {
  background: var(--gap) !important;
  box-shadow: 0 0 0 4px rgba(181,69,69,.16);
}
.mk.is-pilot .mk-dot, .mk.is-pilot .mk-hub {
  box-shadow: 0 0 0 6px rgba(6,131,174,.2);
}
.mk-label {
  position: absolute; left: 10px; top: -7px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink); white-space: nowrap;
  background: rgba(255,255,255,.88);
  padding: 2px 6px; border-radius: 3px;
  pointer-events: none;
}
.leaflet-tooltip.mk-tip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  background: #fff; color: var(--ink); border: 1px solid var(--line);
  border-radius: 4px; box-shadow: none; padding: 4px 8px;
}
.leaflet-tooltip.mk-tip::before { border-top-color: #fff; }
.leaflet-marker-icon.mk { background: none !important; border: none !important; overflow: visible !important; }

@keyframes ring {
  0% { transform: scale(.6); opacity: .7; }
  100% { transform: scale(1.35); opacity: 0; }
}

.flow-canvas {
  position: absolute; left: 0; top: 0;
  pointer-events: none;
}

@media (max-width: 900px) {
  .stage-fade {
    width: 100%;
    background: linear-gradient(
      to bottom,
      rgba(244, 246, 248, 0.94) 0%,
      rgba(244, 246, 248, 0.7) 28%,
      rgba(244, 246, 248, 0.32) 55%,
      rgba(244, 246, 248, 0.08) 78%,
      transparent 100%
    );
    mask-image: linear-gradient(
      to bottom,
      #000 0%,
      #000 22%,
      rgba(0, 0, 0, 0.7) 52%,
      rgba(0, 0, 0, 0.2) 78%,
      transparent 100%
    );
    -webkit-mask-image: linear-gradient(
      to bottom,
      #000 0%,
      #000 22%,
      rgba(0, 0, 0, 0.7) 52%,
      rgba(0, 0, 0, 0.2) 78%,
      transparent 100%
    );
  }
  .hero, .chapter, .finale { max-width: 100%; padding-left: 22px; padding-right: 22px; }
  .hud { top: auto; bottom: 118px; right: 16px; }
  .hud-year { font-size: 36px; }
  .legend { display: none; }
  .filters { left: 16px; top: auto; bottom: 118px; }
  nav { padding: 14px 16px; }
  .nav-proc { display: none; }
  .rail { padding: 12px 16px 14px; }
  .leaflet-control-zoom { display: none; }
}
