/* Blacksburg road coverage — an instrument, not a landing page.
   Chrome is entirely achromatic so the only colour on screen is data. */

:root {
  color-scheme: dark;

  /* Cool near-black, tuned to sit with the dark basemap rather than fight it. */
  --surface-0: #101215;
  --surface-1: #171a1f;
  --surface-2: #1f232a;
  --line:      #262b33;
  --line-soft: #1c2027;

  --ink-0: #f2f3f5;
  --ink-1: #a8adb8;
  --ink-2: #6b7280;

  /* Data. Validated as a categorical pair against both the map and rail
     surfaces: CVD ΔE 26.8, normal-vision ΔE 31.8, both ≥ 3:1 contrast. */
  --explored:   #3987e5;
  --unexplored: #d95926;

  /* Sequential ramp for cell coverage: one hue, stepped by alpha over the
     dark surface. Strongest where least has been run. */
  --cell-0: rgba(217, 89, 38, .58);
  --cell-1: rgba(217, 89, 38, .44);
  --cell-2: rgba(217, 89, 38, .30);
  --cell-3: rgba(217, 89, 38, .18);
  --cell-4: rgba(217, 89, 38, .07);

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --rail-w: 384px;
  --pad: 20px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--surface-0);
  color: var(--ink-0);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

:focus-visible {
  outline: 2px solid var(--explored);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- layout */

.app {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  height: 100dvh;
}

.rail {
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: 1px solid var(--line);
  background: var(--surface-0);
  display: flex;
  flex-direction: column;
}

.map-wrap { position: relative; }
#map { position: absolute; inset: 0; background: var(--surface-1); }

/* ------------------------------------------------------------ rail chrome */

.rail-head {
  padding: var(--pad);
  border-bottom: 1px solid var(--line);
}

.rail-head h1 {
  margin: 0 0 14px;
  font-size: 17px;
  font-weight: 620;
  letter-spacing: -.012em;
  line-height: 1.2;
}
.rail-head h1 span {
  display: block;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 400;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-top: 4px;
}

.scope { display: flex; gap: 0; border: 1px solid var(--line); }
.scope-btn {
  flex: 1;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-1);
  font: inherit;
  font-size: 12px;
  padding: 7px 8px;
  cursor: pointer;
}
.scope-btn + .scope-btn { border-left: 1px solid var(--line); }
.scope-btn:hover { background: var(--surface-1); color: var(--ink-0); }
.scope-btn.is-on { background: var(--surface-2); color: var(--ink-0); font-weight: 560; }

.panel {
  padding: var(--pad);
  border-bottom: 1px solid var(--line);
}

.micro {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-1);
}
.micro.dim, .dim { color: var(--ink-2); }

/* ------------------------------------------------------------- hero score */

.score .figure {
  margin: 10px 0 0;
  font-size: 60px;
  font-weight: 300;
  line-height: 1;
  letter-spacing: -.035em;
  /* Proportional figures: tabular digits read loose at display sizes. */
  font-variant-numeric: proportional-nums;
}
.figure-unit { font-size: 24px; font-weight: 400; color: var(--ink-2); margin-left: 3px; }

.figure-sub {
  margin: 10px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-1);
}
.figure-note {
  margin: 3px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
}
.figure-note strong { color: var(--unexplored); font-weight: 600; }

.meter { background: var(--surface-2); overflow: hidden; }
.meter-fill { height: 100%; background: var(--explored); border-radius: 0 3px 3px 0; }
.meter-lg { height: 6px; margin: 16px 0 12px; }

/* ----------------------------------------------------------------- layers */

.layers { list-style: none; margin: 12px 0 0; padding: 0; }
.layers li + li { margin-top: 2px; }

.layers label {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px 6px 0;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-0);
  min-height: 28px;
}
.layers input { accent-color: var(--explored); width: 15px; height: 15px; margin: 0; cursor: pointer; }

/* Swatches double as the legend, so identity is never checkbox-position alone. */
.key { width: 16px; height: 3px; background: var(--key); flex: none; }
.key-grid  { height: 12px; background: var(--cell-1); border: 1px solid var(--cell-0); }
.key-trace { background: rgba(242,243,245,.42); }
.key-region{ height: 0; border-top: 1px dashed var(--ink-2); }

.ramp { padding: 2px 0 8px 24px; }
.ramp-bar { display: flex; height: 8px; }
.ramp-bar i { flex: 1; }
.ramp-ends {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 10px; color: var(--ink-2); margin-top: 4px;
}

/* -------------------------------------------------------------- breakdown */

.breakdown { width: 100%; border-collapse: collapse; margin-top: 12px; }
.breakdown td { padding: 5px 0; vertical-align: middle; }
.breakdown .bd-name {
  font-size: 12px; color: var(--ink-1); width: 84px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.breakdown .bd-meter { padding: 5px 10px; }
.breakdown .bd-meter .meter { height: 6px; }
.breakdown .bd-pct {
  font-family: var(--font-mono); font-size: 11px; color: var(--ink-0);
  text-align: right; width: 38px; font-variant-numeric: tabular-nums;
}

/* ----------------------------------------------------------- the ledger */
/* The punch list: every street with road still on it, longest first. */

/* Grows to fit its own rows and lets the rail scroll. Do NOT give this `flex: 1`
   with a scrolling parent: it gets sized to the leftover space while the 250-row
   list overflows unhandled, and the rows paint straight over the footer. */
.panel-ledger { display: flex; flex-direction: column; }

.search {
  width: 100%;
  margin: 12px 0 4px;
  padding: 7px 9px;
  background: var(--surface-1);
  border: 1px solid var(--line);
  color: var(--ink-0);
  font: inherit;
  font-size: 13px;
}
.search::placeholder { color: var(--ink-2); }

.ledger { list-style: none; margin: 8px 0 0; padding: 0; }

.ledger button {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name miles" "meter meter";
  gap: 5px 10px;
  width: calc(100% + var(--pad) * 2);
  margin-left: calc(var(--pad) * -1);
  padding: 9px var(--pad);
  appearance: none;
  border: 0;
  border-top: 1px solid var(--line-soft);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ledger li:last-child button { border-bottom: 1px solid var(--line-soft); }
.ledger button:hover { background: var(--surface-1); }
.ledger button.is-on { background: var(--surface-2); }

.ledger .l-name {
  grid-area: name; font-size: 13px; color: var(--ink-0);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ledger .l-miles {
  grid-area: miles; font-family: var(--font-mono); font-size: 11px;
  color: var(--unexplored); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.ledger .l-meter { grid-area: meter; height: 3px; background: var(--surface-2); }
.ledger .l-meter div { height: 100%; background: var(--explored); }

.ledger-foot { margin-top: 12px; }
.ledger-empty { padding: 14px 0; font-size: 13px; color: var(--ink-2); }

.rail-foot { padding: var(--pad); margin-top: auto; }

/* ---------------------------------------------------------------- banner */

/* Any class rule that sets `display` beats the UA stylesheet's
   `[hidden] { display: none }`, so the flex below would render an empty banner
   box whenever the banner is meant to be hidden. Restore it explicitly. */
.banner[hidden] { display: none; }

.banner {
  position: absolute; top: 12px; left: 12px; right: 12px;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 13px;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-left: 2px solid var(--unexplored);
  font-size: 12.5px;
  color: var(--ink-1);
  max-width: 560px;
}
.banner-body { flex: 1; }
.banner strong { color: var(--ink-0); font-weight: 600; }

.banner-close {
  flex: none;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 18px;
  line-height: 1;
  padding: 2px 4px;
  margin: -2px -4px 0 0;
  cursor: pointer;
}
.banner-close:hover { color: var(--ink-0); }
.banner code {
  font-family: var(--font-mono); font-size: 11.5px;
  background: var(--surface-2); padding: 1px 5px; color: var(--ink-0);
}

/* --------------------------------------------------------------- popups */

.maplibregl-popup-content {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 11px 13px;
  box-shadow: none;
  color: var(--ink-0);
  font-family: var(--font-sans);
}
.maplibregl-popup-tip { display: none; }
.maplibregl-popup-close-button { color: var(--ink-2); font-size: 17px; padding: 0 6px; }
.maplibregl-popup-close-button:hover { background: transparent; color: var(--ink-0); }

.pop-name { font-size: 13.5px; font-weight: 600; margin: 0 0 6px; }
.pop-row {
  display: flex; gap: 12px; justify-content: space-between;
  font-family: var(--font-mono); font-size: 11px; color: var(--ink-1);
}
.pop-row + .pop-row { margin-top: 2px; }
.pop-row b { font-weight: 500; color: var(--ink-0); }
.pop-state { font-weight: 600; }
.pop-state.yes { color: var(--explored); }
.pop-state.no  { color: var(--unexplored); }

.maplibregl-ctrl-group { background: var(--surface-1); border: 1px solid var(--line); border-radius: 0; box-shadow: none; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--line); }
.maplibregl-ctrl-attrib { background: rgba(16,18,21,.82) !important; }
.maplibregl-ctrl-attrib a { color: var(--ink-2); }

/* -------------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 46dvh 54dvh; }
  .map-wrap { order: -1; }
  .rail { border-right: 0; border-top: 1px solid var(--line); }
  .ledger button { width: 100%; margin-left: 0; padding-left: 0; padding-right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.banner-detail {
  display: inline-block;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-2);
}
