/* ============================================================
   US Fatal Crash Density — UI chrome styles
   Transport operations chrome. Map layer NOT included.
   Fonts: Source Serif 4 (display) + Public Sans (UI)
   @import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,500;0,8..60,600;0,8..60,700&family=Public+Sans:wght@400;500;600;700&display=swap');
   ============================================================ */

:root {
  --ink:        #17201d;
  --ink-2:      #39443f;
  --muted:      #68756e;
  --panel:      #f4f6f0;
  --panel-2:    #e8eee6;
  --field:      #fffdf8;
  --accent:     #ae4a32;          /* crash signal */
  --accent-2:   #1f6f64;          /* control green */
  --accent-2-dark:#174d48;
  --accent-tint:rgba(31, 111, 100, .10);
  --accent-line:rgba(174, 74, 50, .24);
  --hairline:   rgba(45, 62, 55, .14);
  --hairline-2: rgba(45, 62, 55, .09);
  --border:     rgba(45, 62, 55, .22);
  --shadow:     0 24px 38px -30px rgba(23,32,29,.62), 0 1px 0 rgba(255,255,255,.70) inset;
  --shadow-sm:  0 14px 22px -20px rgba(23,32,29,.55);
  --radius:     8px;
  --radius-sm:  5px;
  --font-ui:    'Public Sans', system-ui, sans-serif;
  --font-display:'Source Serif 4', Georgia, serif;
}

*       { box-sizing: border-box; }
.tnum   { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- Panel shell ---------- */
.panel {
  position: relative;
  background: linear-gradient(180deg, var(--panel) 0%, #eef2eb 100%);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  font-family: var(--font-ui);
  color: var(--ink);
}
.panel__header {
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--hairline-2);
  background:
    linear-gradient(90deg, rgba(31,111,100,.08), transparent 54%),
    linear-gradient(180deg, rgba(255,255,255,.52), rgba(255,255,255,0));
}
.panel__body {
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.panel__scrollfade {
  position: absolute;
  left: 1px;
  right: 1px;
  bottom: 1px;
  height: 48px;
  pointer-events: none;
  z-index: 5;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 9px;
  border-radius: 0 0 var(--radius) var(--radius);
  background: linear-gradient(to top, #eef2eb 8%, rgba(238,242,235,0) 100%);
  opacity: 0;
  transition: opacity .22s ease;
}
.panel__scrollfade.is-visible { opacity: 1; }
.panel__scrollfade .fa-chevron-down {
  color: var(--accent-2-dark);
  font-size: 13px;
  opacity: .72;
  filter: drop-shadow(0 1px 0 rgba(255,255,255,.65));
}

/* ---------- Title ---------- */
.title-row { display: flex; align-items: center; gap: 12px; }
.title-rule {
  width: 3px; height: 44px; border-radius: 0;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  flex: none;
}
.title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: 0;
  line-height: 1.05;
  color: var(--ink);
}
.subtitle { font-size: 12.5px; color: var(--muted); margin-top: 3px; letter-spacing: .01em; }
.title-link {
  display: inline-block; margin-top: 6px;
  font-size: 12px; font-weight: 700; color: var(--accent-2); text-decoration: none;
}
.title-link:hover { text-decoration: underline; }

/* ---------- Section label ---------- */
.label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 7px;
}

/* ---------- Field / input ---------- */
.field {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 14px;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 0 rgba(255,255,255,.8) inset;
}
.field:focus-within { border-color: rgba(31,111,100,.55); box-shadow: 0 0 0 3px rgba(31,111,100,.12); }
.field .fa-solid { color: var(--accent-2); font-size: 14px; }
.field input {
  flex: 1;
  border: 0; outline: 0; background: transparent;
  font-family: var(--font-ui);
  font-size: 15px; font-weight: 600; color: var(--ink);
}

/* ---------- Select ---------- */
.select-wrap { position: relative; }
.select {
  width: 100%; height: 44px;
  padding: 0 38px 0 14px;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 15px; font-weight: 600; color: var(--ink);
  outline: 0; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.select-wrap::after {
  content: "\f078";
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  pointer-events: none; color: var(--accent-2); font-family: "Font Awesome 7 Free"; font-size: 11px; font-weight: 900;
}

/* ---------- Chips / tags ---------- */
.tag {
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  color: var(--accent-2); background: var(--accent-tint);
  padding: 3px 8px; border-radius: 5px;
}

/* ---------- Bin-size group ---------- */
.group {
  background: rgba(255,253,248,.78);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 15px 15px 17px;
}
.group__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.group__value { font-size: 18px; font-weight: 700; color: var(--ink); margin-bottom: 12px; }
.slider { width: 100%; height: 4px; accent-color: var(--accent-2); }

/* ---------- Toggle button (Auto/Manual) ---------- */
.toggle {
  border: 1px solid transparent; cursor: pointer;
  font-family: var(--font-ui);
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  padding: 4px 11px; border-radius: 6px;
  color: var(--field); background: #56635d;
}
.toggle.is-on { background: var(--accent-2); }

/* ---------- Buttons ---------- */
.btn-primary {
  height: 48px; border: 0; cursor: pointer;
  border-radius: var(--radius-sm);
  background: var(--accent-2-dark); color: var(--field);
  font-family: var(--font-ui);
  font-size: 15px; font-weight: 600; letter-spacing: .01em;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 12px 18px -16px rgba(23,32,29,.72);
  transition: background .15s, transform .15s;
}
.btn-primary:hover { background: #103f3a; transform: translateY(-1px); }
.btn-primary:disabled { cursor: wait; opacity: .72; transform: none; }

.btn-icon {
  width: 44px; height: 44px;
  border: 1px solid var(--hairline);
  background: var(--panel);
  border-radius: var(--radius-sm);
  cursor: pointer; color: var(--accent-2-dark); font-size: 17px;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.btn-icon:hover { background: var(--field); color: var(--accent); }
.btn-pill {
  height: 44px; padding: 0 15px;
  border: 1px solid rgba(23,77,72,.25);
  background: var(--accent-2-dark); color: var(--field);
  border-radius: var(--radius-sm); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-ui); font-weight: 700; font-size: 13px; letter-spacing: .05em;
  box-shadow: var(--shadow-sm);
}

/* ---------- Stat cards ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 9px; }
.stat {
  background: rgba(255,253,248,.76);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 13px 12px;
}
.stat__num {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 600; line-height: 1; color: var(--ink);
}
.stat__num--accent { color: var(--accent); }
.stat__cap { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.25; }

/* ---------- Summary callout ---------- */
.callout {
  background: rgba(31,111,100,.08);
  border: 1px solid rgba(31,111,100,.18);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  font-size: 13px; line-height: 1.5; color: var(--ink-2);
}
.callout strong { font-weight: 700; color: var(--accent); }

/* ---------- Selected segment drill-down ---------- */
/* display:flex below would otherwise defeat the [hidden] attribute. */
.segment-detail[hidden],
.segment-detail__section[hidden] { display: none; }
.segment-detail {
  background: var(--field);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-sm);
  padding: 14px 15px 16px;
  display: flex; flex-direction: column; gap: 13px;
}
.segment-detail__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.segment-back {
  height: 32px;
  border: 1px solid var(--hairline);
  background: rgba(244,246,240,.72);
  cursor: pointer;
  color: var(--accent-2-dark);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.segment-back:hover { color: var(--accent); background: var(--field); }
.segment-detail__range {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--font-display); font-size: 18px; font-weight: 600; line-height: 1.15; color: var(--ink); margin-top: -3px;
}

/* Inline route shield reused in the segment range, year header and map overlay.
   The shield's number text is not inside .road-badge, so restate its font here. */
.road-shield-inline { display: block; flex: none; }
.road-shield-inline text { font-family: var(--font-ui); font-weight: 900; }
.road-shield-inline .shield-route { letter-spacing: .2px; }
.segment-detail__count { display: flex; gap: 18px; align-items: baseline; }
.seg-metric { font-size: 13px; color: var(--ink-2); }
.seg-metric .tnum { font-family: var(--font-display); font-size: 22px; font-weight: 600; color: var(--ink); margin-right: 4px; }
.seg-metric--accent .tnum { color: var(--accent); }
.segment-detail__meta { font-size: 12px; color: var(--muted); margin-top: -6px; }
.segment-detail__meta:empty { display: none; }
.segment-detail__streetview[hidden] { display: none; }
.segment-detail__streetview {
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--hairline);
  background: var(--field);
}
.segment-detail__streetview iframe { display: block; width: 100%; height: 100%; border: 0; }
.segment-detail__section { display: flex; flex-direction: column; gap: 8px; }
/* Section header + info marker. Tooltip anchors to the full-width head so the
   panel's overflow-y:auto (which also clips horizontally) can never crop it. */
.seg-section-head { position: relative; display: flex; align-items: center; gap: 6px; margin-bottom: 7px; }
.seg-section-head .label { margin-bottom: 0; }
.seg-info {
  flex: none; width: 16px; height: 16px; padding: 0; border: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(31,111,100,.10); color: var(--accent-2);
  font-family: var(--font-ui); font-size: 10px; font-weight: 700; line-height: 1;
  cursor: help;
}
.seg-info:hover, .seg-info:focus-visible { background: var(--accent-tint); color: var(--accent); }
.seg-info:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 1px; }
.seg-info::after {
  content: attr(data-tip);
  position: absolute; left: 0; right: 0; top: 100%; margin-top: 7px; z-index: 5;
  padding: 8px 10px; border-radius: 8px;
  background: var(--ink); color: rgba(255,255,255,.92);
  font-size: 11.5px; font-weight: 400; line-height: 1.45;
  text-transform: none; letter-spacing: normal; white-space: normal;
  box-shadow: var(--shadow-sm);
  opacity: 0; visibility: hidden; transform: translateY(-4px); pointer-events: none;
  transition: opacity .14s ease, transform .14s ease, visibility .14s;
}
.seg-info:hover::after, .seg-info:focus-visible::after { opacity: 1; visibility: visible; transform: translateY(0); }
.segment-bars { display: flex; flex-direction: column; gap: 6px; }
.seg-row { display: grid; grid-template-columns: 70px 1fr 34px; align-items: center; gap: 9px; font-size: 12px; }
.seg-row__label { color: var(--ink-2); font-weight: 600; }
.seg-row__track { display: block; height: 7px; border-radius: 4px; background: rgba(45,62,55,.10); overflow: hidden; }
.seg-row__fill { display: block; height: 100%; min-width: 2px; border-radius: 4px; background: var(--accent); }
.seg-row__count { text-align: right; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }

/* Crash type — bars with a leading mode-of-crash icon. */
.seg-row--icon { grid-template-columns: 20px 70px 1fr 34px; gap: 8px; }
.seg-row__icon { font-size: 13px; line-height: 1; text-align: center; color: var(--accent-2); }

/* By year — vertical column trend. */
.seg-trend { display: flex; align-items: flex-end; gap: 8px; height: 74px; }
.seg-trend__col {
  flex: 1; min-width: 0; height: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.seg-trend__val { font-size: 11px; font-weight: 700; color: var(--muted); }
.seg-trend__bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.seg-trend__bar {
  width: 100%; min-height: 2px; border-radius: 4px 4px 2px 2px;
  background: rgba(31,111,100,.28); transition: height .25s ease;
}
.seg-trend__col.is-peak .seg-trend__bar { background: var(--accent); }
.seg-trend__col.is-peak .seg-trend__val { color: var(--accent); }
.seg-trend__yr { font-size: 11px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* Time of day — icon tiles. */
.seg-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.seg-tile {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto auto;
  align-items: center; column-gap: 9px; row-gap: 2px;
  padding: 9px 11px; border: 1px solid var(--hairline); border-radius: var(--radius-sm);
  background: rgba(244,246,240,.62);
}
.seg-tile.is-peak { border-color: rgba(31,111,100,.28); background: var(--accent-tint); }
.seg-tile__icon { grid-row: 1 / 3; font-size: 18px; line-height: 1; color: var(--accent-2); }
.seg-tile__count { font-family: var(--font-display); font-size: 18px; font-weight: 600; color: var(--ink); }
.seg-tile__label { font-size: 11px; font-weight: 600; color: var(--muted); }
.seg-tile__track { grid-column: 1 / 3; height: 4px; border-radius: 3px; background: rgba(45,62,55,.10); overflow: hidden; margin-top: 4px; }
.seg-tile__fill { display: block; height: 100%; min-width: 2px; border-radius: 3px; background: var(--accent); }

/* Day of week — heat strip. */
.seg-heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.seg-heat__cell { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.seg-heat__box {
  width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 7px; font-size: 11px; font-weight: 700; color: var(--ink-2);
}
.seg-heat__cell.is-strong .seg-heat__box { color: #fff; }
.seg-heat__cell.is-weekend .seg-heat__box { box-shadow: inset 0 0 0 1.5px rgba(31,111,100,.28); }
.seg-heat__n { font-size: 11px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* Light condition — single stacked proportion bar + legend. */
.seg-stack { display: flex; height: 12px; border-radius: 6px; overflow: hidden; }
.seg-stack__seg { min-width: 3px; }
.seg-stack__legend { display: flex; flex-direction: column; gap: 5px; margin-top: 9px; }
.seg-stack__item { display: grid; grid-template-columns: 11px 1fr auto; align-items: center; gap: 8px; font-size: 12px; }
.seg-stack__swatch { width: 11px; height: 11px; border-radius: 3px; }
.seg-stack__name { color: var(--ink-2); font-weight: 600; }
.seg-stack__pct { font-weight: 700; color: var(--ink); }

/* Weather — icon chips. */
.seg-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.seg-chip {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 6px 10px; border: 1px solid var(--hairline); border-radius: 999px; background: rgba(244,246,240,.76);
}
.seg-chip__icon { font-size: 13px; align-self: center; color: var(--accent-2); }
.seg-chip__count { font-size: 13px; font-weight: 700; color: var(--ink); }
.seg-chip__label { font-size: 12px; color: var(--muted); }

/* ---------- Years legend ---------- */
.years__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; border-bottom: 1px solid var(--hairline-2);
}
.years__list { padding: 8px; }
.year {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 8px; cursor: pointer;
}
.year.is-selected { background: var(--accent-tint); }
.year__dot { width: 13px; height: 13px; border-radius: 50%; flex: none; }
.year.is-selected .year__dot { box-shadow: 0 0 0 3px rgba(31,111,100,.18); }
.year__label { flex: 1; font-size: 14px; font-weight: 600; color: var(--ink); }
.year__count { font-size: 13px; font-weight: 700; color: #5f656e; }

/* ---------- Time-of-day dial ---------- */
.dial { position: relative; width: 128px; height: 128px; margin: 0 auto; }
.dial__center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.dial__big { font-family: var(--font-display); font-size: 26px; font-weight: 600; line-height: 1; color: var(--ink); }
.dial__unit { font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.dial__tick { position: absolute; font-size: 10px; font-weight: 600; color: var(--muted); }
.dial__track { stroke: rgba(20,23,28,.10); }
.dial__value { stroke: var(--accent); }

/* ---------- Bottom legend ---------- */
.legend {
  background: linear-gradient(180deg, var(--panel) 0%, #eef2eb 100%);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 15px 19px;
  display: flex; flex-direction: column; gap: 11px;
}
.legend__row { display: flex; align-items: center; gap: 10px; }
.legend__row span:last-child { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.legend-line  { width: 26px; height: 3px; background: var(--accent); border-radius: 2px; flex: none; }
.legend-dash  { width: 26px; height: 0; border-top: 2px dashed rgba(45,62,55,.48); flex: none; }
.legend-shield{
  width: 18px; height: 18px; border-radius: 4px;
  background: #1c4fa3; color: #fff; font-size: 8px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.legend-scale {
  width: 88px; height: 9px; border-radius: 3px; flex: none;
  background: linear-gradient(90deg,#1f6f64,#648b70,#a59a5a,#d4a24a,#c06b3f,#ae4a32);
}

/* ---------- Zoom controls ---------- */
.zoom {
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  overflow: hidden; box-shadow: var(--shadow-sm);
}
.zoom button {
  width: 42px; height: 42px; border: 0; background: transparent;
  cursor: pointer; font-size: 19px; color: var(--ink);
}
.zoom button:first-child { border-bottom: 1px solid var(--hairline-2); }

.fa-map-nav {
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
.fa-map-nav button {
  width: 40px;
  height: 40px;
  border: 0;
  border-bottom: 1px solid var(--hairline-2);
  background: transparent;
  color: var(--accent-2-dark);
  cursor: pointer;
}
.fa-map-nav button:last-child { border-bottom: 0; }
.fa-map-nav button:hover { background: var(--field); color: var(--accent); }
