/* GPX route map widget — scoped chrome. MapLibre's own CSS (markers, controls,
   attribution) is loaded separately from the CDN in blog_page.html. */
.gpx-map-wrap {
  width: 100%;
  position: relative;
}

.gpx-map {
  width: 100%;
  min-height: 240px;
  border-radius: var(--bs-border-radius, 0.375rem);
  overflow: hidden;
  border: 1px solid var(--bs-border-color, rgba(0, 0, 0, 0.15));
}

/* Keep the attribution readable on the monochrome basemap in either theme. */
.gpx-map .maplibregl-ctrl-attrib {
  font-size: 0.7rem;
}

/* Route endpoint markers. Colours are fixed (they sit on the map, not the page)
   and the white ring keeps them legible on the monochrome basemap. */
.gpx-marker {
  box-sizing: border-box;
}

.gpx-marker-start,
.gpx-marker-rest {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.4);
}

.gpx-marker-start {
  background: #16a34a; /* green — begin */
}

.gpx-marker-rest {
  background: #f59e0b; /* amber — rest, then continued onto the next leg */
}

.gpx-marker-finish,
.gpx-marker-loop {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.4);
  font-size: 14px;
}

.gpx-marker-finish {
  background: #fff; /* white badge, dark flag — the finish */
  color: #111;
}

/* Combined start-finish for loop / out-and-back / lollipop: green like a start,
   flagged like a finish — "begins & ends here". */
.gpx-marker-loop {
  background: #16a34a;
  color: #fff;
}

/* Legend — mobile-first: a strip beneath the map. */
.gpx-legend {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.gpx-legend-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
}

/* Per-route eye toggle. Hidden until gpx-map-widget.js adds .gpx-interactive to
   the wrap, so it never appears as a dead control when the map can't run. */
.gpx-legend-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  line-height: 1;
  font-size: 1.05rem;
  opacity: 0.8;
}

.gpx-map-wrap.gpx-interactive .gpx-legend-toggle {
  display: inline-flex;
}

.gpx-legend-toggle:hover,
.gpx-legend-toggle:focus-visible {
  opacity: 1;
}

/* Dim a route's row while it's toggled off the map. */
.gpx-legend-item.gpx-route-hidden {
  opacity: 0.5;
}

.gpx-legend-swatch {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 0.2rem;
  flex: 0 0 auto;
}

.gpx-legend-label {
  font-weight: 600;
}

.gpx-legend-stats {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.75rem;
  color: var(--bs-secondary-color, #6c757d);
}

.gpx-stat {
  white-space: nowrap;
}

/* Wide viewports: float the legend as an overlay in the map's top-left corner
   (clear of MapLibre's top-right controls and bottom attribution/scale). The
   panel uses the site's own body background + text colour, so it matches the page
   and flips with the light/dark theme toggle (both are redefined per
   data-bs-theme by Halfmoon; --bs-body-bg-rgb is NOT defined, so don't use it). */
@media (min-width: 576px) {
  .gpx-legend {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 1;
    margin-top: 0;
    max-width: min(60%, 22rem);
    max-height: calc(100% - 1.5rem);
    overflow-y: auto;
    padding: 0.5rem 0.75rem;
    border-radius: var(--bs-border-radius, 0.375rem);
    background-color: var(--bs-body-bg, #fff);
    color: var(--bs-body-color, #212529);
    border: 1px solid var(--bs-border-color, rgba(0, 0, 0, 0.15));
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  }
}
