/* Layout: header band, then map + side panel (stacked on phones) */
:root {
  --pine: #1d4d36;
  --pine-deep: #133626;
  --on-pine: #ffffff;
  --on-pine-soft: #cfe1d6;
  --berry: #d2452b;
  --holly: #8fb02c;
  --bg: #eef3f0;
  --surface: #ffffff;
  --ink: #16241d;
  --muted: #586b61;
  --line: #d6e0da;
  --past: #9aaba2;
  --ok: #2f8a4f;
  --warn: #b7791f;
  --font-display: "Fredoka", "Trebuchet MS", system-ui, sans-serif;
  --font-body: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1a14;
    --surface: #15271e;
    --ink: #e7efe9;
    --muted: #9fb3a8;
    --line: #26392f;
    --past: #5f7369;
    --ok: #57c27c;
    --warn: #e0a548;
    --berry: #ec6248;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
}
button { font: inherit; }

/* Header */
.bar {
  background: var(--pine);
  color: var(--on-pine);
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 4px solid var(--berry);
}
.mark {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  background: var(--pine-deep);
  border-radius: 50%;
  font-size: 24px;
}
.bar h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  line-height: 1.15;
  text-wrap: balance;
}
.bar p { margin: 2px 0 0; color: var(--on-pine-soft); font-size: .9rem; }

.demo {
  background: var(--warn);
  color: #1b1405;
  padding: 8px 16px;
  font-size: .9rem;
  font-weight: 700;
}

/* Map + panel */
#map { height: 55vh; min-height: 320px; background: var(--line); }
.panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
@media (min-width: 800px) {
  html, body { height: 100%; }
  body { display: flex; flex-direction: column; }
  .layout {
    flex: 1; min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
  }
  #map { height: 100%; min-height: 0; }
  .panel { overflow-y: auto; border-left: 1px solid var(--line); }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}

/* Status */
.status-row { display: flex; align-items: center; gap: 10px; }
.status-row strong { font-family: var(--font-display); font-weight: 600; font-size: 1.25rem; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--past); flex: none; }
[data-state="live"] .dot { background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: pulse 1.8s infinite; }
[data-state="stale"] .dot { background: var(--warn); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); }
  100% { box-shadow: 0 0 0 12px transparent; }
}
.status p { margin: 6px 0 0; color: var(--muted); }
/* Reserve the status card's usual height while it says "Connecting…", so the cards
   below don't jump down when the real status arrives a moment later */
.status { min-height: 10.75rem; }
.status .status-note { font-weight: 700; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px;
  padding: 10px 18px;
  background: var(--berry); color: #fff;
  font-weight: 700; cursor: pointer;
  margin-top: 12px;
}
.btn:focus-visible, .tab:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--holly); outline-offset: 2px; }
.btn.secondary { background: transparent; color: var(--ink); border: 2px solid var(--line); }
.btn:disabled { opacity: .55; cursor: default; }

/* Next stop */
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; font-weight: 800; color: var(--muted); }
.next-name { font-family: var(--font-display); font-size: 1.4rem; font-weight: 600; margin-top: 4px; }
.next-time { color: var(--berry); font-weight: 800; font-variant-numeric: tabular-nums; }

/* Route tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tab {
  border: 2px solid var(--line); background: transparent; color: var(--ink);
  border-radius: 999px; padding: 6px 12px; cursor: pointer; font-weight: 700; font-size: .9rem;
}
.tab[aria-pressed="true"] { background: var(--pine); border-color: var(--pine); color: var(--on-pine); }
.chip {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  background: var(--berry); color: #fff; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
}
.route-date { margin: 10px 0 0; color: var(--muted); font-weight: 700; }
.route-key { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; color: var(--muted); font-size: .9rem; }
/* The key shows the dots on a little map-coloured chip, so it looks like the map
   and stays visible on the dark cards in dark mode */
.route-key-dots {
  width: 36px; height: 14px; flex: none; border-radius: 7px;
  background:
    radial-gradient(circle, var(--trail, var(--berry)) 1.6px, transparent 2.1px) 2px 50% / 7px 7px repeat-x,
    #f2efe9;
}

/* Stops */
.stops { list-style: none; margin: 12px 0 0; padding: 0; }
.stops li {
  display: grid; grid-template-columns: 4.6rem minmax(0, 1fr); gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.stops li:last-child { border-bottom: 0; }
.stops time { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--pine); }
@media (prefers-color-scheme: dark) { .stops time { color: var(--holly); } }
.stops li.past { color: var(--past); }
.stops li.past time { color: var(--past); }
.stops li.next { background: color-mix(in srgb, var(--berry) 12%, transparent); border-radius: 8px; padding-inline: 8px; margin-inline: -8px; }
.stops li.next span::after { content: " \2190 " attr(data-next); color: var(--berry); font-weight: 800; font-size: .85rem; }

/* Language switch */
.lang-btn {
  margin-left: auto; flex: none;
  border: 2px solid var(--on-pine-soft); background: transparent; color: var(--on-pine);
  border-radius: 999px; padding: 6px 14px; font-weight: 800; cursor: pointer;
}
.lang-btn:hover { background: var(--pine-deep); }
.lang-btn:focus-visible { outline: 3px solid var(--holly); outline-offset: 2px; }
.bar > div:not(.mark) { min-width: 0; }

.foot { color: var(--muted); font-size: .85rem; margin: 0; }
.foot a { color: var(--ink); font-weight: 700; text-decoration: underline; }

/* Netlify's free plan puts a "Powered by Netlify" badge in the bottom corner of the
   screen. Leave empty space at the end of the page so the last lines (the privacy
   note and its link) can always be scrolled clear of it. */
.panel, .driver { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }

/* Map credits ("Leaflet | © OpenStreetMap contributors"): a solid white backing and
   darker links, so the small text passes contrast checks over any part of the map.
   The map itself is always light, so these colours stay the same in dark mode. */
.leaflet-container .leaflet-control-attribution {
  background: #ffffff;
  color: #333333;
  padding: 2px 6px;
}
.leaflet-container .leaflet-control-attribution a { color: #005f86; }
.leaflet-container .leaflet-control-attribution a:focus-visible { outline: 2px solid #005f86; outline-offset: 1px; }

/* Santa marker */
.sleigh-pin {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--berry); border: 4px solid #fff;
  display: grid; place-items: center; font-size: 28px;
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
}
.leaflet-div-icon.sleigh-icon { background: none; border: 0; }

/* Driver page */
.driver { max-width: 560px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.driver h2 { font-family: var(--font-display); font-weight: 600; margin: 0 0 8px; font-size: 1.3rem; }
.field { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }
.field label { font-weight: 700; font-size: .9rem; }
.field input, .field select {
  font: inherit; padding: 10px 12px; border-radius: 10px;
  border: 2px solid var(--line); background: var(--bg); color: var(--ink);
}
.error { color: var(--berry); font-weight: 700; margin: 10px 0 0; }
.big-btn { width: 100%; padding: 18px; font-size: 1.15rem; }
.big-btn.go { background: var(--ok); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.stat { background: var(--bg); border-radius: 10px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.tips { margin: 0; padding-left: 1.2rem; color: var(--muted); }
.tips li { margin: 4px 0; }
.who { color: var(--muted); font-size: .9rem; }
.linkbtn { background: none; border: 0; color: var(--berry); text-decoration: underline; cursor: pointer; padding: 0; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  [data-state="live"] .dot { animation: none; }
}
