/* ==========================================================================
   Tour route map (MapLibre + self-hosted PMTiles)
   Scoped to .RouteMap so it never leaks into the rest of the theme.
   ========================================================================== */

.RouteMap,
.RM-map {
  --rm-brand: #794000;
  --rm-brand-soft: rgba(121, 64, 0, 0.12);
  --rm-ink: #2c2118;
  --rm-paper: #f6f1e7;
  --rm-line: rgba(121, 64, 0, 0.18);
}

.RouteMap {
  position: relative;
  margin: 0 0 2rem;
  border: 1px solid var(--rm-line);
  border-radius: 18px;
  background: var(--rm-paper);
  overflow: hidden;
  box-shadow: 0 18px 40px -30px rgba(44, 33, 24, 0.55);
}

.RouteMap-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  padding: 1rem 1.1rem 0.9rem;
}

.RouteMap-headText {
  flex: 1 1 220px;
  min-width: 0;
}

.RouteMap-kicker {
  margin: 0 0 0.15rem;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--rm-brand);
  font-weight: 600;
}

.RouteMap-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
  color: var(--rm-ink);
  font-weight: 600;
  max-width: 34ch;
}

.RouteMap-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  color: #6d5c4b;
}

.RouteMap-stats span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.RouteMap-stats span + span::before {
  content: "";
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
}

.RouteMap-tools {
  display: flex;
  flex-shrink: 0;
  gap: 0.35rem;
}

.RouteMap-tool {
  appearance: none;
  border: 1px solid var(--rm-line);
  background: #fff;
  color: var(--rm-brand);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.42rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
  min-height: 34px;
}

.RouteMap-tool:hover,
.RouteMap-tool:focus-visible {
  border-color: var(--rm-brand);
}

.RouteMap-tool.is-active {
  background: var(--rm-brand);
  border-color: var(--rm-brand);
  color: #fff;
}

.RouteMap-tool--icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  padding: 0;
}

.RouteMap-tool--icon svg {
  width: 16px;
  height: 16px;
}

.RouteMap-tool:focus-visible,
.RouteMap-pin:focus-visible,
.RouteMap-day:focus-visible {
  outline: 2px solid #1b6ca8;
  outline-offset: 2px;
}

.RouteMap-stage {
  position: relative;
  height: clamp(360px, 52vh, 620px);
  background:
    linear-gradient(180deg, rgba(246, 241, 231, 0) 60%, rgba(246, 241, 231, 0.9) 100%),
    #eae3d5;
}

.RouteMap-canvas {
  position: absolute;
  inset: 0;
}

.RouteMap-canvas .maplibregl-ctrl-attrib {
  font-size: 10px;
  background: rgba(255, 255, 255, 0.82);
}

.RouteMap-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-size: 0.82rem;
  color: #6d5c4b;
  background: var(--rm-paper);
  z-index: 3;
  transition: opacity 0.3s ease;
}

.RouteMap-loading.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.RouteMap-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--rm-brand-soft);
  border-top-color: var(--rm-brand);
  animation: rm-spin 0.9s linear infinite;
}

@keyframes rm-spin {
  to { transform: rotate(360deg); }
}

.RouteMap-fallback {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: var(--rm-paper);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.RouteMap-fallback img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 10px;
}

.RouteMap-days {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 1.9rem;
  z-index: 2;
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding: 0.25rem 0.15rem;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
}

.RouteMap-days::-webkit-scrollbar { display: none; }

.RouteMap-day {
  appearance: none;
  flex: 0 0 auto;
  border: 1px solid rgba(121, 64, 0, 0.22);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px);
  color: var(--rm-ink);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.42rem 0.72rem;
  border-radius: 999px;
  cursor: pointer;
  min-height: 32px;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
  white-space: nowrap;
}

.RouteMap-day:hover { transform: translateY(-1px); }

.RouteMap-day.is-active {
  background: var(--rm-brand);
  border-color: var(--rm-brand);
  color: #fff;
}

.RouteMap-hint {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  z-index: 2;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  color: #4a3c2f;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--rm-line);
  border-radius: 999px;
  padding: 0.28rem 0.6rem;
  transition: opacity 0.4s ease;
}

.RouteMap-hint.is-hidden { opacity: 0; }

/* Map pins (DOM markers, real buttons) */
.RouteMap-pin {
  appearance: none;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: 999px;
  border: 2px solid #fff;
  background: var(--rm-brand);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 6px 14px -6px rgba(44, 33, 24, 0.75);
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.RouteMap-pin:hover { transform: scale(1.08); }

.RouteMap-pin.is-active {
  background: #2c2118;
  transform: scale(1.16);
  box-shadow: 0 0 0 5px rgba(121, 64, 0, 0.18), 0 8px 16px -8px rgba(44, 33, 24, 0.8);
}

.RouteMap-pin.is-start {
  background: #1f5c3a;
}

.RouteMap-pin span { position: relative; top: -1px; }

/* Popup */
.RouteMap .maplibregl-popup-content {
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--rm-ink);
  box-shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.6);
}

.RouteMap .maplibregl-popup-content strong { display: block; font-size: 0.84rem; }
.RouteMap .maplibregl-popup-content em { color: var(--rm-brand); font-style: normal; font-weight: 600; }

/* Full-width map above the itinerary on desktop (mobile keeps the same stack) */
@media (min-width: 992px) {
  .RouteItinerary .RouteMap-stage {
    height: clamp(420px, 52vh, 620px);
  }
}

@media (max-width: 991.98px) {
  .RouteMap-head {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }
  .RouteMap-tools { justify-content: flex-start; }
  .RouteMap-stage { height: clamp(320px, 46vh, 460px); }
}

/* Fullscreen mode */
.RouteMap:fullscreen,
.RouteMap.is-fullscreen {
  border-radius: 0;
  display: flex;
  flex-direction: column;
  background: var(--rm-paper);
  width: 100%;
  height: 100%;
  margin: 0;
}

.RouteMap:fullscreen .RouteMap-stage,
.RouteMap.is-fullscreen .RouteMap-stage {
  flex: 1;
  height: auto;
}

/* No-JS: show the fallback image and hide chrome */
.no-js .RouteMap-days,
.no-js .RouteMap-tools { display: none; }

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

@media (prefers-reduced-motion: reduce) {
  .RouteMap *,
  .RouteMap *::before,
  .RouteMap *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
}

/* Print: static map + text, no controls */
@media print {
  .RouteMap-tools,
  .RouteMap-days,
  .RouteMap-hint { display: none !important; }
  .RouteMap-stage { height: 420px; }
  .RouteMap { break-inside: avoid; box-shadow: none; }
}
