/* Map colors. Blues (light → dark) separate county-wide from local agreements
   by lightness, which survives every type of color blindness; the orange jail
   dots differ in hue and shape. Ended areas are a hatched gray, because any gray
   sits close to the gray base map. Validated with the dataviz skill's
   validate_palette.js (all-pairs CVD ΔE ≥ 22). Text never uses series colors. */
:root {
  --bg: #ffffff;
  --ink: #121212;
  --ink-2: #4a4a4a;
  --ink-3: #6b6b6b; /* 5.3:1 on white */
  --rule: #d6d6d6;
  --county-line: #ffffff;
  --county-base: #eeeeee;
  --fill-county: #4292c6;
  --fill-local: #08306b;
  --fill-facility: #e6550d;
  --fill-ended: #d4d4d4;
  --hatch-ended: #8f8f8f;
  --accent: #08306b;

  --font-head: 'Inquirer Headline', Georgia, 'Times New Roman', serif;
  --font-body: 'Grot 10', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* The page is always on white, per the brief, regardless of system theme. */
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

.graphic {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px;
}

h1 {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: clamp(1.4rem, 4.5vw, 2rem);
  line-height: 1.15;
  margin: 0 0 8px;
}

.dek {
  font-size: 1rem;
  line-height: 1.45;
  color: var(--ink-2);
  margin: 0 0 16px;
}

.status {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  border-top: 1px solid var(--ink);
  padding-top: 8px;
}

.status-date {
  font-weight: bold;
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
}

.status-counts {
  display: flex;
  gap: 16px;
  font-size: 0.95rem;
  color: var(--ink-2);
}

.status-counts strong {
  color: var(--ink);
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}

.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 10px 0 0;
  padding: 0;
  font-size: 0.85rem;
  color: var(--ink-2);
}

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

.swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 2px;
}
.swatch-county { background: var(--fill-county); }
.swatch-local { background: var(--fill-local); }
.swatch-ended {
  background: repeating-linear-gradient(-45deg, var(--hatch-ended) 0 1px, var(--fill-ended) 1px 4px);
}
.swatch-facility {
  background: var(--fill-facility);
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px #fff, 0 0 0 2.5px var(--fill-facility);
  width: 11px;
  height: 11px;
}

.map-wrap {
  position: relative;
  margin: 8px 0 0;
}

#map {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.county { fill: var(--county-base); stroke: var(--county-line); stroke-width: 1; }
.county-mesh { fill: none; stroke: #ffffff; stroke-width: 1; pointer-events: none; }
.state-outline { fill: none; stroke: #9a9a9a; stroke-width: 0.75; pointer-events: none; }

.jurisdiction {
  stroke: #ffffff;
  stroke-width: 0.5;
  transition: fill 250ms ease, opacity 325ms ease-out;
}
.jurisdiction.county-level { fill: var(--fill-county); }
.jurisdiction.local-level { fill: var(--fill-local); }
.jurisdiction.ended { fill: url(#ended-hatch); }
.jurisdiction.hidden, .facility.hidden { opacity: 0; pointer-events: none; }

.facility {
  fill: var(--fill-facility);
  stroke: #ffffff;
  stroke-width: 1.5;
  transition: fill 250ms ease, opacity 325ms ease-out;
}
.facility.ended { fill: #ffffff; stroke: #8a8a8a; }

.jurisdiction:hover, .facility:hover,
.jurisdiction.is-focus, .facility.is-focus { stroke: var(--ink); stroke-width: 1.5; }

.tooltip {
  position: absolute;
  z-index: 2;
  max-width: 240px;
  padding: 8px 10px;
  background: #ffffff;
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  font-size: 0.85rem;
  line-height: 1.35;
  pointer-events: none;
}
.tooltip .tt-agency { font-weight: bold; margin-bottom: 2px; }
.tooltip .tt-row { color: var(--ink-2); }

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.play {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--ink);
  color: #ffffff;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.play svg { width: 16px; height: 16px; fill: currentColor; }
.play .icon-play { display: none; }
.play.paused .icon-play { display: inline; }
.play.paused .icon-pause { display: none; }
.play:focus-visible, #scrubber:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#scrubber {
  flex: 1;
  min-width: 0;
  accent-color: var(--ink);
  height: 40px; /* generous touch target */
  margin: 0;
}

.axis {
  display: flex;
  justify-content: space-between;
  margin-left: 52px;
  font-size: 0.75rem;
  color: var(--ink-3);
}

.note {
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--ink-3);
  margin: 12px 0 0;
}

/* Credit and source sit side by side, wrapping onto two lines on narrow screens. */
.credits {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 16px;
  margin: 12px 0 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--ink-3);
}
.credits a { color: inherit; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 480px) {
  .status-date { font-size: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  .jurisdiction, .facility { transition: none; }
}
