/* Course page (strecke.html): full-width intro with the bib, then sticky 3D map (MapLibre GL, self-built style
   from OSM data) beside the kilometre-by-kilometre story. Shared tokens and components live in site.css. */

/* ---------- map palette: certificate paper, watercolour forest and water; the route is the only saturated thing ---------- */
:root {
  --m-land: #ffffff; --m-field: #f1f6f8; --m-urban: #f3f5f6; --m-industry: #eceff1; --m-park: #d7ece4;
  --m-forest: #9fd3c3; --m-forest-2: #7cc4c9; --m-water: #79d4f2; --m-water-edge: #2f9bff;
  --m-road: #d4dce1; --m-road-major: #c4ced4; --m-track: #a9b8bf; --m-rail: #b3bec4; --m-stream: #6cc6ee;
  --m-building: #dfe8ee; --m-building-hl: #bfe9ff; --m-stone: #efe9dc; --m-label: #4f5f66;
  --m-shade: #1d4d6b; --m-highlight: #ffffff; --m-case: #2d393e;
  --subnav-h: 47px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --m-land: #0c1820; --m-field: #0f1e27; --m-urban: #112029; --m-industry: #13232c; --m-park: #12302f;
  --m-forest: #22605a; --m-forest-2: #1b5a66; --m-water: #146fa8; --m-water-edge: #4ec9ff;
  --m-road: #24394a; --m-road-major: #2e4759; --m-track: #3a5262; --m-rail: #34495a; --m-stream: #1b78ad;
  --m-building: #1d3241; --m-building-hl: #1f5677; --m-stone: #3a3f3c; --m-label: #a6bcc6;
  --m-shade: #000000; --m-highlight: #2b4b5e; --m-case: #040b10; } }
:root[data-theme="dark"] {
  --m-land: #0c1820; --m-field: #0f1e27; --m-urban: #112029; --m-industry: #13232c; --m-park: #12302f;
  --m-forest: #22605a; --m-forest-2: #1b5a66; --m-water: #146fa8; --m-water-edge: #4ec9ff;
  --m-road: #24394a; --m-road-major: #2e4759; --m-track: #3a5262; --m-rail: #34495a; --m-stream: #1b78ad;
  --m-building: #1d3241; --m-building-hl: #1f5677; --m-stone: #3a3f3c; --m-label: #a6bcc6;
  --m-shade: #000000; --m-highlight: #2b4b5e; --m-case: #040b10; }

/* ---------- stacked variants: all three races occupy one grid cell, the tallest reserves the height ---------- */
.sw { display: grid; }
.sw > .v { grid-area: 1 / 1; visibility: hidden; }
[data-race="10"] .sw > .v[data-r="10"], [data-race="21"] .sw > .v[data-r="21"], [data-race="30"] .sw > .v[data-r="30"] { visibility: visible; }

/* ---------- intro ---------- */
.intro { padding-block: 40px 72px; }
.intro-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(28px, 5vw, 80px); align-items: start; max-width: 1280px; margin-inline: auto;
  /* keep the copy clear of the deep-blue outer edge of the watercolour (about 120px from the page edge) */
  padding-left: clamp(0px, calc(124px - (100vw - 1280px) / 2), 108px); }
.switch { display: inline-flex; gap: 6px; padding: 6px; background: var(--paper); border-radius: 999px; box-shadow: var(--shadow-soft); margin-bottom: 34px; }
.switch button { display: flex; align-items: center; gap: 9px; border: 0; background: none; cursor: pointer; padding: 10px 18px 10px 12px; border-radius: 999px; font: 800 16px/1 var(--display); color: var(--muted); transition: background-color .25s, color .25s; }
.switch button i { width: 14px; height: 14px; border-radius: 50%; background: var(--sw); }
.switch button:hover { color: var(--ink); }
.switch button[aria-selected="true"] { background: var(--sw); color: var(--sw-on); }
.switch button[aria-selected="true"] i { background: var(--sw-on); opacity: .85; }
.switch [data-r="10"] { --sw: var(--g); --sw-on: var(--g-on); }
.switch [data-r="21"] { --sw: var(--y); --sw-on: var(--y-on); }
.switch [data-r="30"] { --sw: var(--r); --sw-on: var(--r-on); }
.intro h1 { margin: 0 0 18px; }
.presented { display: flex; align-items: center; gap: 14px; margin: 0 0 28px; font: 700 15px/1.2 var(--text); color: var(--muted); }
.sp-logo { height: 22px; align-items: center; }
.sp-logo a { display: flex; align-items: center; height: 22px; line-height: 0; }
.sp-logo img { height: 22px; width: auto; }
.overview { max-width: 62ch; }
.overview p { margin: 0 0 16px; font-size: 19px; line-height: 1.62; }
.overview p:first-child { font: 600 21px/1.5 var(--text); }
.overview .date { font-weight: 700; margin: 0; }
.intro .actions { margin-top: 28px; }
.intro .bib { margin-top: 18px; }
.bib-band span:last-child { font-variant-numeric: tabular-nums; }
.bib-name { justify-items: center; }
.bib-sponsor { justify-items: center; }
.bib-sponsor img { height: 34px; width: auto; }
/* sponsor logos keep their original colours; Nachfolgekontor and Fischer (dark artwork) sit on a white plate in dark mode */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sp-plate { background: #fff; border-radius: 6px; padding: 3px 6px; height: 28px; margin-block: -3px; } }
:root[data-theme="dark"] .sp-plate { background: #fff; border-radius: 6px; padding: 3px 6px; height: 28px; margin-block: -3px; }

/* ---------- course: sticky map + story ---------- */
.course { display: grid; grid-template-columns: minmax(0, 58fr) minmax(0, 42fr); border-top: 1px solid var(--line); }
.map-col { position: sticky; top: calc(env(safe-area-inset-top, 0px) + var(--head-h) + var(--subnav-h)); height: calc(100dvh - var(--head-h) - var(--subnav-h) - env(safe-area-inset-top, 0px)); z-index: 1; contain: layout paint; }
.map-mask { position: absolute; inset: 0; -webkit-mask: var(--edge) right / 100% 100% no-repeat; mask: var(--edge) right / 100% 100% no-repeat; }
#map { position: absolute; inset: 0; background: var(--m-land); }
.map-soft { position: absolute; top: 0; bottom: 0; right: 0; width: 16%; pointer-events: none; z-index: 3;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--paper) 55%, transparent) 70%, var(--paper)); }
.map-ctl { position: absolute; top: 14px; left: 14px; z-index: 4; display: flex; gap: 6px; }
.map-ctl button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 40px; min-width: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--ink); font: 800 14px/1 var(--display); cursor: pointer; box-shadow: 0 2px 10px rgb(20 40 60 / .12); transition: background-color .2s; }
.map-ctl button:hover { background: var(--paper-2); }
.map-ctl .icon { width: 18px; height: 18px; }
.map-ctl .wide { padding: 0 14px 0 11px; }
.map-attr { position: absolute; left: 14px; top: 62px; z-index: 4; margin: 0; font: 600 12px/1.4 var(--text); color: var(--muted); background: color-mix(in srgb, var(--paper) 85%, transparent); padding: 2px 8px; border-radius: 999px; }
.map-fail { position: absolute; inset: 120px 22% auto 24px; z-index: 4; margin: 0; padding: 14px 16px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; font-weight: 600; }
.maplibregl-map { font: inherit; }
.maplibregl-canvas:focus-visible { outline: 3px solid var(--logo-blue); outline-offset: -3px; }

/* elevation profile docked on the map */
.profile { position: absolute; left: 18px; right: 20%; bottom: 30px; z-index: 4; padding: 12px 16px 8px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-panel); }
.profile-head { display: flex; justify-content: space-between; align-items: baseline; font: 800 13px/1 var(--display); color: var(--muted); }
.profile-head b { color: var(--ink); font-variant-numeric: tabular-nums; }
.profile svg { display: block; width: 100%; height: 92px; margin-top: 6px; cursor: crosshair; touch-action: pan-y; }
.p-area { fill: color-mix(in srgb, var(--race) 30%, transparent); }
.p-line { fill: none; stroke: var(--race-line); stroke-width: 2; }
.p-band { fill: color-mix(in srgb, var(--race) 22%, transparent); }
.p-grid { stroke: var(--line); stroke-width: 1; }
.p-txt { font: 700 11px var(--text); fill: var(--muted); font-variant-numeric: tabular-nums; }
.p-vp { fill: var(--race); stroke: var(--ink); stroke-width: 1.5; }
.p-lm { fill: var(--paper); stroke: var(--ink); stroke-width: 1.5; }
.p-cursor { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 2 3; }
.p-run { fill: var(--race); stroke: var(--ink); stroke-width: 2; }

/* map markers (HTML, so labels can be Nunito without a glyph server) */
.m-place { font: 800 13px/1 var(--display); letter-spacing: .02em; color: var(--m-label); white-space: nowrap; pointer-events: none;
  text-shadow: 0 0 2px var(--m-land), 0 0 5px var(--m-land), 0 0 8px var(--m-land); }
.m-km { font: 900 12px/1 var(--display); color: var(--race-on); background: var(--race); border: 1.5px solid var(--ink); border-radius: 9px; padding: 3px 6px; font-variant-numeric: tabular-nums; pointer-events: none; }
.m-vp { display: flex; align-items: center; gap: 5px; pointer-events: none; }
.vp-badge { width: 26px; height: 26px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--race); color: var(--race-on); box-shadow: 0 0 0 2px var(--paper); }
.vp-badge .icon { width: 15px; height: 15px; stroke-width: 2.2; }
.m-vp > span:not(.vp-badge) { background: var(--paper); color: var(--ink); padding: 4px 7px; border-radius: 7px; border: 1px solid var(--line); font: 800 12px/1 var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.m-start { display: flex; align-items: center; gap: 6px; font: 900 13px/1 var(--display); background: var(--ink); color: var(--paper); padding: 7px 10px; border-radius: 9px; position: relative; margin-bottom: 8px; pointer-events: none; white-space: nowrap; }
.m-start .icon { width: 14px; height: 14px; }
.m-start::after { content: ""; position: absolute; left: 50%; bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top-color: var(--ink); }
.m-runner { width: 20px; height: 20px; border-radius: 50%; background: var(--race); border: 3px solid var(--ink); box-shadow: 0 2px 6px rgb(20 40 60 / .35); pointer-events: none; }
.m-ghost { width: 12px; height: 12px; border-radius: 50%; background: var(--ink); border: 2px solid var(--paper); pointer-events: none; opacity: 0; transition: opacity .15s; }
.m-ghost.on { opacity: 1; }

/* highlights: a plain dot on the spot with the name beside it, set like a place name on a hiking map */
.m-lm { display: flex; align-items: center; gap: 7px; pointer-events: auto; cursor: pointer; }
.m-lm-l { flex-direction: row-reverse; }
.m-lm-dot { width: 14px; height: 14px; flex: none; box-sizing: border-box; border-radius: 50%; background: var(--paper); border: 3px solid var(--ink); transition: background-color .3s, transform .3s; }
.m-lm-name { display: flex; align-items: center; font: 800 13px/1 var(--display); color: var(--ink); white-space: nowrap;
  text-shadow: 0 0 2px var(--m-land), 0 0 5px var(--m-land), 0 0 8px var(--m-land); }
/* Lehnert logo as the label: no plate on the light map (plate only in dark mode, the logo grey would vanish there) */
.m-lm-name img { height: 9px; width: auto; filter: drop-shadow(0 0 1.5px var(--m-land)) drop-shadow(0 0 1.5px var(--m-land)) drop-shadow(0 0 3px var(--m-land)); }
.m-lm:hover .m-lm-name, .m-lm:focus-visible .m-lm-name { text-decoration: underline; text-underline-offset: 3px; }
.m-lm:focus-visible { outline: 3px solid var(--logo-blue); outline-offset: 4px; border-radius: 6px; }
.m-lm.is-near .m-lm-dot { background: var(--race); transform: scale(1.25); }

/* story */
.story { position: relative; z-index: 2; min-width: 0; padding-block: 40px 30vh; }
.story-inner { max-width: 620px; margin-inline: auto 0; padding-right: clamp(0px, 3vw, 48px); }
.legs { list-style: none; margin: 0; padding: 0; }
/* compact legs: no fixed height per leg; the photo floats as a small portrait, the text runs around it */
.leg { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 0 18px; padding-bottom: 44px; }
.leg-body { display: flow-root; }
.leg-body > .leg-media { float: right; width: 176px; margin: 4px 0 10px 20px; }
.leg-body .lm-card { clear: both; }
.rail { position: relative; text-align: right; }
.rail::after { content: ""; position: absolute; right: -10px; top: 54px; bottom: -40px; width: 3px; border-radius: 2px; background: var(--line); transition: background-color .3s; }
.leg.is-done .rail::after, .leg.is-active .rail::after { background: var(--race); }
.rail b { display: block; font: 900 34px/1 var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--muted); padding-top: 6px; transition: color .3s; }
.rail span { display: block; font: 700 13px/1.3 var(--text); color: var(--muted); font-variant-numeric: tabular-nums; }
.leg.is-active .rail b, .leg.is-done .rail b { color: var(--ink); }
.leg h2 { margin: 2px 0 10px; font-size: clamp(22px, 1.9vw, 27px); line-height: 1.15; }
.leg p { margin: 0 0 10px; max-width: 62ch; }
.leg-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip-vp { background: var(--paper); border-color: var(--ink); padding-left: 6px; }
.chip-vp .vp-badge { width: 20px; height: 20px; box-shadow: none; }
.chip-vp .vp-badge .icon { width: 12px; height: 12px; }

/* highlight note in the story: no box, the same dot as on the map; it fills with the race colour when the runner passes */
.lm-card { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 12px; align-items: start; margin: 16px 0 4px; padding: 14px 0 0; border-top: 1px solid var(--line); opacity: .78; transition: opacity .4s; }
.lm-dot { width: 14px; height: 14px; margin-top: 3px; border-radius: 50%; background: var(--paper); border: 3px solid var(--ink); box-sizing: border-box; transition: background-color .4s; }
.lm-card.is-near { opacity: 1; }
.lm-card.is-near .lm-dot { background: var(--race); }
.lm-card h3 { font: 900 18px/1.2 var(--display); margin: 0 0 4px; }
.lm-card p { margin: 0; font-size: 15.5px; line-height: 1.5; color: var(--muted); }
.lm-card .lm-km { display: block; margin-top: 6px; font: 800 13px/1 var(--display); color: var(--ink); font-variant-numeric: tabular-nums; }
.lm-card .lm-logo { display: inline-flex; vertical-align: 0; margin-left: 6px; }
.lm-card .lm-logo img { width: auto; height: 10px; border: 0; border-radius: 0; }

/* photos and drone clips from the club (media/media.json), with a labelled placeholder until they arrive */
.leg-media { margin: 20px 0 0; }
.leg-media img, .leg-media video { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 14px; background: var(--paper-2); }
.leg-media .media-slot { aspect-ratio: 4 / 5; }

.finish { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 0 18px; padding-top: 12px; }
.finish .flag { justify-self: end; width: 48px; height: 48px; border-radius: 50%; background: var(--ink); color: var(--paper); display: grid; place-items: center; }
.finish .flag .icon { width: 24px; height: 24px; }
.finish h2 { font: 900 clamp(30px, 3vw, 40px)/1.05 var(--display); margin: 0 0 12px; letter-spacing: -.015em; }
.finish .actions { margin-top: 24px; }
.finish-after { margin-top: 56px; }

/* layout-shift self-check (strecke.html?cls) */
.cls-report { position: fixed; right: 12px; bottom: 12px; z-index: 5000; max-width: 360px; background: var(--paper); color: var(--ink); border: 2px solid var(--ink); border-radius: 14px; padding: 12px 14px; font: 600 13px/1.45 var(--text); box-shadow: var(--shadow-panel); white-space: pre-wrap; font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  .switch button, .m-lm-dot, .lm-dot, .lm-card, .rail b, .rail::after, .m-ghost { transition: none; }
}

/* ---------- tablet & phone ---------- */
@media (max-width: 960px) {
  .intro-grid { grid-template-columns: minmax(0, 1fr); padding-left: 0; }
  .intro .bib { max-width: 440px; transform: rotate(1deg); }
}
@media (max-width: 900px) {
  .course { display: block; }
  .map-col { height: 48dvh; z-index: 3; }
  .map-mask { -webkit-mask: linear-gradient(#000 calc(100% - 26px), transparent); mask: linear-gradient(#000 calc(100% - 26px), transparent); }
  .map-soft { display: none; }
  .map-ctl { top: 10px; left: 10px; }
  .map-ctl button { height: 36px; min-width: 36px; }
  .map-attr { top: auto; bottom: 96px; left: 10px; font-size: 12px; }
  .map-fail { inset: 60px 12px auto 12px; }
  .profile { left: 10px; right: 10px; bottom: 22px; padding: 8px 12px 4px; }
  .profile svg { height: 50px; margin-top: 4px; }
  .story { z-index: 1; padding-top: 24px; }
  .story-inner { max-width: none; padding-right: 0; }
  .leg { grid-template-columns: 52px minmax(0, 1fr); gap: 0 14px; padding-bottom: 36px; }
  .leg-body > .leg-media { width: 132px; margin-left: 14px; }
  .finish { grid-template-columns: 52px minmax(0, 1fr); gap: 0 14px; }
  .rail b { font-size: 24px; }
  .rail::after { right: -8px; top: 40px; }
  .switch button { padding: 9px 13px 9px 10px; font-size: 15px; }
}
@media (max-width: 600px) {
  .intro { padding-top: 24px; }
  .overview p:first-child { font-size: 19px; }
  .overview p { font-size: 17.5px; }
  .switch { margin-bottom: 22px; }
}
@media (max-width: 420px) {
  .switch { display: flex; width: 100%; }
  .switch button { flex: 1; justify-content: center; padding-inline: 6px; }
  .switch button i { display: none; }
  .bib-band { padding-inline: 34px; }
  .presented { gap: 10px; }
}
.rail .nw { white-space: nowrap; }
.sp-logo > .v { justify-self: start; }
/* dark mode: neutral elevation instead of blue-tinted shadows on the dark map */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) :is(.profile, .map-ctl button) { box-shadow: 0 8px 22px -8px rgb(0 0 0 / .6); } }
:root[data-theme="dark"] :is(.profile, .map-ctl button) { box-shadow: 0 8px 22px -8px rgb(0 0 0 / .6); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) :is(.m-lm-name img, .lm-card .lm-logo) { filter: none; background: #fff; padding: 2px 4px; border-radius: 4px; box-sizing: content-box; } }
:root[data-theme="dark"] :is(.m-lm-name img, .lm-card .lm-logo) { filter: none; background: #fff; padding: 2px 4px; border-radius: 4px; box-sizing: content-box; }
