/* map — page-local rules (★#59 M5). Moved verbatim from map.html's inline <style>; linked after the Leaflet vendor CSS so its overrides keep their source order. */
body { margin: 0; font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); }
/* NB: --page-pad is a 3-value shorthand (8px 20px 72px) — using it inside another
   shorthand position mis-expands (72px became the LEFT pad). Literal values here. */
.map-wrap { max-width: var(--page-max); margin: 0 auto 14px; padding: 0 20px 20px; position: relative; z-index: 0; }
#kkmap { height: clamp(380px, 60vh, 560px); width: 100%; border-radius: var(--radius-lg);
         border: 1px solid var(--border); background: var(--surface-alt); }
.map-legend { font-size: 13px; color: var(--text-muted); display: flex; align-items: center;
              gap: 16px; margin-top: 12px; flex-wrap: wrap; }
.map-legend .dot { background: var(--accent); border: 1px solid var(--surface); border-radius: 50%;
                   display: inline-block; vertical-align: middle; margin-right: 6px; }
.map-legend .dot-lg { width: 18px; height: 18px; }
.map-legend .dot-sm { width: 9px; height: 9px; }
.map-note { font-size: 12px; color: var(--text-subtle); margin-top: 8px; display: flex;
            gap: 6px; align-items: flex-start; line-height: 1.5; }
.kk-pop { font-family: 'Inter', system-ui, sans-serif; min-width: 150px; }
.kk-pop strong { display: block; margin-bottom: 4px; font-size: 14px; color: var(--text); }
.kk-pop .row { font-size: 13px; color: var(--text-muted); }
.kk-pop a { color: var(--accent); font-weight: 600; display: inline-block; margin-top: 8px; text-decoration: none; }
.kk-maplabel.kk-tier1, .kk-maplabel.kk-tier2 { display: none; }
.kk-z-mid .kk-maplabel.kk-tier1 { display: block; }
.kk-z-hi  .kk-maplabel.kk-tier1, .kk-z-hi .kk-maplabel.kk-tier2 { display: block; }
/* D3 — marker clustering (leaflet.markercluster). A cluster bubble means "N
   communities overlap here", not a momentum signal, so it stays brand violet;
   momentum colour is for individual pins once declustered. Theme-safe via tokens
   (overrides the vendor .leaflet-div-icon white box by later source order). */
.kk-cluster { display: flex; align-items: center; justify-content: center; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); border: 2px solid var(--surface);
  font: 700 .82rem/1 'Inter Tight', 'Inter', sans-serif; font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 26%, transparent), var(--shadow);
  transition: transform var(--transition); }
.kk-cluster-m { font-size: var(--fs-2); }
.kk-cluster-l { font-size: var(--fs-3); }
.kk-cluster:hover { transform: scale(1.06); }
/* R1 geo Phase 2 — "Near me" control */
.map-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 12px; }
.near-me-btn { display: inline-flex; align-items: center; gap: 7px; flex: none;
  font-family: 'Inter', sans-serif; font-size: var(--fs-2); font-weight: 600; color: var(--on-accent);
  background: var(--accent); border: none; border-radius: var(--radius); padding: 10px 16px;
  cursor: pointer; transition: transform var(--transition), box-shadow var(--transition); }
.near-me-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.near-me-btn:disabled { opacity: .55; cursor: default; }
.near-me-btn svg { width: 16px; height: 16px; }
.near-me-list { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: var(--fs-2); }
.near-me-list .nm-head { font-weight: 700; color: var(--text); }
.near-me-list a { display: inline-flex; align-items: baseline; gap: 5px; color: var(--accent);
  text-decoration: none; font-weight: 600; border: 1px solid var(--accent-soft);
  border-radius: var(--radius-xl); padding: 5px 11px; }
.near-me-list a:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.near-me-list a span { color: var(--text-muted); font-weight: 500; font-size: var(--fs-1); }
.near-me-list .nm-empty { color: var(--text-muted); }
/* F5 — momentum mode: highlight where price momentum is real (confident calls). */
.mom-btn { display: inline-flex; align-items: center; gap: 7px; flex: none;
  font-family: 'Inter', sans-serif; font-size: var(--fs-2); font-weight: 600; color: var(--accent);
  background: transparent; border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 9px 15px; cursor: pointer; transition: background .15s, color .15s; }
.mom-btn:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.mom-btn[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.mom-btn svg { width: 16px; height: 16px; }
.mom-legend { display: none; font-size: 13px; color: var(--text-muted); align-items: center;
  gap: 8px 16px; flex-wrap: wrap; margin-top: 12px; }
.mom-legend.on { display: flex; }
.mom-legend .mdot { width: 12px; height: 12px; border-radius: 50%; display: inline-block;
  border: 1px solid var(--surface); margin-right: 5px; vertical-align: middle; }
.mom-risers { display: none; margin-top: 18px; }
.mom-risers.on { display: block; }
.mom-risers h3 { font-family: 'Inter Tight', sans-serif; font-size: var(--fs-4); font-weight: 700;
  color: var(--text); margin: 0 0 4px; letter-spacing: -.01em; }
.mom-risers .mr-sub { font-size: var(--fs-2); color: var(--text-muted); margin: 0 0 12px; line-height: 1.55; }
.mr-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.mr-item { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 13px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); text-decoration: none; }
.mr-item:hover { border-color: var(--accent); }
.mr-l { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mr-name { font-weight: 600; font-size: var(--fs-3); color: var(--text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.mr-conf { font-size: var(--fs-1); color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mr-pct { font-family: 'Inter Tight', sans-serif; font-weight: 700; font-size: var(--fs-3);
  color: var(--accent); font-variant-numeric: tabular-nums; flex: none; }
.mr-pct.is-pos { color: var(--pos); }
.mr-pct.is-neg { color: var(--neg); }
.mom-risers .mr-list + h3 { margin-top: 22px; }
.mr-empty { font-size: var(--fs-2); color: var(--text-muted); }

/* R1 geo Phase 3 — price heatmap (choropleth) metric toggle + legend */
/* the [hidden] attribute must beat these display: rules (else the toggle/note leak into pin mode) */
.choro-metric[hidden], .map-note[hidden] { display: none; }
.choro-metric { display: inline-flex; flex: none; border: 1px solid var(--accent);
  border-radius: var(--radius); overflow: hidden; }
.choro-metric .cm-btn { font: 600 .8rem 'Inter', sans-serif; color: var(--accent);
  background: transparent; border: none; padding: 8px 13px; cursor: pointer; transition: background .15s, color .15s; }
.choro-metric .cm-btn + .cm-btn { border-left: 1px solid var(--accent); }
.choro-metric .cm-btn[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.choro-legend { display: none; font-size: 13px; color: var(--text-muted); align-items: center;
  gap: 6px 14px; flex-wrap: wrap; margin-top: 12px; }
.choro-legend.on { display: flex; }
.choro-legend .cl-title { font-weight: 700; color: var(--text); margin-right: 2px; }
.choro-legend .cl-item { display: inline-flex; align-items: center; gap: 5px;
  font-variant-numeric: tabular-nums; }
.choro-legend .cl-sw { width: 16px; height: 12px; border-radius: 3px; flex: none;
  border: 1px solid color-mix(in srgb, var(--text) 18%, transparent); display: inline-block; }
.kk-choro-tip { font: 600 .74rem 'Inter', sans-serif; }

/* R1 geo: "communities near a place" address search */
.geo-search { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.geo-search input { flex: 1 1 260px; min-width: 0; font: 400 .9rem 'Inter', sans-serif; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-ui); border-radius: var(--radius); padding: 10px 14px; }
.geo-search input::placeholder { color: var(--text-subtle); }
.geo-search input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.geo-search select { flex: none; font: 500 .85rem 'Inter', sans-serif; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-ui); border-radius: var(--radius); padding: 0 10px; cursor: pointer; }
.geo-search button { flex: none; font: 600 .85rem 'Inter', sans-serif; color: var(--on-accent);
  background: var(--accent); border: none; border-radius: var(--radius); padding: 10px 20px; cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition); }
.geo-search button:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.geo-search button:disabled { opacity: .55; cursor: default; transform: none; box-shadow: none; }
.geo-near-list { margin-bottom: 12px; }

/* D1 — map loading / empty / error status, centred over the map frame */
.map-frame { position: relative; }
.map-status { position: absolute; inset: 0; z-index: 400; display: none; align-items: center; justify-content: center; pointer-events: none; }
.map-status.show { display: flex; }
.map-status .ms-inner { pointer-events: auto; max-width: 320px; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 16px 20px; font-size: var(--fs-3); color: var(--text-muted); }
.map-status .ms-retry { background: none; border: none; padding: 0; margin-left: 5px; font: inherit; color: var(--accent); font-weight: 600; cursor: pointer; text-decoration: underline; }
.map-status .ms-spin { display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: kk-mspin .7s linear infinite; }
@keyframes kk-mspin { to { transform: rotate(360deg); } }

/* D2 — cooling glyph on the momentum legend (second, non-colour channel: rising = solid ring, cooling = dashed ring on the pins) */
.mom-legend .mdot.mdot-cool { border-style: dashed; border-color: var(--text-muted); }

/* F3 — always-present keyboard-reachable A–Z list mirroring every pin */
.all-communities { margin-top: 20px; border: 1px solid var(--card-border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow), var(--highlight); }
.all-communities > summary { cursor: pointer; padding: 13px 18px; font-family: 'Inter', sans-serif; font-weight: 600; font-size: var(--fs-3); color: var(--text); list-style: none; }
.all-communities > summary::-webkit-details-marker { display: none; }
.all-communities > summary::after { content: "▾"; float: right; color: var(--text-subtle); }
.all-communities[open] > summary::after { content: "▴"; }
.ac-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1px 10px; padding: 0 18px 16px; }
.ac-list a { display: block; padding: 6px 5px; font-size: var(--fs-2); color: var(--accent); text-decoration: none; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-list a:hover, .ac-list a:focus-visible { background: var(--surface-alt); text-decoration: underline; }
