/* 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(452px, calc(100% - 2 * var(--gutter)));
  --dive: cubic-bezier(.65, 0, .2, 1);
  position: relative; isolation: isolate; overflow: hidden;
  height: 100svh; min-height: 620px;
  background: var(--void); color: #fff;
}
.map-stage::before {
  content: ""; position: absolute; z-index: 2; inset: 0 auto 0 0; pointer-events: none;
  width: min(760px, 62%);
  background: linear-gradient(to right, rgba(6, 18, 12, .92) 0%, rgba(6, 18, 12, .8) 34%, rgba(6, 18, 12, .45) 62%, rgba(6, 18, 12, 0) 100%);
  transition: opacity .6s var(--ease);
}
/* Over the pale region map the scrim would grey the streets, and the panel takes its own dark back. */
.map-stage.is-region::before { opacity: 0; }

.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: var(--void); opacity: 1;
  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); }
.map-stage.is-region .map-actions .panel-note { background: rgba(6, 18, 12, .86); }
/* Over the pale map a white ghost button disappears, so it flips to ink on white. */
.map-stage.is-region .btn-panel-ghost { background: rgba(255, 255, 255, .9); color: var(--forest); border-color: rgba(18, 56, 42, .3); }
.map-stage.is-region .btn-panel-ghost:hover { background: #fff; border-color: var(--forest); }

/* 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: each end of the thread carries its own story ---------- */
.map-card {
  display: block; width: 236px; overflow: hidden;
  background: #fff; border-radius: 16px;
  box-shadow: 0 18px 44px -18px rgba(6, 18, 12, .55), 0 0 0 1px rgba(18, 56, 42, .1);
  color: var(--ink); text-align: left;
  transition: transform .5s var(--ease), box-shadow .5s var(--ease);
}
.map-card:hover { transform: translateY(-3px); box-shadow: 0 24px 54px -18px rgba(6, 18, 12, .6), 0 0 0 1px rgba(18, 56, 42, .18); }
.map-card-photo { display: block; aspect-ratio: 16 / 9; overflow: hidden; }
.map-card-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.map-card-body { display: block; padding: 11px 13px 13px; }
.map-card-kicker { display: block; font: 500 10px / 1 var(--sans); letter-spacing: .11em; text-transform: uppercase; color: var(--leaf); }
.map-card b { display: block; font-family: var(--display); font-weight: 500; font-size: 20px; line-height: 1.1; color: var(--forest); margin-top: 5px; }
.map-card-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 12.5px; line-height: 1.45; color: var(--stone); margin-top: 5px; }
.map-card-go { display: inline-flex; align-items: center; gap: 6px; margin-top: 9px; font: 500 12.5px / 1 var(--sans); color: var(--moss); }
.map-card-go i { width: 13px; height: 8px; background: currentColor; transition: transform .5s var(--ease);
  -webkit-mask: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 10'%3E%3Cpath d='M1 5h13M10 1l4 4-4 4' fill='none' stroke='%23000' stroke-width='1.6'/%3E%3C/svg%3E");
  mask: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 10'%3E%3Cpath d='M1 5h13M10 1l4 4-4 4' fill='none' stroke='%23000' stroke-width='1.6'/%3E%3C/svg%3E"); }
.map-card:hover .map-card-go i { transform: translateX(3px); }
/* the wild end is the darker of the two, so the pair reads as patch and match at a glance */
.map-card.is-wild { background: var(--forest); color: #fff; }
.map-card.is-wild .map-card-kicker { color: var(--sprout); }
.map-card.is-wild b { color: #fff; }
.map-card.is-wild .map-card-desc { color: rgba(255, 255, 255, .78); }
.map-card.is-wild .map-card-go { color: var(--sprout); }
/* ---------- Waypoints: the pairs you are not looking at ---------- */
.map-waypoint {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px 5px 8px; border-radius: 999px;
  background: rgba(255, 255, 255, .82); backdrop-filter: blur(6px);
  border: 1px solid rgba(18, 56, 42, .16);
  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. Two cards with photos would fill it, so on a phone the
   card drops to name, line and link, which still fits above its own point. */
@media (max-width: 700px) {
  .map-card { width: 172px; border-radius: 13px; }
  .map-card-photo { display: none; }
  .map-card-body { padding: 10px 12px 12px; }
  .map-card b { font-size: 16px; }
  .map-card-desc { font-size: 11.5px; }
  .map-card-go { margin-top: 7px; font-size: 11.5px; }
}

/* ---------- Panel ---------- */
.map-panel {
  position: absolute; z-index: 3;
  /* overflow-y below makes this a scroll container, which clips horizontally too, so the first
     letter of the eyebrow lost its left edge. Pad the box and pull it back by the same amount. */
  left: calc(var(--gutter) - 6px); top: calc(var(--header-h) + 34px);
  max-height: calc(100% - var(--header-h) - 60px); overflow-y: auto;
  width: var(--panel-w);
  display: flex; flex-direction: column; gap: clamp(14px, 2.2vh, 22px);
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: var(--r-12);
  transition: background-color .5s var(--ease), border-color .5s var(--ease), padding .5s var(--ease);
}
/* Zoomed in, the stage goes pale and the copy has to carry its own dark ground again. */
.map-stage.is-region .panel-lede { display: none; }
.map-stage.is-region .map-panel { padding: 20px; background: rgba(6, 18, 12, .86); border-color: rgba(255, 255, 255, .14); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.panel-head { flex: none; display: grid; gap: clamp(10px, 1.7vh, 16px); }
.panel-head .eyebrow { color: var(--sprout); }
.map-panel h1 { font-size: min(var(--t-64), 8.4vh); max-width: 12ch; line-height: 1.02; }
.map-panel h1 em { color: var(--sprout); }
.panel-lede { font-size: var(--t-18); line-height: 1.5; color: rgba(255, 255, 255, .72); max-width: 34ch; }

.panel-search {
  height: 50px; width: 100%; padding: 0 20px;
  border-radius: 999px; border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .06); color: #fff;
  font: 400 var(--t-16) var(--sans);
  transition: border-color .3s, background-color .3s;
}
.panel-search::placeholder { color: rgba(255, 255, 255, .45); }
.panel-search:hover { border-color: rgba(255, 255, 255, .3); }
.panel-search::-webkit-search-cancel-button { filter: invert(1) opacity(.6); }

.pair-list { flex: none; display: grid; gap: 10px; align-content: start; }
.pair-item {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px;
  padding: 10px 12px; border-radius: var(--r-12);
  border: 1px solid rgba(255, 255, 255, .12); background: rgba(255, 255, 255, .04);
  text-align: left; color: #fff;
  transition: background-color .3s, border-color .3s;
}
.pair-item[hidden] { display: none; }
.pair-item:hover { background: rgba(255, 255, 255, .09); }
.pair-item.is-active { background: rgba(169, 213, 160, .13); border-color: rgba(169, 213, 160, .5); }
.pair-item .pics { display: flex; }
.pair-item .pics img { width: 50px; height: 50px; border-radius: 50%; object-fit: cover; border: 2px solid var(--void); }
.pair-item .pics img + img { margin-left: -14px; }
.pair-item .names b { display: block; font-weight: 500; font-size: 17px; line-height: 1.25; }
.pair-item .names b i { font-family: var(--display); font-style: italic; font-weight: 500; color: var(--sprout); font-size: 1.12em; }
.pair-item .names span { display: block; font-size: 13px; color: rgba(255, 255, 255, .62); margin-top: 5px; }
.pair-item .go { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; border: 1px solid rgba(255, 255, 255, .2); color: var(--sprout); }
.pair-item .go svg { width: 14px; height: 14px; }
.pair-item.is-active .go { background: var(--sprout); color: var(--void); border-color: var(--sprout); }

.panel-empty { font-size: var(--t-14); color: rgba(255, 255, 255, .6); }
.panel-empty[hidden] { display: none; }

.panel-foot { flex: none; display: grid; gap: 14px; padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, .14); }
.panel-summary { font-size: var(--t-16); line-height: 1.6; color: rgba(255, 255, 255, .74); max-width: 36ch;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.panel-actions[hidden] { display: none; }
.btn-panel { background: var(--sprout); color: var(--void); }
.btn-panel:hover { background: #C0E2B8; }
.btn-panel[disabled] { opacity: .6; cursor: default; transform: none; }
.btn-panel-ghost { border: 1px solid rgba(255, 255, 255, .32); color: #fff; }
.btn-panel-ghost:hover { border-color: #fff; background: rgba(255, 255, 255, .08); }
.panel-note { font-size: 13px; line-height: 1.5; color: var(--sprout); }
.panel-note[hidden] { display: none; }

/* ---------- Actions, floating over the globe rather than buried in the panel ---------- */
.map-actions {
  position: absolute; z-index: 4; bottom: 30px;
  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 { justify-content: center; }
.map-actions .btn-panel { box-shadow: 0 14px 40px -12px rgba(6, 18, 12, .8); }
.map-actions .panel-note { background: rgba(6, 18, 12, .8); padding: 9px 16px; border-radius: 999px; backdrop-filter: blur(8px); text-align: center; }

/* Short windows: drop the lede so the three pairs and the actions fit without scrolling the panel */
@media (max-height: 780px) and (min-width: 901px) { .panel-lede { display: none; } .map-panel { top: calc(var(--header-h) + 22px); } .panel-head { gap: 12px; } .map-panel h1 { font-size: min(var(--t-48), 7.4vh); } .pair-item .pics img { width: 44px; height: 44px; } }

/* The globe canvas spans the whole stage; map.js centres the sphere in the space to the right of the panel. */

@media (max-width: 900px) {
  .map-globe, .map-region { inset: 0 0 46svh 0; width: 100%; height: 54svh; left: 0; }
  .map-stage::before { display: none; }
  .map-panel, .map-stage.is-region .map-panel {
    left: 0; right: 0; bottom: 0; top: auto; width: auto; height: 46svh; max-height: none;
    border-radius: var(--r-12) var(--r-12) 0 0;
    border: 1px solid rgba(255, 255, 255, .12); border-width: 1px 0 0 0;
    background: rgba(6, 18, 12, .88);
    backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2);
    overflow-y: auto; gap: 16px;
    padding: 18px var(--gutter) 22px;
  }
  .pair-list { overflow: visible; flex: none; min-height: 0; }
  .map-actions { left: var(--gutter); right: var(--gutter); bottom: calc(46svh + 14px); }
  /* Zoomed in, the map is the content: give it most of the screen so two cards fit above and below
     their points, and let the pair list keep the rest. */
  .map-stage.is-region .map-region { inset: 0 0 30svh 0; height: 70svh; }
  .map-stage.is-region .map-panel { height: 30svh; }
  .map-stage.is-region .map-actions { bottom: calc(30svh + 14px); }
  .panel-foot { flex: none; }
  .map-panel h1 { font-size: var(--t-28); max-width: none; }
  .panel-head { gap: 12px; }
  .panel-lede { display: none; }
  .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; }
}
