/* Map chrome (docs/DESIGN-SYSTEM.md §6): a full-bleed map with a floating HUD on top (search / "Find your
   neighbourhood", the explorer meter, lens chips), a small tool stack (3D | 2D, layers, whole city), one colour-key
   card and a slim credit strip. Tokens: tokens.css. Parts: components.css. Neutral colours; no red/green good/bad. */
html, body { margin: 0; height: 100%; }
body { display: flex; flex-direction: column; background: var(--c-bg); font-size: var(--fs-base); line-height: 1.4;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body.page-map { height: 100dvh; overflow: hidden; position: relative; }

/* ------------------------------------------------------------------------------------------------
   HUD: brand, search, explorer meter, lens chips */
.hud { position: absolute; top: 0; left: 0; right: 0; z-index: 6; padding: var(--gap); display: flex; align-items: center; gap: 8px; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-pill { height: var(--top-h); border-radius: var(--r-pill); }
#brand { display: flex; align-items: center; gap: 8px; padding: 0 16px 0 10px; flex: none; order: 1; }
.brand-mark { width: 24px; height: 24px; flex: none; background: linear-gradient(160deg, var(--c-accent-2), var(--c-accent));
  clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%); position: relative; }
.brand-mark::after { content: ''; position: absolute; inset: 7px; background: var(--c-gold);
  clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%); }
#topbar h1 { font-size: var(--fs-md); margin: 0; white-space: nowrap; }
/* the search pill is the call to action: a frosted pill with the one gold thing on the screen (its round icon) */
.search-box { position: relative; flex: 0 1 320px; min-width: 190px; display: flex; align-items: center; order: 2; }
.search-ico { position: absolute; left: 6px; width: 34px; height: 34px; padding: 8px; border-radius: 50%; color: var(--c-on-gold); pointer-events: none;
  background: linear-gradient(180deg, var(--c-gold-2), var(--c-gold) 70%); box-shadow: inset 0 0 0 .5px rgba(120, 84, 6, .35), 0 3px 8px -3px rgba(183, 126, 8, .6); }
#search { width: 100%; height: 100%; padding: 0 14px 0 49px; border: 0; background: transparent; border-radius: var(--r-pill); font-size: 16px; min-width: 0;
  font-family: var(--font-display); font-weight: 600; letter-spacing: var(--track-snug); color: var(--c-ink); }
#search::placeholder { color: var(--c-ink); opacity: .8; }
#search:focus-visible { outline-offset: 0; }
#search::-webkit-search-cancel-button { -webkit-appearance: none; }
#search-results, #finder { position: absolute; top: calc(100% + 10px); left: 0; width: max(100%, 300px); max-width: calc(100vw - 2 * var(--gap)); margin: 0; z-index: 10; }
#search-results { padding: 6px; list-style: none; max-height: 60vh; overflow: auto; }
#search-results li { padding: 8px 10px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; font-size: var(--fs-base); border-radius: 10px; }
#search-results li.active, #search-results li:hover { background: var(--c-hover); }
.r-label { font-weight: 600; letter-spacing: var(--track-snug); }
.r-sub { color: var(--c-muted); font-size: var(--fs-xs); }
#finder { padding: 14px; }
.finder-title { margin: 0 0 10px; font-family: var(--font-display); font-weight: var(--fw-display); font-size: var(--fs-l); letter-spacing: var(--track-snug); }
.finder-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.finder-go { width: 100%; }
#explorer { order: 5; flex: none; margin-left: auto; min-width: 84px; justify-content: center; } /* the width is reserved before the count arrives: no layout shift */
#explorer-card { position: absolute; z-index: 8; top: calc(var(--top-h) + 2 * var(--gap)); right: var(--gap); width: min(320px, calc(100% - 2 * var(--gap))); padding: 16px; transform-origin: top right; }
#explorer-card h2 { margin: 8px 0 2px; font-size: var(--fs-xl); letter-spacing: var(--track-tight); }
#explorer-card .progress { margin: 10px 0 6px; }
#explorer-card .ex-actions { display: grid; gap: 8px; margin-top: 12px; }
#lens-dock { order: 3; flex: 1 1 0; min-width: 0; min-height: 40px; }
.lens-buttons { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 6px 4px 12px; margin: -6px -4px -12px; }
.lens-buttons::-webkit-scrollbar { display: none; }
.lens-btn { flex: none; }
.chip-lens .ic { border-radius: 50%; }
.chip-lens.active .ic { box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .9); }

#map { flex: 1; min-height: 0; position: relative; background: var(--c-bg); margin-bottom: var(--foot-h); }
/* first-paint poster: the same areas in the same colours as a flat drawing, placed exactly where the map will
   open. It is on screen while the map engine loads, then fades into the live map (main.js, app.js). */
#poster { position: absolute; left: 0; right: 0; top: 0; bottom: var(--foot-h); z-index: 1; pointer-events: none; overflow: hidden; transition: opacity 420ms var(--ease); }
#poster.out { opacity: 0; }
#poster svg { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
#poster path { stroke: #fff; stroke-width: 1; stroke-linejoin: round; }
#poster path.res { fill-opacity: .86; }
#poster path.nonres { fill-opacity: .6; }

/* ------------------------------------------------------------------------------------------------
   tool stack: 3D | 2D, layers, whole city */
#map-tools { position: absolute; z-index: 4; left: var(--gap); top: calc(var(--top-h) + 2 * var(--gap) + 8px); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
#mode-switch { flex-direction: column; min-width: 44px; min-height: 84px; } /* its size is reserved before its two buttons exist */
#mode-switch button { width: 38px; min-width: 0; padding: 0; }
/* the game's front door (game-polish): a start card with one big gold Start button, drawn with the first view. Gold is
   the page's one "do this next" colour, so it cannot be mistaken for the violet lens chips. Its look lives here and not
   in the game's own late stylesheet, so it is right at the first paint and the same after a game. Folded (.is-mini) it is
   a small gold pill. The pulse is transform and opacity only, and off with reduced motion. */
.quest-start { position: fixed; z-index: 5; left: 50%; bottom: calc(var(--foot-h) + 2 * var(--gap)); transform: translateX(-50%); width: min(400px, calc(100% - 2 * var(--gap)));
  display: grid; gap: 6px; padding: 16px 16px 8px; border-radius: 22px; background: var(--c-surface); color: var(--c-ink); text-align: center;
  box-shadow: 0 0 0 1px var(--c-line-strong), var(--shadow-2); }
.qs-kicker { margin: 0; font-size: var(--fs-2xs); font-weight: 700; letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--c-accent); }
.qs-title { margin: 0; font-family: var(--font-display); font-weight: var(--fw-display); font-size: var(--fs-xl); letter-spacing: var(--track-tight); line-height: 1.15; }
.qs-sub { margin: 0 0 6px; font-size: var(--fs-base); line-height: 1.35; color: var(--c-ink-2); text-wrap: balance; }
.quest-play { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 60px; padding: 0 22px; border: 0; border-radius: 18px;
  background: linear-gradient(180deg, var(--c-gold-2), var(--c-gold) 70%); color: var(--c-on-gold); box-shadow: inset 0 0 0 1.5px var(--c-on-gold), var(--shelf-gold); cursor: pointer;
  font-family: var(--font-display); font-weight: 700; font-size: var(--fs-xl); letter-spacing: var(--track-snug); white-space: nowrap; transition: transform var(--dur-fast) var(--ease); }
.quest-play[hidden] { display: none; }
.quest-play::before { content: ''; border-left: 13px solid currentColor; border-top: 9px solid transparent; border-bottom: 9px solid transparent; }
.quest-play::after { content: ''; position: absolute; inset: -5px; border-radius: 23px; box-shadow: 0 0 0 3px var(--c-gold); opacity: 0; pointer-events: none; animation: qs-pulse 2.4s var(--ease) infinite; }
.quest-play:active { transform: scale(var(--press-scale)); }
.quest-play:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 3px; }
.qs-what { display: none; }
.qs-skip { justify-self: center; min-height: var(--tap); padding: 0 12px; border: 0; background: none; color: var(--c-ink-2); font: inherit; font-size: var(--fs-sm); font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.quest-start.is-mini { display: block; width: max-content; max-width: calc(100% - 2 * var(--gap)); padding: 0; border-radius: var(--r-pill); background: none; box-shadow: none; }
.quest-start.is-mini > :not(.quest-play) { display: none; }
.quest-start.is-mini .quest-play { width: auto; min-height: 48px; padding: 0 20px 0 16px; border-radius: var(--r-pill); font-size: var(--fs-l); }
.quest-start.is-mini .quest-play::before { border-left-width: 10px; border-top-width: 7px; border-bottom-width: 7px; }
.quest-start.is-mini .quest-play::after { border-radius: var(--r-pill); }
.quest-start.is-mini .qs-go { display: none; }
.quest-start.is-mini .qs-what { display: inline; }
.quest-start.is-busy, body.quest-open .quest-start, body.build-open .quest-start { display: none; }
@keyframes qs-pulse { 0% { opacity: .8; transform: scale(.97); } 70%, 100% { opacity: 0; transform: scale(1.05); } }
@media (prefers-reduced-motion: reduce) { .quest-play, .quest-play::after { animation: none; transition: none; } }

/* ------------------------------------------------------------------------------------------------
   colour key card (bottom left): what the colours show, a one-line key; opens upward for the full legend or the layers */
#controls {
  position: absolute; left: var(--gap); bottom: calc(var(--foot-h) + var(--gap)); width: 372px; max-width: calc(100% - 2 * var(--gap));
  max-height: calc(100% - var(--foot-h) - var(--top-h) - 4 * var(--gap)); z-index: 4; display: flex; flex-direction: column-reverse;
  border-radius: 20px; font-size: var(--fs-sm);
}
/* open (the long legend or the layer list): reading text comes first, so the card goes almost solid */
#controls:has(#legend:not([hidden])), #controls:has(#layer-list:not([hidden])) { background: var(--c-overlay); }
#key-bar { padding: 10px 14px 11px; display: flex; flex-direction: column; gap: 7px; flex: none; min-height: 84px; }
#metric-pick { min-height: 26px; }
/* the active metric is real text (the title of what you are looking at); the native select lies over it, unseen */
.metric-pick { display: flex; align-items: center; position: relative; height: 26px; border-radius: 6px; }
.metric-title { flex: 1; min-width: 0; padding-right: 22px; font-family: var(--font-display); font-weight: var(--fw-display); font-size: var(--fs-md); letter-spacing: var(--track-snug);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-pick select { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; border: 0; opacity: 0; font-size: 16px; appearance: none; -webkit-appearance: none; cursor: pointer; }
.metric-pick:has(select:focus-visible) { outline: 2.5px solid var(--c-focus); outline-offset: 3px; }
.metric-pick::after { content: ''; position: absolute; right: 5px; top: 7px; width: 6px; height: 6px; border-right: 2px solid var(--c-muted); border-bottom: 2px solid var(--c-muted);
  transform: rotate(45deg); pointer-events: none; }
#legend-toggle { width: 100%; border: 0; background: transparent; padding: 0; border-radius: var(--r-s); text-align: left; }
#legend-mini { display: block; }
.mini-strip { display: flex; gap: 2px; height: 8px; }
.mini-strip i { flex: 1; border-radius: 2px; box-shadow: inset 0 0 0 .5px var(--c-swatch-edge); }
.mini-strip i:first-child { border-radius: 4px 2px 2px 4px; }
.mini-strip i:last-child { border-radius: 2px 4px 4px 2px; }
.mini-ends { display: flex; justify-content: space-between; gap: 8px; margin-top: 5px; font-size: var(--fs-xs); font-weight: 600; color: var(--c-ink-2); font-variant-numeric: tabular-nums; }
.mini-ends .mini-more { color: var(--c-accent); }
.mini-text { font-size: var(--fs-sm); color: var(--c-ink-2); }
#legend, #layer-list { overflow: auto; padding: 16px 14px 8px; border-bottom: .5px solid var(--c-line-strong); overscroll-behavior: contain; }
#legend h3, #layer-list h3 { font-size: var(--fs-l); margin: 0 0 6px; }
.lg-row { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.lg-row .count { margin-left: auto; color: var(--c-muted); font-variant-numeric: tabular-nums; text-align: right; }
.lg-row .rule { font-size: var(--fs-2xs); max-width: 60%; }
.sw { display: inline-block; width: 20px; height: 12px; box-shadow: inset 0 0 0 .5px var(--c-swatch-edge); border-radius: 4px; flex: none; }
.sw.hatch { background: repeating-linear-gradient(135deg, var(--c-hatch-a) 0 3px, var(--c-hatch-b) 3px 4px); }
.sw.pale { background: var(--c-hatch-a); }
/* the two hatch marks a layer from the list can carry (e.g. zoning on hold / zoned by agreement): they lean opposite ways */
.sw.hatch-a { background: repeating-linear-gradient(135deg, var(--c-surface) 0 3px, var(--c-ink-2) 3px 4px); }
.sw.hatch-b { background: repeating-linear-gradient(45deg, var(--c-surface) 0 3px, var(--c-ink-2) 3px 4px); }
.not-built-msg { color: var(--c-warn-ink); background: var(--c-warn-bg); border: 1px solid var(--c-warn-line); border-radius: var(--r-s); padding: 4px 8px; font-size: var(--fs-sm); }
.explainer { font-size: var(--fs-base); line-height: 1.35; margin: 0 0 8px; }
.legend-words { font-size: var(--fs-sm); color: var(--c-ink-2); margin: 2px 0 6px; }
/* citywide market card (lib/market.js): a separate bordered card, never styled like the map legend swatches */
.market-card { margin: 10px 0 6px; padding: 12px; border-radius: 14px; background: var(--c-surface); box-shadow: var(--ring), var(--shelf); }
.market-card h3 { margin: 0 0 2px; font-size: var(--fs-md); }
.mk-month { margin: 0 0 6px; font-size: var(--fs-xs); color: var(--c-muted); }
.mk-rows { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; }
.mk-row { display: contents; }
.mk-label { font-size: var(--fs-sm); }
.mk-val { font-size: var(--fs-sm); font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.mk-val.null { color: var(--c-muted); font-weight: 400; }
.mk-yoy { grid-column: 1 / -1; margin: -2px 0 3px; font-size: var(--fs-2xs); color: var(--c-muted); text-align: right; }
.mk-more { margin: 6px 0 2px; font-size: var(--fs-sm); }
.mk-more summary, .sides-rule summary { cursor: pointer; color: var(--c-accent); font-weight: 600; }
.mk-more ul { padding-left: 16px; margin: 4px 0; word-break: break-all; font-size: var(--fs-2xs); }
.mk-trend { display: grid; grid-template-columns: 1fr; gap: 1px; margin: 8px 0 0; }
.mk-trend .spark { display: block; max-width: 100%; color: var(--c-accent); }
.mk-trend-cap { font-size: var(--fs-2xs); color: var(--c-muted); font-variant-numeric: tabular-nums; }
.mk-src { margin: 8px 0 2px; }
.mk-scope { margin: 2px 0 4px; font-size: var(--fs-xs); font-weight: 700; }
.sides-rule { margin: 8px 0; font-size: var(--fs-sm); }
.sides-rule ul { padding-left: 16px; margin: 4px 0; }

/* layer chips */
.ly-grid { display: grid; grid-template-columns: 1fr; gap: 6px; margin: 0 0 8px; }
/* fix round: each toggle is a row that says what it shows (name, one plain line, On / Add); the list has a Done button */
.ly-chip { width: 100%; height: auto; min-height: var(--tap); justify-content: flex-start; text-align: left; white-space: normal; padding-top: 6px; padding-bottom: 6px; }
.ly-t { flex: 1 1 auto; min-width: 0; display: grid; gap: 1px; }
.ly-name { font-weight: 600; }
.ly-chip .ly-state { flex: none; white-space: nowrap; }
/* the list has its own heading: the chips' label line steps aside while it is open */
body:has(#layer-list:not([hidden])) .lens-what { display: none; }
.ly-what { font-size: var(--fs-xs); font-weight: 400; color: var(--c-muted); line-height: 1.3; }
.ly-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; position: sticky; top: 0; z-index: 1; background: inherit; }
.ly-head h3 { margin: 0; }
.ly-close { min-height: var(--tap); padding: 6px 16px; font-weight: 700; }
.lens-what { margin: 6px 0 0; padding: 5px 12px; width: fit-content; max-width: 100%; border-radius: var(--r-m); background: var(--c-overlay); color: var(--c-ink); font-size: var(--fs-sm); font-weight: 600; line-height: 1.3; box-shadow: var(--shadow-1); pointer-events: none; }
@media (max-width: 720px) { .lens-what { max-width: calc(100% - var(--tap) - 3 * var(--gap)); } }
/* the dock's box now reaches down beside the tool column: only its own chips take taps, the rest lets them through to the map tools */
#lens-dock { pointer-events: none; }
#lens-dock .lens-buttons { pointer-events: auto; }
/* the game paints the map with its own colours: the colour-by chips step aside while it is open (they would change nothing on screen) */
body.quest-open:not(.quest-detail) #lens-dock { display: none; }
.tool-cap { display: block; font-family: var(--font-display); font-weight: 700; font-size: 9.5px; line-height: 1.05; letter-spacing: 0; }
.tool-btn.build-entry.has-cap { width: auto; min-width: var(--tap); padding: 6px 8px 5px; }
.tool-btn.has-cap { height: auto; min-height: var(--tap); padding: 5px 2px 4px; display: grid; justify-items: center; gap: 1px; }
.ly-group { font-size: var(--fs-2xs); font-weight: 700; letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--c-muted); margin: 12px 0 6px; }
.ly-chip .ly-dot { width: 12px; height: 12px; border-radius: 50%; margin: 0 2px 0 6px; flex: none; background: var(--c-muted); opacity: .45; }
.ly-chip[aria-pressed="true"] .ly-dot { opacity: 1; }
/* game-polish: "Add to map". Each chip says its state in words with a plus or a tick; on = a thick outline too */
.ly-lede { margin: 0 0 8px; }
.ly-now { margin: 0 0 4px; padding: 8px 10px; border-radius: var(--r-m); background: var(--c-surface-2); }
.ly-now .ly-group { margin-top: 0; }
.ly-now .note { margin: 0; }
.ly-state { margin-left: 2px; padding: 1px 8px; border-radius: var(--r-pill); box-shadow: inset 0 0 0 1px var(--c-control-edge); font-size: var(--fs-xs); font-weight: 700; color: var(--c-ink-2); }
.ly-state::before { content: '+ '; }
.ly-chip[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--c-accent); }
.ly-chip[aria-pressed="true"] .ly-state { background: var(--c-accent); color: var(--c-on-accent); box-shadow: none; }
.ly-chip[aria-pressed="true"] .ly-state::before { content: '✓ '; }
.ly-more { margin: -2px 0 6px; }
.ly-more > summary { cursor: pointer; font-size: var(--fs-xs); font-weight: 700; color: var(--c-accent); padding: 4px 0; }
.ly-detail { margin: 6px 0 8px; padding: 8px 10px; background: var(--c-surface-2); border-radius: var(--r-m); }
.ly-detail h4 { margin: 0 0 4px; font-family: var(--font-ui); font-size: var(--fs-sm); font-weight: 700; }
.ly-swatches { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: var(--fs-xs); color: var(--c-ink-2); }
.ly-sw { display: inline-flex; align-items: center; gap: 4px; }
.ly-filter { display: block; margin: 6px 0 0; font-size: var(--fs-sm); }
.ly-filter select { max-width: 100%; height: 34px; border: 1px solid var(--c-line-strong); border-radius: var(--r-s); background: var(--c-surface); padding: 0 6px; }

/* ------------------------------------------------------------------------------------------------
   tooltip, status, selftest */
#tooltip { position: fixed; z-index: 7; pointer-events: none; background: var(--c-tooltip); color: var(--c-on-tooltip); border-radius: var(--r-m);
  padding: 8px 12px; font-size: var(--fs-sm); max-width: 280px; box-shadow: var(--shadow-2); top: 0; left: 0; }
.tt-name { font-family: var(--font-display); font-weight: var(--fw-display); font-size: var(--fs-base); letter-spacing: var(--track-snug); }
.tt-src { opacity: .7; font-size: var(--fs-2xs); }
#status { position: absolute; left: 50%; bottom: calc(var(--foot-h) + 14px); transform: translateX(-50%); z-index: 8; cursor: pointer;
  background: var(--c-warn-bg); color: var(--c-warn-ink); border: 1px solid var(--c-warn-line); border-radius: var(--r-m); padding: 8px 14px; font-size: var(--fs-sm);
  display: none; max-width: min(90vw, 720px); box-shadow: var(--shadow-1); }
#status.show { display: block; }
#selftest { position: absolute; left: 10px; bottom: calc(var(--foot-h) + 10px); z-index: 9; max-height: 40vh; overflow: auto; max-width: 520px;
  background: var(--c-selftest-bg); color: var(--c-selftest-ink); font-size: 11px; padding: 8px; border-radius: 6px; margin: 0; }

/* HTML map labels (side names; fallback names when the basemap has no glyph server) */
.map-label { pointer-events: none; white-space: nowrap; text-align: center; }
.side-label { font-size: 9.5px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; color: var(--c-ink); padding: 5px 10px 5px 11px;
  border-radius: var(--r-pill); background: rgba(255, 255, 255, .84); box-shadow: inset 0 0 0 .5px rgba(255, 255, 255, .9), 0 0 0 .5px rgba(28, 26, 38, .1), 0 4px 10px -4px rgba(28, 26, 38, .4); }
body:not(.z-sides) .side-marker, body.layer-off-sides .side-marker, body:not(.z-12) .side-small { display: none; }
.side-small { font-size: 9px; max-width: 170px; white-space: normal; border-radius: var(--r-m); }
.name-label { font-size: 11px; font-weight: 700; color: var(--c-map-label); padding: 2px 8px; border-radius: var(--r-pill); background: var(--c-label-plate); }
.river-label { font-size: 13px; font-style: italic; color: var(--c-river-label); text-shadow: 0 0 3px var(--c-map-halo); }
.bridge-label { font-size: 10.5px; color: var(--c-map-label); background: var(--c-label-plate); padding: 0 3px; border-radius: 3px; }
body:not(.z-12) .fallback-marker.name-label, body:not(.z-12) .fallback-marker.bridge-label { display: none; }
body.mode-game .fallback-marker.name-label, body.layer-off-bridges .fallback-marker.bridge-label,
body.layer-off-water .fallback-marker.river-label { display: none; }
.search-pin { width: 26px; height: 34px; background: var(--c-accent); clip-path: path('M13 0C6 0 0 6 0 13c0 9 13 21 13 21s13-12 13-21C26 6 20 0 13 0z');
  border: 0; box-shadow: none; pointer-events: none; }
.search-pin::after { content: ''; position: absolute; left: 8px; top: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--c-gold); }
/* declutter (web/js/lib/declutter.js): overlapped HTML markers are hidden, still measured */
.dc-hidden { visibility: hidden !important; pointer-events: none !important; }

/* map controls: soft round buttons; the attribution stays one tap away on the map and in full in the credit strip */
.maplibregl-ctrl-group { border-radius: 14px !important; box-shadow: var(--shadow-1) !important; overflow: hidden; }
.maplibregl-ctrl-group button { width: 38px; height: 38px; }
.maplibregl-ctrl-attrib { font-size: 10.5px; }
.maplibregl-ctrl-bottom-right { z-index: 3; }
.maplibregl-canvas:focus-visible { outline: none; }

/* lite view (no WebGL): the same areas as a flat drawing */
.lite-map { position: absolute; inset: 0; width: 100%; height: 100%; padding: calc(var(--top-h) + 76px) 12px 110px; touch-action: manipulation; }
.lite-map path.area { stroke: #fff; stroke-width: 1.2; vector-effect: non-scaling-stroke; cursor: pointer; transition: opacity var(--dur-fast) var(--ease); }
.lite-map path.area:hover { opacity: .82; }
.lite-map path.area.sel { stroke: var(--c-ink); stroke-width: 2.5; }
.lite-map path.water { fill: var(--c-water); stroke: none; pointer-events: none; }

/* ------------------------------------------------------------------------------------------------
   footer: always visible; "Credits" opens the full data attribution */
#footer {
  height: var(--foot-h); display: flex; flex-wrap: nowrap; gap: 4px 12px; align-items: center; padding: 4px 12px; z-index: 7;
  position: absolute; left: 0; right: 0; bottom: 0; /* out of the flow, so opening the credits never resizes the map */
  box-shadow: 0 -.5px 0 rgba(28, 26, 38, .12); font-size: var(--fs-xs); color: var(--c-muted); background: var(--c-surface);
}
#footer-text { color: var(--c-ink); font-weight: 600; font-size: var(--fs-sm); letter-spacing: var(--track-snug); white-space: nowrap; }
#disclaimer { white-space: nowrap; }
#data-attribution { flex: 1 1 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.footer-link { flex: none; font-weight: 600; text-decoration: none; }
#credits-toggle { flex: none; border: 0; background: var(--c-chip); color: var(--c-accent); font-weight: 600; font-size: var(--fs-xs); padding: 4px 10px; border-radius: var(--r-pill); }
#footer.expanded { flex-wrap: wrap; height: auto; max-height: 45vh; overflow: auto; padding-bottom: 8px; box-shadow: var(--shadow-2); }
#footer.expanded #data-attribution, #footer.expanded #disclaimer { white-space: normal; overflow: visible; flex-basis: 100%; order: 3; }
/* hasansharif.ca: the basemap credit sits with the data credits (shown when Credits is open, always on the sources page) */
#basemap-credit { display: none; }
#footer.expanded #basemap-credit, body.sources #basemap-credit { display: block; flex-basis: 100%; order: 3; white-space: normal; font-size: var(--fs-2xs); }
.map-guide { flex: none; }
.footer-guide-btn { list-style: none; cursor: pointer; font-weight: 600; font-size: var(--fs-xs); color: var(--c-accent); padding: 4px 10px; border-radius: var(--r-pill); background: var(--c-chip); }
.footer-guide-btn::-webkit-details-marker { display: none; }
.map-guide-body { position: fixed; right: 12px; bottom: calc(var(--foot-h) + 10px); width: min(560px, calc(100vw - 24px)); max-height: 62vh; overflow: auto; z-index: 9; padding: 16px 18px; color: var(--c-ink); font-size: var(--fs-sm); line-height: 1.5; }
.map-guide-body h2 { margin: 0 0 8px; font-size: var(--fs-l); }
.map-guide-body h3 { margin: 14px 0 6px; font-size: var(--fs-base); }
.map-guide-body p { margin: 0 0 8px; }
.map-guide-body ul { margin: 0 0 8px; padding-left: 18px; }
.map-guide-body li { margin-bottom: 4px; }

/* ------------------------------------------------------------------------------------------------
   phone: one-handed. Row 1 = search + meter, row 2 = lens chips; tools on the right edge; the key above the credit strip. */
@media (max-width: 720px) {
  .hud { flex-wrap: wrap; row-gap: 10px; }
  #brand { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); box-shadow: none; }
  #brand #fixture-badge { position: fixed; top: 2px; left: 50%; transform: translateX(-50%); z-index: 9; }
  .search-box { flex: 1 1 0; min-width: 0; }
  #explorer { order: 3; margin-left: 0; }
  #lens-dock { order: 4; flex: 0 0 100%; }
  .chip-lens { height: 36px; }
  #search-results li { padding: 10px 12px; }
  #map-tools { left: auto; right: var(--gap); top: calc(var(--top-h) + 38px + 3 * var(--gap) + 12px); align-items: flex-end; }
  /* the front door on a phone. Open: a card across the bottom, in thumb reach; the colour key steps aside and its box stays as a
     spacer of the card's height (--qs-pad), so the city is fitted above the card. Folded: the gold pill floats above the colour
     key (its bar is 84 px tall) and steps aside while the long legend or the layer list is open, or an area's panel is up. */
  .quest-start { left: var(--gap); right: var(--gap); bottom: calc(var(--foot-h) + var(--gap)); width: auto; transform: none; }
  .quest-start.is-mini { left: 0; right: 0; margin-inline: auto; bottom: calc(var(--foot-h) + 2 * var(--gap) + 84px); }
  .quest-start.is-mini[data-view="lite"] { bottom: calc(var(--foot-h) + var(--gap) + 60px); }
  /* Lite's own buttons (List, zoom, Build) ride above the open card instead of under it */
  body.qs-open.view-lite .lite-btn, body.qs-open.view-lite .lite-zoom { bottom: calc(var(--qs-pad, 0px) + 2 * var(--gap)); }
  body.qs-open:not(.view-lite) #controls { display: block; visibility: hidden; pointer-events: none; height: var(--qs-pad, 0px); min-height: 0; overflow: hidden; }
  body:has(#legend:not([hidden])) .quest-start, body:has(#layer-list:not([hidden])) .quest-start, body.panel-open .quest-start { display: none; }
  #explorer-card { top: calc(var(--top-h) + 2 * var(--gap) + 4px); }
  #controls { right: var(--gap); width: auto; max-width: none; max-height: calc(100% - var(--foot-h) - 140px); }
  body.panel-open #controls, body.panel-open #map-tools { display: none; }
  body.panel-open .lite-map { padding-bottom: 60vh; }
  #footer { flex-wrap: wrap; align-content: center; gap: 0 10px; padding: 3px 10px; height: var(--foot-h); overflow: hidden; }
  #footer-text { font-size: var(--fs-xs); flex-basis: calc(100% - 196px); }
  #disclaimer { font-size: var(--fs-2xs); flex-basis: calc(100% - 196px); }
  #data-attribution { display: none; }
  .map-guide { position: absolute; right: 136px; top: 6px; }
  .map-guide-body { left: 12px; right: 12px; width: auto; }
  .footer-link { position: absolute; right: 82px; top: 9px; }
  #credits-toggle { position: absolute; right: 8px; top: 6px; }
  #footer.expanded #data-attribution { display: block; font-size: var(--fs-2xs); margin-top: 4px; }
  #footer.expanded .map-guide, #footer.expanded .footer-link, #footer.expanded #credits-toggle { position: static; }
  .maplibregl-ctrl-top-left, .maplibregl-ctrl-top-right { display: none; }
  .maplibregl-ctrl-bottom-right .maplibregl-ctrl-group { display: none; }
  .maplibregl-ctrl-bottom-right { bottom: 100px; }
  body.panel-open .maplibregl-ctrl-bottom-right { display: none; }
  #toasts { top: calc(var(--top-h) + 38px + 3 * var(--gap) + 10px); }
}
@media (max-width: 350px) {
  .meter { padding: 0 10px 0 6px; }
  #explorer-total { display: none; }
  #explorer { min-width: 62px; }
  #search { padding: 0 6px 0 42px; letter-spacing: -.02em; text-overflow: ellipsis; } /* still 16 px: a smaller input makes phones zoom on focus */
  .search-ico { left: 6px; width: 30px; height: 30px; padding: 7px; }
  #footer:not(.expanded) .map-guide, #footer:not(.expanded) .footer-link { display: none; }
  #footer-text, #disclaimer { flex-basis: calc(100% - 76px); }
}

/* ------------------------------------------------------------------------------------------------
   shell states (game-0): data on demand, the Lite | Full switch, notices with one action */
#search-results li.r-loading { cursor: default; color: var(--c-muted); }
.link-btn { border: 0; background: none; padding: 0; color: var(--c-accent); text-decoration: underline; cursor: pointer; font: inherit; font-weight: 600; }
.ly-chip.is-loading { opacity: .65; }
.ly-error { margin: 0 0 8px; padding: 6px 10px; font-size: var(--fs-sm); color: var(--c-warn-ink); background: var(--c-warn-bg); border-radius: var(--r-s); }
#view-switch .vs-text { line-height: 1.05; text-align: center; }
#view-switch .vs-text { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-xs); letter-spacing: var(--track-snug); }
.share-url { width: 100%; margin-top: 8px; font-size: var(--fs-sm); }
/* a notice that says why and offers the other view; it has no timer (WCAG 2.2.1), so it has a close button */
/* centred without a transform (game-4): the pop-in animation sets `transform`, which wiped translateX(-50%) and pushed the
   toast past the right edge (the page could pan sideways); left: 50% also squeezed its text to half the screen */
#toast { position: absolute; z-index: 9; left: 0; right: 0; margin-inline: auto; width: max-content; top: calc(var(--top-h) + 2 * var(--gap) + 4px);
  max-width: min(94vw, 560px); padding: 6px 6px 6px 16px; gap: 10px; border-radius: var(--r-l); }
.toast-offer .toast-text { flex: 1; line-height: 1.3; }
.toast-action { border: 0; background: var(--c-surface); color: var(--c-ink); border-radius: var(--r-pill); padding: 0 14px; min-height: 36px;
  font-family: var(--font-display); font-weight: var(--fw-display); white-space: nowrap; cursor: pointer; transition: transform var(--dur-fast) var(--ease); }
.toast-action:active { transform: scale(var(--press-scale)); }
.toast-close { border: 0; background: none; color: inherit; opacity: .75; font-size: 22px; line-height: 1; min-width: 36px; min-height: 36px; cursor: pointer; }
/* game-4: a picked area's mark on the full map (My areas). game-polish: a gold badge with a tick and the name, ringed in
   white and edged in ink so it reads on every fill; tokens only, transform/opacity only, still with reduced motion */
.pick-flag { pointer-events: none; padding-bottom: 16px; } /* the marker box: the badge sits just above the area's own name */
.pick-badge { display: inline-flex; align-items: center; gap: 5px; max-width: 168px; padding: 3px 10px 3px 4px; border-radius: var(--r-pill);
  background: var(--c-gold); color: var(--c-on-gold); font-family: var(--font-display); font-weight: 700; font-size: var(--fs-sm); line-height: 1.2;
  box-shadow: 0 0 0 1.5px var(--c-on-gold), 0 0 0 3.5px var(--c-surface), var(--shadow-2); animation: pick-flag-in var(--dur-pop) var(--ease-pop) both; }
.pick-flag-pin { flex: none; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--c-on-gold); color: var(--c-gold); font-size: 13px; line-height: 1; }
.pick-flag-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes pick-flag-in { from { opacity: 0; transform: translateY(6px) scale(.7); } }
@media (prefers-reduced-motion: reduce) { .pick-badge { animation: none; } }
/* ?fps=1: a small frame meter for the phone check (GAME-PLAN §23.3); nothing is sent anywhere */
#fps-meter { position: fixed; right: 8px; bottom: calc(var(--foot-h) + 8px); z-index: 10; pointer-events: none; font: 600 12px var(--font-ui);
  background: var(--c-tooltip); color: var(--c-on-tooltip); padding: 2px 6px; border-radius: var(--r-s); font-variant-numeric: tabular-nums; }
/* the dark token set (?theme=dark, a test hook until a dark map skin exists): MapLibre's own controls follow it */
:root[data-theme="dark"] .maplibregl-ctrl.maplibregl-ctrl-attrib { background-color: var(--c-label-plate); color: var(--c-ink-2); }
:root[data-theme="dark"] .maplibregl-ctrl-attrib a { color: var(--c-ink); }
:root[data-theme="dark"] .maplibregl-ctrl-group { background: var(--c-surface); }
:root[data-theme="dark"] .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }
@media (max-width: 720px) {
  #toast { top: auto; bottom: calc(var(--foot-h) + 70px); }
  body.panel-open #toast { display: none; }
  /* while the game's sheet is up, the notice sits under the top bar, never over the sheet's buttons (game-4) */
  body.quest-open #toast { top: calc(var(--top-h) + 2 * var(--gap) + 4px); bottom: auto; }
  /* fix round: with the start card open the notice sat on its Start button ("Feels slow? Try Lite mode." on a slow phone, exactly
     when a clear Start matters most): it goes to the top there too */
  body.qs-open #toast { top: calc(var(--top-h) + 2 * var(--gap) + 4px); bottom: auto; }
}

/* ------------------------------------------------------------------------------------------------
   sources page */
body.sources { display: block; overflow: auto; height: auto; background: var(--c-surface-2); }
body.sources #topbar { position: sticky; top: 0; display: flex; align-items: center; gap: 12px; z-index: 6; background: var(--c-surface); box-shadow: var(--shadow-1); padding: 10px 16px; }
body.sources #topbar h1 { font-size: var(--fs-xl); margin: 0; }
body.sources #topbar nav { margin-left: auto; }
body.sources #topbar nav a { font-weight: 600; text-decoration: none; }
.sources main { max-width: 960px; margin: 0 auto; padding: 16px; }
.sources h2 { margin-top: 28px; font-size: var(--fs-xl); }
.sources #sources, .sources #excluded { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(380px, 100%), 1fr)); gap: 12px; }
.sources .card { border-radius: var(--r-l); padding: 14px 16px; margin: 0 0 12px; background: var(--c-surface); min-width: 0; box-shadow: var(--ring), var(--shelf); }
.sources #sources .card, .sources #excluded .card { margin: 0; }
.sources .card h3 { margin: 0 0 6px; font-size: var(--fs-l); }
.sources .card p { margin: 3px 0; font-size: var(--fs-sm); }
.sources .card a, .sources .card code { overflow-wrap: anywhere; word-break: break-word; }
.sources code { font-size: 12px; }
.sources table { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); }
.sources th, .sources td { border-bottom: 1px solid var(--c-line); padding: 4px 6px; text-align: left; vertical-align: top; }
.sources .lvl-WARN { color: #7a5a00; font-weight: 600; }
.sources .lvl-FAIL { color: #8a1f11; font-weight: 700; }
.sources .lvl-NOTE { color: #2f4f7a; }
.sources .toc a { margin-right: 12px; }
body.sources #footer { position: static; flex-wrap: wrap; height: auto; }
body.sources #data-attribution { white-space: normal; display: block; }

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