/* ══════════════════════════════════════════════════════════════════════════════════════════════
   vhc-map — the map component. Responsive by viewport, not by a frame toggle.
   Moved from `app/TEST_AREA/map-spike/vhc-map.css` (2026-09-24).

   ⚠️ **Everything is scoped under `.vhc-map`.** The spike owned the whole page (`html,body`, `#map`,
   `#bar`); inside a WordPress page those would restyle the theme and collide with its ids. ⟹ The page
   rules became the ROOT's, and the ids became `.vhcm-*` classes.
   ⭐ Height comes from the placement (`[vhc_map height="…"]` → `--vhc-map-h`), since an embedded map
   has no viewport of its own to fill.
   ══════════════════════════════════════════════════════════════════════════════════════════════ */
.vhc-map *{box-sizing:border-box}
.vhc-map{position:relative;display:flex;flex-direction:column;min-height:320px;
  /* ⭐ The profile's height is set per trail (--vhc-prof-h, vhc-map.js); the block grows by what it adds over the
     old 54 px strip, so the MAP keeps the height its placement asked for. */
  /* ⤳ 2026-10-07 (Karl, second pass): the block has a FIXED height again and the map and the profile SHARE it — the grip
     between them trades one for the other. A trail block starts larger, with the 600 px map as 70% of it (profile 30%).
     The branch list that ate the map on a phone has LEFT the block (it sits under the map, like Nearby). */
  height:var(--vhc-map-h,600px);
  font:15px/1.45 system-ui,-apple-system,sans-serif;color:#18181b;background:#f4f4f5;
  -webkit-text-size-adjust:100%}
.vhc-map .vhcm-map{flex:1;min-height:0;position:relative}
/* a TRAIL block: the placement's map height is 70% of it, so the profile starts at 30% */
.vhc-map[data-trail-id]:not(.is-max){height:calc(var(--vhc-map-h,600px) / 0.7)}
@media (max-width: 640px){
  /* a phone: never more than 85% of the screen, so the page below stays reachable */
  .vhc-map:not(.is-max){height:min(var(--vhc-map-h,600px),70vh)}
  .vhc-map[data-trail-id]:not(.is-max){height:min(calc(var(--vhc-map-h,600px) / 0.7),85vh)}
}}
.vhc-map [hidden]{display:none !important}

/* ⛔ **Absence, in words** — shown over the map when the points could not be fetched or there are none.
   An empty map with no sentence is indistinguishable from one still loading. */
.vhc-map .vhcm-status{position:absolute;left:50%;top:12px;transform:translateX(-50%);z-index:3;margin:0;
  max-width:calc(100% - 24px);padding:6px 12px;border-radius:8px;background:rgba(24,24,27,.86);color:#fff;
  font-size:13px;line-height:1.4;text-align:center}

/* ── the trail bar: title + the elevation strip ──────────────────────────────────────────────
   ⚠️ `env(safe-area-inset-bottom)` — on an iPhone the home indicator overlaps a bottom-anchored
   bar, and a profile you cannot touch the last 20 px of is a profile with a broken end. */
.vhc-map .vhcm-bar{background:#fff;border-top:1px solid #e4e4e7;padding:6px 10px calc(6px + env(safe-area-inset-bottom));
  display:flex;flex-direction:column;gap:4px;flex:0 0 auto}
.vhc-map .vhcm-meta{display:flex;gap:10px;align-items:baseline;font-size:12px;color:#52525b;flex-wrap:wrap}
.vhc-map .vhcm-meta b{color:#18181b}
/* ⭐ The cursor readout has its OWN line, its height reserved whether or not the cursor is on the trail (2026-10-01, Karl:
   "the extra data on the vhcm-meta line wraps and is causing the map and graph to jump while tracking the cursor"). ↩ It
   shared the title's line, so it wrapped the bar mid-hover, the bar grew, and the map above it shrank. One line, never
   wrapped (an ellipsis instead), so the bar's height is fixed. */
.vhc-map .vhcm-pos{order:3;flex:0 0 100%;min-height:1.45em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-variant-numeric:tabular-nums}
.vhc-map .vhcm-tools{order:2}
.vhc-map .vhcm-prof{height:var(--vhc-prof-h,54px);flex:0 0 var(--vhc-prof-h,54px)}
.vhc-map .vhcm-prof svg{width:100%;height:100%;display:block}

/* ── POPUP ────────────────────────────────────────────────────────────────────────────────────
   🔴 On a phone a floating bubble is the wrong shape: it covers the thing you tapped, its close
   button is a 12 px target, and it reflows the map when it opens near an edge. ⟹ Under the
   breakpoint the popup becomes a BOTTOM SHEET — fixed, full width, thumb-reachable close. */
.vhc-map .maplibregl-popup-content{padding:12px 14px;border-radius:10px;box-shadow:0 4px 20px rgba(0,0,0,.25);
  font:14px/1.45 system-ui,sans-serif}
.vhc-map .maplibregl-popup-close-button{font-size:22px;width:34px;height:34px;line-height:30px;color:#52525b}

@media (max-width: 640px){
  /* ⭐ **Inset from the edges, not flush.** (Karl, 2026-09-23.) A card that runs into the screen
     edge reads as part of the chrome; a few pixels of gap makes it a card sitting ON the map, and
     it keeps the rounded corners visible on all four sides instead of two.
     ⚠️ The bottom gap is ADDED to the safe-area inset rather than replacing it — on a notched phone
     the home indicator still needs its clearance underneath the gap. */
  /* ⚠️ 4 px, not 8 — the attribution has left the map, so the card no longer has to clear it.
     (Karl: *"the pop up can come down a couple of pixels."*) */
  .vhc-map .maplibregl-popup{max-width:none !important;width:auto;left:6px !important;right:6px;
    top:auto !important;bottom:calc(4px + env(safe-area-inset-bottom)) !important;
    transform:none !important}
  .vhc-map .maplibregl-popup-tip{display:none}
  .vhc-map .maplibregl-popup-content{border-radius:14px;padding:14px;
    box-shadow:0 4px 26px rgba(0,0,0,.28)}
  /* ⭐ 44 px is the Apple HIG minimum touch target and the reason this is not just "bigger". */
  .vhc-map .maplibregl-popup-close-button{width:44px;height:44px;font-size:26px;line-height:40px}
  /* ⚠️ MapLibre's default control buttons are 29 px — under the minimum, and the first thing that
     feels wrong on a phone. */
  .vhc-map .maplibregl-ctrl button{width:40px !important;height:40px !important}
  .vhc-map .maplibregl-ctrl-group{border-radius:8px}
  /* the phone scale (×0.8) is applied in vhc-map.js, so the default here is only for a strip with no trail yet */
  .vhc-map .vhcm-prof{height:var(--vhc-prof-h,44px);flex:0 0 var(--vhc-prof-h,44px)}
  .vhc-map .vhcm-meta{font-size:11px;gap:7px}
}
/* ⛔ The attribution must stay legible and tappable — it is a licence obligation, not decoration. */
.vhc-map .maplibregl-ctrl-attrib{font-size:11px}

/* ── THE CARD POPUP ───────────────────────────────────────────────────────────────────────────
   ⭐ Shaped from the two production maps: image, action row, title, township, type badge.
   ⚠️ The popup CONTENT gets no padding — the image must run edge to edge — so the padding moves
   onto `.body`. That is why `.maplibregl-popup-content` is overridden to 0 here. */
.vhc-map .maplibregl-popup-content:has(.vhc-card){padding:0;overflow:hidden}
.vhc-map .vhc-card{width:248px;max-width:100%}
.vhc-map .vhc-card .ph{position:relative;aspect-ratio:16/10;background:#f4f4f5}
.vhc-map .vhc-card .ph img{width:100%;height:100%;object-fit:cover;display:block}
.vhc-map .vhc-card .ph.noimg{display:flex;align-items:center;justify-content:center;color:#a1a1aa;
  font-size:12px;border-bottom:1px dashed #e4e4e7}
/* ⚠️ The actions sit ON the image, so they need their own contrast — a white icon on an unknown
   photo is unreadable half the time. A translucent plate is the cheapest thing that always works. */
.vhc-map .vhc-card .acts{position:absolute;right:6px;bottom:6px;display:flex;gap:4px}
.vhc-map .vhc-card .acts.flat{position:static;margin-right:auto}
.vhc-map .vhc-card .act{width:32px;height:32px;border:0;border-radius:7px;cursor:pointer;
  background:rgba(255,255,255,.92);color:#3f3f46;display:grid;place-items:center;
  box-shadow:0 1px 4px rgba(0,0,0,.2)}
.vhc-map .vhc-card .act:hover{background:#fff;color:#18181b}
.vhc-map .vhc-card .act[aria-pressed="true"]{color:#dc2626}
.vhc-map .vhc-card .body{padding:10px 12px 11px}
.vhc-map .vhc-card .t{font-weight:700;font-size:15px;line-height:1.25}
.vhc-map .vhc-card .town{color:#71717a;font-size:13px;margin-top:1px}
.vhc-map .vhc-card .foot{display:flex;align-items:center;justify-content:flex-end;margin-top:8px;min-height:26px}
.vhc-map .vhc-card .badge{width:26px;height:26px;border-radius:50%;display:grid;place-items:center;
  color:#fff;font-size:13px;line-height:1}

@media (max-width: 640px){
  /* ⭐ As a bottom sheet the card is full width and the image gets a shorter, wider crop — a 16:10
     hero on a phone pushes the title and actions below the fold of the sheet. */
  .vhc-map .vhc-card{width:100%}
  .vhc-map .vhc-card .ph{aspect-ratio:21/9;border-radius:10px;overflow:hidden}
  .vhc-map .vhc-card .body{padding:12px 2px 2px}
  .vhc-map .vhc-card .t{font-size:17px}
  .vhc-map .vhc-card .town{font-size:14px}
  .vhc-map .vhc-card .act{width:40px;height:40px}   /* ⚠️ touch minimum, same rule as the close button */
}

/* ⚠️ Spike diagnostic only — `popup.showTiming`. Off for a deployment. */
.vhc-map .vhc-card + .timing,.vhc-map .timing{font:11px/1.4 ui-monospace,monospace;color:#a1a1aa;
  padding:6px 12px 8px;border-top:1px solid #f4f4f5}

/* ── SHEET vs CHROME ──────────────────────────────────────────────────────────────────────────
   ⭐ `--sheet-h` is published by the page after measuring the open sheet. ⛔ A constant would be
   wrong on half the cards — the height moves with the image aspect, a two-line title and the
   safe-area inset. */
.vhc-map{--sheet-h:0px}
@media (max-width: 640px){
  /* ⭐ **Only the things you PRESS move.** Navigation and geolocate lift clear of the card; the
     scale and the attribution stay in the strip below it. ⛔ Lifting everything is what sent the
     whole stack off the top, and it moved two controls that never needed to move. */
  .vhc-map .maplibregl-ctrl-bottom-right{
    transform:translateY(calc(-1 * var(--sheet-h)));
    transition:transform .22s ease;
  }
  /* ⛔ The 40 px touch minimum applies to BUTTONS, not to a scale bar — it is read, not pressed. */
  .vhc-map .maplibregl-ctrl-bottom-left .maplibregl-ctrl-scale{font-size:10px;padding:0 4px;
    border-width:1px;background:rgba(255,255,255,.78)}
  .vhc-map .maplibregl-ctrl-bottom-left button{width:22px !important;height:22px !important}
}


/* ── ATTRIBUTION, BELOW THE MAP ────────────────────────────────────────────────────────────────
   ⭐ Out of the map frame entirely, so it competes with nothing — not the card, not the controls,
   not the terrain. ⛔ Still visible and adjacent to the map: it is a licence obligation, and the
   fix for "it is in the way" is to move it, never to hide it. */
.vhc-map .vhcm-attrib{font-size:10px;line-height:1.4;color:#a1a1aa;padding-top:3px}
.vhc-map .vhcm-attrib .maplibregl-ctrl-attrib{position:static;margin:0;padding:0;background:none;box-shadow:none;
  font-size:10px}
.vhc-map .vhcm-attrib .maplibregl-ctrl-attrib a{color:#71717a}
.vhc-map .vhcm-attrib .maplibregl-ctrl-attrib-button{display:none}   /* ⛔ nothing to expand — it is never compact here */

/* ── profile controls (2026-10-01): gradient ⇄ plain · expand · 2D/3D · the drag handle · the gradient legend ─────── */
.vhc-map .vhcm-tools{margin-left:auto;display:inline-flex;gap:6px}
.vhc-map .vhcm-btn{min-width:36px;height:30px;padding:0 10px;border:1px solid #d4d4d8;border-radius:6px;background:#fff;
  color:#18181b;font:600 12px/1 system-ui,-apple-system,sans-serif;cursor:pointer}
.vhc-map .vhcm-btn[aria-pressed="true"]{background:#18181b;color:#fff;border-color:#18181b}
.vhc-map .vhcm-btn:focus-visible{outline:2px solid #1d4ed8;outline-offset:2px}
.vhc-map .vhcm-btn--max{font-size:16px}
.vhc-map .vhcm-grip{flex:0 0 12px;cursor:ns-resize;touch-action:none;background:#fff;border-top:1px solid #e4e4e7;
  display:flex;align-items:center;justify-content:center}
.vhc-map .vhcm-grip::before{content:'';width:40px;height:4px;border-radius:2px;background:#a1a1aa}
.vhc-map .vhcm-grip:focus-visible{outline:2px solid #1d4ed8;outline-offset:-2px}
.vhc-map .vhcm-grip + .vhcm-bar{border-top:0}
.vhc-map .vhcm-legend{display:flex;flex-wrap:wrap;gap:4px 10px;font-size:11px;color:#52525b}
.vhc-map .vhcm-legend__item{display:inline-flex;align-items:center;gap:4px}
.vhc-map .vhcm-legend__item i{width:12px;height:8px;border-radius:2px;display:inline-block}
/* expanded: the whole block to 90 % of the screen (the map and the profile share it) */
.vhc-map.is-max{height:90vh !important;height:90dvh !important}
@media (max-width:640px){ .vhc-map .vhcm-btn{height:36px;min-width:40px} .vhc-map .vhcm-grip{flex-basis:16px} }


/* the Reset zoom chip (slice 8) is shown only while zoomed — ⚠️ `hidden` must beat the button's own display */
.vhcm-btn[hidden] { display: none !important; }

/* ── the Routes panel (2026-10-06): a service's route per row — swatch, name, toggle ───────────────────────────── */
.vhc-map .vhcm-routes { max-width: min(18rem, 70vw); max-height: calc(var(--vhc-map-h, 26rem) - 40px); overflow: auto; background: #fff; font-size: 12px; line-height: 1.3; }
.vhc-map .vhcm-routes summary { cursor: pointer; padding: 6px 10px; font-weight: 700; list-style: none; }
.vhc-map .vhcm-routes summary::-webkit-details-marker { display: none; }
.vhc-map .vhcm-routes summary::after { content: ' ▾'; font-weight: 400; }
.vhc-map .vhcm-routes details[open] summary::after { content: ' ▴'; }
.vhc-map .vhcm-routes ul { list-style: none; margin: 0; padding: 0 10px 4px; }
.vhc-map .vhcm-routes li { margin: 0; }
.vhc-map .vhcm-routes label { display: flex; align-items: center; gap: 6px; padding: 3px 0; cursor: pointer; }
.vhc-map .vhcm-routes input { margin: 0; flex: none; }
.vhc-map .vhcm-routes__swatch { flex: none; width: 14px; height: 4px; border-radius: 2px; }
.vhc-map .vhcm-routes__swatch--point { width: 10px; height: 10px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.vhc-map .maplibregl-ctrl-group button.vhcm-routes__all { width: auto; height: auto; color: #222; }   /* ⚠️ MapLibre sizes EVERY group button 29×29 */
.vhc-map .vhcm-routes__all { display: block; margin: 0 10px 8px; padding: 2px 8px; border: 1px solid currentColor; border-radius: 4px; background: none; cursor: pointer; font: inherit; }

/* the Home control (2026-10-06): an explicit colour — a theme's button colour (white on VHC) made the icon vanish */
.vhc-map .maplibregl-ctrl-group button.vhcm-home { color: #333; }
.vhc-map .maplibregl-ctrl-group button.vhcm-home:hover { color: #000; }
.vhc-map .vhcm-routes, .vhc-map .vhcm-routes label { color: #222; }
.vhc-map .vhcm-routes__far { font-style: normal; opacity: .7; }
.vhc-map .maplibregl-ctrl-group button.vhcm-expand { color: #333; font-size: 16px; line-height: 1; }
/* Home stands out a little more: the first control, a touch heavier */
.vhc-map .maplibregl-ctrl-group button.vhcm-home svg path { stroke-width: 2.4; }
.vhc-map .vhcm-routes__name { cursor: pointer; }
.vhc-map .vhcm-routes__name:hover, .vhc-map .vhcm-routes__name:focus-visible { text-decoration: underline; }

/* ── branch switches (2026-10-06): one per named <trk>, shown only for a multi-track GPX ─────────────────────── */
.vhcm-tracks{margin-top:12px;font-size:13px}
.vhcm-tracks > summary{cursor:pointer}
.vhcm-tracks .vhcm-branches__list{display:flex;flex-direction:column;gap:0;margin:0;padding:0}
.vhcm-tracks label{display:flex;align-items:center;gap:8px;cursor:pointer;min-height:2.25rem;border-top:1px solid #e4e4e7;margin:0}
.vhcm-tracks input{margin:0}
.vhcm-tracks .vhcm-branches__swatch{width:18px;height:4px;border-radius:2px;flex:none}
.vhcm-tracks .vhcm-branches__all{align-self:flex-start;margin:8px 0;padding:2px 10px;border:1px solid currentColor;border-radius:4px;background:none;font:inherit;cursor:pointer;color:#18181b}

/* Build-Brief-LLM-Features §12 — the Nearby popup. 🔴 Karl, 2026-10-07: the close button JUMPED (top-right → bottom-left, a
   blue square) — a theme's `button` rule reaching into MapLibre's. Pinned here, scoped to our popup, so it cannot move. */
.vhc-map .vhcm-nearby-role { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: #4f46e5; }
.vhc-map .vhcm-nearby-role--in { color: #0f766e; }
.vhc-map .vhcm-nearby-role--on { color: #b45309; }
.vhc-map .vhcm-nearby-link { display: inline-block; margin-top: 4px; font-weight: 600; }
.vhc-map .vhcm-nearby-pop .maplibregl-popup-close-button {
  position: absolute !important; top: 4px !important; right: 4px !important; bottom: auto !important; left: auto !important;
  width: 26px !important; height: 26px !important; padding: 0 !important; margin: 0 !important; border: 0 !important;
  border-radius: 50% !important; background: rgba(255, 255, 255, .92) !important; color: #1f2937 !important;
  font-size: 18px !important; line-height: 26px !important; box-shadow: 0 1px 3px rgba(0, 0, 0, .25) !important; z-index: 2;
}
/* the Nearby card: a SHORT image, so the card fits a 26rem map; above the map's own controls on a phone (they sat on top) */
.vhc-map .vhcm-nearby-card .ph { height: 110px !important; min-height: 0 !important; aspect-ratio: auto !important; overflow: hidden; }
.vhc-map .vhcm-nearby-card .ph img { height: 110px; width: 100%; object-fit: cover; display: block; }
.vhc-map .maplibregl-popup.vhcm-nearby-pop { z-index: 5; }

/* ── the RESULTS map (vhc-results-map.js, 2026-10-12): pins, labels and popups for a host such as chattyMatty ────────── */
.vhcr-pin{width:var(--vhcr-s,28px);height:var(--vhcr-s,28px);border-radius:50%;background:var(--vhcr-c,#E74C3C);color:#fff;
  display:flex;align-items:center;justify-content:center;border:2px solid #fff;box-shadow:0 2px 4px rgba(0,0,0,.4);
  font-size:calc(var(--vhcr-s,28px) / 2);cursor:pointer}
.vhcr-label{white-space:nowrap;font-size:.75rem;line-height:1.2}
.vhcr-pop{min-width:170px;max-width:230px;font-size:.8rem;line-height:1.3;color:#1f2328;text-align:left}
.vhcr-pop img{display:block;width:100%;height:95px;object-fit:cover;border-radius:4px;margin-bottom:6px;background:#ddd}
.vhcr-pop b{display:block;font-size:.85rem}
.vhcr-pop span{display:block;color:#777;font-size:.72rem;margin-top:2px}
.vhcr-pop .vhcr-open{display:inline-block;margin-top:7px;padding:3px 9px;background:#0d6efd;color:#fff;border-radius:3px;
  font-size:.72rem;text-decoration:none}
.maplibregl-ctrl .vhcr-fit{display:flex;align-items:center;justify-content:center;color:#333}
.vhcr-pop .vhcr-site{display:inline-block;width:14px;height:14px;margin:0 4px 0 0;border-radius:2px;vertical-align:-2px;object-fit:contain;background:#fff}
