/* Santa Run Tracker. Mobile first, system fonts, no outside requests. */
:root {
  --navy: #0f1b2d;
  /* Logo kit v1: Engine Red, Helmet Gold, Night Run Navy. Truck colours on the map are separate (src/shared/units.ts). */
  --red: #c31432;
  --red-dark: #9a1028;
  --gold: #f2b043;
  --snow: #fbfaf7;
  --pine: #1f5c45;
  --ink: #1d1d1f;
  --muted: #55555c;
  --line: #dcd8cf;
  --card: #ffffff;
  --danger-bg: #fdecee;
  --warn-bg: #fff4d9;
  --ok-bg: #e6f2ec;
  --info-bg: #e9eef5;
  --radius: 12px;
  --gap: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.125rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--snow);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-wrap: break-word;
}
img, svg, video, canvas { max-width: 100%; }
main { flex: 1 0 auto; width: 100%; }
h1, h2, h3 { line-height: 1.2; color: var(--navy); margin: 0 0 0.5em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; margin-top: 1.75em; }
h3 { font-size: 1.2rem; margin-top: 1.5em; }
p, ul, ol { margin: 0 0 1em; }
ul, ol { padding-left: 1.4em; }
li { margin-bottom: 0.4em; }
a { color: var(--red-dark); text-decoration-thickness: 0.08em; text-underline-offset: 0.15em; }
a:hover { color: var(--red); }
.muted { color: var(--muted); }
.small { font-size: 0.95rem; }

/* Focus: always visible */
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; box-shadow: 0 0 0 5px var(--navy); }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: absolute; left: 8px; top: -60px;
  background: var(--gold); color: var(--navy);
  padding: 10px 14px; border-radius: 8px; font-weight: 700; z-index: 100;
}
.skip-link:focus { top: 8px; }

.wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 16px; }
.wrap-wide { max-width: 1100px; }
.page { padding-top: 24px; padding-bottom: 48px; }

/* Header */
.site-header { position: relative; z-index: 800; background: var(--navy); color: #fff; border-bottom: 4px solid var(--red); }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding-top: 12px; padding-bottom: 12px; max-width: 1100px; }
.brand { color: #fff; text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; flex: none; max-width: 100%; }
.brand img, .footer-logo { display: block; height: 48px; width: auto; max-width: 100%; }
/* Without JavaScript the links show as one wrapped row. */
.site-menu { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin-left: auto; min-width: 0; }
.site-header .site-nav, .site-header .site-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-left: 0; }
.site-header .site-nav a, .site-header .site-actions a { color: #fff; text-decoration: none; padding: 10px 12px; border-radius: 8px; min-height: 44px; display: inline-flex; align-items: center; font-size: 1rem; white-space: normal; }
.site-header .site-nav a:hover, .site-header .site-actions a:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
.site-header .site-nav a[aria-current="page"], .site-header .site-actions a[aria-current="page"] { text-decoration: underline; text-underline-offset: 6px; }
.site-header .site-nav a.nav-cta, .site-header .site-actions a.nav-cta { background: var(--gold); color: var(--navy); font-weight: 700; }
.site-header .site-nav a.nav-cta:hover, .site-header .site-actions a.nav-cta:hover { background: #ffd07a; color: var(--navy); }

/* Phone menu. With JS the header gets .has-menu: below 960px (and at any width when the
   toolbar's bigger text is on) the links fold into a panel under the bar, opened by .menu-toggle. */
.menu-toggle {
  display: inline-flex; align-items: center; gap: 8px; margin-left: auto;
  min-width: 44px; min-height: 44px; padding: 8px 12px;
  font: inherit; font-size: 1rem; font-weight: 700; line-height: 1.2;
  color: #fff; background: var(--navy); border: 2px solid rgba(255, 255, 255, 0.55); border-radius: 8px; cursor: pointer;
}
.menu-toggle:hover { background: rgba(255, 255, 255, 0.14); }
/* The icon's middle bar is a border (not a background) so high contrast keeps it visible. */
.menu-icon { position: relative; display: block; flex: none; width: 20px; height: 0; border-top: 2px solid currentColor; }
.menu-icon::before, .menu-icon::after { content: ""; position: absolute; left: 0; width: 20px; height: 2px; background: currentColor; border-radius: 1px; }
.menu-icon::before { top: -8px; }
.menu-icon::after { top: 4px; }
.site-header.is-open .menu-icon { border-top-width: 0; }
.site-header.is-open .menu-icon::before { top: -1px; transform: rotate(45deg); }
.site-header.is-open .menu-icon::after { top: -1px; transform: rotate(-45deg); }
html.menu-open { overflow: hidden; }

.site-header.has-menu .site-menu { display: none; }
/* Logo and Menu stay on one row: on the smallest phones (320px) the logo gives up a few pixels instead. */
.site-header.has-menu .wrap { flex-wrap: nowrap; }
.site-header.has-menu .brand { flex: 0 1 auto; min-width: 0; }
.site-header.has-menu.is-open .site-menu {
  display: block; position: absolute; left: 0; right: 0; top: 100%; margin: 0; padding: 0 0 16px;
  background: var(--navy); border-bottom: 4px solid var(--red);
  max-height: calc(100vh - var(--menu-top, 80px)); max-height: calc(100dvh - var(--menu-top, 80px)); overflow-y: auto; overscroll-behavior: contain;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
}
.site-header.has-menu .site-nav, .site-header.has-menu .site-actions { display: block; }
.site-header.has-menu .site-nav a, .site-header.has-menu .site-actions a {
  display: flex; width: 100%; min-height: 52px; padding: 12px 16px; font-size: 1.125rem; border-radius: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}
.site-header.has-menu .site-nav a:first-child { border-top: 0; }
.site-header.has-menu .site-actions a.nav-cta { width: auto; justify-content: center; margin: 16px 16px 0; border: 0; border-radius: 8px; }

@media (min-width: 960px) {
  html:not([class*="a11y-text-"]) .site-header.has-menu .menu-toggle { display: none; }
  html:not([class*="a11y-text-"]) .site-header.has-menu .site-menu { display: flex; flex-wrap: nowrap; align-items: center; gap: 4px 16px; margin-left: auto; padding: 0; }
  html:not([class*="a11y-text-"]) .site-header.has-menu .site-nav, html:not([class*="a11y-text-"]) .site-header.has-menu .site-actions { display: flex; flex-wrap: nowrap; }
  html:not([class*="a11y-text-"]) .site-header.has-menu .site-nav a, html:not([class*="a11y-text-"]) .site-header.has-menu .site-actions a {
    display: inline-flex; width: auto; min-height: 44px; padding: 10px 12px; font-size: 1rem; border: 0; border-radius: 8px;
  }
  html:not([class*="a11y-text-"]) .site-header.has-menu .site-actions a.nav-cta { margin: 0 0 0 4px; }
}

/* Sign-in icon. A link to /signin that /js/site.js turns into a button for the pop-up. It is the last
   child of the bar, after #site-menu, so it sits outside the phone panel (it stays in the bar) and the
   tab order matches what you see: logo, Menu, links, icon. With the phone menu on, the open panel is
   out of flow, so the bar reads: logo ...... [Menu] [icon]. On wide screens the links' own
   margin-left: auto pushes them and the icon to the right. */
.signin-icon {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 44px; height: 44px; padding: 0; box-sizing: border-box;
  color: #fff; background: transparent; border: 2px solid rgba(255, 255, 255, 0.55); border-radius: 50%;
  text-decoration: none; cursor: pointer;
}
.signin-icon:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
.signin-icon[aria-current="page"] { background: rgba(255, 255, 255, 0.22); border-color: #fff; }
.signin-icon svg { display: block; width: 24px; height: 24px; }
/* Phone bar: logo, Menu and icon on one row at 320px. The logo keeps its shape and gives up width. */
.site-header.has-menu .menu-toggle { flex: none; }
.site-header.has-menu .wrap { gap: 8px 10px; }
.site-header.has-menu .brand img { height: auto; max-height: 48px; }
/* Below 960px (the same line the header's <picture> switches on) the brand is the pin alone: a 48px square,
   so the pin itself stands about 40px tall and the link is a full tap target. object-fit keeps it undistorted. */
@media (max-width: 959px) {
  .brand img, .site-header.has-menu .brand img { width: 48px; height: 48px; max-height: none; object-fit: contain; }
  .brand { min-width: 48px; }
}

/* Bigger text: the bar may wrap instead of squeezing the Menu label. The pin is small, so it shares the
   row with Menu and the icon; if they still do not fit, Menu wraps below. */
html[class*="a11y-text-"] .site-header.has-menu .wrap { flex-wrap: wrap; }

@media (min-width: 960px) {
  html:not([class*="a11y-text-"]) .site-header.has-menu .wrap { gap: 8px 16px; }
}

/* Sign-in pop-up. A native modal <dialog>, so it sits in the top layer above everything else. */
html.signin-open { overflow: hidden; }
.signin-dialog {
  --sd-top: 16px;
  width: min(400px, calc(100% - 32px)); max-height: calc(100vh - var(--sd-top) - 16px); max-height: calc(100dvh - var(--sd-top) - 16px);
  margin: var(--sd-top) auto auto; padding: 0; overflow: hidden; box-sizing: border-box;
  color: var(--ink); background: #fff; border: 0; border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}
.signin-dialog::backdrop { background: rgba(15, 27, 45, 0.65); }
/* The card scrolls (large text can be taller than the screen); the X stays put on the dialog. */
.signin-card { padding: 24px 20px 20px; box-sizing: border-box; max-height: inherit; overflow-y: auto; overscroll-behavior: contain; }
.signin-title { margin: 0 44px 12px 0; font-size: 1.5rem; line-height: 1.2; color: var(--navy); }
.signin-status { margin: 0 0 12px; color: var(--muted); }
.signin-status:empty { display: none; }
.signin-close {
  position: absolute; top: 10px; right: 10px; display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0; color: var(--navy); background: transparent;
  border: 2px solid transparent; border-radius: 50%; cursor: pointer;
}
.signin-close:hover { background: rgba(15, 27, 45, 0.08); border-color: var(--line); }
.signin-close svg { display: block; width: 22px; height: 22px; }
.signin-dialog .form > p { margin: 0; }
/* Six digits have to fit a narrow card, also at the largest text size. */
.signin-dialog .code-input { font-size: min(2rem, 8vw) !important; letter-spacing: 0.25em; }
@media (min-width: 640px) {
  .signin-dialog { --sd-top: 10vh; }
}

/* Back to top. Made by /js/site.js; one step under the toolbar launcher (z-index 900), which stays reachable. */
.to-top {
  position: fixed; right: 12px; z-index: 890;
  bottom: min(calc(12px + var(--a11y-lift, 0px) + env(safe-area-inset-bottom, 0px)), calc(100vh - 72px));
  width: 48px; height: 48px; padding: 0; display: flex; align-items: center; justify-content: center;
  color: var(--gold); background: var(--navy); border: 2px solid var(--gold); border-radius: 50%;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35); cursor: pointer;
}
.to-top:hover { background: #1a2b45; }
.to-top svg { display: block; width: 24px; height: 24px; }
/* Room under the last line so the button never sits on a footer link. a11y.css gives the same
   amount to the toolbar launcher, so the two don't add up. */
html.has-to-top body { padding-bottom: calc(72px + var(--a11y-lift, 0px)); }
html.menu-open .to-top { display: none; }
@media print { .to-top { display: none !important; } }

/* Hero */
.hero { background: var(--navy); color: #fff; padding: 40px 0 44px; }
.hero h1 { color: #fff; font-size: 2.25rem; }
.hero p { font-size: 1.2rem; max-width: 36em; }
.hero .actions { margin-top: 24px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 12px 22px;
  font: inherit; font-size: 1.1rem; font-weight: 700; line-height: 1.2;
  color: #fff; background: var(--red);
  border: 2px solid var(--red); border-radius: var(--radius);
  text-decoration: none; cursor: pointer; text-align: center;
  max-width: 100%;
}
.btn:hover { background: var(--red-dark); border-color: var(--red-dark); color: #fff; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.6; cursor: not-allowed; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: var(--navy); }
.btn-gold:hover { background: #ffd07a; border-color: #ffd07a; color: var(--navy); }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--navy); }
.btn-ghost:hover { background: var(--navy); color: #fff; border-color: var(--navy); }
.hero .btn-ghost { color: #fff; border-color: #fff; }
.hero .btn-ghost:hover { background: #fff; color: var(--navy); }
.btn-block { display: flex; width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* Forms */
.form { display: grid; gap: 18px; }
.field { display: grid; gap: 6px; }
.field > label, .field > .label, legend { font-weight: 700; color: var(--navy); }
.hint { font-size: 0.95rem; color: var(--muted); }
.req { color: var(--red-dark); }
input[type="text"], input[type="email"], input[type="tel"], input[type="url"], input[type="search"], input[type="number"], input[type="password"], input[type="date"], input[type="time"], select, textarea {
  font: inherit; font-size: 1.1rem; color: var(--ink);
  width: 100%; min-height: 52px; padding: 10px 14px;
  background: #fff; border: 2px solid #8a8a93; border-radius: var(--radius);
}
textarea { min-height: 110px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--navy); }
input[aria-invalid="true"] { border-color: var(--red); }
.check { display: flex; gap: 12px; align-items: flex-start; }
.check input { flex: none; width: 24px; height: 24px; margin: 3px 0 0; accent-color: var(--red); }
.check label { font-weight: 400; color: var(--ink); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0; min-width: 0; background: var(--card); display: grid; gap: 18px; }
legend { padding: 0 8px; font-size: 1.15rem; }
.slug-row { display: flex; align-items: center; gap: 0; min-width: 0; }
.slug-prefix { flex: none; padding: 0 8px 0 0; color: var(--muted); font-size: 0.95rem; }
.slug-status { min-height: 1.5em; font-size: 0.95rem; }
.slug-status.ok { color: var(--pine); font-weight: 700; }
.slug-status.bad { color: var(--red-dark); font-weight: 700; }
.code-input { font-size: 2rem !important; letter-spacing: 0.4em; text-align: center; font-variant-numeric: tabular-nums; }
.form-error { color: var(--red-dark); font-weight: 700; margin: 0; }
.form-error:empty { display: none; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card-link { display: grid; gap: 2px; text-decoration: none; color: var(--ink); }
.card-link:hover { border-color: var(--navy); color: var(--ink); }
.card-link strong { color: var(--navy); font-size: 1.15rem; }
.card-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.card-list li { margin: 0; }
.grid { display: grid; gap: 16px; }
.steps { counter-reset: step; list-style: none; padding: 0; display: grid; gap: 16px; }
.steps > li { counter-increment: step; position: relative; margin: 0; padding: 16px 16px 16px 64px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.steps > li::before {
  content: counter(step); position: absolute; left: 16px; top: 16px;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--red); color: #fff; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.steps h3 { margin: 0 0 4px; }
.steps p { margin: 0; }

/* Banners */
.banner { padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--info-bg); margin: 0 0 16px; }
.banner-warn { background: var(--warn-bg); border-color: #e2c277; }
.banner-error { background: var(--danger-bg); border-color: #e7a3ac; }
.banner-ok { background: var(--ok-bg); border-color: #9cc4b1; }
.banner > :last-child { margin-bottom: 0; }
.draft-banner { background: var(--warn-bg); border: 2px solid #c99a2e; padding: 12px 16px; border-radius: var(--radius); font-weight: 700; margin-bottom: 24px; }

/* Toasts */
.toasts { position: fixed; left: 0; right: 0; bottom: 16px; display: grid; gap: 8px; justify-items: center; padding: 0 16px; z-index: 1000; pointer-events: none; }
.toast { pointer-events: auto; background: var(--navy); color: #fff; padding: 12px 18px; border-radius: var(--radius); max-width: 28rem; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); }
.toast-error { background: var(--red-dark); }

/* Prose pages */
.prose { max-width: 42rem; }
.prose h2 { font-size: 1.35rem; }
.prose table { border-collapse: collapse; width: 100%; }

/* Map pieces used by the wave-2 pages */
.map { width: 100%; height: 60vh; min-height: 320px; background: #e8e6df; }
.truck-marker { width: 40px; height: 64px; transition: opacity 0.3s; }
.truck-marker svg { display: block; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4)); }
.maplibregl-ctrl-attrib { font-size: 12px; }

[hidden] { display: none !important; }

@media (min-width: 640px) {
  h1 { font-size: 2.5rem; }
  .hero h1 { font-size: 3rem; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
}
@media (max-width: 639px) {
  .form-row { display: grid; gap: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Small phones without JS: tighter links in the wrapped row. */
@media (max-width: 480px) {
  .site-header .wrap { gap: 0 8px; }
  .site-header:not(.has-menu) .site-nav a, .site-header:not(.has-menu) .site-actions a { padding: 10px 8px; font-size: .95rem; }
}

/* Footer. Kept last on purpose: header and footer changes stay out of each other's lines. */
.site-footer { background: var(--navy); color: #d9deea; padding: 40px 0 0; font-size: 1rem; margin-top: 32px; border-top: 4px solid var(--red); }
.site-footer a { color: #fff; }
.site-footer .wrap { max-width: 1100px; display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.site-footer li { margin: 0; }
.site-footer a { display: inline-block; padding: 8px 0; text-decoration: none; }
.site-footer a:hover, .site-footer a:focus-visible { text-decoration: underline; }
.footer-logo { margin: 0 0 8px; width: 181px; max-width: 100%; height: auto; }
.footer-brand p { margin: 0; }
.footer-brand .footer-copy { font-size: 0.95rem; color: #d9deea; }
/* New three-group footer. The truck phone pages (drive, driver) keep the older brand + bare list markup above. */
.site-footer .footer-top, .site-footer .footer-bottom { flex: 1 1 100%; min-width: 0; }
.footer-top { display: grid; gap: 28px; }
.footer-tagline { max-width: 28ch; margin: 0 0 4px; overflow-wrap: anywhere; }
.footer-powered { font-size: 0.95rem; }
.footer-nav { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 20px 24px; min-width: 0; }
.footer-group { min-width: 0; }
.site-footer .footer-heading { margin: 0 0 6px; padding: 0; font-family: inherit; font-size: 0.8rem; font-weight: 700; line-height: 1.3; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); }
.site-footer .footer-group ul { display: block; }
.site-footer .footer-group a, .site-footer .footer-legal a { display: flex; align-items: center; min-height: 44px; padding: 0; overflow-wrap: anywhere; }
.footer-bottom { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 24px; margin-top: 32px; padding: 16px 0 20px; border-top: 1px solid rgba(255, 255, 255, 0.15); font-size: 0.95rem; }
.footer-bottom p { margin: 0; }
.site-footer .footer-legal { gap: 0 16px; }
@media (min-width: 600px) {
  .footer-nav { grid-template-columns: repeat(3, 1fr); }
}
/* The logo sits beside the links only on wide screens. Narrower, or with the toolbar's bigger text,
   it gets its own row, so the three group headings stay on one line and the links line up. */
@media (min-width: 960px) {
  html:not([class*="a11y-text-"]) .footer-top { grid-template-columns: 1.4fr 3fr; gap: 40px; align-items: start; }
}
@media (max-width: 599px) {
  .footer-bottom { flex-direction: column; align-items: flex-start; }
}
/* The floating buttons (accessibility on the left, back to top on the right) need about 72px at the
   bottom of the page, plus the cookie banner while it shows (--a11y-lift). On pages with the site
   footer that room goes inside the footer, so it stays navy instead of a light strip under it. */
:root.has-to-top body:has(.site-footer),
:root.a11y-floating body:has(.site-footer) { padding-bottom: 0; }
:root.has-to-top .site-footer,
:root.a11y-floating .site-footer { padding-bottom: calc(72px + var(--a11y-lift, 0px)); }
/* Credits (OpenStreetMap, GeoNames). Small and muted, on its own line under the copyright and legal links. */
.footer-bottom .footer-copy { order: 1; }
.footer-bottom .footer-legal { order: 2; }
.footer-bottom .footer-credits { order: 3; flex: 0 1 auto; width: 100%; min-width: 0; font-size: 0.85rem; line-height: 1.5; color: #c4cbdb; overflow-wrap: anywhere; }
.site-footer .footer-credits a { display: inline; padding: 0; text-decoration: underline; text-underline-offset: 2px; }
