/* -----------------------------------------------------------------------
   Guernsey Roadworks
   Restrained, typographic, single column. See docs/PAYLOAD_SCHEMA.md for
   the data this page renders. No component library, no build step.
   ----------------------------------------------------------------------- */

:root {
  --bg: #FFFFFF;
  --fg: #111312;
  --fg-secondary: #6B7270;
  --fg-tertiary: #9AA09E;
  --rule: #E6E8E7;
  --surface: #F6F7F6;
  --primary: #357c57;
  --accent: #F8C537;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    Helvetica, Arial, sans-serif;
  --max-width: 820px;
}

* {
  box-sizing: border-box;
}

/* Icon family: Google's Material Symbols (loaded in index.html's <head>,
   same CDN already trusted for the Inter font) - a real, cohesive icon
   set, not hand-drawn SVG. Write the icon's name as the element's text
   content (e.g. <span class="material-symbols-outlined">block</span>)
   and the font renders it as a glyph. */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
  color: var(--primary);
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-feature-settings: 'tnum' 1, 'cv11' 1;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 48px 24px 80px;
}

h1, h2, h3, p, ul, ol {
  margin: 0;
}

ul, ol {
  list-style: none;
  padding: 0;
}

.rule {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 56px 0;
}

/* ---------- header ---------- */

.site-header {
  margin-bottom: 48px;
}

.brand-logo {
  display: block;
  width: clamp(230px, 38vw, 310px);
  height: auto;
  max-width: 100%;
}

/* ---------- status / loading / error ---------- */

.status {
  color: var(--fg-secondary);
  font-size: 15px;
  padding: 80px 0;
  text-align: center;
}

/* ---------- hero ---------- */

.hero {
  padding: 8px 0 24px;
}

.hero-eyebrow {
  font-size: 15px;
  color: var(--fg-secondary);
  margin-bottom: 6px;
}

.hero-figure-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 14px;
  margin: 0;
}

.hero-figure {
  font-size: clamp(52px, 13vw, 108px);
  font-weight: 800;
  letter-spacing: -0.055em;
  line-height: 0.85;
  color: var(--primary);
  word-break: break-word;
}

.hero-figure-unit {
  font-size: clamp(52px, 13vw, 108px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 0.85;
  color: var(--primary);
}

.hero-caption {
  font-size: 16px;
  font-weight: 500;
  color: var(--fg-secondary);
  margin-top: 10px;
}

.hero-explainer {
  font-size: 14px;
  color: var(--fg-secondary);
  margin-top: 20px;
  max-width: 560px;
}

.hero-explainer strong {
  font-weight: 700;
  color: var(--fg);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- road search ---------- */

.road-search {
  margin-top: 0;
}

.road-search-icon {
  font-size: 22px;
  vertical-align: -4px;
  margin-right: 8px;
}

.road-search-box {
  position: relative;
  margin-top: 16px;
}

.road-search-input {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--fg);
  background: var(--bg);
  border: 1.5px solid var(--rule);
  border-radius: 10px;
  padding: 14px 16px;
}

.road-search-input:focus {
  outline: none;
  border-color: var(--primary);
}

.road-search-suggestions {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 10px;
}

.road-search-suggestion {
  padding: 12px 16px;
  font-size: 15px;
  cursor: pointer;
  border-bottom: 1px solid var(--rule);
}

.road-search-suggestion:last-child {
  border-bottom: none;
}

.road-search-suggestion:hover,
.road-search-suggestion.is-active {
  background: var(--surface);
}

.road-search-result {
  margin-top: 20px;
  background: var(--surface);
  border-radius: 10px;
  padding: 24px 22px;
}

.road-search-result-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--fg-secondary);
}

.road-search-result-figure {
  font-size: clamp(36px, 7vw, 56px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--primary);
  margin-top: 10px;
}

.road-search-result-label {
  font-size: 15px;
  color: var(--fg-secondary);
  margin-top: 6px;
}

.road-search-result-sub {
  font-size: 13px;
  color: var(--fg-tertiary);
  margin-top: 10px;
}

.road-search-empty {
  margin-top: 20px;
  font-size: 14px;
  color: var(--fg-tertiary);
}

/* ---------- headline stat grid ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: auto auto auto;
  gap: 16px;
  margin-top: 56px;
}

.stat {
  display: grid;
  grid-row: 1 / span 3;
  grid-template-rows: subgrid;
  background: var(--surface);
  border-radius: 10px;
  padding: 26px 22px;
}

.stat-value {
  font-size: clamp(28px, 4.4vw, 38px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  font-feature-settings: 'tnum' 1;
  color: var(--primary);
}

.stat-label {
  font-size: 14px;
  color: var(--fg-secondary);
  margin-top: 10px;
  line-height: 1.35;
}

.stat-sub {
  font-size: 13px;
  color: var(--fg-tertiary);
  margin-top: 8px;
}

/* ---------- disruption-by-year chart ---------- */

.chart-wrap {
  position: relative;
  margin-top: 24px;
}

.trend-svg {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 640 / 240;
}

.chart-grid {
  stroke: var(--rule);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart-line {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.chart-line-partial {
  stroke-dasharray: 5 5;
  opacity: 0.55;
}

.chart-dot-ring {
  fill: var(--bg);
}

.chart-dot {
  fill: var(--primary);
}

.chart-dot-partial {
  fill: var(--bg);
  stroke: var(--primary);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.chart-hit {
  fill: transparent;
  pointer-events: all;
  cursor: pointer;
}

.chart-hit:focus {
  outline: none;
}

.chart-hit:focus-visible {
  outline: 2px solid var(--fg-tertiary);
  outline-offset: 2px;
}

/* Axis labels and the endpoint value are plain HTML, positioned by
   percentage over the SVG, not SVG <text> - keeps them a real, legible
   CSS px size at every viewport width instead of scaling (and shrinking
   to illegibility on mobile) with the SVG's viewBox. */
.chart-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.chart-y-label {
  position: absolute;
  left: 0;
  /* Sits just above its gridline, never straddling it - centering (-50%)
     let the "0" label's lower half collide with the x-axis year row
     directly underneath it on real devices (Inter's line-height leaves
     less clearance than the fallback font this was first checked with). */
  transform: translateY(calc(-100% - 4px));
  font-size: 12px;
  color: var(--fg-tertiary);
}

.chart-x-label {
  position: absolute;
  bottom: 0;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--fg-tertiary);
}

.chart-end-label {
  position: absolute;
  /* Below the point and right-aligned to end at it, not centered: below
     because it's the last point on the line, so nothing continues past
     it here, unlike above/left where the incoming line segment would
     cross straight through the text; right-aligned (extending only
     leftward, into the chart) because the last point sits at the right
     edge, so a centered label overflows off the page on narrow screens. */
  transform: translate(-100%, 14px);
  font-size: 13px;
  font-weight: 700;
  color: var(--fg);
  white-space: nowrap;
}

.chart-tooltip {
  position: absolute;
  transform: translate(-50%, -115%);
  background: var(--fg);
  color: var(--bg);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.4;
  pointer-events: none;
  white-space: nowrap;
  z-index: 2;
}

.chart-tooltip-year {
  font-weight: 700;
}

.chart-tooltip-value {
  color: var(--bg);
  opacity: 0.85;
  margin-top: 2px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--fg-secondary);
}

.chart-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-legend-swatch {
  display: inline-block;
  width: 20px;
  border-top: 2px solid var(--primary);
}

.chart-legend-swatch-partial {
  border-top-style: dashed;
  opacity: 0.55;
}

.chart-table-details {
  margin-top: 20px;
}

.chart-table-details summary {
  cursor: pointer;
  font-size: 14px;
  color: var(--fg-secondary);
}

.chart-table-details summary:hover {
  color: var(--fg);
}

.chart-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  font-size: 14px;
}

.chart-table th,
.chart-table td {
  text-align: right;
  padding: 8px 6px;
  border-bottom: 1px solid var(--rule);
  font-variant-numeric: tabular-nums;
}

.chart-table th {
  color: var(--fg-secondary);
  font-weight: 600;
  font-size: 13px;
}

.chart-table th:first-child,
.chart-table td:first-child {
  text-align: left;
}

/* ---------- section headings ---------- */

h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.section-icon {
  font-size: 22px;
  vertical-align: -4px;
  margin-right: 8px;
}

.accent-count {
  color: var(--primary);
}

/* ---------- tabs (underlined text, not buttons) ---------- */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin-top: 24px;
  border-bottom: 1px solid var(--rule);
}

.tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--fg-tertiary);
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  padding: 0 0 10px;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--fg-secondary);
}

.tab.is-active {
  color: var(--fg);
  font-weight: 600;
  border-bottom-color: var(--fg);
}

.tab:focus-visible {
  outline: 2px solid var(--fg-tertiary);
  outline-offset: 2px;
}

.panel {
  padding-top: 24px;
}

/* ---------- today's works list ---------- */

.work-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 22px 0;
  border-bottom: 1px solid var(--rule);
}

.work-list li:first-child {
  padding-top: 0;
}

.work-list li:last-child {
  border-bottom: none;
}

.work-main {
  min-width: 0;
}

.work-road {
  font-size: 16px;
  font-weight: 600;
}

.work-parish {
  font-size: 13px;
  font-weight: 400;
  color: var(--fg-tertiary);
  margin-top: 2px;
}

.work-reason {
  font-size: 14px;
  color: var(--fg-secondary);
  line-height: 1.45;
  margin-top: 8px;
  /* Cap it at two lines - the live feed's raw description is sometimes a
     long machine-generated sentence; summarizeReason() cleans it up, but
     this is a backstop so an unusually long one still can't sprawl the
     whole card. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.work-meta {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin-top: 8px;
}

.work-end {
  flex: 0 0 auto;
  text-align: right;
  font-size: 14px;
  color: var(--fg-secondary);
  white-space: nowrap;
}

.work-end .work-type {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 2px;
}

.empty-note {
  color: var(--fg-tertiary);
  font-size: 14px;
  padding: 8px 0;
}

/* ---------- leaderboards ---------- */

.leaderboard-list li {
  padding: 14px 0;
  border-bottom: 1px solid var(--rule);
}

.leaderboard-list li:first-child {
  padding-top: 0;
}

.leaderboard-list li:last-child {
  border-bottom: none;
}

.lb-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
}

.lb-name {
  font-size: 16px;
  font-weight: 600;
}

.lb-rank {
  color: var(--fg-tertiary);
  font-weight: 500;
  margin-right: 4px;
}

.lb-figures {
  flex: 0 0 auto;
  text-align: right;
  white-space: nowrap;
}

.lb-days {
  font-size: 16px;
  font-weight: 700;
}

.lb-jobs {
  font-size: 13px;
  color: var(--fg-tertiary);
  margin-left: 6px;
}

.lb-bar-track {
  height: 3px;
  background: var(--rule);
  margin-top: 10px;
}

.lb-bar {
  height: 100%;
  background: var(--fg-tertiary);
}

.leaderboard-list li:first-child .lb-bar {
  background: var(--accent);
}

/* ---------- worst roads ---------- */

.road-list {
  margin-top: 24px;
}

.road-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
}

.road-list li:last-child {
  border-bottom: none;
}

.road-name {
  font-size: 16px;
  font-weight: 600;
}

.road-figures {
  text-align: right;
  white-space: nowrap;
}

.road-years {
  font-weight: 700;
}

.road-days {
  font-size: 13px;
  color: var(--fg-tertiary);
  margin-left: 6px;
}

/* ---------- footer ---------- */

.site-footer {
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
  font-size: 13px;
  color: var(--fg-tertiary);
}

.site-footer p + p {
  margin-top: 8px;
}

.footer-logo {
  display: block;
  width: clamp(230px, 38vw, 310px);
  height: auto;
  max-width: 100%;
  margin-bottom: 20px;
}

/* ---------- mobile ---------- */

@media (max-width: 480px) {
  .wrap {
    padding: 32px 18px 64px;
  }

  .stat-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    gap: 28px;
  }

  .stat {
    grid-row: auto;
    grid-template-rows: none;
  }

  .rule {
    margin: 48px 0;
  }

  .tabs {
    gap: 8px 16px;
  }

  .work-end {
    text-align: right;
  }

  .lb-jobs {
    display: none;
  }

  .road-days {
    display: none;
  }

  .chart-table .col-breakdown {
    display: none;
  }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
