/* /map/ — the Photo Map (spec §3–§6).
 *
 * Full-viewport Leaflet stage with a fixed side panel on desktop and a
 * bottom sheet on mobile. Brand-toned markers per §4:
 *   .map-pin--exact       → rust point pin
 *   .map-pin--approximate → hollow rust ring (soft "near here")
 *   .map-pin--area        → sea-glass blob (no false-precise point)
 * Clusters are brand-styled (rust with cream stroke) — never the default
 * Leaflet blue.
 *
 * All layout below runs on relative units + flex/grid so it renders
 * cleanly at 380px (mobile) and 1200px (desktop).
 */

.map-page {
  background: var(--c-cream);
}

.map-main {
  position: relative;
  height: calc(100vh - 4rem); /* room for the site header */
  overflow: hidden;
}

#map-stage {
  position: absolute;
  inset: 0;
  background: var(--c-cream);
}

/* Leaflet's default attribution reads too loudly on the brand palette —
   dim it a touch and pin bottom-left so the bottom sheet has room. */
.map-page .leaflet-container {
  background: #EAE4D6;
  font-family: inherit;
}
.map-page .leaflet-control-attribution {
  background: rgba(245, 239, 228, 0.86);
  color: var(--c-ink-muted);
  font-size: 0.8125rem;
  padding: 2px 6px;
}
.map-page .leaflet-control-attribution a {
  color: var(--c-ink-muted);
}
.map-page .leaflet-control-zoom a {
  background: var(--c-cream);
  color: var(--c-navy);
  border-color: rgba(28, 46, 74, 0.15);
}
.map-page .leaflet-control-zoom a:hover {
  background: #E6DFCF;
}

/* ── markers ─────────────────────────────────────────────────────── */

.map-pin {
  display: block;
  will-change: transform;
}
.map-pin__dot {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  transition: transform 150ms var(--easing, ease);
}
.map-pin__dot--exact {
  background: var(--c-rust);
  box-shadow:
    0 0 0 2px var(--c-cream),
    0 0 0 3px rgba(28, 46, 74, 0.35),
    0 2px 4px rgba(28, 46, 74, 0.25);
}
.map-pin__dot--approximate {
  /* softer: hollow ring with a cream core — reads "near here" */
  background: var(--c-cream);
  border: 3px solid var(--c-rust);
  box-shadow:
    0 0 0 2px rgba(245, 239, 228, 0.9),
    0 2px 4px rgba(28, 46, 74, 0.20);
}
.map-pin:hover .map-pin__dot,
.map-pin:focus-visible .map-pin__dot {
  transform: scale(1.18);
}

.map-pin--area path {
  transition: fill-opacity 200ms var(--easing, ease), stroke-opacity 200ms var(--easing, ease);
}
.map-pin--area:hover path {
  fill-opacity: 0.4 !important;
  stroke-opacity: 0.6 !important;
}

/* ── cluster badge ───────────────────────────────────────────────── */

.map-cluster {
  display: grid;
  place-items: center;
  background: var(--c-rust);
  color: var(--c-cream);
  border-radius: 50%;
  box-shadow:
    0 0 0 3px var(--c-cream),
    0 2px 8px rgba(28, 46, 74, 0.30);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 150ms var(--easing, ease);
}
.map-cluster:hover {
  transform: scale(1.06);
}
.map-cluster__count {
  line-height: 1;
}

/* Marker-cluster ships default `.marker-cluster` styles; silence them
   so only our .map-cluster shows. */
.marker-cluster,
.marker-cluster div,
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background: none !important;
}
.marker-cluster div { background: none !important; }
.marker-cluster span { display: none !important; }

/* ── Near-me button ──────────────────────────────────────────────── */

.map-nearme {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  z-index: 900;
  background: var(--c-cream);
  color: var(--c-navy);
  border: 1px solid rgba(28, 46, 74, 0.25);
  border-radius: 999px;
  padding: 0.55rem 1rem 0.55rem 2.1rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(28, 46, 74, 0.15);
  transition: background 150ms var(--easing, ease), transform 150ms var(--easing, ease);
}
.map-nearme::before {
  content: '';
  position: absolute;
  left: 0.75rem;
  top: 50%;
  width: 12px;
  height: 12px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: var(--c-rust);
  box-shadow: 0 0 0 3px rgba(193, 77, 46, 0.25);
}
.map-nearme:hover {
  background: #E6DFCF;
}
.map-nearme.is-loading {
  opacity: 0.7;
  pointer-events: none;
}

/* ── side panel / bottom sheet ───────────────────────────────────── */

.map-panel {
  position: absolute;
  z-index: 1000;
  background: var(--c-cream);
  color: var(--c-ink);
  box-shadow: 0 4px 24px rgba(28, 46, 74, 0.20);
  overflow: hidden;
}
/* `hidden` must win over the flex layouts below. Browsers set
   `[hidden] { display: none }` but our media queries would otherwise
   override that with `display: flex`. */
.map-panel[hidden] { display: none !important; }

/* Desktop: right side panel */
@media (min-width: 720px) {
  .map-panel {
    top: 0;
    right: 0;
    bottom: 0;
    width: min(420px, 38vw);
    display: flex;
    flex-direction: column;
    border-left: 1px solid rgba(28, 46, 74, 0.10);
  }
}

/* Mobile: bottom sheet, half-height */
@media (max-width: 719px) {
  .map-panel {
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 62vh;
    display: flex;
    flex-direction: column;
    border-top: 1px solid rgba(28, 46, 74, 0.10);
    border-radius: 12px 12px 0 0;
  }
  .map-panel::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    margin: 0.5rem auto 0;
    border-radius: 2px;
    background: rgba(28, 46, 74, 0.25);
    flex: 0 0 auto;
  }
  /* leave the "Near me" button visible under the sheet */
  .map-nearme {
    bottom: calc(62vh + 0.5rem);
  }
}

.map-panel__close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--c-navy);
  font-size: 1.6rem;
  cursor: pointer;
  z-index: 2;
}
.map-panel__close:hover {
  background: rgba(28, 46, 74, 0.08);
}

.map-panel__head {
  padding: 1.25rem 3rem 0.75rem 1.25rem;
  flex: 0 0 auto;
  border-bottom: 1px solid rgba(28, 46, 74, 0.08);
}
.map-panel__eyebrow {
  margin: 0 0 0.15rem;
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-ink-muted);
}
.map-panel__title {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.25;
  color: var(--c-navy);
}

.map-panel__list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1 1 auto;
}

/* ── panel row ───────────────────────────────────────────────────── */

.map-row {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid rgba(28, 46, 74, 0.06);
}
.map-row--focused {
  background: rgba(193, 77, 46, 0.06);
}
.map-row__link {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 0.75rem;
  align-items: start;
  color: inherit;
  text-decoration: none;
}
.map-row__link:hover .map-row__title {
  color: var(--c-rust);
}
.map-row__thumb {
  width: 76px;
  height: 76px;
  object-fit: cover;
  border-radius: 4px;
  background: #EAE4D6;
}
.map-row__meta {
  min-width: 0;
}
.map-row__date {
  margin: 0 0 0.15rem;
  font-size: 0.8125rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-ink-muted);
}
.map-row__title {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.3;
  color: var(--c-navy);
  transition: color 120ms var(--easing, ease);
  /* clamp long titles to 3 lines in the row */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.map-row__badges {
  margin: 0.35rem 0 0;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.map-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  background: rgba(28, 46, 74, 0.08);
  color: var(--c-navy);
}
.map-badge--now { background: rgba(193, 77, 46, 0.14); color: var(--c-rust); }
.map-badge--color { background: rgba(127, 169, 160, 0.20); color: #2E5A54; }
.map-badge--anim { background: rgba(28, 46, 74, 0.14); color: var(--c-navy); }

/* ── then / now slider inside a row ──────────────────────────────── */

.map-row__thennow {
  margin-top: 0.6rem;
}
.map-row__slider {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 4px;
  background: #EAE4D6;
  cursor: ew-resize;
  user-select: none;
  outline-offset: 3px;
}
.map-row__slider .thennow-slider__then,
.map-row__slider .thennow-slider__now {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.map-row__slider .thennow-slider__now-wrap {
  position: absolute;
  inset: 0;
  width: 50%;
  overflow: hidden;
  border-right: 2px solid var(--c-cream);
}
.map-row__slider .thennow-slider__handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--c-cream);
  box-shadow: 0 0 0 1px rgba(28, 46, 74, 0.30);
  transform: translateX(-1px);
  pointer-events: none;
}
.map-row__slider .thennow-slider__grip {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--c-rust);
  box-shadow:
    0 0 0 3px var(--c-cream),
    0 0 0 4px rgba(28, 46, 74, 0.35);
}
.map-row__slider .thennow-slider__labels {
  position: absolute;
  inset: auto 0 0.35rem 0;
  display: flex;
  justify-content: space-between;
  padding: 0 0.5rem;
  pointer-events: none;
}
.map-row__slider .thennow-slider__label {
  font-size: 0.8125rem;
  letter-spacing: 0.03em;
  color: var(--c-cream);
  background: rgba(14, 24, 38, 0.62);
  padding: 2px 6px;
  border-radius: 3px;
}

/* ── noscript fallback (spec §7) ─────────────────────────────────── */

.map-noscript {
  padding: 2rem;
  color: var(--c-navy);
  overflow-y: auto;
  max-height: 100%;
  background: var(--c-cream);
}
.map-noscript p { max-width: 40rem; }
.map-noscript__places { list-style: none; padding: 0; }
.map-noscript__places > li { margin: 1rem 0; }
.map-noscript__places ul { margin: 0.35rem 0 0 1rem; }

.map-error {
  padding: 2rem;
  color: var(--c-navy);
  background: var(--c-cream);
}

/* ── reduced motion ──────────────────────────────────────────────── */

[data-motion="reduced"] .map-pin__dot,
[data-motion="reduced"] .map-cluster,
[data-motion="reduced"] .map-pin--area path {
  transition: none;
}


/* ───────────────────────────────────────────────────────────────────
   F4 · Then/Now at the pin — inline "This spot today" video card
   + "Stand here →" geo link. Spec: docs/ux-upgrade-spec.md
   ─────────────────────────────────────────────────────────────────── */

.map-row__nowclip {
  margin-top: 0.5rem;
}

.map-row__nowclip-toggle {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid rgba(28, 46, 74, 0.16);
  border-radius: 3px;
  background: #F5EFE4;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.map-row__nowclip-toggle:hover,
.map-row__nowclip-toggle:focus-visible {
  border-color: rgba(193, 77, 46, 0.45);
  box-shadow: 0 2px 8px rgba(28, 46, 74, 0.10);
  outline: none;
}

.map-row__nowclip-poster {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: rgba(28, 46, 74, 0.06);
}

.map-row__nowclip-play {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 3rem; height: 3rem;
  background: rgba(28, 46, 74, 0.85);
  color: #F5EFE4;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  padding-left: 0.15rem;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(14, 24, 38, 0.35);
}

.map-row__nowclip-label {
  position: absolute;
  left: 0.5rem;
  bottom: 0.5rem;
  padding: 0.2rem 0.55rem;
  background: rgba(28, 46, 74, 0.85);
  color: #F5EFE4;
  font-family: var(--ff-ui, Inter, sans-serif);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: 2px;
  pointer-events: none;
}

.map-row__nowclip-video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0E1826;
  border: 1px solid rgba(28, 46, 74, 0.16);
  border-radius: 3px;
}

/* Stand here → geo link */
.map-row__stand-here {
  display: inline-block;
  margin-top: 0.55rem;
  padding: 0.35rem 0;
  color: var(--c-rust-text, #A03D22);
  font-family: var(--ff-ui, Inter, sans-serif);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-decoration: none;
  border-bottom: 1px solid rgba(193, 77, 46, 0.42);
}

.map-row__stand-here:hover,
.map-row__stand-here:focus-visible {
  border-bottom-color: currentColor;
  outline: none;
}
