/* Trek route map — mirrors kanchenjungaguides.com's trek map. */
.mg-route-section,
.mg-route-host {
  --mg-route-brand: #0b5cab;
  --mg-route-ink: #16324f;
  --mg-route-muted: #5c6570;
  --mg-route-line: #d7e8f4;
}
.mg-route-section {
  scroll-margin-top: 7rem;
  margin: 2rem 0;
  padding: 1rem;
  border: 1px solid var(--mg-route-line);
  border-radius: 0.75rem;
  background: #fff;
}
@media (min-width: 640px) {
  .mg-route-section { padding: 1.25rem; }
}

.mg-route-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.mg-route-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 1.5rem;
  line-height: 2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--mg-route-ink);
}
.mg-route-title svg { color: var(--mg-route-brand); flex-shrink: 0; }
.mg-route-download {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--mg-route-brand);
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--mg-route-brand);
  text-decoration: none;
}
.mg-route-download:hover { background: rgba(11, 92, 171, 0.05); }

.mg-route-map {
  position: relative;
  height: 28rem;
  width: 100%;
  margin-top: 1rem;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
/* Placeholder tint while Mapbox GL lazy-loads. */
.mg-route-map[data-mg-route-map] { background: #e8eee4; }
.mg-route-unavailable {
  display: grid;
  place-items: center;
  padding: 0 1.5rem;
  background: #f8fafc;
  text-align: center;
  font-size: 0.875rem;
  color: var(--mg-route-muted);
}

/* Host is moved between the inline slot and <body> for fullscreen. */
.mg-route-host { position: relative; height: 100%; width: 100%; }
.mg-route-host.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 100000;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  background: #fff;
}
/* Higher specificity than Mapbox's own `.mapboxgl-map { position: relative }`,
   which is lazy-loaded after this file and would otherwise collapse the map to 0px. */
.mg-route-host .mg-route-canvas { position: absolute; inset: 0; z-index: 0; }
/* z-index 0 above makes the map its own stacking context: markers (and their
   z-index ordering) can never rise over the legend or buttons. */

.mg-route-host .mg-route-fs-btn {
  position: absolute;
  left: 0.75rem;
  top: 0.75rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  height: 29px;
  margin: 0;
  padding: 0 0.625rem;
  border: 0;
  border-radius: 0.375rem;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  color: var(--mg-route-ink, #16324f);
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  transition: background-color 0.15s;
}
.mg-route-host .mg-route-fs-btn:hover { background: #f1f5f9; }
.mg-route-host .mg-route-view-btn { left: auto; right: 3.25rem; }
@media (max-width: 480px) {
  .mg-route-host .mg-route-view-btn { right: auto; left: 0.75rem; top: 3rem; }
}

/* Icons (lucide) */
.mg-route-ico { width: 14px; height: 14px; }
.mg-route-ico-sm { width: 12px; height: 12px; }
.mg-route-ico-xs { width: 14px; height: 14px; flex-shrink: 0; }
.mg-route-popup-note .mg-route-ico-xs { width: 12px; height: 12px; }

/* Waypoint markers — sized by importance: overnight stop > day hike > stop on the way. */
.mg-route-marker-wrap.is-day,
.mg-route-marker-wrap.is-start { z-index: 3; }
.mg-route-marker-wrap.is-airport { z-index: 2; }
.mg-route-marker-wrap.is-spur { z-index: 1; }
.mg-route-marker-wrap.is-stop { z-index: 0; }
.mg-route-marker-wrap:hover { z-index: 4; }

.mg-route-marker {
  display: grid;
  place-items: center;
  box-sizing: border-box;
  height: 26px;
  min-width: 26px;
  margin: 0;
  padding: 0;
  border: 2.5px solid #fff;
  border-radius: 9999px;
  background: var(--mg-route-brand, #0b5cab);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.35), 0 0 0 1px rgba(15, 23, 42, 0.08);
  color: #fff;
  font-family: inherit;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.15s;
}
.mg-route-marker:hover {
  transform: scale(1.12);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.4), 0 0 0 1px rgba(15, 23, 42, 0.08);
}
.mg-route-marker:focus-visible { outline: 3px solid #fbbf24; outline-offset: 2px; }
.mg-route-marker.is-day { padding: 0 6px; }
.mg-route-marker.is-start { width: 26px; }
.mg-route-marker.is-start.has-days { width: auto; gap: 3px; padding: 0 7px 0 5px; grid-auto-flow: column; }
.mg-route-marker.is-airport { width: 24px; height: 24px; min-width: 24px; background: #0284c7; }
.mg-route-marker.is-spur { width: 20px; height: 20px; min-width: 20px; border-width: 2px; background: #0d9488; }
.mg-route-marker.is-spur .mg-route-ico { width: 12px; height: 12px; }
/* A named kind of place (lake, gompa, base camp…) — colour set inline per type. */
.mg-route-marker.is-place { width: 22px; height: 22px; min-width: 22px; border-width: 2px; }
.mg-route-marker.is-place .mg-route-ico { width: 13px; height: 13px; }
/* Stop on the way: a small ringed dot — a place passed through, not a day's end. */
.mg-route-marker.is-stop {
  width: 14px;
  height: 14px;
  min-width: 14px;
  border: 3px solid var(--mg-route-brand, #0b5cab);
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.35);
}

/* Legend — collapsible: a small toggle button, the rows open above it. */
.mg-route-legend {
  position: absolute;
  bottom: 0.75rem;
  left: 0.75rem;
  z-index: 2;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
  gap: 0.375rem;
  max-width: calc(100% - 1.5rem);
  max-height: calc(100% - 4.5rem);
  pointer-events: none;
}
.mg-route-host .mg-route-legend-toggle {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  height: 29px;
  margin: 0;
  padding: 0 0.625rem;
  border: 0;
  border-radius: 0.375rem;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  color: var(--mg-route-ink, #16324f);
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
}
.mg-route-host .mg-route-legend-toggle:hover { background: #f1f5f9; }
.mg-route-legend-chevron { width: 14px; height: 14px; transition: transform 0.15s; transform: rotate(180deg); }
.mg-route-legend.is-open .mg-route-legend-chevron { transform: none; }
.mg-route-legend-body {
  display: none;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.mg-route-legend.is-open .mg-route-legend-body { display: block; }
.mg-route-legend-rows { display: flex; flex-direction: column; gap: 0.3rem; }
.mg-route-legend-row { display: flex; align-items: center; gap: 0.5rem; }
.mg-route-legend-row svg { flex-shrink: 0; }
.mg-route-legend-row > span:last-child {
  white-space: nowrap;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--mg-route-ink, #16324f);
}
.mg-route-legend-dot {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-sizing: border-box;
  width: 18px;
  height: 18px;
  margin: 0 3px;
  border: 2px solid #fff;
  border-radius: 9999px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  color: #fff;
}
.mg-route-legend-dot.is-spur { background: #0d9488; }
.mg-route-legend-stop {
  flex-shrink: 0;
  box-sizing: border-box;
  width: 14px;
  height: 14px;
  margin: 0 6px;
  border: 3px solid var(--mg-route-brand, #0b5cab);
  border-radius: 9999px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}
.mg-route-legend-dot.is-airport { background: #0284c7; }
.mg-route-legend-dot.is-start { background: var(--mg-route-brand, #0b5cab); }

/* Popup — above every marker (they stack up to z-index 4). */
.mg-route-host .mapboxgl-popup { z-index: 5; }
.mg-route-popup .mapboxgl-popup-content { padding: 8px 10px; border-radius: 6px; }
.mg-route-popup-link:focus { outline: none; }
.mg-route-popup-link:focus-visible { outline: 2px solid var(--mg-route-brand, #0b5cab); outline-offset: 2px; border-radius: 3px; }
.mg-route-popup-link {
  display: block;
  padding: 2px 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--mg-route-ink, #16324f);
  text-decoration: none;
}
a.mg-route-popup-link:hover { color: var(--mg-route-brand, #0b5cab); }
.mg-route-popup-link span { margin-left: 4px; color: var(--mg-route-brand, #0b5cab); }
.mg-route-popup-note {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0 4px 2px;
  font-size: 12px;
  font-weight: 500;
  color: var(--mg-route-brand, #0b5cab);
}
.mg-route-popup-alt {
  margin: 0;
  padding: 0 4px 2px;
  font-size: 12px;
  font-weight: 500;
  color: var(--mg-route-muted, #5c6570);
}
.mg-route-popup-note.is-spur { color: #0f766e; }
.mg-route-popup-note.is-stop { color: var(--mg-route-muted, #5c6570); }
.mg-route-popup-note.is-airport { color: #0369a1; }
