/* Map page. One full-viewport stage that carries three views: globe, region, local. */

.vh { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Stage ---------- */
.map-stage {
  --panel-w: min(404px, calc(100% - 2 * var(--gutter)));
  --dive: cubic-bezier(.65, 0, .2, 1);
  position: relative; isolation: isolate; overflow: hidden;
  height: 100svh; min-height: 620px;
  background: #eef3ec; color: var(--ink);
}
main .map-stage[data-hero]::after { content: none; }
.map-globe {
  /* shares a name with the home page globe, so it morphs across the page transition */
  view-transition-name: globe;
  position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0;
  touch-action: none;
  transform-origin: 50% 50%;
  transition: opacity .55s var(--ease), transform 1.05s var(--dive), filter .55s var(--ease);
}
.map-region {
  position: absolute; inset: 0; z-index: 1;
  opacity: 0; pointer-events: none;
  transform: scale(.88); transform-origin: 50% 50%;
  transition: opacity .6s var(--ease), transform 1.05s var(--dive);
  background: #F1F5EE;
}
/* The globe is nearly black and the street map nearly white, so a straight crossfade flashes.
   This washes the map in from the dark, under the descent. */
.map-region::after {
  content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background: #eef3ec; opacity: 0; transition: opacity .75s var(--ease);
}
/* MapLibre's own stylesheet is injected after ours and sets .maplibregl-map{position:relative} on
   this very element. Same specificity, later in the cascade, so it used to win and collapse the
   container to zero height, leaving a blank stage. Written stronger on purpose. */
.map-region .region-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
/* Both layers keep travelling the same way, so it reads as one descent rather than a crossfade:
   the globe swells past you and the map rises to meet it. */
.map-stage.is-region .map-region { opacity: 1; pointer-events: auto; transform: none; }
.map-stage.is-region .map-region::after { opacity: 0; }
.map-stage.is-region .map-globe { opacity: 0; pointer-events: none; transform: scale(2.4); filter: blur(5px); }
/* MapLibre chrome, kept quiet */
.map-region .maplibregl-ctrl-group { border-radius: 999px; overflow: hidden; box-shadow: var(--shadow-float); }
.map-region .maplibregl-ctrl-attrib { font: 400 11px/1.4 var(--sans); }
.map-region .maplibregl-ctrl-top-right { margin-top: calc(var(--header-h) - 60px); }

/* ---------- Marker cards: glass, each end of the thread with its own way in ---------- */
.map-card { display: block; width: 252px; overflow: hidden; border-radius: 20px; color: var(--ink); text-align: left;
  background: rgba(251,252,249,.82); -webkit-backdrop-filter: blur(22px) saturate(1.6); backdrop-filter: blur(22px) saturate(1.6);
  border: 1px solid rgba(255,255,255,.75); box-shadow: 0 30px 60px -28px rgba(6,18,12,.7), 0 0 0 1px rgba(6,18,12,.06), inset 0 1px 0 rgba(255,255,255,.9); }
.map-card-photo { position: relative; display: block; aspect-ratio: 16 / 10; overflow: hidden; margin: 6px 6px 0; border-radius: 15px; }
.map-card-photo img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 1s var(--ease); }
.map-card-photo:hover img { transform: scale(1.06); }
.map-card-kicker { position: absolute; top: 8px; left: 8px; padding: 5px 9px; font-size: 11.5px; }
.map-card-body { display: grid; gap: 6px; padding: 11px 14px 14px; }
.map-card b { display: block; font-family: var(--display); font-weight: 500; font-size: 21px; line-height: 1.05; color: var(--forest); }
.map-card-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; line-height: 1.45; color: var(--stone); }
.map-card-acts { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-top: 4px; }
.map-card-view, .map-card-give { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 14px; border-radius: 11px; font: 500 13.5px/1 var(--sans); transition: background-color .3s, box-shadow .3s, color .3s; }
.map-card-view { color: var(--forest); background: rgba(255,255,255,.7); box-shadow: inset 0 0 0 1px var(--line-strong); }
.map-card-view:hover { background: #fff; box-shadow: inset 0 0 0 1px var(--forest); }
.map-card-view svg { width: 13px; height: 13px; }
.map-card-give { background: var(--forest); color: #fff; }
.map-card-give:hover { background: var(--moss); }
.map-card.is-wild .map-card-give { background: var(--moss); }
/* ---------- Waypoints: the pairs you are not looking at ---------- */
.map-waypoint {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px 7px 9px; border-radius: 10px;
  background: rgba(251, 252, 249, .72); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, .8); box-shadow: 0 0 0 1px rgba(18,56,42,.1);
  font: 500 11.5px / 1 var(--sans); color: var(--stone);
  white-space: nowrap; cursor: pointer;
  transition: background-color .3s, color .3s, border-color .3s, transform .4s var(--ease);
}
.map-waypoint i { width: 8px; height: 8px; border-radius: 50%; background: var(--sprout); flex: none; }
.map-waypoint.is-wild i { background: transparent; border: 2px solid var(--leaf); }
.map-waypoint:hover { background: #fff; color: var(--forest); border-color: var(--leaf); transform: translateY(-1px); }

/* Phones give the map barely half the screen: the card drops to its name and its two actions. */
@media (max-width: 700px) { .map-stage { --x: 1; } }
.cards-compact .map-card { width: 196px; border-radius: 16px; }
.cards-compact .map-card-photo, .cards-compact .map-card-desc { display: none; }
.cards-compact .map-card-body { padding: 11px 12px 12px; gap: 8px; }
.cards-compact .map-card b { font-size: 18px; }
.cards-compact .map-card-view, .cards-compact .map-card-give { height: 34px; font-size: 13px; white-space: nowrap; }

/* ---------- Panel: the same glass as the gift control ---------- */
.map-panel { position: absolute; z-index: 3; left: var(--gutter); top: calc(var(--header-h) + var(--header-fade-depth) + 14px); width: var(--panel-w);
  max-height: calc(100% - var(--header-h) - var(--header-fade-depth) - 40px); overflow-y: auto; scrollbar-width: none; gap: 14px; }
.map-panel::-webkit-scrollbar { display: none; }
.panel-head { display: grid; gap: 12px; justify-items: start; }
.panel-lede { max-width: 30em; }
.panel-empty { font-size: 14px; color: var(--stone); }
.panel-empty[hidden] { display: none; }
.map-focus { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line-strong); }
.map-focus .gl-tile { min-height: 124px; }

/* ---------- Actions float over the globe, in glass ---------- */
.map-actions { position: absolute; z-index: 4; bottom: 34px; left: calc(var(--gutter) + var(--panel-w) + 24px); right: var(--gutter); display: grid; justify-items: center; gap: 10px; pointer-events: none; }
.map-actions > * { pointer-events: auto; }
.map-actions .panel-actions { display: flex; justify-content: center; gap: 8px; }
.panel-actions[hidden] { display: none; }
.map-actions .gl-float { height: 52px; padding: 0 22px; font-size: 16px; box-shadow: 0 18px 40px -18px rgba(0,0,0,.7); }
.panel-note { padding: 9px 16px; border-radius: 10px; font-size: 13px; line-height: 1.5; text-align: center; color: #fff; background: rgba(6,18,12,.5); border: 1px solid rgba(255,255,255,.24); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.panel-note[hidden] { display: none; }

@media (max-height: 800px) and (min-width: 901px) { .panel-lede { display: none; } .map-panel { top: calc(var(--header-h) + var(--header-fade-depth) + 8px); gap: 10px; padding: 14px; } .map-focus .gl-tile { min-height: 100px; } .gl-row { padding: 6px 10px 6px 6px; } .gl-pics img { width: 40px; height: 40px; } }

@media (max-width: 900px) {
  .map-globe, .map-region { inset: 0 0 46svh 0; width: 100%; height: 54svh; left: 0; }
  .map-panel, .map-stage.is-region .map-panel { left: 10px; right: 10px; bottom: 10px; top: auto; width: auto; height: calc(46svh - 10px); max-height: none; border-radius: 22px; padding: 16px; overflow-y: auto; }
  .map-actions { left: var(--gutter); right: var(--gutter); bottom: calc(46svh + 14px); }
  .map-stage.is-region .map-region { inset: 0 0 38svh 0; height: 62svh; }
  .map-stage.is-region .map-panel { height: calc(38svh - 10px); }
  .map-stage.is-region .map-actions { bottom: calc(38svh + 14px); }
  .map-panel .panel-head { display: none; }
  .panel-lede { display: none; }
  .gl-title { font-size: 26px; max-width: none; }
  .map-focus .gl-tile { min-height: 96px; }
  .map-region .maplibregl-ctrl-top-right { margin-top: calc(var(--header-h) - 70px); }
}

/* ---------- How to read the map: one line, no cards ---------- */
.legend { padding: clamp(28px, 4vw, 44px) 0; background: var(--canvas); border-bottom: 1px solid var(--line); }
.legend-key { display: flex; justify-content: center; flex-wrap: wrap; gap: 14px clamp(28px, 4vw, 56px); font-size: var(--t-16); color: var(--stone); }
.legend-key > span { display: inline-flex; align-items: center; gap: 12px; }
.legend-key b { color: var(--forest); font-weight: 500; }
.legend-key .dot-thread { margin: 0 8px; }

.dot-urban { width: 14px; height: 14px; border-radius: 50%; background: var(--sprout); box-shadow: 0 0 0 3px #fff, 0 0 0 12px rgba(169,213,160,.18); }
.dot-wild { width: 14px; height: 14px; border-radius: 50%; background: var(--void); box-shadow: 0 0 0 3px var(--sprout); }
.dot-thread { width: 30px; height: 2px; background: var(--sprout); position: relative; transform: rotate(-25deg); }
.dot-thread::before, .dot-thread::after { content: ""; position: absolute; top: -4px; width: 10px; height: 10px; border-radius: 50%; }
.dot-thread::before { left: -6px; background: var(--sprout); }
.dot-thread::after { right: -6px; background: var(--void); box-shadow: 0 0 0 2px var(--sprout); }

@media (max-width: 900px) {
  .legend-key { flex-direction: column; align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  .map-globe, .map-region { transition: opacity .3s linear; transform: none !important; filter: none !important; }
  .map-region::after { transition: opacity .3s linear; }
}

/* the pale street map needs the lighter glass; the globe keeps the smoked one */
.map-panel { --ink-1: var(--forest); --ink-2: var(--stone); --row: rgba(255,255,255,.55); --row-hover: rgba(255,255,255,.85); --row-on: #fff; --edge: rgba(18,56,42,.12); --accent: var(--leaf); --pic-ring: #fff; background: rgba(246,250,245,.8); border-color: rgba(255,255,255,.7); }
.map-panel .gl-btn { background: var(--forest); color: #fff; }
.map-panel .gl-btn svg { background: var(--sprout); color: var(--forest); }
.map-panel > .panel-head .tag-dark { background: rgba(255,255,255,.7); color: var(--forest); border-color: rgba(255,255,255,.9); box-shadow: 0 0 0 1px rgba(18,56,42,.1); }
.map-panel .tag-strong { background: rgba(18,56,42,.86); color: var(--sprout); }

@media (min-width: 901px) {
  .map-panel { padding: 16px; gap: 11px; }
  .map-panel .gl-title { font-size: clamp(26px, 2.2vw, 34px); }
  .map-panel .panel-lede { font-size: 14px; }
  .map-panel .gl-search { height: 44px; }
  .map-panel .gl-row { padding: 6px 10px 6px 6px; }
  .map-panel .gl-pics img { width: 40px; height: 40px; }
  .map-panel .gl-names b { font-size: 15px; }
  .map-panel .map-focus { padding-top: 11px; gap: 8px; }
  .map-panel .map-focus .gl-tile { min-height: 100px; }
  .map-panel .gl-btn { height: 48px; font-size: 15px; }
  .map-panel .gl-btn svg { width: 34px; height: 34px; padding: 9px; }
}

/* No globe any more: the map is the page */
.map-stage .map-region { opacity: 1; transform: none; pointer-events: auto; }
.map-stage .map-region::after { opacity: 0; }
.map-stage:not(.is-ready) .map-region::after { opacity: 1; }
.map-actions { left: calc(var(--gutter) + var(--panel-w) + 24px); }
@media (max-width: 1179px) and (min-width: 901px) { .map-actions { left: var(--gutter); } }
