/* The public speed map. Mobile-first: the map is the page, the chrome is a thin
   bar above it, and everything below 640px is the default rather than a
   breakpoint bolted on afterwards. */

:root {
  --orange: #f0891a;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --low: #16a34a;
  --mid: #f59e0b;
  --high: #dc2626;
  --none: #9ca3af;
  --head: 52px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font: 15px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: #fff;
  /* A pinch-zoom on the map must not also zoom the page chrome. */
  -webkit-text-size-adjust: 100%;
}

.map-head {
  height: var(--head);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  /* Safe-area inset so the notch does not sit on the logo. */
  padding-left: max(14px, env(safe-area-inset-left));
  padding-right: max(14px, env(safe-area-inset-right));
}
.map-logo img { display: block; height: 28px; width: auto; }
.map-login {
  font-size: 14px;
  font-weight: 600;
  color: var(--orange);
  text-decoration: none;
  padding: 8px 4px;          /* a 44px-tall tap target without a visible box */
}

#map {
  height: calc(100% - var(--head));
  width: 100%;
  background: #eef1f4;       /* the colour tiles average to, so loading is calm */
}

/* Overlays sit on top of the map area, not the header. */
.overlay {
  position: absolute;
  top: var(--head);
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #fff;
  z-index: 500;              /* above Leaflet's panes (400) and controls (800 is tooltips) */
}
.overlay-card { max-width: 30rem; text-align: center; }
.overlay-card h1 { margin: 0 0 12px; font-size: 20px; font-weight: 700; }
.overlay-card p { margin: 0 0 12px; color: var(--muted); }
.overlay-card a { color: var(--orange); }
.quiet { font-size: 13px; }

.linklike {
  font: inherit;
  color: var(--orange);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}

/* Popup content. Leaflet supplies the bubble; this is what goes in it. */
.pop-label {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}
.pop-stats {
  margin: 0;
  display: grid;
  grid-template-columns: auto auto;
  gap: 3px 14px;
  font-size: 13px;
}
.pop-stats dt { color: var(--muted); }
.pop-stats dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }
.pop-stats .big { font-weight: 700; }
.pop-note {
  margin: 10px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.pop-over-high { color: var(--high); font-weight: 700; }

/* Legend. Bottom-left on a phone so it does not fight Leaflet's zoom control
   (top-left) or the attribution (bottom-right). */
.legend {
  position: absolute;
  left: max(10px, env(safe-area-inset-left));
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 500;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
.legend-title { display: block; font-weight: 600; margin-bottom: 4px; }
.legend ul { margin: 0; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 6px; line-height: 1.7; }
.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.dot-low { background: var(--low); }
.dot-mid { background: var(--mid); }
.dot-high { background: var(--high); }
.dot-none { background: var(--none); }

@media (min-width: 640px) {
  :root { --head: 60px; }
  .map-logo img { height: 34px; }
  .legend { font-size: 13px; }
}
