/* ── CSS variables (light + dark, self-contained) ─────────────── */
:root {
  --background: #f5f7fa;
  --text: #1c1c28;
  --accent: #0067c5;
  --accent-light: #5ba8ff;
  --surface: #ffffff;
  --muted: #6f7780;
  --border: #e1e6ee;
  --shadow: rgba(15, 25, 45, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #0e1117;
    --text: #f5f7fa;
    --accent: #4cc3ff;
    --accent-light: #8ad7ff;
    --surface: #161b23;
    --muted: #c0c7d1;
    --border: #2a3040;
    --shadow: rgba(0, 0, 0, 0.45);
  }
}

/* ── Page reset — full-screen map ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: var(--background);
}

#map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ── Brand card — bottom-center pill (title bar) ───────────────── */
.sm-brand-card {
  position: fixed;
  bottom: 52px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: rgba(22, 27, 35, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid #2a3040;
  border-radius: 999px;
  padding: 6px 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  display: flex;
  align-items: baseline;
  gap: 10px;
  max-width: calc(100vw - 32px);
  white-space: nowrap;
}

.sm-brand-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #c0c7d1;
  text-decoration: none;
  transition: color 0.15s ease;
}
.sm-brand-link:hover { color: #4cc3ff; }

.sm-brand-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #f5f7fa;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ── Play/Pause button — bottom-left ─────────────────────────── */
.sm-play-btn {
  position: fixed;
  bottom: 32px;
  left: 20px;
  z-index: 20;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1.5px solid #2a3040;
  background: rgba(22, 27, 35, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #f5f7fa;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(0,0,0,0.5);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.15s ease;
  padding: 0;
}
.sm-play-btn:hover {
  transform: translateY(-1px) scale(1.05);
  box-shadow: 0 10px 24px rgba(0,0,0,0.5);
  border-color: #4cc3ff;
}
.sm-play-btn svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* ── Scene dot indicators — bottom-center (nav bar) ──────────── */
.sm-dots {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(22, 27, 35, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid #2a3040;
  border-radius: 99px;
  padding: 8px 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
}

.sm-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2a3040;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease, width 0.25s ease, border-radius 0.25s ease;
  flex-shrink: 0;
}
.sm-dot:hover {
  background: #c0c7d1;
  transform: scale(1.25);
}
.sm-dot.is-active {
  background: #4cc3ff;
  width: 22px;
  border-radius: 99px;
  transform: none;
}

/* ── Next button — right center ──────────────────────────────── */
.sm-next-btn {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1.5px solid #2a3040;
  background: rgba(22, 27, 35, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #f5f7fa;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(0,0,0,0.5);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.15s ease;
  padding: 0;
}
.sm-next-btn:hover {
  transform: translateY(-50%) scale(1.05);
  box-shadow: 0 10px 24px rgba(0,0,0,0.5);
  border-color: #4cc3ff;
}
.sm-next-btn svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* ── Basemap toggle buttons ──────────────────────────────────── */
.maplibregl-ctrl-group button.satellite-btn,
.maplibregl-ctrl-group button.view-toggle-btn {
  width: auto;
  padding: 0 10px;
  height: 29px;
  font-size: 12px;
  font-weight: 600;
  background: #1e2530;
  color: #e8edf2;
  white-space: nowrap;
}
.maplibregl-ctrl-group button.satellite-btn:hover,
.maplibregl-ctrl-group button.view-toggle-btn:hover { background: #2a3040; }
.maplibregl-ctrl-group button.satellite-btn.active,
.maplibregl-ctrl-group button.view-toggle-btn.active {
  background: #0e2a4a;
  color: #4cc3ff;
}

/* ── Fixed-center popup — sits above brand card ──────────────── */
.sm-popup-fixed {
  position: fixed !important;
  bottom: 92px !important;
  left: 50% !important;
  top: auto !important;
  transform: translateX(-50%) !important;
}
.sm-popup-fixed .maplibregl-popup-tip {
  display: none !important;
}

/* ── MapLibre popup overrides ────────────────────────────────── */
.maplibregl-popup-content {
  background: #fff;
  color: #000;
  border: 1px solid #e1e6ee;
  border-radius: 14px;
  padding: 0;
  box-shadow: 0 12px 32px rgba(15, 25, 45, 0.12);
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  min-width: 242px;
  max-width: 600px;
  max-height: 70vh;
  overflow-x: hidden;
  overflow-y: auto;
}

.maplibregl-popup-tip {
  border-top-color: #fff !important;
}

.maplibregl-popup-close-button {
  position: absolute;
  top: 0;
  right: 0;
  color: #555;
  font-size: 1.1rem;
  padding: 8px 11px;
  line-height: 1;
  border-radius: 0 14px 0 0;
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 1;
  transition: color 0.15s ease, background 0.15s ease;
}
.maplibregl-popup-close-button:hover {
  color: #000;
  background: rgba(225, 230, 238, 0.4);
}

/* ── Rich popup inner layout ─────────────────────────────────── */
.sm-popup {
  padding: 14px 16px 16px;
}

.sm-popup-header {
  margin-bottom: 10px;
  padding-right: 20px; /* clear close button */
}
.sm-popup-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: #000;
  line-height: 1.3;
}
.sm-popup-subtitle {
  margin: 3px 0 0;
  font-size: 0.9rem;
  color: #333;
  line-height: 1.4;
}

/* Image — bleeds to popup edges */
.sm-popup-figure {
  margin: -14px -16px 12px;
  padding: 0;
}
.sm-popup-img {
  width: 100%;
  display: block;
  max-height: 160px;
  object-fit: cover;
}
.sm-popup-figure figcaption {
  font-size: 0.8rem;
  color: #555;
  padding: 4px 10px 2px;
  text-align: right;
}

/* Video-mode popup — force a wide fixed width so the video fills space */
.sm-popup-video-mode .maplibregl-popup-content {
  width: 560px;
}

/* YouTube embed — full-width bleed, 16:9 */
.sm-popup-video-wrap {
  margin: 0 -16px 12px;
  background: #000;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  position: relative;
}
.sm-yt-placeholder,
.sm-popup-video-wrap iframe,
.sm-popup-video-wrap video {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  border: none;
  display: block;
  object-fit: cover;
}

/* Mapillary street-view embed — full-width, 16:9 */
.sm-popup-mapillary {
  margin: 0 -16px 12px;
  background: #111;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  position: relative;
}
.sm-popup-mapillary iframe {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  border: none;
  display: block;
}

/* Body text */
.sm-popup-body {
  font-size: 0.95rem;
  color: #000;
  line-height: 1.55;
  margin-bottom: 10px;
}
.sm-popup-body p { margin: 0 0 6px; }
.sm-popup-body p:last-child { margin-bottom: 0; }

.sm-popup-bullets {
  margin: 0 0 10px;
  padding-left: 18px;
  font-size: 0.95rem;
  color: #000;
  line-height: 1.55;
}
.sm-popup-bullets li {
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Stats table */
.sm-popup-stats {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-bottom: 12px;
  border-top: 1px solid #e1e6ee;
}
.sm-popup-stats tr + tr td,
.sm-popup-stats tr + tr th {
  border-top: 1px solid #e1e6ee;
}
.sm-popup-stats th {
  text-align: left;
  font-weight: 600;
  color: #333;
  padding: 5px 8px 5px 0;
  white-space: nowrap;
  width: 42%;
}
.sm-popup-stats td {
  text-align: right;
  color: #000;
  padding: 5px 0;
  font-weight: 700;
}

/* CTA link — full-width filled button */
.sm-popup-link {
  display: block;
  text-align: center;
  background: #0067c5;
  color: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.1s ease;
  margin-top: 2px;
}
.sm-popup-link:hover {
  background: color-mix(in srgb, #0067c5 80%, #000);
  transform: translateY(-1px);
  color: #fff;
}
.sm-popup-links {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.sm-popup-links .sm-popup-link {
  flex: 1 1 0;
  padding: 5px 8px;
  font-size: 0.78rem;
  border-radius: 6px;
  margin-top: 0;
}
.sm-popup-link--secondary {
  background: transparent;
  color: #0067c5;
  border: 1.5px solid #0067c5;
  padding: 5px 8px;
}
.sm-popup-link--secondary:hover {
  background: rgba(0, 103, 197, 0.08);
  transform: translateY(-1px);
  color: #0067c5;
}

/* ── Mobile tweaks ───────────────────────────────────────────── */
@media (max-width: 600px) {
  .sm-brand-card {
    bottom: 48px;
    padding: 5px 12px;
    gap: 8px;
  }
  .sm-brand-title { font-size: 0.88rem; }

  .maplibregl-popup-content {
    max-width: 308px;
  }

  .sm-play-btn {
    bottom: 24px;
    left: 14px;
  }

  .sm-dots {
    bottom: 14px;
    gap: 6px;
    padding: 6px 12px;
  }
}
