/* Map page layout. Tokens, type and shared components live in site.css. */
:root {
  --attr-w: 240px;     /* set live by app.js: width of Leaflet's attribution corner */
  --dock-h: 20px;      /* set live by app.js: height of the bottom row (credits bar / attribution) */
  --tiles: grayscale(1) sepia(0.12) contrast(0.85) brightness(1.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --tiles: invert(1) hue-rotate(180deg) grayscale(1) brightness(0.72) contrast(0.9); }
}
:root[data-theme="dark"] { --tiles: invert(1) hue-rotate(180deg) grayscale(1) brightness(0.72) contrast(0.9); }

html, body { height: 100%; }
:root { --menu-h: 44px; }
.map-masthead { position: fixed; z-index: 1003; top: 0; left: 0; right: 0; max-width: none; height: calc(var(--menu-h) + env(safe-area-inset-top));
  align-items: center; flex-wrap: nowrap; padding: env(safe-area-inset-top) 16px 0; background: var(--panel); }
#map { position: fixed; inset: calc(var(--menu-h) + env(safe-area-inset-top)) 0 0 0; background: var(--paper); }
#map.over-point { cursor: pointer; }
.leaflet-container { background: var(--paper); font: inherit; }
.leaflet-tile-pane { filter: var(--tiles); }
.leaflet-dots-pane { z-index: 450; pointer-events: none; }
#dots { position: absolute; top: 0; left: 0; pointer-events: none; }
.leaflet-bar { border: 1.5px solid var(--fg) !important; border-radius: var(--radius) !important; box-shadow: var(--shadow) !important; }
.leaflet-bar a { background: var(--bg) !important; color: var(--fg) !important; border-color: var(--line) !important; }

/* Floating panels over the map */
#bar form, #modes, #results, #legend, #sheet {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ---------- top bar ---------- */
#bar { position: fixed; z-index: 1000; top: calc(var(--menu-h) + 10px + env(safe-area-inset-top)); left: 16px; right: 16px;
  max-width: 460px; display: flex; flex-direction: column; gap: 8px; }
#bar form { display: flex; align-items: center; padding: 3px; border: 1.5px solid var(--fg); }
#q { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 16px; padding: 10px 10px 8px; outline: none; }
#q::placeholder { color: var(--muted); }
/* Locate control (above the zoom buttons) */
.locate-control a { display: grid !important; place-items: center; }
.locate-control svg { width: 18px; height: 18px; }
#locate.busy svg { animation: pulse 1s ease-in-out infinite; }
#locate.on { color: #1a73e8 !important; }
@keyframes pulse { 50% { opacity: 0.35; } }
#results { list-style: none; margin: 0; padding: 4px; max-height: 45vh; overflow: auto; }
#results li button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px 8px; border-radius: 3px; line-height: 1.3; }
#results li button:hover, #results li button:focus-visible, #results li button[aria-selected="true"] { background: color-mix(in srgb, var(--fg) 7%, transparent); }
#results li button:disabled { color: var(--muted); cursor: default; }
#results strong { display: block; font-weight: 700; }
#results .where { font-size: 13px; color: var(--muted); }

#modes { display: flex; gap: 2px; padding: 3px; align-self: flex-start; }
#modes button { border: 0; background: none; padding: 7px 11px 5px; border-radius: 3px; color: var(--muted);
  font: 600 12px/1.3 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; }
#modes button.on { background: var(--fg); color: var(--bg); }


/* ---------- legend ---------- */
#legend { position: fixed; z-index: 1000; left: 16px; right: 16px; bottom: 12px;
  max-width: 460px; overflow: hidden; }
#legend-toggle { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  border: 0; background: none; padding: 11px 14px 9px; font-size: 14px; text-align: left; }
.layers-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px 5px 8px;
  border: 1.5px solid var(--fg); border-radius: var(--radius); font: 600 12px/1 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; }
.layers-btn svg { width: 16px; height: 16px; }
.layers-btn .chev { width: 14px; height: 14px; transition: transform .15s; }
#legend-toggle:hover .layers-btn { background: color-mix(in srgb, var(--fg) 8%, transparent); }
#legend-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
#counts b { font: 700 14px var(--mono); font-variant-numeric: tabular-nums; }
#counts .count { white-space: nowrap; }  /* never split a number from its label */
#counts .sep { margin: 0 3px; color: var(--muted); }
#counts .counts-head { font-weight: 700; }
/* Per-layer count at the end of each legend row */
#legend-body .row-n { flex: none; margin-left: auto; padding-left: 10px; font: 700 14px var(--mono); font-variant-numeric: tabular-nums; }
#legend-body .row-n.off { color: var(--muted); font-weight: 500; }
#legend-body label:has([data-k="lead"]) .row-n:not(.off) { color: var(--lead); }
#counts { min-width: 0; }
#counts .c-lead { color: var(--lead); }
#counts .c-listed { color: var(--listed); }
#legend-body { max-height: 55vh; overflow: auto; padding: 2px 14px 12px; display: grid; gap: 6px; font-size: 14px;
  border-top: 1px solid var(--line); }
#legend-body label { display: flex; align-items: center; gap: 9px; min-height: 34px; }
#legend-body label > span { flex: 1; font-weight: 600; }
#legend-body small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
#legend-body input { width: 18px; height: 18px; margin: 0; accent-color: var(--fg); }
.adv summary { cursor: pointer; padding: 8px 0 4px; }
.adv label + label { margin-top: 6px; }

/* ---------- detail sheet ---------- */
#sheet { position: fixed; z-index: 1001; left: 16px; right: 16px; bottom: 12px;
  max-width: 460px; max-height: 70vh; overflow: auto; padding: 16px 16px 14px; }
#sheet-close { position: absolute; top: 6px; right: 6px; width: 40px; height: 40px; border: 0; background: none; font-size: 26px; color: var(--muted); }
#sheet h2 { margin: 0; font-size: 19px; }
#sheet .title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 8px 36px 4px 0; }
/* Status badge: outlined stamp; tap or hover for a short explanation */
.status-wrap { position: relative; display: inline-flex; }
.status-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px 3px; border: 1.5px solid currentColor;
  border-radius: 3px; background: none; font: 700 11px/1.2 var(--mono); letter-spacing: 0.05em; text-transform: uppercase; cursor: help; }
.status-badge::after { content: "?"; display: inline-grid; place-items: center; width: 13px; height: 13px; border-radius: 50%;
  border: 1px solid currentColor; font-size: 9px; line-height: 1; }
.status-badge.active { color: var(--fg); }
.status-badge.planned { color: var(--muted); border-style: dashed; }
.status-badge.removed, .status-badge.unknown { color: var(--muted); }
.status-tip { position: absolute; z-index: 5; top: calc(100% + 6px); left: 0; width: max-content; max-width: min(260px, 70vw);
  padding: 8px 10px; background: var(--fg); color: var(--paper); border-radius: 4px; font-size: 13px; line-height: 1.35;
  visibility: hidden; opacity: 0; transition: opacity .12s; pointer-events: none; }
.status-wrap:hover .status-tip, .status-wrap.open .status-tip, .status-badge:focus-visible + .status-tip { visibility: visible; opacity: 1; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions .btn { flex: 1 1 auto; }
.hint { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.hint a.plain, #sheet dd a.plain { color: inherit; }
.arrow { display: inline-block; }
.you { width: 16px; height: 16px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(26,115,232,.25); }

/* ---------- mapped-camera details (shown in the same sheet) ---------- */
.back-link { display: block; margin: 0 0 8px; font-size: 14px; font-weight: 700; text-decoration: none; }
.pop .fields { margin: 8px 0; }
.pop details { margin-bottom: 10px; font-size: 12px; }
.pop summary { cursor: pointer; }
.pop table { border-collapse: collapse; margin-top: 6px; width: 100%; font: 12px/1.35 var(--mono); }
.pop th, .pop td { text-align: left; vertical-align: top; padding: 2px 8px 2px 0; overflow-wrap: anywhere; }
.pop th { color: var(--muted); font-weight: 500; white-space: nowrap; }
/* What Flock's list says about a violet (matched) camera: same bar-and-tint look as .verify, in violet. */
.flock-box { margin: 12px 0; padding: 10px 12px 4px; border-left: 4px solid var(--listed);
  background: color-mix(in srgb, var(--listed) 9%, transparent); }
.flock-box h3 { margin: 0 0 2px; color: var(--listed); }
.flock-box .fields { margin: 6px 0 8px; }
.flock-box .fields + .fields { padding-top: 8px; border-top: 1px solid color-mix(in srgb, var(--listed) 30%, transparent); }
.flock-box .muted { margin: 4px 0 8px; font-size: 13px; }

/* ---------- bottom row: our credits bar + Leaflet's attribution corner ---------- */
/* Leaflet's attribution (© OpenStreetMap) stays visible in the bottom-right at every size: the OSM tile
   policy forbids hiding it. Our bar shares that row. Wide screens: centered in the space right of the
   legend panel. Narrow screens: from the left edge up to the attribution, with the legend lifted above. */
.leaflet-control-attribution { font: 11px/18px var(--mono) !important; padding: 1px 6px !important;
  background: var(--panel) !important; color: var(--muted) !important; border-top-left-radius: 4px; }
.leaflet-control-attribution a { color: inherit !important; }
#credits { position: fixed; z-index: 1002; bottom: 0; left: 492px; right: var(--attr-w);
  display: flex; justify-content: center; pointer-events: none; }
.credits-bar { pointer-events: auto; max-width: 100%; padding: 1px 8px; background: var(--panel);
  border-radius: 4px 4px 0 0; font: 11px/18px var(--mono); color: var(--muted); text-align: center; }
.credits-bar a { color: inherit; }

@media (max-width: 1140px) {  /* below this the space right of the legend is too narrow for one line */
  #credits { left: 0; justify-content: flex-start; }
  .credits-bar { border-radius: 0 4px 0 0; padding: 1px 16px calc(1px + env(safe-area-inset-bottom)); text-align: left; }
  .leaflet-bottom.leaflet-right .leaflet-control-attribution { padding-bottom: calc(1px + env(safe-area-inset-bottom)) !important; }
  #legend, #sheet { bottom: calc(var(--dock-h) + 8px); }
  .leaflet-bottom.leaflet-right .leaflet-control-zoom { margin-bottom: 10px; }
}

/* Phones: two rows. Our bar full width at the very bottom, Leaflet's corner right above it. */
@media (max-width: 600px) {
  #credits { right: 0; }
  .credits-bar { width: 100%; border-radius: 0; padding-left: 10px; padding-right: 10px; }
  .osm-date { display: none; }
  .leaflet-bottom.leaflet-right { bottom: var(--bar-h, 20px); }
  .leaflet-bottom.leaflet-right .leaflet-control-attribution { padding-bottom: 1px !important; }
  #legend, #sheet { bottom: calc(var(--bar-h, 20px) + var(--attr-h, 20px) + 8px); }
}

/* ---------- data loading overlay ---------- */
/* Centered over the map, under the search bar and sheet. Clicks pass through so the map stays usable. */
#loading { position: fixed; z-index: 999; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(360px, calc(100vw - 32px)); padding: 18px 20px 16px; pointer-events: none;
  background: var(--panel); border: 1.5px solid var(--fg); border-radius: var(--radius); box-shadow: var(--shadow); }
#loading .loading-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  margin: 0 0 12px; font-size: 19px; font-weight: 800; line-height: 1.2; }
#loading-pct { font: 700 15px var(--mono); font-variant-numeric: tabular-nums; }
.loading-track { height: 10px; border: 1.5px solid var(--fg); border-radius: 3px; overflow: hidden; }
#loading-fill { width: 0; height: 100%; background: var(--lead); transition: width .2s linear; }
#loading.indeterminate #loading-fill { width: 35%; animation: loading-slide 1.3s ease-in-out infinite; }
@keyframes loading-slide { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
#loading .loading-sub { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
#loading.failed .loading-track { display: none; }
#loading-retry { margin-top: 12px; pointer-events: auto; }
@media (prefers-reduced-motion: reduce) {
  #loading.indeterminate #loading-fill { width: 100%; animation: none; opacity: 0.35; }
}

/* ---------- load notice (every visit) ---------- */
#notice { max-width: min(440px, calc(100vw - 32px)); padding: 20px 20px 16px; border: 1.5px solid var(--fg);
  border-radius: var(--radius); background: var(--bg); color: var(--fg); box-shadow: var(--shadow); }
#notice::backdrop { background: rgba(20, 18, 14, 0.45); }
#notice .notice-lead { margin: 0 0 12px; padding-left: 12px; border-left: 4px solid var(--lead); font-size: 16px; line-height: 1.45; }
#notice .disclaimer { margin: 0 0 16px; }
#notice form { display: flex; justify-content: flex-end; }

@media (max-width: 599px) { .leaflet-control-zoom { display: none; } }
@media (min-width: 900px) {
  #sheet { left: auto; right: 16px; top: calc(var(--menu-h) + 10px + env(safe-area-inset-top)); bottom: auto; width: 380px;
    max-height: calc(100vh - var(--menu-h) - var(--dock-h) - 20px); }
}

/* Menu bar stays one row at every width (site.css moves the links to a second row on narrow text pages). */
@media (max-width: 460px) {
  .map-masthead nav { order: 0; flex-basis: auto; margin-left: auto; }
  .js .map-masthead .theme-switch { margin-left: -8px; }
}
.map-masthead .wordmark { flex: none; white-space: nowrap; }
@media (max-width: 420px) { .map-masthead { gap: 14px; } .map-masthead nav { gap: 12px; } .wordmark { font-size: 13px; } }
@media (max-width: 400px) { .map-masthead { gap: 10px; } .map-masthead nav { gap: 10px; letter-spacing: 0.03em; } }
/* Smallest phones: the wordmark shrinks to its orange dot (the text stays for screen readers). */
@media (max-width: 359px) { .map-masthead .wordmark { font-size: 0; gap: 0; } .map-masthead .wordmark::before { width: 16px; height: 16px; border-width: 3.5px; } }
