/* SpotRaces — site base: minimal reset (replaces Tailwind's preflight) and the page frame pieces that are
   not in the design system. Load after tokens.css and before components.css. */

*, *::before, *::after { box-sizing: border-box; }
/* Site layout values: sizes and timings the design system's tokens don't name. Each is defined once here and
   components.css uses it by name (docs/design.md, "Site layout values").
   --header-h: the site header's fixed height, a control-height row with --space-2 above and below plus its hairline
   (57 px). The fixed calendar header, the sticky sidebar and the compact-mode observer all offset from it. */
html { -webkit-text-size-adjust: 100%;
  --header-h: calc(var(--control-height) + 2 * var(--space-2) + var(--border-width));
  --touch-target: 44px;        /* icon-only buttons: the minimum hit area */
  --icon-button-glyph: 24px;   /* icon-only buttons: the icon */
  --icon-small: 14px;          /* icons on 14 px text: the race row's terrain and place lines */
  --text-small: 14px;          /* small labels: the header's «Calendario» */
  --text-theme-label: 14px;    /* uppercase label beside the footer theme preference */
  --text-footer-brand: 18px;   /* «SpotRaces» and its mark in the footer */
  --footer-link: 32px;         /* the footer's mail and social links: their hit area */
  --footer-icon: 20px;         /* the footer's mail icon and social logos */
  --theme-option: 26px;        /* each choice in the footer theme pill, 30 px tall with its border and padding */
  --text-field: 15px;          /* text typed in compact fields, as in .sr-input */
  --compact-search-max: 320px; /* the fixed header's compact search on wide pages */
  --duration-fast: 150ms;      /* colour changes: race titles */
  --duration-base: 200ms;      /* fades: header modes, day dividers */
  --day-stuck-alpha: 85%;      /* how much of --bg a stuck day divider keeps over the blur */
  --route-point: 22px;         /* the arrow that moves along a route map */
  --route-end: 10px;           /* a route map's start and finish marks */
  --route-profile-h: 120px;    /* a route's elevation profile plot */
  --dot-ratio: 0.6;            /* each dot's diameter, of its square cell: the rest is the space between dots */
  --range-line-w: 2px;         /* a range slider's lines, its thumbs */
  --range-line-overshoot: 8px; /* how far they stand out of the histogram, above and below */
  --range-thumb-w: 24px;       /* the invisible thumb around each line, what is grabbed */
  --date-field-min-w: 152px;   /* a native date field's narrowest, its date and calendar icon whole */
  --share-menu-w: 240px;       /* the share button's fallback menu on wide screens */
  --route-map-max-h: 60svh;    /* a route map's tallest, so the slider stays in view while the point moves */
}
body, h1, h2, h3, p, ul, ol, figure, fieldset { margin: 0; }
ul[class], ol[class] { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

/* From a page of the site to another, where the browser can, one fades into the other instead of flashing. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-group(root) { animation-duration: var(--duration-fast); }
}

/* Skip link: off-screen until focused, then pinned to the top-left corner. */
.sr-skip { position: absolute; top: var(--space-3); left: var(--space-3); z-index: 10;
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-full);
  background: var(--ink); color: var(--bg); font: 500 14px/1.25 var(--font-sans); text-decoration: none;
  transform: translateY(calc(-100% - var(--space-6))); }
.sr-skip:focus { transform: none; }

/* Page body. The page fills at least the screen and the main content takes the free height, so the footer always
   ends the page at the bottom of the screen, even on short pages. */
.sr-page { display: flex; flex-direction: column; min-height: 100svh; }
.sr-main { flex: 1 0 auto; padding: var(--space-8) 0 var(--space-16); }
.sr-main:focus { outline: none; }

/* Footer (SiteFooter), under a top hairline; the page ends just below its icons. The brand with the theme pill
   beside it; the ways into the calendar, each group under its uppercase title with its links in a run separated by
   «·»; the notice; the mail and social icons. Narrow, as short as it can be: the notice right under the brand, each
   title in a column to the left of its links, the icons spread across the width. Wide: the four groups in four
   columns, title over links; the notice on the left of the last line and the icons on its right. */
.sr-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand theme" "notice notice" "nav nav" "links links";
  align-items: center; gap: var(--space-2) var(--space-4); padding: var(--space-4) 0 var(--space-3);
  border-top: var(--border-width) solid var(--line); font: 400 14px/1.4 var(--font-sans); color: var(--ink-subtle); }
.sr-footer__brand { grid-area: brand; display: flex; align-items: center; gap: var(--space-2);
  font: 800 var(--text-footer-brand)/1 var(--font-sans); letter-spacing: -0.02em; color: var(--ink); }
.sr-footer__brand .sr-mark { width: var(--text-footer-brand); height: var(--text-footer-brand); }
.sr-footer__notice { grid-area: notice; max-width: var(--measure); }
.sr-footer__links { grid-area: links; display: flex; align-items: center; justify-content: space-between; margin-top: var(--space-3); }
.sr-footer__links a { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  width: var(--footer-link); height: var(--footer-link); border-radius: var(--radius-full); color: var(--ink); text-decoration: none; }
.sr-footer__links .sr-symbol { width: var(--footer-icon); height: var(--footer-icon); }
.sr-footer__links a:hover { background: var(--surface-2); }
.sr-footer .sr-theme-switch { grid-area: theme; justify-self: end; }
.sr-footer__nav { grid-area: nav; display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: baseline;
  gap: var(--space-3) var(--space-4); margin-top: var(--space-3); }
.sr-footer__group { display: contents; }
.sr-footer__group h2 { font: 600 11px/1.33 var(--font-sans); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-subtle); }
.sr-footer__group ul { display: flex; flex-wrap: wrap; gap: var(--space-1) 0; margin: 0; padding: 0; list-style: none; line-height: 1.5; }
/* The «·» goes after each link but the last, so a line that wraps ends with it rather than starting with it. */
.sr-footer__group li:not(:last-child)::after { content: "·"; content: "·" / ""; margin: 0 var(--space-1); color: var(--ink-subtle); }
.sr-footer__group a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line);
  text-decoration-thickness: var(--border-width); text-underline-offset: var(--space-1); }
.sr-footer__group a:hover { text-decoration-color: currentColor; }
@container shell (min-width: 720px) {
  .sr-footer { grid-template-areas: "brand theme" "nav nav" "notice links"; column-gap: var(--space-6); padding: var(--space-5) 0 var(--space-4); }
  .sr-footer__nav { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: start; column-gap: var(--space-8); margin-top: var(--space-4); }
  .sr-footer__group { display: grid; align-content: start; gap: var(--space-2); }
  .sr-footer__group h2 { font-size: 12px; letter-spacing: .16em; }
  .sr-footer__group ul { font-size: 15px; line-height: 1.5; }
  .sr-footer__group li:not(:last-child)::after { margin: 0 var(--space-2); }
  .sr-footer__group a { text-underline-offset: var(--space-2); }
  .sr-footer__notice { margin-top: var(--space-5); }
  .sr-footer__links { gap: var(--space-6); margin-top: var(--space-5); }
}

/* Calendar: .sr-calendar brings its own vertical padding; the heading and the search span both columns. Like the
   other two columns they may shrink below their content's intrinsic width, so a 320 px screen never scrolls sideways. */
.sr-main:has(> .sr-calendar) { padding: 0; }
.sr-calendar__head, .sr-calendar__search { grid-column: 1 / -1; min-width: 0; }

/* 404 */
.sr-notfound { display: grid; justify-items: start; gap: var(--space-4); max-width: var(--measure); }
.sr-notfound__code { font: 500 12px/1.33 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); }
.sr-notfound h1 { font: 800 32px/1.05 var(--font-sans); letter-spacing: -0.025em; }
.sr-notfound p { color: var(--ink-muted); }
.sr-notfound .sr-button { margin-left: calc(-1 * var(--space-2)); }

/* Edition page: .sr-racehead and .sr-racepage carry their own vertical padding. */
.sr-main:has(> .sr-racehead) { padding: 0; }

/* Edition page: the route of the chosen race (RouteMap). Not in the design system yet: the track, the finish and the
   profile line are --accent; the start, the moving point and the cursor are --ink. */
.sr-racepage__route { display: grid; }

/* A route: its figures over a hairline, the map, the readout and the elevation profile. Its width is capped so the
   map, at its width ÷ height (--ratio, set by the figure), is no taller than --route-map-max-h. */
.sr-route { max-width: calc(var(--route-map-max-h) * var(--ratio)); }
.sr-route__stats { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-8); margin: 0; padding-bottom: var(--space-4); border-bottom: var(--border-width) solid var(--line); }
.sr-route__stats dt { font: 600 12px/1.33 var(--font-sans); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-subtle); }
.sr-route__stats dd { margin: var(--space-1) 0 0; font: 700 22px/1.1 var(--font-sans); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; color: var(--ink); }
.sr-route__stats small { margin-left: 3px; font: 400 13px/1 var(--font-mono); letter-spacing: 0; color: var(--ink-muted); }

.sr-route__map { position: relative; overflow: hidden; }
/* A map has an image drawn for each theme, and shows the one of the page's: the dark one by default, as the theme.
   The theme selectors mirror tokens.css. */
.sr-route__map img { width: 100%; height: auto; }
.sr-route__map--themed .sr-route__image:not(.sr-route__image--dark) { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .sr-route__map--themed .sr-route__image { display: block; }
  :root:not([data-theme]) .sr-route__map--themed .sr-route__image--dark { display: none; }
}
:root[data-theme="light"] .sr-route__map--themed .sr-route__image { display: block; }
:root[data-theme="light"] .sr-route__map--themed .sr-route__image--dark { display: none; }
/* A map not drawn for the themes yet has one image, as OpenStreetMap's tile server drew it (light): the site keeps its
   colours, softened, and the dark theme inverts it and rotates the hue back, so water stays blue and parks green. */
.sr-route__map:not(.sr-route__map--themed) img { filter: var(--route-map-filter); }
.sr-route__map { --route-map-filter: invert(1) hue-rotate(180deg) saturate(.6) brightness(.8) contrast(.95); }
@media (prefers-color-scheme: light) { :root:not([data-theme]) .sr-route__map { --route-map-filter: saturate(.65) contrast(.95) brightness(1.08); } }
:root[data-theme="light"] .sr-route__map { --route-map-filter: saturate(.65) contrast(.95) brightness(1.08); }
.sr-route__map svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.sr-route__map path { fill: none; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.sr-route__casing { stroke: var(--bg); stroke-opacity: .85; stroke-width: 6px; }
.sr-route__track { stroke: var(--accent); stroke-width: 3px; }
.sr-route__end, .sr-route__point { position: absolute; left: calc(var(--x, 0) * 100%); top: calc(var(--y, 0) * 100%); translate: -50% -50%;
  box-sizing: border-box; border-radius: var(--radius-full); }
.sr-route__end { width: var(--route-end); height: var(--route-end); }
.sr-route__end span { position: absolute; top: 50%; translate: 0 -50%; font: 700 9px/1 var(--font-sans); letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink); text-shadow: 0 0 3px var(--bg), 0 0 3px var(--bg); white-space: nowrap; }
.sr-route__end--start { border: 2px solid var(--ink); background: var(--bg); }
.sr-route__end--start span { left: calc(100% + var(--space-2)); }
.sr-route__end--finish { background: var(--accent); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.sr-route__end--finish span { right: calc(100% + var(--space-2)); }
/* The point is an arrow turned (--angle, set by the script) the way the route runs there. */
.sr-route__point { width: var(--route-point); height: var(--route-point); rotate: var(--angle, 0deg); filter: drop-shadow(0 1px 2px rgb(0 0 0 / .35)); }
.sr-route__point svg { position: static; display: block; }
.sr-route__point path { fill: #fff; stroke: var(--accent); stroke-width: 2px; }
/* The map's credits, in a corner of it (--top-right... clear of the start and the finish): a pill with the main ones and an
   (i) in the corner itself, which opens a panel with all of them beside the pill. Folded (.is-folded, by map-credits.js),
   the pill gives way to the (i) alone, and its links leave the tab order; the panel still has them. The panel is a popover,
   in the top layer: anchored to its (i) where the browser positions by anchors, else in the middle of the screen. */
.sr-mapcredits { position: absolute; display: flex; align-items: center; gap: var(--space-1); max-width: calc(100% - 2 * var(--space-2)); }
.sr-mapcredits--top-right { top: var(--space-2); right: var(--space-2); }
.sr-mapcredits--top-left { top: var(--space-2); left: var(--space-2); flex-direction: row-reverse; }
.sr-mapcredits--bottom-right { bottom: var(--space-2); right: var(--space-2); }
.sr-mapcredits--bottom-left { bottom: var(--space-2); left: var(--space-2); flex-direction: row-reverse; }
.sr-mapcredits a { color: inherit; text-decoration: underline; text-decoration-color: var(--line-strong); text-decoration-thickness: var(--border-width); text-underline-offset: 2px; }
.sr-mapcredits a:hover { text-decoration-color: currentColor; }
.sr-mapcredits__short { min-width: 0; max-width: 24rem; margin: 0; padding: 2px var(--space-2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  border: var(--border-width) solid var(--line-strong); border-radius: var(--radius-full); background: color-mix(in srgb, var(--bg) 92%, transparent);
  font: 400 11px/1.4 var(--font-sans); color: var(--ink); }
.sr-mapcredits.is-folded .sr-mapcredits__short { max-width: 0; padding-inline: 0; border-width: 0; opacity: 0; visibility: hidden; }
/* The (i): a 22 px ring whose press area reaches the 44 px of a touch target. */
.sr-mapcredits__toggle { position: relative; flex: none; display: grid; place-items: center; width: 22px; height: 22px; padding: 0;
  border: var(--border-width) solid var(--line-strong); border-radius: var(--radius-full); background: var(--bg); color: var(--ink);
  font: 700 12px/1 var(--font-sans); cursor: pointer; }
.sr-mapcredits__toggle::after { content: ""; position: absolute; inset: calc((22px - var(--touch-target)) / 2); }
.sr-mapcredits__toggle:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: 2px; }
.sr-mapcredits__panel { position: fixed; inset: 0; width: max-content; height: fit-content; max-width: min(18rem, calc(100vw - 4 * var(--space-4)));
  margin: auto; padding: var(--space-3); overflow: visible;
  border: var(--border-width) solid var(--line-strong); border-radius: var(--radius-md); background: var(--bg);
  font: 400 12px/1.45 var(--font-sans); color: var(--ink); white-space: normal; }
/* Beside its (i), toward the inside of the map: below it in the top corners, above it in the bottom ones; flipped when it
   would leave the screen. */
@supports (position-area: bottom) {
  .sr-mapcredits__panel { inset: auto; margin: var(--space-1) 0; position-try-fallbacks: flip-block; }
  .sr-mapcredits--top-right .sr-mapcredits__panel { position-area: bottom span-left; }
  .sr-mapcredits--top-left .sr-mapcredits__panel { position-area: bottom span-right; }
  .sr-mapcredits--bottom-right .sr-mapcredits__panel { position-area: top span-left; }
  .sr-mapcredits--bottom-left .sr-mapcredits__panel { position-area: top span-right; }
}
.sr-mapcredits__title { margin: 0 0 var(--space-2); font: 600 11px/1.33 var(--font-sans); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-muted); }
.sr-mapcredits__panel dl { display: grid; gap: var(--space-2); margin: 0; }
.sr-mapcredits__panel dl > div { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); gap: var(--space-2); }
.sr-mapcredits__panel dt { font-weight: 600; color: var(--ink-muted); }
.sr-mapcredits__panel dd { margin: 0; }
.sr-mapcredits__panel small { display: block; margin-top: 2px; font-size: 11px; line-height: 1.4; color: var(--ink-muted); }
@media (prefers-reduced-motion: no-preference) {
  .sr-mapcredits__short { transition: max-width var(--duration-fast) ease, padding var(--duration-fast) ease, opacity var(--duration-fast) ease, visibility 0s; }
  .sr-mapcredits.is-folded .sr-mapcredits__short { transition: max-width var(--duration-fast) ease, padding var(--duration-fast) ease, opacity var(--duration-fast) ease, visibility 0s var(--duration-fast); }
}

.sr-route__readout { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); margin-top: var(--space-4); font: 400 13px/1.4 var(--font-mono); color: var(--ink-muted); }
.sr-route__readout strong { font-weight: 700; color: var(--ink); }
.sr-route__profile { padding-top: var(--space-4); }
.sr-route__plot { position: relative; height: var(--route-profile-h); cursor: crosshair; touch-action: pan-y; }
.sr-route__plot:has(input:focus-visible) { outline: var(--focus-width) solid var(--focus); outline-offset: var(--space-1); }
.sr-route__plot svg { width: 100%; height: 100%; overflow: visible; }
.sr-route__plot :is(line, path) { vector-effect: non-scaling-stroke; }
.sr-route__grid { stroke: var(--line); stroke-width: 1px; }
.sr-route__area { fill: color-mix(in srgb, var(--ink) 14%, transparent); }
.sr-route__elevation { fill: none; stroke: var(--accent); stroke-width: 2px; stroke-linejoin: round; }
.sr-route__level { position: absolute; left: 0; top: calc(var(--at) * 100%); translate: 0 -100%; padding-bottom: 2px;
  font: 400 11px/1 var(--font-mono); color: var(--ink-subtle); pointer-events: none; }
.sr-route__cursor { position: absolute; top: 0; bottom: 0; left: calc(var(--x, 0) * 100%); width: 1px; background: var(--ink); pointer-events: none; }
.sr-route__cursor::after { content: ""; position: absolute; left: 50%; top: calc(var(--y, 0) * 100%); width: var(--status-dot); height: var(--status-dot);
  translate: -50% -50%; border-radius: var(--radius-full); background: var(--accent); box-shadow: 0 0 0 2px var(--bg); }
/* The gradient there, over the line; kept inside the plot at its ends, like the km labels. */
.sr-route__grade { position: absolute; bottom: 100%; left: 0; translate: calc(var(--x, 0) * -100%) 0; padding-bottom: 2px;
  font: 700 11px/1 var(--font-mono); color: var(--accent); white-space: nowrap; }
.sr-route__axis { position: relative; height: 16px; margin-top: var(--space-2); font: 400 11px/16px var(--font-mono); color: var(--ink-subtle); }
.sr-route__axis span { position: absolute; left: calc(var(--at) * 100%); translate: calc(var(--at) * -100%) 0; white-space: nowrap; }
