/* Location map story (js/views/location.js). Loaded after app.css.
   Desktop (>= 900px): chapter cards scroll past a pinned map.
   Mobile: tap chips above a normal-height map, one card at a time. */

#location .ls {
  --ls-h: clamp(460px, calc(100svh - var(--topbar) - 40px), 940px);
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: clamp(20px, 2.6vw, 40px);
}

/* ---------- Pinned stage: map + chapter tabs ---------- */
#location .ls-stage {
  grid-column: 2; grid-row: 1; align-self: start;
  position: sticky; top: calc(var(--topbar) + 20px);
  height: var(--ls-h);
}
#location .ls-map { height: 100%; min-height: 0; }
#location .ls-tabs {
  position: absolute; z-index: 3; top: 12px; left: 12px; max-width: calc(100% - 72px);
  display: flex; gap: 2px; padding: 3px; border-radius: 6px;
  background: rgba(252, 252, 251, .86); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
}
#location .ls-tabs::-webkit-scrollbar { display: none; }
#location .ls-tabs button {
  flex: none; min-height: 32px; padding: 0 12px; border: 0; border-radius: var(--r-btn);
  background: transparent; color: var(--pewter); font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer;
  transition: background-color var(--t), color var(--t);
}
#location .ls-tabs button:hover { color: var(--carbon); }
#location .ls-tabs button[aria-current="step"] { background: var(--ash-2); color: var(--carbon); }

/* ---------- Chapter cards ---------- */
#location .ls-steps { grid-column: 1; grid-row: 1; min-width: 0; }
#location .ls-step { min-height: 72svh; display: flex; align-items: center; }
#location .ls-step:first-child { min-height: 64svh; align-items: flex-start; }
#location .ls-card {
  width: 100%; padding: clamp(22px, 2.2vw, 32px);
  background: var(--ash); border-radius: var(--r-card);
  transition: opacity .5s cubic-bezier(.2, .7, .1, 1);
}
#location .ls-card h3 {
  font-size: clamp(24px, 2.1vw, 32px); font-weight: 300; letter-spacing: -0.02em; line-height: 1.12;
  color: var(--carbon); text-wrap: balance;
}
#location .ls-card > p { margin: 12px 0 0; font-size: 15px; line-height: 1.6; color: var(--graphite); max-width: 46ch; }

#location .ls-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 16px; margin: 24px 0 0; }
#location .ls-stats div { display: flex; flex-direction: column-reverse; gap: 4px; min-width: 0; }
#location .ls-stats dd {
  margin: 0; color: var(--carbon); font-size: clamp(32px, 3vw, 44px); font-weight: 200;
  letter-spacing: -0.03em; line-height: 1.02; font-variant-numeric: tabular-nums lining-nums;
}
#location .ls-stats dt { font-size: 13px; color: var(--pewter); }

#location .ls-pois { margin-top: 20px; padding: 4px; background: var(--canvas); border-radius: 8px; }
#location .ls-pois button {
  width: 100%; display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  min-height: 44px; padding: 8px 10px; border: 0; border-radius: 6px; background: none; text-align: left; cursor: pointer;
  transition: background-color var(--t);
}
#location .ls-pois button:hover, #location .ls-pois button.active { background: var(--ash); }
#location .ls-pois i { width: 8px; height: 8px; border-radius: 50%; }
#location .ls-pois .n { font-size: 14px; color: var(--carbon); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#location .ls-pois .d { font-size: 12px; line-height: 1.35; color: var(--pewter); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

#location .ls-next { display: none; margin-top: 20px; }
#location .ls-next i { font-size: 14px; }

/* ---------- Explorer (last chapter) ---------- */
#location .ls-explore-head { padding: 20px 20px 0; }
#location .ls-explore-head h3 { font-size: 24px; font-weight: 300; letter-spacing: -0.02em; line-height: 1.15; color: var(--carbon); }
#location .ls-explore-head p { margin: 6px 0 0; font-size: 14px; color: var(--pewter); }
#location .ls-explore .loc-list { position: relative; min-height: 0; }
#location .ls-explore-foot { display: flex; padding: 4px 12px 12px; }

/* ---------- Map pins ---------- */
#location .ls-pin {
  width: 30px; height: 30px; padding: 0; border: 0; background: none;
  display: grid; place-items: center; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
#location .ls-dot {
  width: 13px; height: 13px; border-radius: 50%; border: 2px solid #fff; background: var(--c, #9aa5a0);
  transition: transform var(--t) cubic-bezier(.2, .7, .1, 1), opacity var(--t);
}
#location .ls-pin.is-hi .ls-dot { transform: scale(1.4); }
#location .ls-pin.is-dim .ls-dot { opacity: .3; transform: scale(.75); }
#location .ls-pin.is-off, #location .ls-area.is-off { display: none; }
#location .ls-tag {
  position: absolute; top: 50%; left: calc(100% - 4px);
  display: flex; flex-direction: column; padding: 6px 10px; border-radius: var(--r-btn);
  background: var(--carbon); color: #fff; font-size: 12px; line-height: 1.3; text-align: left; white-space: nowrap;
  opacity: 0; transform: translate(-4px, -50%); pointer-events: none;
  transition: opacity var(--t), transform var(--t) cubic-bezier(.2, .7, .1, 1);
}
#location .ls-tag b { font-weight: 600; }
#location .ls-tag span { color: rgba(255, 255, 255, .72); font-variant-numeric: tabular-nums; }
#location [data-side="left"] > .ls-tag { left: auto; right: calc(100% - 4px); text-align: right; transform: translate(4px, -50%); }
#location .is-label > .ls-tag,
#location .ls-pin:hover > .ls-tag,
#location .ls-pin:focus-visible > .ls-tag { opacity: 1; transform: translate(0, -50%); }

#location .ls-site {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink, #fff); font-size: 16px; font-weight: 600; letter-spacing: -0.02em;
}
#location .ls-site::before {
  content: ""; position: absolute; inset: -12px; z-index: -1; border-radius: 50%;
  background: var(--accent); opacity: 0; animation: ls-pulse 3.2s cubic-bezier(.2, .7, .1, 1) infinite;
}
#location .ls-site .ls-tag { left: calc(100% + 8px); }
#location .ls-site-mark { position: relative; }
@keyframes ls-pulse {
  0% { transform: scale(.6); opacity: .32; }
  100% { transform: scale(1.5); opacity: 0; }
}

#location .ls-area {
  font-size: 13px; font-weight: 600; letter-spacing: .01em; color: #56717d; white-space: nowrap; pointer-events: none;
}

/* MapLibre's two-finger hint, in the site's type. */
#location .maplibregl-cooperative-gesture-screen { font: 600 15px/1.4 var(--font-body); background: rgba(23, 26, 28, .5); }

/* ---------- Desktop ---------- */
@media (min-width: 900px) {
  #location .ls-step:not(.is-active) .ls-card { opacity: .38; }
  #location .ls-step.ls-explore { min-height: 0; height: var(--ls-h); margin-top: 18svh; display: block; }
  #location .ls-explore .loc-side { height: 100%; }
  #location .ls-explore .loc-list { max-height: none; }
}

/* ---------- Mobile: chips, normal map, one card ---------- */
@media (max-width: 899.98px) {
  #location .ls { display: block; }
  #location .ls-stage { position: relative; top: auto; height: auto; display: flex; flex-direction: column; gap: 10px; }
  #location .ls-tabs {
    order: 0; position: relative; top: auto; left: auto; max-width: 100%;
    background: var(--ash-2); -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  #location .ls-tabs button[aria-current="step"] { background: var(--canvas); }
  #location .ls-map { order: 1; height: clamp(300px, 56svh, 520px); min-height: 0; }
  #location .ls-steps { margin-top: 12px; }
  #location .ls-step { display: none; min-height: 0; }
  #location .ls-step.is-active { display: block; }
  #location .ls-step.ls-explore { height: auto; margin: 0; }
  #location .ls-explore .loc-list { flex: none; max-height: 52svh; }
  #location .ls-next { display: inline-flex; }
  #location .ls-tag { font-size: 11.5px; padding: 5px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  #location .ls-card, #location .ls-dot, #location .ls-tag, #location .ls-tabs button { transition: none; }
  #location .ls-site::before { animation: none; }
}

@media print {
  #location .ls { display: block; }
  #location .ls-stage, #location .ls-next, #location .ls-explore-foot { display: none !important; }
  #location .ls-step { display: block !important; min-height: 0 !important; height: auto !important; margin: 0 0 6mm !important; break-inside: avoid; }
  #location .ls-card { opacity: 1 !important; background: none; padding: 0; }
  #location .ls-explore .loc-side { height: auto; }
}
