/* Palette and type come from road signs:
   regulatory white and black, guide green, warning yellow, stop red. */
:root {
  --ink: #15181b;
  --asphalt: #59616a;
  --line: rgba(21, 24, 27, 0.13);
  --paper: #fff;
  --wash: #f1f3ef;
  --guide: #00664f;
  --guide-deep: #004d3b;
  --warn: #f5b800;
  --fine: #d4281c;
  --build: #69717a;
  --font: "Overpass", "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --sheet-h: 176px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font: 400 15px/1.45 var(--font);
  color: var(--ink);
  background: var(--wash);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, p, ol, ul, dl, dd { margin: 0; padding: 0; }
ol, ul { list-style: none; }
a { color: var(--guide); text-underline-offset: 2px; }

/* Ink ring on light surfaces: 17.8:1 on white. The search bar uses a white ring on green. */
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
h1:focus { outline: none; } /* a heading that takes focus after a view change */

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

.noscript { position: fixed; inset: auto 0 0; padding: 16px; background: var(--paper); z-index: 9; }

/* ---------- Map ---------- */

#map { position: fixed; inset: 0; }
.maplibregl-map { font: inherit; }
.maplibregl-ctrl-group { border-radius: 10px; box-shadow: 0 2px 10px rgba(21, 24, 27, 0.16); }
.maplibregl-ctrl-group:not(:empty) { box-shadow: 0 0 0 1px var(--line), 0 2px 10px rgba(21, 24, 27, 0.14); }
.maplibregl-ctrl-attrib { font-size: 11px; }

/* Camera markers. A dot from far away, a speed limit sign up close or near the address. */
.cam { z-index: 1; }
.cam.is-near { z-index: 2; }
.cam.is-selected { z-index: 3; }

.cam__btn {
  all: unset;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  cursor: pointer;
  border-radius: 6px;
  transition: transform 0.2s var(--ease);
}
.cam__btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; box-shadow: 0 0 0 2px #fff; }

.cam__dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--status);
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(21, 24, 27, 0.4);
}

[data-status="warn"] { --status: var(--warn); }
[data-status="fine"] { --status: var(--fine); }
[data-status="build"] { --status: var(--build); }
[data-status="other"] { --status: var(--ink); }

.cam[data-status="build"] .cam__dot {
  width: 9px;
  height: 9px;
  background: #fff;
  box-shadow: 0 0 0 2px var(--build);
}

.cam .sign { display: none; }
/* app.js gives is-sign only to markers whose sign fits without covering another. */
.cam.is-sign .cam__dot { display: none; }
.cam.is-sign .sign { display: grid; }
.cam.is-sign .cam__btn { width: 34px; height: 40px; }
.cam.is-selected .cam__btn { transform: scale(1.4); }
/* A camera in range with no room for a sign: a larger dot. */
.cam.is-near:not(.is-sign) .cam__dot { transform: scale(1.35); }

/* The speed limit sign */
.sign {
  --w: 26px;
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  align-content: center;
  width: var(--w);
  height: calc(var(--w) * 1.22);
  background: #fff;
  border-radius: calc(var(--w) * 0.14);
  box-shadow:
    inset 0 0 0 calc(var(--w) * 0.04) #fff,
    inset 0 0 0 calc(var(--w) * 0.1) var(--ink),
    0 1px 5px rgba(21, 24, 27, 0.35);
  color: var(--ink);
  font-weight: 800;
  line-height: 1;
  text-align: center;
}
.sign b {
  font-size: calc(var(--w) * 0.56);
  font-weight: 800;
  letter-spacing: -0.03em;
  /* Overpass sits high in its box. Nudge the figures to the optical middle. */
  transform: translateY(8%);
}
.sign__words {
  font-size: calc(var(--w) * 0.155);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.12;
  margin-bottom: calc(var(--w) * 0.02);
}
/* Status lamp on the corner of the sign */
.sign::after {
  content: "";
  position: absolute;
  top: calc(var(--w) * -0.17);
  right: calc(var(--w) * -0.17);
  width: calc(var(--w) * 0.4);
  height: calc(var(--w) * 0.4);
  border-radius: 50%;
  background: var(--status);
  box-shadow: 0 0 0 calc(var(--w) * 0.06) #fff;
}
[data-status="build"] > .sign, .sign[data-status="build"] {
  color: var(--build);
  box-shadow:
    inset 0 0 0 calc(var(--w) * 0.04) #fff,
    inset 0 0 0 calc(var(--w) * 0.1) var(--build),
    0 1px 4px rgba(21, 24, 27, 0.22);
}
[data-status="build"] > .sign::after, .sign[data-status="build"]::after {
  background: #fff;
  box-shadow: inset 0 0 0 calc(var(--w) * 0.08) var(--build), 0 0 0 calc(var(--w) * 0.06) #fff;
}
.sign--row { --w: 34px; }
.sign--big { --w: 84px; }
.sign--big b { font-size: calc(var(--w) * 0.5); }
.sign--big::after { top: -7px; right: -7px; width: 18px; height: 18px; box-shadow: 0 0 0 3px #fff; }
.sign--big[data-status="build"]::after { box-shadow: inset 0 0 0 4px var(--build), 0 0 0 3px #fff; }

/* While a route shows, the cameras off it fade. A camera someone opened stays clear.
   The fade goes on the button: MapLibre writes its own opacity on the marker itself. */
.has-route .cam:not(.is-near):not(.is-selected) .cam__btn { opacity: 0.3; }

/* A drive: the route, and the letters at its two ends */
.pin--end {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding-top: 2px;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}
.pin--end[data-end="to"] { background: var(--ink); }

/* Address pin */
.pin {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--guide);
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(21, 24, 27, 0.35), 0 3px 10px rgba(21, 24, 27, 0.35);
  z-index: 4;
}

/* ---------- Dock: search and panel ---------- */

.dock {
  position: fixed;
  z-index: 5;
  top: 16px;
  left: 16px;
  width: clamp(300px, 44vw, 408px);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.dock > * { pointer-events: auto; }

/* Search bar, built like a freeway guide sign */
.search {
  position: relative;
  flex: none;
  padding: 5px;
  background: var(--guide);
  border-radius: 13px;
  box-shadow:
    inset 0 0 0 3px var(--guide),
    inset 0 0 0 5px #fff,
    0 8px 24px rgba(0, 61, 47, 0.28);
  color: #fff;
}
.search:focus-within { outline: 3px solid var(--ink); outline-offset: 2px; }
.search__row {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 48px;
  padding: 0 5px 0 13px;
}
.search__row[hidden], .search__trip[hidden] { display: none; }
/* A drive: two lines on the sign, start over end, like a guide sign with two exits. */
.search__trip { padding: 0; }
.search__trip .search__row { position: relative; height: 51px; padding: 0 5px 0 10px; }
.search__trip .search__row + .search__row::before {
  content: "";
  position: absolute;
  top: 0;
  left: 11px;
  right: 11px;
  height: 1px;
  background: rgba(255, 255, 255, 0.42);
}
.search__end {
  flex: none;
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  padding-top: 2px;
  border-radius: 50%;
  background: #fff;
  color: var(--guide-deep);
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}
.search__btn:focus-visible { outline: 2px solid #fff; outline-offset: -3px; }
.search.is-busy .search__icon { animation: pulse 0.6s ease-in-out infinite alternate; }
.search svg {
  width: 22px; height: 22px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
}
.search svg .fill { fill: currentColor; stroke: none; }
.search svg .tint { fill: rgba(255, 255, 255, 0.22); stroke: none; }
.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 3px 8px 0 10px;
  border: 0;
  border-radius: 6px;
  outline: 0;
  background: none;
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.005em;
  text-overflow: ellipsis;
}
.search input::placeholder { color: rgba(255, 255, 255, 0.8); font-weight: 500; }
/* Keep browser autofill (especially iPhone Contacts/Safari autofill) white-on-green inside the frame. */
.search input:-webkit-autofill,
.search input:-webkit-autofill:hover,
.search input:-webkit-autofill:focus {
  -webkit-text-fill-color: #fff;
  caret-color: #fff;
  -webkit-box-shadow: 0 0 0 1000px var(--guide) inset;
  box-shadow: 0 0 0 1000px var(--guide) inset;
  transition: background-color 99999s ease-out 0s;
}
@supports selector(:autofill) {
  .search input:autofill {
    color: #fff;
    caret-color: #fff;
    box-shadow: 0 0 0 1000px var(--guide) inset;
  }
}
.search__btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: #fff;
}
.search__clear { width: 32px; height: 36px; opacity: 0.88; }
.search__clear svg { width: 20px; height: 20px; stroke-width: 2; }
.search__clear:hover { opacity: 1; }
.search__close { position: relative; margin-left: 4px; }
.search__close::before {
  content: "";
  position: absolute;
  left: -3px;
  top: 9px;
  bottom: 9px;
  width: 1px;
  background: rgba(255, 255, 255, 0.34);
}
.search__btn:hover { background: rgba(255, 255, 255, 0.14); }
.search__btn[hidden] { display: none; }
.search__btn.is-busy svg { animation: pulse 0.9s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: 0.35; } }

.suggest {
  position: absolute;
  z-index: 2;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: min(60dvh, 420px);
  overflow-y: auto;
  padding: 6px;
  background: var(--paper);
  color: var(--ink);
  border-radius: 13px;
  box-shadow: 0 0 0 1px var(--line), 0 14px 36px rgba(21, 24, 27, 0.2);
}
.suggest[hidden] { display: none; }
.suggest li {
  padding: 10px 12px 9px;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1.3;
}
.suggest li strong { display: block; font-weight: 700; font-size: 16px; }
.suggest li span { display: block; color: var(--asphalt); font-size: 14px; }
.suggest li[role="option"]:hover { background: var(--wash); }
.suggest li[aria-selected="true"] { background: var(--wash); outline: 2px solid var(--ink); outline-offset: -2px; }
.suggest li.suggest__note { cursor: default; color: var(--asphalt); }

/* Panel */
.panel {
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-radius: 14px;
  box-shadow: 0 0 0 1px var(--line), 0 12px 32px rgba(21, 24, 27, 0.14);
  overflow: hidden;
  container-type: inline-size;
}
.panel__grip { display: none; }
.panel__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 22px 18px;
}

h1 {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.012em;
  text-wrap: balance;
}
h2 {
  margin: 22px 0 2px;
  font-size: 14px;
  font-weight: 700;
  color: var(--asphalt);
}
.lede { margin-top: 10px; font-size: 16px; max-width: 34ch; }
.hint { margin-top: 18px; color: var(--asphalt); }

/* Legend */
.legend { margin-top: 18px; border-top: 1px solid var(--line); }
.legend li {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 11px 0 10px;
  border-bottom: 1px solid var(--line);
}
.legend__dot {
  justify-self: center;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--status);
}
[data-status="build"] > .legend__dot { background: #fff; box-shadow: inset 0 0 0 2.5px var(--build); }
.legend strong { display: block; font-weight: 700; }
.legend small { display: block; color: var(--asphalt); font-size: 13.5px; line-height: 1.35; }
.legend__n { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Count: one heading, "6 cameras within 2 miles of ..." */
.count { display: grid; grid-template-columns: auto 1fr; column-gap: 14px; align-items: center; font-size: 22px; }
.count__n {
  font-size: 92px;
  font-weight: 800;
  line-height: 0.74;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
  padding-top: 0.14em; /* Overpass figures sit high */
}
.count__what small {
  display: block;
  margin-top: 3px;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0;
  color: var(--asphalt);
  overflow-wrap: anywhere;
}
.mix { margin-top: 14px; font-size: 16px; }

.notice {
  margin-top: 14px;
  padding: 11px 13px 10px;
  border-radius: 9px;
  background: #fff4cc;
  box-shadow: inset 3px 0 0 var(--warn);
  font-size: 14.5px;
}

/* Distance picker */
.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 18px;
  padding: 3px;
  border-radius: 10px;
  background: var(--wash);
}
.seg button {
  height: 38px;
  padding-top: 2px;
  border: 0;
  border-radius: 8px;
  background: none;
  font-weight: 600;
  color: var(--asphalt);
}
.seg button[aria-checked="true"] {
  background: var(--ink);
  color: #fff;
  font-weight: 700;
}

/* Camera list */
.cams li + li { border-top: 1px solid var(--line); }
.row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  width: calc(100% + 16px);
  margin: 0 -8px;
  padding: 13px 8px 11px 14px;
  border: 0;
  border-radius: 9px;
  background: none;
  text-align: left;
}
.row:hover { background: var(--wash); }
.row__main { min-width: 0; line-height: 1.3; }
.row__main strong { display: block; font-size: 16px; font-weight: 700; }
.row__main span { display: block; color: var(--asphalt); font-size: 14px; }
.row__side { display: grid; justify-items: end; gap: 4px; }
.dist { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 1px;
  border-radius: 99px;
  background: var(--wash);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.chip::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  margin-top: -2px;
  background: var(--status);
}
.chip[data-status="warn"] { background: #fff1c2; }
.chip[data-status="fine"] { background: #fde3e0; }
.chip[data-status="build"]::before { background: none; box-shadow: inset 0 0 0 2px var(--build); }

/* On a narrow panel the status chip goes: the lamp on the sign still shows the status. */
@container (max-width: 350px) {
  .row { gap: 11px; padding-left: 12px; }
  .row__side .chip { display: none; }
}

/* Camera detail */
.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: -6px 0 14px -8px;
  padding: 7px 10px 5px 4px;
  border: 0;
  border-radius: 8px;
  background: none;
  font-weight: 600;
  color: var(--guide);
}
.back:hover { background: var(--wash); }
.back svg { width: 18px; height: 18px; margin-top: -2px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.detail { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; padding: 6px 6px 0 8px; }
.detail p { margin: 4px 0 10px; color: var(--asphalt); }

.facts { margin-top: 22px; border-top: 1px solid var(--line); }
.facts div {
  display: grid;
  grid-template-columns: 9.5em 1fr;
  gap: 12px;
  padding: 11px 0 9px;
  border-bottom: 1px solid var(--line);
}
.facts dt { color: var(--asphalt); }
.facts dd { font-weight: 600; }
.facts dd small { display: block; font-size: 13.5px; font-weight: 400; color: var(--asphalt); }

.btn {
  display: inline-flex;
  align-items: center;
  height: 42px;
  margin-top: 18px;
  padding: 2px 16px 0;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}
.btn:hover { background: #000; }
button.btn { border: 0; }
.btn svg { width: 20px; height: 20px; margin: -2px 8px 0 -2px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* Route choices: one row for each route, with its camera count */
.routes { display: grid; gap: 8px; margin-top: 18px; }
.routes button {
  display: grid;
  grid-template-columns: 3.1em 1fr;
  gap: 12px;
  align-items: center;
  padding: 11px 14px 9px 10px;
  border: 0;
  border-radius: 11px;
  background: var(--wash);
  text-align: left;
  line-height: 1.3;
}
.routes button[aria-checked="true"] { background: var(--ink); color: #fff; }
.routes__n {
  display: grid;
  justify-items: center;
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  padding-top: 0.1em;
}
.routes__n small { font-size: 11.5px; font-weight: 600; letter-spacing: 0.01em; margin-top: 1px; }
.routes strong { display: block; font-size: 16px; font-weight: 700; }
.routes small { display: block; font-size: 13.5px; }
.routes button > span:last-child small { opacity: 0.82; }
.trip__sum { margin-top: 6px; color: var(--asphalt); }
.crossed { margin-top: 22px; }
.crossed p { padding: 0 0 6px; color: var(--asphalt); font-size: 14px; }
.crossed .cams { padding-bottom: 6px; }

/* Fines and source */
.foot { margin-top: 24px; }
/* Fold-away lists: the fines table and the all-cameras list */
.fold { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.fold summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 0 11px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.fold summary::-webkit-details-marker { display: none; }
.fold summary::after {
  content: "";
  width: 8px; height: 8px;
  margin: -4px 4px 0 0;
  border-right: 2.2px solid var(--asphalt);
  border-bottom: 2.2px solid var(--asphalt);
  transform: rotate(45deg);
  transition: transform 0.2s var(--ease);
}
.fold[open] summary::after { transform: translateY(4px) rotate(-135deg); }
.fines table { width: 100%; border-collapse: collapse; }
.fines th, .fines td { padding: 7px 0 5px; border-top: 1px solid var(--line); font-weight: 400; text-align: left; }
.fines td { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.fines p { padding: 10px 0 14px; color: var(--asphalt); font-size: 14px; }
.how { border-top: 0; }
.how ul { padding: 0 0 12px; color: var(--asphalt); font-size: 14px; }
.how li { position: relative; padding: 3px 0 3px 14px; }
.how li::before { content: ""; position: absolute; left: 0; top: 0.75em; width: 5px; height: 5px; border-radius: 50%; background: var(--asphalt); }
.all { margin-top: 18px; border-top: 0; }
.all .cams { padding-bottom: 6px; }
.source { margin-top: 14px; color: var(--asphalt); font-size: 13px; line-height: 1.45; }

/* ---------- Phone: search on top, panel as a bottom sheet ---------- */

/* Same query as `phone` in app.js. A short, wide screen keeps the side panel. */
@media (max-width: 719px) and (min-height: 480px) {
  .dock { position: static; width: auto; max-height: none; display: contents; }

  .search {
    position: fixed;
    z-index: 7;
    top: calc(var(--safe-t) + 10px);
    left: calc(env(safe-area-inset-left, 0px) + 10px);
    right: calc(env(safe-area-inset-right, 0px) + 10px);
  }
  .search__row { height: 46px; }
  .search__trip .search__row { height: 49px; }
  .suggest { max-height: min(46dvh, calc(100dvh - 145px), 360px); }

  .panel {
    position: fixed;
    z-index: 6;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--sheet-h);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 0 0 1px var(--line), 0 -8px 30px rgba(21, 24, 27, 0.16);
    transition: height 0.32s var(--ease);
    will-change: height;
  }
  .panel.is-dragging { transition: none; }

  .panel__grip {
    flex: none;
    display: grid;
    place-items: center;
    width: 100%;
    height: 30px;
    padding: 0;
    border: 0;
    background: none;
    touch-action: none;
    cursor: grab;
  }
  .panel__grip span { width: 40px; height: 5px; border-radius: 99px; background: rgba(21, 24, 27, 0.55); }
  .panel__grip:focus-visible { outline-offset: -4px; }

  .panel__body { padding: 2px 20px calc(var(--safe-b) + 20px); }

  h1 { font-size: 22px; }
  .count { font-size: 20px; }
  .count__n { font-size: 80px; }

  .maplibregl-ctrl-bottom-right, .maplibregl-ctrl-bottom-left { bottom: var(--sheet-h); transition: bottom 0.32s var(--ease); }
}

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

/* A very narrow phone: the address field needs the room more than the looking glass does. */
@media (max-width: 380px) {
  #near { padding-left: 7px; }
  #near .search__icon { display: none; }
  .search__trip .search__row { padding-left: 7px; padding-right: 3px; }
}
