main .gpx-embed {
  width: calc(100% + (2 * var(--media-bleed)));
  max-width: var(--media-max);
  margin: 2.5rem auto;
  margin-left: calc(-1 * var(--media-bleed));
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--code-bg);
}

.gpx-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
}

.gpx-title {
  color: var(--heading-color);
  font-family: var(--font-main);
  font-size: 1.05rem;
}

.gpx-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.85rem 1.15rem 1.15rem;
  border-top: 1px solid var(--border);
}

.gpx-download {
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.gpx-download:hover,
.gpx-download:focus-visible {
  color: var(--link-color);
}

/* Attribution, styled as a small bordered badge — the same treatment hikeabove.com itself
   uses for its "Discover Above" link — but slimmer, and in the site's own neutral border/
   text tokens rather than Above's green: the only colour stays confined to the small,
   self-contained logo mark, not the badge chrome. */
.gpx-above-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--link-color);
  font: inherit;
  font-size: 0.8rem;
  text-decoration: none;
  white-space: nowrap;
}

.gpx-above-link:hover,
.gpx-above-link:focus-visible {
  border-color: var(--link-color);
}

/* A CSS background-image rather than an <img>: this badge sits inside .post-content,
   which the site styles heavily for real post photos (responsive width, forced
   border-radius, the build's image-performance pass rewriting width/height to the
   source file's true pixel size) — all of it wrong for an 16px logo mark, and fighting
   it caused more layout breakage than it was worth. A plain element with a background
   image answers to none of that. */
.gpx-above-icon {
  width: 16px;
  height: 16px;
  border-radius: 22%;
  background-image: url("/assets/images/above-icon-light.png");
  background-size: cover;
  flex-shrink: 0;
}

@media (prefers-color-scheme: dark) {
  .gpx-above-icon {
    background-image: url("/assets/images/above-icon-dark.png");
  }
}

.gpx-map-shell {
  min-height: clamp(17rem, 52vw, 29rem);
  background: var(--code-bg);
}

/* Sizing only — the icon, copy and click-target/focus treatment come from the shared
   .embed-placeholder component in main.css (13-rich-content-media.css). Padding is restated
   here: the shared component's own padding is a responsive clamp() sized for a 16:9 iframe
   placeholder, not for this widget's taller map area, so this keeps GPX's original fixed value. */
.gpx-map,
.gpx-map-placeholder {
  width: 100%;
  min-height: clamp(17rem, 52vw, 29rem);
}

.gpx-map-placeholder {
  padding: 2rem;
}

.gpx-map-placeholder[hidden],
.gpx-map[hidden] {
  display: none;
}

.gpx-elevation {
  padding: 1rem 1.15rem 0;
  border-top: 1px solid var(--border);
}

.gpx-elevation-chart {
  position: relative;
  min-height: 8rem;
  padding-left: 3.25rem;
}

.gpx-elevation svg {
  display: block;
  width: 100%;
  height: 8rem;
  overflow: visible;
  touch-action: pan-y;
}

.gpx-elevation polygon {
  fill: color-mix(in srgb, var(--link-color) 17%, transparent);
}

.gpx-elevation polyline {
  fill: none;
  stroke: var(--link-color);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.gpx-elevation-cursor {
  stroke: var(--heading-color);
  stroke-dasharray: 5 5;
  vector-effect: non-scaling-stroke;
}

.gpx-elevation-max,
.gpx-elevation-min {
  position: absolute;
  left: 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1;
}

.gpx-elevation-max { top: 0; }
.gpx-elevation-min { bottom: 0; }

.gpx-elevation-tooltip {
  position: absolute;
  top: 0.25rem;
  padding: 0.3rem 0.45rem;
  border-radius: 0.25rem;
  color: var(--code-color);
  background: var(--code-bg);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.18);
  font-size: 0.75rem;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}

.gpx-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 0;
  padding: 1rem 1.15rem 1.15rem;
  gap: 0.75rem;
}

.gpx-stat { min-width: 0; }

.gpx-stat dt {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.2;
}

.gpx-stat dd {
  margin: 0.2rem 0 0;
  color: var(--heading-color);
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
}

.gpx-status {
  margin: 0;
  padding: 0 1.15rem 1.15rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.gpx-error { color: #b42318; }

/*
 * Start/finish markers, matched to Above's own A/B endpoint badge (MapBadgeImages.swift:
 * endpointBadge) — white ring, orange fill, bold white letter, 28px with a 3px ring. Fixed
 * colours rather than the site's light/dark tokens: Above draws these onto the basemap via
 * `AboveTheme.onMap`, which always resolves to the light value because the basemap itself
 * has no dark mode, and OpenTopoMap here is the same kind of always-light surface.
 */
.gpx-endpoint-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  color: #fff;
  font-family: var(--font-main);
  font-size: 0.75rem;
  font-weight: 700;
  background: #f29421;
}

/* Shown on the map while hovering the elevation chart below — same blue as the route line,
   sized well under the 28px endpoint badges so it never reads as a third A/B-style stop. */
.gpx-elevation-cursor-dot {
  display: block;
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  background: #1b6bdb;
}

/* Same breakpoint main.css uses to drop post images to edge-to-edge with square corners
   (--media-bleed collapses to --page-gutter there) — the embed's own bleed width already
   follows that automatically via --media-bleed, so only the corners need to catch up here. */
@media (max-width: 42rem) {
  main .gpx-embed {
    border-radius: 0;
  }

  .gpx-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
