/* Route detail.
   Desktop: editorial header, then a map / story / stop-rail workspace.
   Phone: the map leads and the story sits in a sheet below it. */

.route-page { display: block; padding-bottom: 40px; }

/* ── Header ────────────────────────────────────────────────────── */
.route-hero { display: grid; grid-template-columns: minmax(340px, 40%) 1fr; align-items: center; min-height: 440px; }
.route-hero-copy { padding: 32px clamp(24px, 2.6vw, 48px) 36px clamp(24px, 4vw, 64px); }
.route-hero h1 { font-size: clamp(40px, 4.6vw, 66px); letter-spacing: -.025em; }
.route-subtitle { margin: 14px 0 0; font-family: var(--serif); font-size: clamp(19px, 1.7vw, 25px); line-height: 1.25; color: var(--orange-text); }
.route-lede { margin: 18px 0 0; max-width: 44ch; font-size: 16.5px; line-height: 1.65; color: var(--ink); }

.route-hero-media { position: relative; align-self: stretch; min-height: 440px; }
.route-hero-photo { position: absolute; inset: 0; }
.route-hero-photo img { width: 100%; height: 100%; object-fit: cover; }
.route-hero-note { position: absolute; top: clamp(20px, 4vw, 54px); right: clamp(20px, 3vw, 54px); max-width: 230px; text-align: right; font-size: 23px; }
/* The facts card below overlaps the hero by 34px (.route-facts), so the credit
   (which carries the photograph's licence) and the place chip sit above it. */
.route-hero-place { position: absolute; right: clamp(18px, 2vw, 32px); bottom: 56px; }
.route-hero-media .photo-credit { left: 26px; right: auto; bottom: 48px; }

/* ── Facts ─────────────────────────────────────────────────────── */
.route-facts {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0;
  width: min(100% - 48px, var(--wrap)); margin: -34px auto 0; position: relative; z-index: 2;
  background: var(--paper-bright); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-md); overflow: hidden;
}
.route-facts .metric { padding: 15px 18px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.route-facts .metric:nth-child(4n) { border-right: 0; }
.route-facts .metric:nth-child(n+5) { border-bottom: 0; }
.route-facts .metric.is-muted { color: var(--ink-muted); }
.route-facts .metric-button { display: flex; align-items: center; gap: inherit; width: 100%; min-height: 44px; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.route-facts .metric-button[disabled] { cursor: progress; opacity: .7; }
.route-facts .metric.is-muted .ico { color: var(--ink-muted); }
.route-facts .metric.is-muted b { color: var(--ink-soft); font-weight: 600; }

/* ── Tab bar ───────────────────────────────────────────────────── */
.route-bar {
  position: sticky; top: var(--header-h); z-index: 500;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  width: min(100% - 48px, var(--wrap)); margin: 26px auto 0; padding: 7px 8px 7px 4px;
  background: rgba(253, 250, 244, .96); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.route-tabs { display: flex; flex-wrap: wrap; gap: 2px; }
.route-tabs::-webkit-scrollbar { display: none; }
.route-tabs a {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  padding: 11px 16px; border-radius: 7px; font-size: var(--text-sm); font-weight: 600; color: var(--ink-soft);
  border-bottom: 2px solid transparent;
}
.route-tabs a .ico { width: 17px; height: 17px; }
@media (hover: hover) { .route-tabs a:hover { background: var(--paper-deep); } }
.route-tabs a[aria-current='location'] { color: var(--orange-text); border-bottom-color: var(--orange-text); background: var(--orange-wash); }
.route-bar-actions { display: flex; gap: 8px; flex: none; }
.route-bar-actions .ico { width: 16px; height: 16px; }
.route-bar-actions .is-saved { border-color: var(--orange-text); color: var(--orange-text); background: var(--orange-wash); }

/* What the section links jump to must land below the sticky header and this bar (not
   scroll-padding-top on the page: see story.css). main.js publishes the bar's real height as
   --route-bar-h; the number is for before it runs. */
.route-overview, .stop-rail, .stop-panel, .route-glance, .map-panel { scroll-margin-top: calc(var(--header-h) + 16px + var(--route-bar-h, 58px)); }

/* ── Workspace ─────────────────────────────────────────────────── */
.route-workspace {
  display: grid; grid-template-columns: minmax(300px, 0.95fr) minmax(0, 1.25fr) minmax(280px, 0.85fr);
  gap: 20px; width: min(100% - 48px, var(--wrap)); margin: 20px auto 0; align-items: start;
}

/* Map */
.map-panel { position: sticky; top: calc(var(--header-h) + 76px); }
.map-frame {
  position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius);
  background: #eef2e6; box-shadow: var(--shadow-sm); aspect-ratio: 5 / 6; min-height: 420px;
}
.map-frame .route-map { position: absolute; inset: 0; width: 100%; height: 100%; }
.route-photos { margin-top: 28px; }
.photo-strip { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 12px; margin: 0; list-style: none; scroll-snap-type: x proximity; }
.photo-strip li { flex: 0 0 min(60vw, 220px); scroll-snap-align: start; }
.photo-strip-item { display: block; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--paper-bright); cursor: zoom-in; }
.photo-strip-item .photo, .photo-strip-item img { display: block; width: 100%; height: 100%; object-fit: cover; }
.lightbox { position: fixed; inset: 0; z-index: 1000; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding: 16px; background: rgb(var(--ink-rgb) / 92%); }
.lightbox[hidden] { display: none; }
.lightbox-figure { margin: 0; display: grid; gap: 10px; justify-items: center; min-width: 0; }
.lightbox-image { max-width: 100%; max-height: 78vh; object-fit: contain; border-radius: var(--radius); }
.lightbox-caption { color: var(--white); font-size: var(--text-xs); text-align: center; }
.lightbox-close, .lightbox-step { min-width: 44px; min-height: 44px; border: 0; border-radius: 999px; background: rgb(var(--white-rgb) / 16%); color: var(--white); font-size: 26px; line-height: 1; cursor: pointer; }
.lightbox-close { position: absolute; right: 12px; top: 12px; z-index: 1; }
.lightbox-close:focus-visible, .lightbox-step:focus-visible { outline: 3px solid var(--white); outline-offset: 2px; }
.has-lightbox { overflow: hidden; }
.route-map .map-placeholder { width: 100%; height: 100%; }
.map-controls { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); display: grid; gap: 6px; }
.map-toolbar { position: absolute; left: 12px; top: 12px; display: flex; gap: 6px; flex-wrap: wrap; max-width: calc(100% - 70px); }
.map-control {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 38px; height: 38px;
  padding: 0 10px; border-radius: 7px; border: 1px solid var(--line-strong); background: var(--paper-bright);
  font-size: var(--text-xs); font-weight: 600;
}
@media (hover: hover) { .map-control:hover { border-color: var(--ink); } }
.map-control .ico { width: 17px; height: 17px; }
.map-control[aria-pressed='true'] { color: var(--orange-text); border-color: var(--orange-text); }
.map-note { position: absolute; left: 16px; bottom: 12px; font-size: 20px; color: var(--ink-soft); transform: rotate(-4deg); pointer-events: none; }

/* Stop story */
.stop-panel {
  padding: 24px clamp(18px, 1.8vw, 30px) 28px; background: var(--paper-bright);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.stop-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.stop-panel-meta { display: flex; align-items: center; gap: 14px; font-size: var(--text-xs); color: var(--ink-muted); }
.stop-lang { display: inline-flex; align-items: center; gap: 5px; }
.stop-lang .ico { width: 15px; height: 15px; }
.stop-title { font-size: clamp(30px, 2.9vw, 43px); }
.stop-tagline { margin-top: 6px; font-family: var(--serif); font-size: clamp(18px, 1.5vw, 24px); color: var(--orange-text); line-height: 1.25; }
.stop-summary { margin-top: 14px; font-size: 16.5px; line-height: 1.68; color: var(--ink); }

.stop-media { position: relative; margin-top: 20px; border-radius: var(--radius); overflow: hidden; }
.stop-media .photo img { width: 100%; }
.stop-media::after {
  content: ''; position: absolute; inset: auto 0 0 0; height: 46%; pointer-events: none;
  background: linear-gradient(0deg, rgba(12, 28, 51, .88), rgba(12, 28, 51, 0));  /* a scrim so the control stays legible on any photograph */
}
.stop-play {
  position: absolute; inset: auto 0 0 0; z-index: 1; display: flex; align-items: center; gap: 13px;
  padding: 14px 18px; background: none;
  color: var(--white); font-size: 15px; font-weight: 600; width: 100%; text-align: left;
}
.stop-play-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--orange); }
.stop-play-mark .ico { width: 19px; height: 19px; fill: var(--white); stroke: none; margin-left: 2px; }
@media (hover: hover) { .stop-play:hover .stop-play-mark { background: var(--orange-deep); } }
.stop-media-note { position: absolute; top: 10px; right: 12px; padding: 5px 9px; border-radius: 4px; background: rgba(12, 28, 51, .72); color: rgb(var(--white-rgb) / 95%); font-size: var(--text-xs); }

.stop-tabs { display: flex; flex-wrap: wrap; gap: 22px; margin: 22px 0 0; border-bottom: 1px solid var(--line); }
.stop-tabs button { padding: 10px 0; font-size: var(--text-xs); font-weight: 600; color: var(--ink-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.stop-tabs button[aria-selected='true'] { color: var(--orange-text); border-bottom-color: var(--orange-text); }
.stop-tab-panel { padding-top: 18px; }
.stop-quote { position: relative; margin: 0; padding: 18px 20px 18px 54px; background: var(--paper-deep); border-radius: var(--radius); }
.stop-quote .ico { position: absolute; left: 18px; top: 18px; width: 24px; height: 24px; color: var(--orange-text); opacity: .5; }
.stop-quote p { font-family: var(--serif); font-size: 17px; line-height: 1.65; }
.stop-tab-panel .data-note { margin-top: 12px; }
.stop-facts { display: grid; gap: 12px; }
.stop-facts > div { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.stop-facts dt { font-size: var(--text-xs); color: var(--ink-muted); }
.stop-facts dd { margin: 0; font-size: var(--text-xs); font-weight: 600; }
.stop-related li + li { margin-top: 8px; }
.stop-related button { display: block; width: 100%; text-align: left; padding: 11px 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
@media (hover: hover) { .stop-related button:hover { border-color: var(--orange-text); } }
.stop-related b { display: block; font-size: var(--text-sm); }
.stop-related span { font-size: var(--text-xs); color: var(--ink-muted); }

/* Stop rail */
.stop-rail {
  position: sticky; top: calc(var(--header-h) + 76px);
  padding: 18px 16px 20px; background: var(--paper-bright); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); max-height: calc(100svh - var(--header-h) - 110px);
  display: flex; flex-direction: column;
}
.stop-rail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.stop-rail-head h2 { margin: 0; }
.stop-list { overflow-y: auto; overscroll-behavior: contain; flex: 1; margin: 0 -6px; padding: 0 6px; }
.stop-row { position: relative; }
.stop-item {
  position: relative; display: grid; grid-template-columns: 26px 54px 1fr; align-items: center; gap: 11px;
  width: 100%; padding: 9px 52px 9px 8px; border-radius: 8px; text-align: left; border: 1px solid transparent;
}
@media (hover: hover) { .stop-item:hover { background: var(--paper); } }
.stop-item.is-active { background: var(--orange-wash); border-color: rgba(198, 81, 27, .3); }
.stop-item.is-active .stop-index { background: var(--orange); }
.stop-thumb { overflow: hidden; border-radius: 6px; }
.stop-thumb img { aspect-ratio: 1 / 1; }
.stop-item-copy { min-width: 0; }
.stop-item-copy b { display: block; font-size: var(--text-xs); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stop-item-copy small { display: block; font-size: var(--text-xs); color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stop-item-meta { display: inline-flex; align-items: center; gap: 4px; margin-top: 3px; font-size: var(--text-xs); color: var(--ink-muted); }
.stop-item-meta .ico { width: 12px; height: 12px; }
/* A second button beside the row, not inside it: 44px to hit, a 30px ring to see. */
.stop-item-play {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: var(--orange-text);
}
.stop-item-play::before { content: ''; grid-area: 1 / 1; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--orange); }
.stop-item-play .ico { grid-area: 1 / 1; width: 13px; height: 13px; fill: currentColor; stroke: none; margin-left: 1px; }
@media (hover: hover) { .stop-item-play:hover { color: var(--white); } }
@media (hover: hover) { .stop-item-play:hover::before { background: var(--orange); } }
.stop-rail-all { width: 100%; margin-top: 14px; }

/* ── Glance and elevation ──────────────────────────────────────── */
.route-glance {
  display: grid; grid-template-columns: minmax(260px, .8fr) minmax(0, 1.5fr); gap: 24px;
  width: min(100% - 48px, var(--wrap)); margin: 26px auto 0; padding: 22px clamp(18px, 2vw, 28px);
  background: var(--paper-bright); border: 1px solid var(--line); border-radius: var(--radius);
}
.glance-facts h2 { margin-bottom: 16px; }
.glance-facts .metric-row { gap: 16px 24px; }
.glance-facts .data-note { margin-top: 14px; }
.glance-elevation-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
.glance-elevation-head h3 { margin: 0; }
.glance-elevation .elevation-svg { height: 168px; }

/* ── Overview and related ──────────────────────────────────────── */
.route-overview {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(240px, .7fr); gap: 28px;
  width: min(100% - 48px, var(--wrap)); margin: 26px auto 0; padding-top: 6px;
}
.overview-copy h2 { margin-bottom: 12px; }
.overview-copy p { font-size: 16.5px; line-height: 1.7; color: var(--ink); max-width: 68ch; }
.overview-copy .chip-list { margin-top: 16px; }
.overview-geometry { padding: 16px 18px; border-left: 2px solid var(--orange); background: var(--paper-deep); border-radius: 0 var(--radius) var(--radius) 0; }
.overview-geometry h3 { margin-bottom: 7px; }
.route-related { width: min(100% - 48px, var(--wrap)); margin: 46px auto 0; }
.route-card-grid.is-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ── Tablet ────────────────────────────────────────────────────── */
@media (max-width: 1240px) {
  .route-workspace { grid-template-columns: minmax(0, 1fr) minmax(280px, .8fr); }
  .map-panel { grid-column: 1 / -1; position: static; }
  .map-frame { aspect-ratio: 16 / 9; min-height: 340px; }
  .route-glance { grid-template-columns: 1fr; }
  .route-card-grid.is-three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1023px) {
  .route-hero-place { bottom: 20px; }
  .route-hero-media .photo-credit { bottom: 9px; }
  .route-hero { grid-template-columns: 1fr; }
  .route-hero-copy { order: 2; padding: 26px 20px 30px; }
  .route-hero-media { order: 1; min-height: 46vh; }
  .route-hero-photo { position: relative; }
  .route-hero-photo.torn-left { -webkit-mask-image: none; mask-image: none; }
  .route-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 18px; }
  .route-facts .metric:nth-child(4n) { border-right: 1px solid var(--line); }
  .route-facts .metric:nth-child(odd) { border-right: 1px solid var(--line); }
  .route-facts .metric:nth-child(even) { border-right: 0; }
  .route-facts .metric:nth-child(n+5) { border-bottom: 1px solid var(--line); }
  .route-facts .metric:nth-last-child(-n+2) { border-bottom: 0; }
  .route-workspace { grid-template-columns: 1fr; }
  .stop-rail { position: static; max-height: none; }
  .route-overview { grid-template-columns: 1fr; }
}

/* ── Phone: the map leads, the story rides in a sheet ──────────── */
@media (max-width: 639px) {
  /* Flatten the workspace so the map can sit above the editorial header:
     a phone opens this page to walk, not to read a spread. */
  .route-page { display: flex; flex-direction: column; }
  .route-workspace, .route-bar { display: contents; }

  .map-panel { order: 1; margin: 0; }
  .route-hero { order: 2; }
  .route-facts { order: 3; }
  .route-scrubber { order: 3; }   /* after the map and the facts: a phone opens on the map */
  .route-tabs { order: 4; }
  .stop-panel { order: 5; }
  .stop-rail { order: 6; }
  .route-glance { order: 7; }
  .route-overview { order: 8; }
  .route-related { order: 9; }
  .route-bar-actions { order: 10; }

  .map-frame {
    aspect-ratio: auto; height: 54vh; min-height: 300px; border-radius: 0;
    border-left: 0; border-right: 0;
  }
  .map-toolbar { left: 10px; top: 10px; }
  .map-control { min-width: 44px; height: 44px; }
  .map-controls { right: 10px; }
  .map-note { display: none; }

  /* The header becomes a compact card raised over the map. */
  .route-hero { grid-template-columns: 1fr; margin-top: -22px; }
  .route-hero-media { display: none; }
  .route-hero-copy {
    padding: 18px 18px 20px; background: var(--paper-bright);
    border-radius: 16px 16px 0 0; box-shadow: 0 -6px 20px rgba(18, 41, 74, .1);
  }
  .route-hero-copy::before {
    content: ''; display: block; width: 44px; height: 4px; margin: 0 auto 14px;
    border-radius: 2px; background: var(--line-strong);
  }
  .route-hero h1 { font-size: clamp(30px, 8.6vw, 40px); }
  .route-subtitle { font-size: var(--text-md); }
  .route-lede { font-size: 15px; }
  .breadcrumb { margin-bottom: 12px; }

  .route-facts, .stop-panel, .stop-rail, .route-glance, .route-overview, .route-related {
    width: calc(100% - 28px); margin-inline: auto;
  }
  .route-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 14px; }

  /* The section links are one row that scrolls sideways (they wrapped to two rows, 106px of a phone screen), and the
     actions become a bar that stays in reach. The right edge fades where the row continues. */
  .route-overview, .stop-rail, .stop-panel, .route-glance, .map-panel { scroll-margin-top: calc(var(--header-h) + 16px + var(--route-bar-h, 54px)); }
  .route-tabs {
    position: sticky; top: var(--header-h); z-index: 500; flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain;
    scrollbar-width: none; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    width: 100%; margin: 14px 0 0; padding: 4px 14px;
    background: rgba(248, 243, 233, .96); backdrop-filter: blur(8px);
    border-block: 1px solid var(--line);
  }
  .route-tabs::-webkit-scrollbar { display: none; }
  .route-tabs a { flex: 0 0 auto; min-height: 44px; padding: 0 13px; font-size: var(--text-xs); }
  .route-bar-actions {
    position: fixed; left: 0; right: 0; bottom: var(--player-h); z-index: 700;
    padding: 9px max(14px, env(safe-area-inset-right)) calc(9px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    background: rgba(253, 250, 244, .97); backdrop-filter: blur(10px);
    border-top: 1px solid var(--line); gap: 8px;
  }
  .route-bar-actions .button { flex: 1; min-height: 44px; }
  .route-bar-actions .button-primary { flex: 1.4; }
  body[data-view='route'] { padding-bottom: calc(var(--player-h) + 72px); }
  /* While the player is open it is the one bar at the bottom: the action bar steps aside instead of stacking above it.
     Share and Save come back when the player is closed. */
  body:has(.listen-bar) .route-bar-actions { display: none; }
  body[data-view='route']:has(.listen-bar) { padding-bottom: var(--player-h); }

  .stop-panel { margin-top: 14px; padding: 18px 16px 22px; }
  .stop-tabs { gap: 16px; }
  .stop-tabs button { min-height: 44px; }
  .stop-item { grid-template-columns: 24px 48px 1fr; }
  .glance-elevation .elevation-svg { height: 130px; }
  .route-card-grid.is-three { grid-template-columns: 1fr; }
}

/* ── Phone in landscape (roadmap 201) ─────────────────────────────
   The screen is wide but only about 390px tall. The map fits one screen instead of a 16:9 block taller than it,
   and the header scrolls away instead of taking a sixth of the height. The page is not locked to portrait. */
@media (orientation: landscape) and (max-height: 500px) {
  .map-frame { aspect-ratio: auto; height: calc(100svh - 32px); min-height: 240px; }
}

/* The stop that is playing: marked with the word, not only colour, so it reads in sun and for colour-blind visitors. */
.stop-item.is-playing { border-color: var(--ink); box-shadow: inset 3px 0 0 var(--ink); }
.stop-playing-tag { display: inline-block; margin-top: 4px; padding: 1px 8px; border-radius: 999px; background: var(--ink-deep); color: var(--white); font-size: var(--text-xs); font-weight: 600; }
.stop-playing-tag[hidden] { display: none; }

.glance-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
.elevation-wrap { touch-action: pan-y; cursor: crosshair; }
.elevation-plot { position: relative; }
.elevation-cursor { position: absolute; top: calc(100% * 16 / 168); bottom: calc(100% * 24 / 168); width: 2px; margin-left: -1px; background: var(--orange); pointer-events: none; }
.elevation-cursor[hidden] { display: none; }
.elevation-readout { margin: 6px 0 0; }
@media (pointer: coarse) { .glance-actions .button, .glance-actions .text-link { min-height: 44px; } }

@media print {
  .site-header, .site-footer, .route-bar-actions, .route-tabs, .map-panel, .listen-bar, .stop-rail-all, .photo-strip, .route-related, .glance-actions, .toast, .consent-bar,
  .elevation-readout, .elevation-cursor, .stop-play, .stop-item-play, .stop-playing-tag, .metric-button { display: none !important; }
  .route-page { width: 100% !important; max-width: none !important; }
  .route-hero, .route-glance, .route-overview, .stop-item { break-inside: avoid; }
  .route-overview a[href^='http']::after { content: ' (' attr(href) ')'; font-size: var(--text-xs); }
}

/* One existing map and stop rail move into this native modal; neither is cloned. */
.route-map-dialog {
  width: min(1480px, calc(100% - 32px)); max-width: none; height: min(920px, calc(100svh - 32px)); max-height: none;
  padding: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 14px;
  background: var(--paper-bright); color: var(--ink); box-shadow: var(--shadow-lg);
}
.route-map-dialog [data-map-dialog-close] { min-width: 44px; min-height: 44px; }
.route-map-dialog[open] [data-map="fullscreen"] { display: none; }
.route-map-dialog::backdrop { background: rgb(12 28 51 / 78%); }
.route-map-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; margin-bottom: 14px; }
.route-map-dialog-head h2 { margin: 0; font-family: var(--serif); font-size: var(--text-md); }
.route-map-dialog-content { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 320px); gap: 16px; height: calc(100% - 58px); min-height: 0; }
.route-map-dialog-content > .map-frame { height: 100%; min-height: 0; aspect-ratio: auto; }
.route-map-dialog-content > .stop-rail { position: static; height: 100%; max-height: none; min-height: 0; }
.route-map-dialog-content > [data-map-dialog-empty] { align-self: start; margin: 0; padding: 14px; }

.elevation-control { display: grid; grid-template-columns: auto minmax(100px, 1fr) auto; align-items: center; gap: 12px; margin-top: 8px; color: var(--ink-soft); font-size: var(--text-xs); }
.elevation-control input { width: 100%; min-height: 44px; accent-color: var(--orange); cursor: ew-resize; }
.elevation-control output { min-width: 110px; color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; }


@media (max-width: 639px) {
  .route-map-dialog { width: calc(100% - 12px); height: calc(100svh - 12px); padding: 10px; border-radius: 12px; }
  .route-map-dialog-head { margin-bottom: 10px; }
  .route-map-dialog-content { grid-template-columns: 1fr; grid-template-rows: minmax(250px, 52svh) minmax(0, 1fr); gap: 10px; height: calc(100% - 54px); }
  .route-map-dialog-content > .map-frame { border-radius: 8px; }
  .route-map-dialog-content > .stop-rail { padding: 12px; }
  .elevation-control { grid-template-columns: 1fr auto; gap: 4px 12px; }
  .elevation-control input { grid-column: 1 / -1; grid-row: 2; }
  .elevation-control output { grid-column: 2; grid-row: 1; }
}

.map-control { min-width: 44px; min-height: 44px; }
@media (min-width: 1241px) { .map-frame { min-height: 340px; max-height: calc(100svh - var(--header-h) - var(--route-bar-h, 58px) - 32px); } }

/* The route line over the hero photograph: drawn in once, still when motion is not wanted. */
.route-hero-media { position: relative; }
.route-draw { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.route-draw path { fill: none; stroke: var(--orange-on-dark); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; filter: drop-shadow(0 1px 2px rgba(12, 28, 51, .6)); stroke-dasharray: 1; stroke-dashoffset: 0; }
@media (prefers-reduced-motion: no-preference) {
  .route-draw path { stroke-dashoffset: 1; animation: route-draw 3s .4s cubic-bezier(.4, 0, .2, 1) forwards; }
}
@keyframes route-draw { to { stroke-dashoffset: 0; } }

/* The mosaic: the hero photograph keeps its place and gains a column of the route's other photographs. */
.route-hero-main { position: relative; min-height: inherit; }
@media (min-width: 640px) { .route-hero-media.has-mosaic { display: grid; grid-template-columns: minmax(0, 1fr) clamp(96px, 14%, 168px); gap: 6px; } }
.route-mosaic { display: grid; grid-auto-rows: minmax(0, 1fr); gap: 6px; }
.route-mosaic.is-3, .route-mosaic.is-4 { grid-template-columns: 1fr; }
.mosaic-tile { display: block; width: 100%; height: 100%; min-height: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--paper-deep); cursor: zoom-in; }
.mosaic-tile .photo, .mosaic-tile picture, .mosaic-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 1023px) {
  .route-hero-media.has-mosaic { grid-template-columns: 1fr; }
  .route-hero-main { min-height: 46vh; }
  .route-mosaic { grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); grid-auto-rows: auto; height: 76px; }
}

/* The stop-photo scrubber: one photograph at a time, a range under it moves along the route. */
.route-scrubber { width: min(100% - 48px, var(--wrap)); margin: 22px auto 0; }
.scrubber-stage { position: relative; aspect-ratio: 16 / 9; max-height: 52vh; border-radius: var(--radius); overflow: hidden; background: var(--paper-deep); }
.scrubber-frame { position: absolute; inset: 0; margin: 0; }
.scrubber-frame[hidden] { display: none; }
.scrubber-frame .photo, .scrubber-frame picture, .scrubber-frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.scrubber-frame figcaption { position: absolute; left: 0; right: 0; bottom: 0; padding: 28px 18px 14px; color: var(--white); background: linear-gradient(to top, rgba(12, 28, 51, .8), rgba(12, 28, 51, 0)); }
.scrubber-range { display: block; width: 100%; margin: 12px 0 0; accent-color: var(--orange); height: 28px; cursor: ew-resize; }
.scrubber-range:focus-visible { outline: 2px solid var(--orange-text); outline-offset: 3px; border-radius: 4px; }
@media (max-width: 1023px) { .route-scrubber { width: calc(100% - 32px); } }

/* The photograph's credit carries its licence: the route line never crosses it. */
.route-hero-media .photo-credit { z-index: 2; }

/* Walking mode: a short status over the foot of the map, and a pressed state for the button. */
.map-walk-status { position: absolute; z-index: 450; left: 12px; right: 76px; bottom: 12px; margin: 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: color-mix(in srgb, var(--paper-bright) 95%, transparent); font-size: var(--text-xs); color: var(--ink); box-shadow: var(--shadow-md); }
.map-walk-status:empty { display: none; }
.map-control[data-map='walk'][aria-pressed='true'] { background: var(--orange); border-color: var(--orange-text); color: var(--white); }
