/* maps.cwandt.com
   Built on the CW&T design system (see tokens.css).

   Rules being honoured, from the system's SKILL.md:
     1. The ID label is the mark — no wordmark logo.
     2. Ink on paper; colour reserved for signal.
     3. Space Mono everywhere.
     4. Hairline rules instead of cards — no shadows, no radius, no gradients.
     5. Honest specs — coordinates and counts stated plainly.
*/

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: flex;
  font-size: var(--fs-14);
  overflow: hidden;
}

/* ───────────────────────── panel ───────────────────────── */

.panel {
  position: relative;
  z-index: 500;
  flex: 0 0 var(--panel-w);
  width: var(--panel-w);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-right: var(--bw-hair) solid var(--ink);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}
.panel::-webkit-scrollbar { width: 9px; }
.panel::-webkit-scrollbar-thumb { background: var(--rule); border: 3px solid var(--paper); }

.masthead {
  padding: var(--sp-5) var(--sp-5) var(--sp-6);
  border-bottom: var(--bw-hair) solid var(--ink);
}

.masthead__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}

/* Colour scheme — a two-segment switch, stated rather than implied. */
.theme { display: flex; flex: none; }
.theme__opt {
  padding: 3px 7px;
  border: var(--bw-hair) solid var(--rule);
  background: var(--paper);
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  border-radius: 0;
  cursor: pointer;
  transition: opacity var(--dur) var(--ease);
}
.theme__opt + .theme__opt { margin-left: -1px; }
.theme__opt:hover { opacity: 0.55; }
.theme__opt:focus-visible { outline: 2px solid var(--signal-orange); outline-offset: 1px; z-index: 1; }
.theme__opt[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
  z-index: 1;
}

/* Rule 1 — the ID label, set plainly, top-left. */
.idl { min-width: 0; }
.idl__code { font-size: var(--fs-12); }
.idl__expansion {
  font-size: 9px;
  line-height: var(--lh-snug);
  letter-spacing: 0;
  margin-top: 2px;
}

.masthead__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
}

.title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-48);
  font-weight: 700;
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
}
.ver {
  font-size: var(--fs-12);
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--ls-label);
}
.subtitle {
  margin: var(--sp-3) 0 0;
  max-width: 30ch;
  font-size: var(--fs-12);
  line-height: var(--lh-body);
  color: var(--fg-2);
}

/* ───────────────────────── blocks ───────────────────────── */

.block { border-bottom: var(--bw-hair) solid var(--ink); }
.block__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-5) var(--sp-2);
}
.lbl {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  font-weight: 700;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--fg-1);
}
.lbl--dim {
  font-weight: 400;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}

/* ── list toggles ── */

.lists { padding: 0 var(--sp-5) var(--sp-4); display: grid; gap: -1px; }
.lists > * + * { margin-top: -1px; }

.list-btn {
  --sw: var(--signal-orange);
  position: relative;
  display: grid;
  grid-template-columns: 13px 1fr auto;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-3) var(--sp-3);
  background: var(--paper);
  border: var(--bw-hair) solid var(--rule);
  color: var(--fg-1);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: opacity var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.list-btn:hover { opacity: 0.55; }
.list-btn[aria-pressed="true"] { border-color: var(--ink); z-index: 1; }
.list-btn:focus-visible { outline: 2px solid var(--signal-orange); outline-offset: 1px; }

.list-btn__box {
  width: 13px;
  height: 13px;
  border: var(--bw-hair) solid var(--ink-faint);
  background: transparent;
  position: relative;
}
.list-btn[aria-pressed="true"] .list-btn__box {
  border-color: var(--sw);
  background: var(--sw);
}
.list-btn[aria-pressed="true"] .list-btn__box::after {
  content: "";
  position: absolute;
  left: 4px; top: 0px;
  width: 4px; height: 8px;
  border: solid var(--paper);
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}

.list-btn__name {
  font-size: var(--fs-12);
  font-weight: 700;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  line-height: var(--lh-snug);
}
.list-btn__scope {
  display: block;
  font-size: 10px;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--fg-3);
  margin-top: 1px;
}
.list-btn__n {
  font-size: var(--fs-12);
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}
.list-btn[aria-pressed="true"] .list-btn__n { color: var(--fg-1); font-weight: 700; }
.list-btn.is-stale .list-btn__scope::after {
  content: " · cached";
  color: var(--signal-red);
}

/* ── actions ── */

.block--actions { padding-bottom: var(--sp-4); }
.actions { padding: 0 var(--sp-5); display: grid; }
.actions > * + * { margin-top: -1px; }

.act {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-3);
  border: var(--bw-hair) solid var(--ink);
  background: var(--paper);
  color: var(--fg-1);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: opacity var(--dur) var(--ease);
}
.act:hover { opacity: 0.55; }
.act:focus-visible { outline: 2px solid var(--signal-orange); outline-offset: 1px; }

.act__t {
  font-size: var(--fs-12);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.act__d {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: var(--fg-2);
  text-transform: none;
  letter-spacing: 0;
  margin-top: 3px;
  line-height: var(--lh-snug);
}
.act__k {
  font-size: var(--fs-16);
  line-height: 1;
  color: var(--fg-3);
}

.fineprint {
  margin: var(--sp-4) var(--sp-5) 0;
  font-size: 10px;
  line-height: var(--lh-body);
  color: var(--fg-3);
}
.fineprint em { font-style: italic; }

/* ── places ── */

.block--places {
  flex: 1 0 auto;
  border-bottom: none;
  display: flex;
  flex-direction: column;
}
.search-wrap { padding: 0 var(--sp-5) var(--sp-3); }
.search {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: var(--bw-hair) solid var(--rule);
  border-radius: 0;
  background: var(--paper-2);
  color: var(--fg-1);
  font: inherit;
  font-size: var(--fs-12);
}
.search::placeholder { color: var(--fg-3); }
.search:focus { outline: none; border-color: var(--ink); }

.places { list-style: none; margin: 0; padding: 0 0 var(--sp-12); }

.place {
  position: relative;
  display: grid;
  grid-template-columns: 2.9rem 1fr;
  border-top: var(--bw-hair) solid var(--rule);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.place:hover { background: var(--paper-2); }
.place.is-active { background: var(--paper-2); }
.place.is-active::before {
  content: "";
  position: absolute;
  left: 0; top: 0;
  width: 2px; height: 100%;
  background: var(--pin, var(--signal-orange));
}
.place__n {
  padding: var(--sp-3) 0 var(--sp-3) var(--sp-5);
  font-size: var(--fs-12);
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}
.place.is-active .place__n { color: var(--pin, var(--signal-orange)); font-weight: 700; }
.place__body { padding: var(--sp-3) var(--sp-5) var(--sp-4) 0; min-width: 0; }
.place__name {
  font-size: var(--fs-14);
  font-weight: 700;
  line-height: var(--lh-snug);
}
.place__note {
  margin-top: 3px;
  font-style: italic;
  font-size: var(--fs-12);
  line-height: var(--lh-body);
  color: var(--fg-2);
}
.place__meta {
  margin-top: var(--sp-2);
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  font-size: 10px;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--fg-3);
}
.place__tag { display: inline-flex; align-items: center; gap: var(--sp-1); }
.place__tag::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: var(--radius-pill);
  background: var(--pin, var(--signal-orange));
}
.place__go { margin-left: auto; color: var(--fg-2); }

.places__empty {
  padding: var(--sp-6) var(--sp-5);
  color: var(--fg-3);
  font-size: var(--fs-12);
}

.colophon {
  padding: var(--sp-4) var(--sp-5) var(--sp-6);
  border-top: var(--bw-hair) solid var(--ink);
  display: grid;
  gap: var(--sp-1);
}
.colophon__row {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  font-size: 10px;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}

/* ───────────────────────── stage / map ───────────────────────── */

.stage { position: relative; flex: 1 1 auto; height: 100%; min-width: 0; }
.map { position: absolute; inset: 0; background: var(--map-bg); }

.leaflet-tile-pane { filter: var(--tile-filter); }
.leaflet-container { background: var(--map-bg); font-family: var(--font-mono); }

.leaflet-control-attribution {
  background: var(--paper) !important;
  color: var(--fg-3) !important;
  font-family: var(--font-mono) !important;
  font-size: 10px !important;
  border-top: var(--bw-hair) solid var(--rule);
  border-left: var(--bw-hair) solid var(--rule);
}
.leaflet-control-attribution a { color: var(--fg-2) !important; }

.leaflet-control-zoom { border: none !important; margin: var(--sp-4) !important; }
.leaflet-control-zoom a {
  width: 28px !important; height: 28px !important;
  line-height: 26px !important;
  background: var(--paper) !important;
  color: var(--fg-1) !important;
  border: var(--bw-hair) solid var(--ink) !important;
  border-radius: 0 !important;
  font-family: var(--font-mono) !important;
  font-size: var(--fs-16) !important;
  font-weight: 700 !important;
  transition: opacity var(--dur) var(--ease);
}
.leaflet-control-zoom a:first-child { border-bottom: none !important; }
.leaflet-control-zoom a:hover { opacity: 0.55; }

/* ── pins ── */

/* Circular — the one sanctioned exception in the system's radius scale
   ("rare — circular dots, status badges"). A circle holds less area than
   the square did, so the dot runs 2px wider to keep the index legible. */
.pin {
  display: grid;
  place-items: center;
  width: 22px; height: 22px;
  background: var(--paper);
  border: var(--bw-bold) solid var(--pin, var(--signal-orange));
  border-radius: var(--radius-pill);
  color: var(--fg-1);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: transform var(--dur) var(--ease);
}
.pin:hover { transform: scale(1.3); z-index: 800; }
.pin.is-active {
  background: var(--pin, var(--signal-orange));
  color: var(--paper);
  transform: scale(1.45);
  z-index: 900;
}
.pin-wrap { background: none !important; border: none !important; width: auto !important; height: auto !important; }

/* A whole list, collapsed because its pins would overlap at this zoom. */
.cluster {
  display: inline-flex;
  align-items: stretch;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  border: var(--bw-bold) solid var(--pin, var(--signal-orange));
  background: var(--paper);
  cursor: pointer;
  transition: opacity var(--dur) var(--ease);
}
.cluster:hover { opacity: 0.55; }
.cluster__k {
  padding: 4px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--fg-1);
}
.cluster__n {
  display: grid;
  place-items: center;
  padding: 4px 6px;
  background: var(--pin, var(--signal-orange));
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ── popup ── */

.leaflet-popup-content-wrapper {
  background: var(--paper);
  color: var(--fg-1);
  border: var(--bw-hair) solid var(--ink);
  border-radius: 0;
  box-shadow: var(--shadow-0);
  padding: 0;
}
.leaflet-popup-content { margin: 0; width: 15.5rem !important; line-height: var(--lh-body); }
.leaflet-popup-tip {
  background: var(--paper);
  border: var(--bw-hair) solid var(--ink);
  border-radius: 0;
  box-shadow: var(--shadow-0);
}
.leaflet-popup-close-button {
  color: var(--fg-3) !important;
  font-size: var(--fs-18) !important;
  padding: 5px 7px 0 0 !important;
}
.leaflet-popup-close-button:hover { opacity: 0.55; }

.pop { padding: var(--sp-3) var(--sp-4) var(--sp-3); }
.pop__idx {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: var(--ls-label);
  color: var(--pin, var(--signal-orange));
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.pop__name {
  margin: var(--sp-1) 0 0;
  font-size: var(--fs-16);
  font-weight: 700;
  line-height: var(--lh-snug);
}
.pop__note {
  margin: var(--sp-2) 0 0;
  font-style: italic;
  font-size: var(--fs-12);
  line-height: var(--lh-body);
  color: var(--fg-2);
}
.pop__coord {
  margin-top: var(--sp-3);
  padding-top: var(--sp-2);
  border-top: var(--bw-hair) solid var(--rule);
  font-size: 10px;
  letter-spacing: var(--ls-label);
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}
.pop__btn {
  display: block;
  margin-top: var(--sp-2);
  padding: var(--sp-2);
  border: var(--bw-hair) solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  text-align: center;
  text-decoration: none;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: opacity var(--dur) var(--ease);
}
.pop__btn:hover { opacity: 0.55; }

/* ── readout — rule 5, honest specs ── */

.readout {
  position: absolute;
  left: var(--sp-4); bottom: var(--sp-4);
  z-index: 460;
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-2);
  background: var(--paper);
  border: var(--bw-hair) solid var(--rule);
  font-size: 10px;
  letter-spacing: var(--ls-label);
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.readout__sep { color: var(--fg-3); }

/* ── boot ── */

.boot {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: grid;
  place-items: center;
  background: var(--paper);
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--fg-3);
  transition: opacity var(--dur-slow) var(--ease);
}
.boot.is-done { opacity: 0; pointer-events: none; }
.boot.is-error { color: var(--signal-red); }

/* ── mobile ── */

.sheet-toggle { display: none; }

@media (max-width: 820px) {
  body { flex-direction: column; }
  .stage { flex: 1 1 auto; height: 100%; order: 1; }

  .panel {
    order: 2;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    width: 100%;
    flex: none;
    height: 78dvh;
    max-height: 78dvh;
    border-right: none;
    border-top: var(--bw-hair) solid var(--ink);
    transform: translateY(100%);
    transition: transform var(--dur-slow) var(--ease);
    z-index: 1000;
  }
  .panel.is-open { transform: translateY(0); }

  .masthead { padding-top: var(--sp-6); }
  .title { font-size: var(--fs-32); }

  .sheet-toggle {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    z-index: 990;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom));
    background: var(--paper);
    border: none;
    border-top: var(--bw-hair) solid var(--ink);
    color: var(--fg-1);
    font-family: var(--font-mono);
    font-size: var(--fs-12);
    font-weight: 700;
    letter-spacing: var(--ls-label);
    text-transform: uppercase;
    cursor: pointer;
  }
  .sheet-toggle__bar { width: 34px; height: 2px; background: var(--ink-faint); }

  .readout { bottom: 104px; }
  .leaflet-bottom.leaflet-right { bottom: 62px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
