:root {
  --text: #1c2733;
  --muted: #3f4a54;
  --accent: #2f6fed;
  --clear: #157a42;
  --approaching: #8f5a15;
  --down: #a52f2f;
  --glass: rgba(255,255,255,0.42);
  --glass-strong: rgba(255,255,255,0.52);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-size: cover;
  background-position: center;
  /* Fallback tone until the photo arrives. Without this the page paints
     white for about a second: the backdrop's URL lives in a class that
     JavaScript adds, so the browser's preload scanner can't see it and the
     fetch can't start until app.js has downloaded and run. Each colour is
     the average of its own photo, so the page opens in roughly the right
     tone and the image resolves into it rather than flashing over white. */
  background-color: #2a2a2e;
}
/* AVIF cuts these full-screen photos by ~58%, which matters on a metered
   1GB/month egress allowance where every new visitor pulls one. The plain
   url() above each image-set() is the fallback: browsers that don't
   support image-set() (or AVIF) ignore the second declaration and keep
   the original JPEG. */
.backdrop.bg-morning {
  background-color: #6c5f32;
  background-image: url('/img/backgrounds/pumpkin-patch.jpeg');
  background-image: image-set(
    url('/img/backgrounds/pumpkin-patch.avif') type('image/avif'),
    url('/img/backgrounds/pumpkin-patch.jpeg') type('image/jpeg')
  );
}
.backdrop.bg-afternoon {
  background-color: #a09584;
  background-image: url('/img/backgrounds/wheat-field.jpg');
  background-image: image-set(
    url('/img/backgrounds/wheat-field.avif') type('image/avif'),
    url('/img/backgrounds/wheat-field.jpg') type('image/jpeg')
  );
}
.backdrop.bg-evening {
  background-color: #b19183;
  background-image: url('/img/backgrounds/golden-hour.jpg');
  background-image: image-set(
    url('/img/backgrounds/golden-hour.avif') type('image/avif'),
    url('/img/backgrounds/golden-hour.jpg') type('image/jpeg')
  );
}
.backdrop.bg-night {
  background-color: #4a3718;
  background-image: url('/img/backgrounds/ayscoughfee-night.jpg');
  background-image: image-set(
    url('/img/backgrounds/ayscoughfee-night.avif') type('image/avif'),
    url('/img/backgrounds/ayscoughfee-night.jpg') type('image/jpeg')
  );
}

/* Soft gradient instead of cards — gives the hero text (title, weather,
   clock) enough contrast to sit directly on the photo, the way Coningsby's
   clock does, without wrapping every element in its own box. */
.vignette-top {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(8,12,18,0.55) 0%, rgba(8,12,18,0.22) 32%, rgba(8,12,18,0) 58%);
  pointer-events: none;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 32px 28px 40px;
}

.on-photo {
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5), 0 6px 20px rgba(0,0,0,0.3);
}

/* Static "liquid glass" surface: a stronger blur/saturate than a plain
   frosted card, plus a mild SVG refraction (feDisplacementMap) so the
   photo bends slightly behind the glass instead of just blurring flat,
   and a specular highlight along the top edge like light catching curved
   glass. No motion — just the material. */
.glass {
  position: relative;
  background: var(--glass);
  backdrop-filter: url(#liquid-glass-distort) blur(14px) saturate(70%) brightness(1.5) contrast(0.92);
  -webkit-backdrop-filter: blur(16px) saturate(70%) brightness(1.5) contrast(0.92);
  border: 1px solid rgba(255,255,255,0.5);
  box-shadow:
    0 20px 60px rgba(15,25,40,0.25),
    inset 0 1px 0 rgba(255,255,255,0.55),
    inset 0 -1px 0 rgba(255,255,255,0.06);
}
.glass::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0) 32%);
}
.glass.glass-strong { background: var(--glass-strong); }
.glass.glass-warn {
  background: rgba(210,150,50,0.55);
  border-color: rgba(255,255,255,0.5);
}

/* The night photo is mostly black sky, so light glass + dark text reads
   as near-invisible over it (glass borrows its contrast from whatever is
   behind it). Swap to dark glass + light text specifically for the night
   background. */
body.is-night {
  --text: #f2f5f8;
  --muted: #b7c2cc;
  --clear: #4fd888;
  --approaching: #eab04e;
  --down: #f07a7a;
}
body.is-night .glass {
  background: rgba(18,22,28,0.4);
  border-color: rgba(255,255,255,0.16);
}
body.is-night .glass.glass-strong { background: rgba(18,22,28,0.5); }
body.is-night .glass::before {
  background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0) 32%);
}
body.is-night .data-col,
body.is-night .train-row,
body.is-night .event-row {
  border-color: rgba(255,255,255,0.16) !important;
}
body.is-night .pill { background: rgba(31,157,85,0.3); border-color: rgba(79,216,136,0.4); }
body.is-night .pill.approaching { background: rgba(179,114,27,0.32); border-color: rgba(234,176,78,0.4); }
body.is-night .pill.down { background: rgba(194,59,59,0.32); border-color: rgba(240,122,122,0.4); }

.night-flying-banner {
  align-self: center;
  margin-bottom: 22px;
  padding: 10px 22px;
  border-radius: 999px;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
}

.location .eyebrow {
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.85;
  font-weight: 700;
  margin-bottom: 4px;
}
.location a.built-by {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(255,255,255,0.5);
  opacity: 0.9;
}
.location a.built-by:hover { text-decoration-color: currentColor; }

.location h1 {
  margin: 0;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.weather-inline {
  text-align: right;
  min-width: 300px;
  color: var(--text);
  border-radius: 22px;
  padding: 13px 20px;
}
.weather-now { display: flex; align-items: baseline; justify-content: flex-end; gap: 8px; }
.weather-now .icon { font-size: 1.3rem; }
.weather-now .temp { font-size: 1.6rem; font-weight: 800; }
.weather-now .cond { font-size: 0.95rem; color: var(--muted); }
.weather-meta { font-size: 0.72rem; color: var(--muted); margin-top: 1px; }

.forecast-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid rgba(255,255,255,0.45);
}
.forecast-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.forecast-item .hour { font-size: 0.64rem; color: var(--muted); text-transform: uppercase; }
.forecast-item .icon { font-size: 1.15rem; }
.forecast-item .temp { font-size: 0.78rem; font-weight: 700; }

.school-run {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid rgba(255,255,255,0.45);
}
.school-run-label {
  font-size: 0.66rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.school-run-slots { display: flex; gap: 18px; }
/* Stacked like .forecast-item, not inline — the label now varies in length
   ("Today AM" vs "Tomorrow PM" vs "Mon AM" once it rolls past the
   weekend), so a single horizontal row risked wrapping or overflowing. */
.school-run-slot { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.school-run-slot .label { font-size: 0.62rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
.school-run-slot .icon { font-size: 1rem; }
.school-run-slot .temp { font-size: 0.78rem; font-weight: 700; }

.clock-block { margin-top: 48px; }
.clock-block .time {
  font-family: 'Oswald', -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: clamp(3.6rem, 12vw, 8rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.clock-block .date {
  margin-top: 10px;
  font-size: 1.05rem;
  opacity: 0.9;
}

/* Each row of the data-dense lower section is its own floating glass
   card, with real space between them, rather than one continuous sheet
   with faint internal dividers — makes the groupings (Traffic / In The
   Know) actually read as distinct. */
.data-surface {
  margin-top: 48px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  color: var(--text);
}

.data-section {
  border-radius: 28px;
  padding: 26px 30px;
}
.section-label {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  margin: 0 0 14px;
  text-shadow: 0 1px 3px rgba(255,255,255,0.5);
}
body.is-night .section-label { text-shadow: 0 1px 3px rgba(0,0,0,0.4); }

.closure-alert {
  margin-bottom: 16px;
  padding: 10px 16px;
  border-radius: 12px;
  color: #fff;
}
.closure-row {
  font-size: 0.82rem;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.25);
  padding-left: 10px;
  border-left: 3px solid rgba(255,255,255,0.5);
}
/* Unplanned (incident, no roadworks tag, usually open-ended) reuses the
   app's existing "down"/urgent red so it reads as the same severity level
   as barriers-down or heavy-traffic elsewhere on the page. Planned
   roadworks closures stay a calmer amber — noteworthy, not urgent. */
.closure-row.unplanned { border-left-color: #f07a7a; }
.closure-row.planned { border-left-color: #eab04e; }
.closure-row + .closure-row {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.3);
}

.data-grid {
  display: grid;
}
.data-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.data-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
/* Equal thirds, so this section's columns and dividers line up with the
   three-column sections above and below it. Local News is still played down
   relative to the What's On columns, but through smaller type (.data-col-news)
   rather than a narrower column, which would break that alignment. */
.data-grid.cols-know { grid-template-columns: repeat(3, 1fr); }
.data-col {
  padding: 0 18px;
  border-left: 1px solid rgba(28,39,51,0.14);
}
.data-col:first-child { padding-left: 0; border-left: none; }

.col-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.col-title .eyebrow {
  font-size: 0.86rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(255,255,255,0.5);
}
body.is-night .col-title .eyebrow { text-shadow: 0 1px 3px rgba(0,0,0,0.4); }

.pill[hidden] { display: none; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 5px 12px 5px 10px;
  border-radius: 999px;
  background: rgba(31,157,85,0.2);
  border: 1px solid rgba(31,157,85,0.32);
  color: var(--clear);
  box-shadow: 0 1px 2px rgba(15,25,40,0.08), inset 0 1px 0 rgba(255,255,255,0.45);
}
.pill::before {
  content: '';
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}
.pill.approaching { background: rgba(179,114,27,0.22); border-color: rgba(179,114,27,0.35); color: var(--approaching); }
.pill.down { background: rgba(194,59,59,0.22); border-color: rgba(194,59,59,0.35); color: var(--down); }

.headline { font-size: 0.94rem; font-weight: 700; margin-bottom: 8px; }
.exercise-note { font-size: 0.78rem; color: var(--muted); margin: -4px 0 8px; }

.train-row, .event-row {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 0;
  border-top: 1px solid rgba(28,39,51,0.11);
}
.train-row:first-of-type, .event-row:first-of-type { border-top: none; }
.train-row .time, .event-row .when { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.78rem; }
.freight-tag, .note-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: rgba(63,74,84,0.12);
  border-radius: 4px;
  padding: 1px 5px;
  margin-right: 4px;
  vertical-align: middle;
}
body.is-night .freight-tag, body.is-night .note-tag { background: rgba(255,255,255,0.14); }
.event-row .name { font-weight: 600; font-size: 0.88rem; }
.event-row .name a { color: inherit; text-decoration: none; }
.event-row .name a:hover { text-decoration: underline; }

.traffic-body { display: flex; flex-direction: column; gap: 10px; }
/* A <button> now, not a <div> — tapping it opens the lightbox — so the
   default button chrome (border, background, font) is reset back to how
   the plain tile looked before. */
.traffic-tile {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(28,39,51,0.14);
  background: #dfe6ec;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.traffic-tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* The explicit display:block above would otherwise out-specificity the
   browser's default [hidden]{display:none} and break the existing
   map-load-failure fallback (tile.hidden = true in app.js). */
.traffic-tile[hidden] { display: none; }
/* Subtle "this is tappable" cue on hover — pointer devices only, so it
   doesn't flash on tap for touch users. The "Tap to enlarge" text in the
   caption is the actual affordance; this just reinforces it. */
@media (hover: hover) {
  .traffic-tile:hover img { transform: scale(1.03); }
}
.traffic-tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  transition: transform 0.2s ease;
}
.traffic-tile .tile-caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  text-align: center;
  font-size: 0.62rem;
  letter-spacing: 0.02em;
  color: rgba(255,255,255,0.95);
  background: rgba(20,30,45,0.45);
  padding: 3px 0;
}
.tile-caption-hint {
  color: rgba(255,255,255,0.72);
}
body.is-night .traffic-tile { box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16); }
.traffic-info .headline { font-size: 0.88rem; margin-bottom: 2px; }

/* Tap-to-enlarge lightbox for the traffic tile — a full-screen overlay
   with the same image at LARGE_SIZE (see tileConfig.js), fetched only on
   open rather than on the 20-second poll. */
.traffic-lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(10, 14, 20, 0.82);
}
.traffic-lightbox[hidden] { display: none; }
.traffic-lightbox img {
  max-width: min(90vw, 900px);
  max-height: 90vh;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.traffic-lightbox-close {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.16);
  color: #fff;
  font: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.traffic-lightbox-close:hover { background: rgba(255,255,255,0.28); }

/* Fuel — one tab per grade, because a single combined table would be three
   times as long and nobody buys two grades at once. Tabs are the same pill
   language as the status pills, just neutral until selected. */
.fuel-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.fuel-tab {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(63,74,84,0.1);
  border: 1px solid rgba(28,39,51,0.14);
  border-radius: 999px;
  padding: 5px 14px;
  cursor: pointer;
}
.fuel-tab:hover { background: rgba(63,74,84,0.16); }
.fuel-tab.is-active {
  color: var(--text);
  background: rgba(255,255,255,0.55);
  border-color: rgba(255,255,255,0.7);
  box-shadow: 0 1px 2px rgba(15,25,40,0.08), inset 0 1px 0 rgba(255,255,255,0.6);
}
body.is-night .fuel-tab { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.16); }
body.is-night .fuel-tab:hover { background: rgba(255,255,255,0.14); }
body.is-night .fuel-tab.is-active { background: rgba(255,255,255,0.18); border-color: rgba(255,255,255,0.3); }

.fuel-row {
  display: grid;
  /* Rank / name+place / price. No distance column: straight-line mileage
     reads as driving distance, and doing it properly would mean asking for
     the visitor's location. */
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-top: 1px solid rgba(28,39,51,0.11);
}
.fuel-row:first-of-type { border-top: none; }
body.is-night .fuel-row { border-color: rgba(255,255,255,0.16); }

.fuel-rank {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.fuel-station { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.fuel-name {
  font-size: 0.88rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fuel-where { font-size: 0.72rem; color: var(--muted); }
.fuel-price {
  font-size: 0.98rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* Cheapest row gets the same green as a "clear" status, so the answer to
   "where's cheapest" is readable at a glance without reading the numbers. */
.fuel-row:first-of-type .fuel-price { color: var(--clear); }

.col-date { font-size: 0.78rem; color: var(--muted); margin-bottom: 6px; }

.data-col-news .headline,
.data-col-news .event-row .name { font-size: 0.8rem; }
.data-col-news .event-row .when { font-size: 0.7rem; }
.more-note {
  display: block;
  font-size: 0.74rem;
  color: var(--muted);
  padding-top: 4px;
  text-decoration: underline;
  text-decoration-color: rgba(120,130,140,0.4);
}
.more-note:hover { text-decoration-color: currentColor; }
.empty-note { font-size: 0.82rem; color: var(--muted); padding: 6px 0; }

.credits {
  align-self: center;
  margin-top: 4px;
  padding: 9px 18px;
  border-radius: 999px;
  text-align: center;
  font-size: 0.68rem;
  color: var(--muted);
}
.credits a { color: inherit; text-decoration: underline; text-decoration-color: rgba(120,130,140,0.4); }
.credits a:hover { text-decoration-color: currentColor; }

@media (max-width: 760px) {
  .hero-top { flex-direction: column; }
  /* Desktop puts weather on the left / Spalding on the right via source
     order, but on mobile (stacked) Spalding should still appear first. */
  .hero-top .location { order: -1; }
  .weather-inline { text-align: left; min-width: 0; }
  .weather-now { justify-content: flex-start; }
  .forecast-row { justify-content: space-between; }
  .data-grid.cols-2, .data-grid.cols-3, .data-grid.cols-know { grid-template-columns: 1fr; row-gap: 20px; }
  .data-col {
    border-left: none !important;
    padding: 20px 0 0 !important;
    border-top: 1px solid rgba(28,39,51,0.14);
  }
  .data-col:first-child { border-top: none; padding-top: 0 !important; }
}

/* "Add to home screen" invitation. Phones only, and only when the page
   isn't already running from the home screen — app.js decides. Fixed to
   the bottom so it never pushes the crossing status out of view. */
.install-prompt.glass {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 10;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 14px;
  border-radius: 18px;
}
.install-prompt[hidden] { display: none; }
.install-prompt-icon { width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0; }
.install-prompt-body { flex: 1; min-width: 0; }
.install-prompt-title { font-weight: 700; font-size: 0.92rem; }
.install-prompt-text { font-size: 0.82rem; color: var(--muted); margin-top: 2px; }
.install-prompt-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.install-prompt-add {
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 8px 16px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.install-prompt-close {
  font: inherit;
  font-size: 1.4rem;
  line-height: 1;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
