/* Napa County crash dashboard
   Palette (client): #051E38 #07284B #09325D #556677 #676E75 on white */

:root {
  --navy-900: #051E38;
  --navy-800: #07284B;
  --navy-700: #09325D;
  --slate: #556677;
  --gray: #676E75;

  --paper: #FFFFFF;
  --tint: #F1F3F6;          /* pale slate band */
  --rule: #DCE1E7;          /* hairlines and tracks */
  --ink: var(--navy-900);
  --ink-muted: var(--slate);

  --hero-ink: #FFFFFF;
  --hero-muted: #B7C2CE;

  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --wrap: 1120px;
  --gutter: clamp(16px, 4vw, 40px);
}

*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

h1, h2, p, ul, figure { margin: 0; }

a { color: var(--navy-700); text-underline-offset: 0.18em; }
a:hover { color: var(--navy-900); }
a:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--navy-700);
  outline-offset: 3px;
  border-radius: 2px;
}

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* Top bar */
.topbar {
  background: var(--navy-900);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.topbar__inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  font-size: 0.9375rem;
}
.topbar a { color: var(--hero-muted); text-decoration: none; }
.topbar a:hover { color: var(--hero-ink); text-decoration: underline; }
.topbar a:focus-visible { outline-color: #FFFFFF; }
.topbar__back { display: inline-flex; align-items: center; gap: 6px; }

/* Hero */
.hero {
  background: var(--navy-900);
  color: var(--hero-ink);
  padding: clamp(40px, 6vw, 72px) 0 clamp(44px, 6vw, 72px);
}
.hero__place {
  color: var(--hero-muted);
  font-size: 0.9375rem;
  margin-bottom: 20px;
}
.hero h1 {
  font-size: clamp(2rem, 4.2vw, 3.125rem);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.02em;
  max-width: 24ch;
}
.hero__lead {
  margin-top: 20px;
  color: var(--hero-muted);
  font-size: 1.125rem;
  max-width: 60ch;
}

/* Key figures */
.figures {
  background: var(--tint);
  border-bottom: 1px solid var(--rule);
}
.figures__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.figure {
  padding: 28px 24px 30px;
  border-left: 1px solid var(--rule);
}
.figure:first-child { border-left: 0; padding-left: 0; }
.figure__value {
  font-size: clamp(1.75rem, 3vw, 2.375rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--navy-700);
}
.figure__label {
  margin-top: 6px;
  font-size: 0.9375rem;
  line-height: 1.45;
  color: var(--ink-muted);
  max-width: 24ch;
}

/* Analysis panels: commentary left, chart right */
.panel { padding: clamp(48px, 7vw, 80px) 0 0; }
.panel__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2.2fr);
  gap: clamp(24px, 4vw, 56px);
  align-items: start;
}
.panel__notes h2 {
  font-size: 1.5rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 16px;
}
.panel__notes p {
  color: var(--ink-muted);
  max-width: 40ch;
}
.panel__notes p + p { margin-top: 12px; }
.panel__notes strong { color: var(--ink); font-weight: 700; }

.panel__chart {
  border-top: 3px solid var(--navy-900);
  padding-top: 14px;
  min-width: 0;
}
.chart__title {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 8px;
}
.chart { width: 100%; }
.chart--heatmap { height: 330px; }
.chart--impairment { height: 420px; }
.chart--yearly { height: 360px; }
.chart__note {
  margin-top: 6px;
  font-size: 0.875rem;
  color: var(--gray);
}
.chart__error {
  padding: 24px 0;
  color: var(--ink-muted);
}

/* Chart legend (HTML, so it wraps on phones) */
.legend {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  font-size: 0.875rem;
  color: var(--ink);
  margin-bottom: 4px;
}
.legend li { display: inline-flex; align-items: center; gap: 8px; }
.legend__swatch { width: 12px; height: 12px; border-radius: 2px; }
.legend__swatch--weekday { background: var(--gray); }
.legend__swatch--weekend { background: var(--navy-700); }
.legend__line { width: 18px; border-top: 2px dashed var(--navy-900); }

/* Data tables behind each chart */
.datatable { margin-top: 12px; font-size: 0.875rem; }
.datatable summary {
  cursor: pointer;
  color: var(--navy-700);
  font-weight: 600;
  width: max-content;
}
.datatable > div { overflow-x: auto; margin-top: 10px; }
.datatable table { border-collapse: collapse; min-width: 100%; }
.datatable th,
.datatable td {
  padding: 6px 10px;
  text-align: right;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
.datatable th:first-child,
.datatable td:first-child { text-align: left; }
.datatable th { color: var(--ink-muted); font-weight: 600; }

/* Severity rows */
.severity { list-style: none; padding: 0; display: grid; gap: 18px; margin-top: 6px; }
.severity__row {
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr) 9.5rem;
  align-items: center;
  gap: 16px;
}
.severity__name { font-weight: 600; }
.severity__track {
  height: 18px;
  background: var(--tint);
  border-radius: 0 4px 4px 0;
}
.severity__bar {
  display: block;
  height: 100%;
  min-width: 3px;
  background: var(--navy-700);
  border-radius: 0 4px 4px 0;
}
.severity__value { text-align: right; color: var(--ink-muted); white-space: nowrap; }
.severity__value b { color: var(--ink); font-weight: 700; }

/* About */
.about {
  margin-top: clamp(56px, 8vw, 96px);
  padding: clamp(40px, 6vw, 64px) 0;
  background: var(--tint);
  border-top: 1px solid var(--rule);
}
.about__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(24px, 5vw, 64px);
}
.about h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 12px; }
.about p { color: var(--ink-muted); max-width: 60ch; }
.about p + p { margin-top: 12px; }
.about__list { padding-left: 1.2em; color: var(--ink-muted); max-width: 60ch; }
.about__list li + li { margin-top: 8px; }

/* Footer */
.footer { background: var(--navy-900); color: var(--hero-muted); font-size: 0.9375rem; }
.footer__inner {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 28px;
  padding-bottom: 28px;
}
.footer a { color: var(--hero-ink); }
.footer a:focus-visible { outline-color: #FFFFFF; }

/* Tablet */
@media (max-width: 900px) {
  .panel__grid,
  .about__grid { grid-template-columns: minmax(0, 1fr); }
  .figures__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figure:nth-child(3) { border-left: 0; padding-left: 0; }
  .figure:nth-child(n + 3) { border-top: 1px solid var(--rule); }
  .panel__notes p { max-width: 60ch; }
}

/* Phone */
@media (max-width: 560px) {
  body { font-size: 1rem; }
  .topbar__inner { flex-direction: column; align-items: flex-start; gap: 4px; padding-top: 10px; padding-bottom: 10px; }
  .figure { padding: 20px 12px 22px; }
  .figure:nth-child(odd) { padding-left: 0; }
  .chart--heatmap { height: 300px; }
  .chart--impairment { height: 460px; }
  .chart--yearly { height: 300px; }
  .severity__row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 6px; }
  .severity__track { grid-column: 1 / -1; grid-row: 2; }
}
