/* /map/ — Where to go. DESIGN-ROOM §8: borders only (no shadows), mono for chips, credits and numbers. */
:root {
  --map-surface: #0f1828; --map-line: #2b3548; --map-soft: #162238; --map-muted: #a9b0bc;
  /* one colour per category (with one shape per category; never colour alone) */
  --c-shelters: #7bd3c8; --c-fire-stations: #f0af62; --c-pharmacies: #8ab6e8; --c-hospitals: #e39aab;
}
:root[data-theme=light] {
  --map-surface: #fff; --map-soft: #ece9e2; --map-line: #cfc9bf; --map-muted: #4e4b46;
  --c-shelters: #0f6b63; --c-fire-stations: #9a5200; --c-pharmacies: #2a5d9f; --c-hospitals: #a33a52;
}
.map-page { margin: 0; background: var(--bg); color: var(--ink); font: 400 var(--t3)/1.45 var(--sans); overflow: hidden; }
.map-page * { box-sizing: border-box; }
:where(.map-page) button, :where(.map-page) input { font: inherit; }
.map-page a { color: inherit; text-underline-offset: .18em; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.map-main { position: relative; height: calc(100svh - var(--eb-h, 64px) - var(--dock-h, 0px)); min-height: 360px; }
/* #map is its own stacking context, so Leaflet's z-index 400–1000 panes and controls stay under every panel (UX-4) */
.map-main > #map { position: absolute; inset: 0; z-index: 0; isolation: isolate; background: var(--map-soft); }
.map-ui, .map-bottom, .map-sheet, .map-about-body, .map-results { border: 1px solid var(--map-line); background: var(--map-surface); }

/* ---- controls panel ---- */
.map-ui { position: absolute; z-index: 5; top: 12px; left: 12px; width: min(400px, calc(100% - 24px)); padding: 14px; }
.map-offline { margin: -14px -14px 12px; padding: 8px 14px; border-bottom: 1px solid var(--lit); color: var(--ink); font: 500 var(--t1)/1.3 var(--sans); }
.map-title { margin: 0 0 10px; font-size: var(--t5); font-weight: 500; letter-spacing: -.03em; line-height: 1.1; }
.map-row { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 8px; }
.map-search { display: grid; flex: 1; gap: 4px; min-width: 0; font: var(--t1)/1.2 var(--mono); }
.map-search input { width: 100%; height: 44px; padding: 8px 10px; border: 1px solid var(--map-line); border-radius: 3px; background: var(--map-soft); color: var(--ink); font: 400 var(--t3)/1.2 var(--sans); }
.map-near, .map-list, .map-save, .sheet-action, .map-results-list button, .map-results-close {
  display: inline-flex; align-items: center; min-height: 44px; padding: 8px 12px; border: 1px solid var(--map-line); border-radius: 3px;
  background: transparent; color: var(--ink); cursor: pointer; text-align: left; text-decoration: none; font: 600 var(--t1)/1.15 var(--mono);
}
.map-near { flex: none; justify-content: center; }
.map-chiprow { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.map-layers { display: flex; flex-wrap: wrap; gap: 6px; }
.map-layers button { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 10px 6px 6px; border: 1px solid var(--map-line); border-radius: 3px; background: transparent; color: var(--ink); font: 600 var(--t1)/1.1 var(--mono); cursor: pointer; white-space: nowrap; }
.map-layers button[aria-pressed=false] { opacity: .5; text-decoration: line-through; }
.map-layers .map-pin { width: 28px; height: 28px; }
.map-status { margin: 10px 0 0; color: var(--map-muted); font-size: var(--t1); }
.map-results { margin-top: 8px; padding: 8px; }
.map-results[hidden] { display: none; }
.map-results-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.map-results-head p { margin: 0; font: 600 var(--t1)/1.2 var(--mono); }
.map-results-list { display: grid; gap: 5px; max-height: 255px; margin-top: 8px; overflow: auto; }
.map-results-list button { width: 100%; font: 400 var(--t1)/1.25 var(--sans); }
.map-results-list p { margin: 4px 0 0; color: var(--map-muted); font-size: var(--t1); }

/* ---- pins: a ring (one shape per category) holding the category pictogram ---- */
.map-pin { display: block; width: 44px; height: 44px; color: var(--c-shelters); }
.map-pin.fire-stations { color: var(--c-fire-stations); }
.map-pin.pharmacies { color: var(--c-pharmacies); }
.map-pin.hospitals { color: var(--c-hospitals); }
/* The pictogram lives in the sprite; <use> clones it into a shadow tree, so it is styled by inheritance
   (fill/stroke on the svg) plus sprite-level rules keyed on its own classes. */
.map-pin svg { display: block; width: 100%; height: 100%; overflow: visible; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.map-pin .ring { fill: var(--map-surface); stroke: currentColor; stroke-width: 3; }
.sprite .pg * { vector-effect: non-scaling-stroke; }
.sprite .pg .pa { stroke: var(--picto-accent, currentColor); }
.sprite .pg .paf { fill: var(--picto-accent, currentColor); fill-opacity: .25; stroke: none; }
.map-pin.under-renovation { opacity: .6; }
.map-pin.under-renovation .ring { stroke-dasharray: 5 4; }
.map-pin.is-active .ring { stroke: var(--ink); stroke-width: 5; }
.leaflet-marker-icon.map-marker-wrap { background: transparent; border: 0; }
/* clusters: a solid disc with a mono count — distinct from every category ring */
.map-cluster { display: grid; place-items: center; width: 44px; height: 44px; border: 2px solid var(--map-surface); border-radius: 50%; background: var(--ink); color: var(--map-surface); font: 600 var(--t1)/1 var(--mono); }
.leaflet-container { font: inherit; }
.leaflet-control-zoom a { width: 44px !important; height: 44px !important; line-height: 42px !important; }

/* ---- place sheet ---- */
.map-sheet { position: absolute; z-index: 6; right: 12px; top: 12px; bottom: 12px; display: flex; flex-direction: column; width: min(430px, calc(100% - 24px)); padding: 20px 18px; overflow: hidden; }
.map-sheet[hidden] { display: none !important; }
.map-sheet-body { min-height: 0; overflow: auto; }
.sheet-close { position: absolute; top: 10px; right: 10px; width: 44px; height: 44px; border: 1px solid var(--map-line); background: var(--map-soft); color: var(--ink); font-size: var(--t4); cursor: pointer; }
.sheet-picto { width: 96px; height: 96px; margin: 0 0 12px; }
/* the sheet's large pictogram keeps the site's one amber accent (§10) */
.sheet-picto { --picto-accent: var(--lit); }
.map-sheet h2 { margin: 0 52px 8px 0; font-size: var(--t5); font-weight: 500; line-height: 1.1; }
.map-sheet p { margin: 8px 0; }
.sheet-kind { font: 600 var(--t1)/1.2 var(--mono); text-transform: uppercase; letter-spacing: .04em; color: var(--map-muted); }
.warning { color: var(--alert); }
.meta, .capacity, .coords { font: 400 var(--t1)/1.35 var(--mono); color: var(--map-muted); }
.capacity { color: var(--ink); }
.sheet-actions { display: grid; gap: 8px; margin: 14px 0; }
.sheet-action { justify-content: center; width: 100%; text-align: center; }
.map-sheet-foot { display: none; }

/* ---- about + attribution bar (always visible, every viewport: UX-1 / D3) ---- */
.map-bottom { position: absolute; z-index: 7; left: 12px; bottom: 12px; display: flex; align-items: center; gap: 10px; width: min(560px, calc(100% - 24px)); padding: 6px 10px 6px 6px; }
.map-about { flex: none; }
.map-about summary { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border: 1px solid var(--map-line); border-radius: 3px; cursor: pointer; font: 600 var(--t1)/1.1 var(--mono); list-style: none; white-space: nowrap; }
.map-about summary::-webkit-details-marker { display: none; }
.map-about[open] summary { background: var(--map-soft); }
.map-about-body { position: absolute; left: -1px; bottom: calc(100% + 6px); width: min(560px, calc(100vw - 24px)); max-height: min(70svh, calc(100svh - 220px)); padding: 12px 14px; overflow: auto; }
.map-honesty { margin: 0; padding: 0 0 0 18px; font-size: var(--t1); color: var(--ink); }
.map-honesty li + li { margin-top: 6px; }
.map-save { margin-top: 12px; }
.map-progress { margin: 8px 0 0; color: var(--map-muted); font-size: var(--t1); }
.map-progress:empty { display: none; }
.map-attribution { flex: 1; min-width: 0; margin: 0; font: 400 11px/1.35 var(--mono); color: var(--map-muted); }
.map-attribution a { color: var(--ink); }

.map-page :focus-visible { outline: 3px solid var(--lit); outline-offset: 2px; }

/* ---- phones: a compact controls bar (search + Near me, one scrolling chip row), the about/credit bar at the
   foot, results and place details as bottom sheets above it, no zoom buttons (pinch) — UX-3 ---- */
@media (max-width: 1023.98px) {
  .map-ui { top: 8px; left: 8px; width: calc(100% - 16px); padding: 8px; }
  .map-offline { margin: -8px -8px 8px; padding: 6px 8px; }
  .map-title, .map-search-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .map-chiprow { flex-wrap: nowrap; margin: 6px -8px 0; padding: 0 8px 2px; overflow-x: auto; scrollbar-width: none; }
  .map-layers { flex-wrap: nowrap; }
  .map-list { flex: none; white-space: nowrap; }
  .map-status { margin-top: 6px; line-height: 1.3; }
  .map-results { position: fixed; z-index: 8; left: 0; right: 0; bottom: var(--bar-top, 56px); max-height: 32svh; margin: 0; display: flex; flex-direction: column; border-width: 1px 0; }
  .map-results[hidden] { display: none; }
  .map-results-list { max-height: none; flex: 1; min-height: 0; }
  /* while a result list is open the chips and the status line fold away: the list title says the same */
  .results-open .map-chiprow, .results-open .map-status { display: none; }
  .map-results { padding: 6px 8px; }
  .map-results-head p { flex: 1; min-width: 0; font-size: 12px; }
  .map-results-close { flex: none; min-height: 44px; padding: 4px 10px; }
  .map-results-list { margin-top: 6px; }
  .map-results-list button { min-height: 44px; padding: 6px 10px; }
  .map-bottom { left: 0; right: 0; bottom: 0; width: auto; gap: 8px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-width: 1px 0 0; }
  .map-about-body { position: fixed; left: 0; right: 0; bottom: var(--bar-top, 56px); width: auto; max-height: 62svh; border-width: 1px 0; }
  .map-about summary { width: 76px; padding: 0 6px; justify-content: center; text-align: center; white-space: normal; line-height: 1.15; }
  .map-attribution { font-size: 10px; line-height: 1.3; }
  .map-layers button { gap: 4px; padding: 4px 8px 4px 4px; font-size: 12px; }
  .map-layers .map-pin { width: 26px; height: 26px; }
  .map-sheet { top: auto; left: 0; right: 0; bottom: var(--bar-h, 0px); width: auto; max-height: 68%; padding: 16px 16px 0; border-width: 1px 0; }
  .map-sheet-foot { display: flex; align-items: stretch; gap: 6px; flex: none; margin: 12px -16px 0; padding: 5px 8px calc(5px + env(safe-area-inset-bottom)); border-top: 1px solid var(--map-line); background: var(--map-surface); }
  .map-sheet-foot .sf-sirens, .map-sheet-foot .sf-112 { display: flex; align-items: center; min-height: 48px; text-decoration: none; }
  .map-sheet-foot .sf-sirens { flex: 0 0 auto; min-width: 76px; max-width: 92px; justify-content: center; padding: 0 10px; background: var(--lit); color: var(--on-lit); font: 700 14px/1.05 var(--sans); text-align: center; }
  .map-sheet-foot .sf-112 { flex: 1 1 auto; gap: 10px; justify-content: flex-start; padding: 0 10px; border: 1px solid var(--ink); color: var(--ink); font-size: var(--t2); line-height: 1.1; }
  .map-sheet-foot .sf-112 b { font-size: 17px; line-height: 1; }
  .map-sheet-foot .sf-note { display: block; }
  .sheet-picto { width: 72px; height: 72px; }
  .sheet-open .map-ui, .sheet-open .map-results { display: none; }
  .leaflet-control-zoom { display: none; }
}
@media (max-width: 399.98px) {
  .map-row .map-list { flex-basis: 100%; justify-content: center; }
  .map-sheet-foot .sf-sirens { min-width: 70px; max-width: 74px; padding: 0 6px; }
  .map-sheet-foot .sf-112 { gap: 7px; padding: 0 7px; font-size: 14px; }
}
@media (max-height: 499.98px) and (orientation: landscape) {
  .map-page { overflow: auto; }
  .map-main { height: calc(100svh - var(--eb-h, 64px) - var(--dock-h, 0px)); min-height: 0; }
}
/* below 1024 the site's dock steps aside while a sheet is open, so the map takes its height (UX-15) */
@media (max-width: 1023.98px) { html.sheet-open { --dock-h: 0px; } }
html.sheet-open .leaflet-control-zoom { display: none; }
@media (prefers-reduced-motion: reduce) { .map-page * { transition: none !important; animation: none !important; } }
@media print { .map-ui, .map-sheet, .leaflet-control-container { display: none !important; } .map-main { height: 70vh; } .map-page { overflow: visible; } }
.sheet-picto .map-pin { width: 100%; height: 100%; }
.sheet-picto .ring { stroke-width: 1.25; }
.sheet-picto svg { stroke-width: 2; }

.skip-link{position:fixed;z-index:700;top:8px;left:8px;padding:10px 16px;background:var(--surface);transform:translateY(-160%)}
.skip-link:focus{transform:none}
