:root {
  color-scheme: light;
  --page: #f4efe6;
  --surface: #fbf8f2;
  --ink: #16130e;
  --ink-2: #4f4a40;
  --muted: #6b6559;
  --accent-text: #b4461c;
  --hair: #e2dccf;
  --land: #e6e0d3;
  --edge: rgba(22, 19, 14, 0.28);
  --coast: rgba(22, 19, 14, 0.45);
  --accent: #eb6834;
  --blue: #2a78d6;
  --focus: #16130e;
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #12110f;
    --surface: #1a1a19;
    --ink: #f5f2ea;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --hair: #2c2c2a;
    --land: #2a2926;
    --edge: rgba(245, 242, 234, 0.25);
    --coast: rgba(245, 242, 234, 0.4);
    --accent: #d95926;
    --accent-text: #ee8558;
    --blue: #3987e5;
    --focus: #f5f2ea;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #12110f;
  --surface: #1a1a19;
  --ink: #f5f2ea;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --hair: #2c2c2a;
  --land: #2a2926;
  --edge: rgba(245, 242, 234, 0.25);
  --coast: rgba(245, 242, 234, 0.4);
  --accent: #d95926;
  --accent-text: #ee8558;
  --blue: #3987e5;
  --focus: #f5f2ea;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 17px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; }
.muted { color: var(--muted); }

.masthead {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; gap: 16px;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hair);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  max-width: 1440px;
  margin: 0 auto;
}
.stage { position: relative; }
.map-wrap {
  position: sticky; top: 49px;
  height: calc(100vh - 49px); height: calc(100dvh - 49px);
  margin: 0;
  padding: 24px;
}
#map { width: 100%; height: 100%; display: block; touch-action: pan-y; }

.legend {
  position: absolute; left: 32px; bottom: 32px;
  font: 500 12px/1.3 var(--mono);
  color: var(--ink-2);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--hair);
  border-radius: 8px;
  padding: 10px 12px;
  max-width: calc(100% - 64px);
}
.legend .title { color: var(--ink); margin-bottom: 6px; letter-spacing: 0.04em; }
.legend .ramp { display: flex; height: 10px; width: 220px; max-width: 100%; border-radius: 3px; overflow: hidden; }
.legend .ramp span { flex: 1; }
.legend .ticks { display: flex; justify-content: space-between; width: 220px; max-width: 100%; margin-top: 4px; font-variant-numeric: tabular-nums; }
.legend .keys { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend .dot { border-radius: 50%; }

.tip {
  position: absolute; pointer-events: none; z-index: 4;
  min-width: 180px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--hair);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
  padding: 10px 12px;
  font-size: 13px; line-height: 1.4;
}
.tip[hidden] { display: none; }
.tip .t-name { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.tip .t-row { display: flex; justify-content: space-between; gap: 16px; }
.tip .t-row b { font-weight: 600; font-variant-numeric: tabular-nums; }
.tip .t-row span { color: var(--ink-2); }

.story { padding: 0 32px 30vh 16px; }
.step {
  min-height: 92vh;
  display: flex; flex-direction: column; justify-content: center;
  max-width: 520px;
  opacity: 0.35;
  transition: opacity 400ms ease;
}
.step.active { opacity: 1; }
.step.towns, .step.method { min-height: auto; padding: 18vh 0 8vh; max-width: 600px; }
.kicker { color: var(--accent-text); margin: 0 0 12px; }
h1, h2 { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; margin: 0 0 16px; }
h1 { font-size: clamp(44px, 6vw, 76px); line-height: 0.98; }
h1 em { color: var(--accent-text); }
h2 { font-size: clamp(32px, 3.6vw, 48px); line-height: 1.05; }
h2 .big { font-family: var(--sans); font-weight: 600; letter-spacing: -0.02em; }
.lede { font-size: 19px; color: var(--ink-2); }
.hint { color: var(--muted); margin-top: 24px; }
p { margin: 0 0 14px; }
p strong { font-weight: 600; }
.note { font-size: 14px; color: var(--muted); margin-top: 16px; }

.table-wrap { overflow-x: auto; border-top: 1px solid var(--ink); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--hair); white-space: nowrap; }
th { font-weight: 600; cursor: pointer; user-select: none; vertical-align: bottom; }
th .sub { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
th[aria-sort] { color: var(--accent-text); }
th:focus-visible, tr:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num { position: relative; }
td .bar { position: absolute; right: 6px; bottom: 3px; height: 2px; border-radius: 1px; background: var(--blue); opacity: 0.55; }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr.hl { background: color-mix(in srgb, var(--accent) 10%, transparent); }

.method ul { list-style: none; padding: 0; margin: 0 0 8px; }
.method li { padding: 10px 0; border-bottom: 1px solid var(--hair); }
.method li .mono { display: block; color: var(--muted); }

@media (max-width: 860px) {
  html { scroll-padding-top: calc(48vh + 56px); scroll-padding-top: calc(48dvh + 56px); }
  body { font-size: 16px; }
  .masthead { padding: 12px 16px; }
  .layout { display: block; }
  .stage { position: sticky; top: 45px; z-index: 2; height: 48vh; height: 48dvh; background: var(--page); border-bottom: 1px solid var(--hair); }
  .map-wrap { position: relative; top: 0; height: 100%; padding: 8px 8px 0; }
  .legend { left: 12px; bottom: 8px; padding: 6px 8px; font-size: 11px; }
  .legend .ramp, .legend .ticks { width: 160px; }
  .story { padding: 0 16px 20vh; }
  .step { min-height: 70vh; max-width: none; }
  .step.hero { min-height: 60vh; }
  .step.towns, .step.method { padding: 8vh 0 4vh; }
  table { font-size: 13px; }
  th, td { padding: 7px 3px; }
  td { height: 44px; }
  td:first-child { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
}
@media (prefers-reduced-motion: reduce) {
  .step { transition: none; }
}

.jump { display: inline-block; margin-top: 20px; color: var(--ink); font: 500 13px/1 var(--mono); letter-spacing: 0.06em; text-decoration: none; border-bottom: 1px solid var(--accent-text); padding-bottom: 4px; }
.jump:hover { color: var(--accent-text); }
a:focus-visible, input:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.search { display: block; width: 100%; margin: 4px 0 12px; padding: 10px 12px; font: 400 15px/1.2 var(--sans); color: var(--ink); background: var(--surface); border: 1px solid var(--hair); border-radius: 8px; }
.search::placeholder { color: var(--muted); }
.empty td { color: var(--muted); white-space: normal; }
.status { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--ink-2); font-size: 15px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
