:root {
  --orange-1: #ff6340;
  --orange-2: #ffb19f;
  --orange-3: #ffe0d9;
  --orange-4: #ffefec;
  --blue-1: #0a466e;
  --blue-2: #85a2b7;
  --blue-3: #cedae2;
  --blue-4: #e7ecf0;
  --white: #ffffff;
  --ink: #072f4a;
  --gold: #f4bd45;
  --silver: #b8c5ce;
  --bronze: #c98255;
  --page: #f8fafb;
  --radius-sm: 0.75rem;
  --radius-md: 1.25rem;
  --radius-lg: 2rem;
  --shadow: 0 1.2rem 3rem rgba(10, 70, 110, 0.1);
  --space-1: 0.5rem;
  --space-2: 0.75rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2rem;
  --space-6: 3rem;
  --space-7: 4.5rem;
  --content: 76rem;
  color-scheme: light;
  font-family: "Graphik Web", Graphik, Arial, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  line-height: 1.5;
}

button, a { font: inherit; }
button { color: inherit; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--white);
  background: var(--blue-1);
  border-radius: var(--radius-sm);
  transform: translateY(-150%);
}

.skip-link:focus { transform: translateY(0); }

.site-header {
  min-height: 4.75rem;
  max-width: var(--content);
  margin: 0 auto;
  padding: 0 var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--blue-1);
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  color: var(--white);
  background: var(--orange-1);
  border-radius: 50% 50% 50% 0.35rem;
  font-size: 1rem;
  font-weight: 900;
  transform: rotate(-5deg);
}

.prototype-badge {
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--blue-3);
  border-radius: 999px;
  color: var(--blue-1);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hero {
  padding: clamp(2rem, 5vw, 4.5rem) max(var(--space-4), calc((100vw - var(--content)) / 2));
  background:
    radial-gradient(circle at 88% 18%, rgba(255, 99, 64, 0.13) 0 5.5rem, transparent 5.6rem),
    linear-gradient(145deg, var(--orange-4), var(--white) 70%);
}

.hero-dashboard {
  max-width: var(--content);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(19rem, 0.8fr);
  gap: var(--space-4);
  align-items: stretch;
}

.eyebrow, .section-label {
  margin: 0 0 var(--space-2);
  color: var(--orange-1);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1, h2, h3, p { text-wrap: pretty; }

h1, h2, h3 { margin: 0; line-height: 1.05; letter-spacing: -0.045em; font-family: "Graphik-Semibold", "Graphik Web", Graphik, Arial, sans-serif; }

h1 { max-width: 48rem; font-size: clamp(2.75rem, 7vw, 5.8rem); }
h2 { font-size: clamp(2rem, 4.5vw, 3.7rem); }
h3 { font-size: 1.25rem; }

.national-card {
  position: relative;
  overflow: hidden;
  min-width: 0;
  min-height: 31rem;
  padding: clamp(1.5rem, 4vw, 3rem);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-4) var(--space-6);
  color: var(--white);
  background: var(--blue-1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.national-card::after {
  content: "";
  position: absolute;
  right: -3rem;
  bottom: -4.5rem;
  width: 14rem;
  height: 14rem;
  border: 1.4rem solid rgba(133, 162, 183, 0.13);
  border-radius: 50%;
  pointer-events: none;
}

.national-card .section-label { color: var(--orange-2); }
.national-message { margin: 0; font-size: clamp(1.35rem, 3vw, 2.25rem); font-weight: 800; letter-spacing: -0.035em; }
.national-count { margin: 0.45rem 0 0; color: var(--blue-3); font-size: 1.05rem; }
.updated { margin: 0.25rem 0 0; color: var(--blue-2); font-size: 0.82rem; }

.national-score {
  align-self: center;
  color: var(--orange-1);
  font-size: clamp(3.5rem, 8vw, 6rem);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.08em;
}

.national-score span:last-child { font-size: 0.42em; letter-spacing: -0.02em; }

.national-progress {
  --progress: 0%;
  position: relative;
  grid-column: 1 / -1;
  height: 1.25rem;
  margin: 1.65rem 0 0.5rem;
  background: rgba(231, 236, 240, 0.18);
  border-radius: 999px;
}

.national-progress-fill {
  display: block;
  width: var(--progress);
  height: 100%;
  background: var(--orange-1);
  border-radius: inherit;
  transition: width 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.national-progress-bus {
  position: absolute;
  top: 50%;
  left: clamp(0px, calc(var(--progress) - 1.275rem), calc(100% - 2.55rem));
  transform: translateY(-50%);
  transition: left 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.primary-button, .secondary-button {
  position: relative;
  z-index: 1;
  min-height: 3.25rem;
  padding: 0.85rem 1.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  border: 0;
  border-radius: 999px;
  font-weight: 850;
  cursor: pointer;
}

.primary-button {
  grid-column: 1 / -1;
  justify-self: start;
  color: var(--blue-1);
  background: var(--orange-1);
  box-shadow: 0 0.65rem 1.5rem rgba(0, 0, 0, 0.14);
}

.primary-button:hover { background: var(--orange-2); transform: translateY(-1px); }
.primary-button:focus-visible, .secondary-button:focus-visible, .dialog-close:focus-visible, a:focus-visible { outline: 3px solid var(--orange-2); outline-offset: 3px; }

.activity-panel {
  min-width: 0;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--orange-3);
  border-radius: var(--radius-lg);
  box-shadow: 0 1rem 2.5rem rgba(10, 70, 110, 0.07);
}

.activity-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--blue-4);
}

.activity-panel h2 {
  font-size: clamp(1.45rem, 2.3vw, 2rem);
  letter-spacing: -0.035em;
}

.live-indicator {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #688497;
  font-size: 0.68rem;
  white-space: nowrap;
}

.live-indicator i {
  width: 0.45rem;
  height: 0.45rem;
  background: var(--orange-1);
  border-radius: 50%;
}

.race-section, .activity-section {
  max-width: var(--content);
  margin: 0 auto;
  padding: var(--space-7) var(--space-4);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--space-5);
}

.section-note {
  max-width: 25rem;
  margin: 0;
  color: #56758a;
  font-size: 0.95rem;
}

.legend {
  margin-top: var(--space-5);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.4rem;
  color: #56758a;
  font-size: 0.8rem;
}

.legend span { display: inline-flex; align-items: center; gap: 0.45rem; }
.legend i { font-style: normal; }
.legend-line { width: 1.7rem; height: 0.35rem; background: var(--orange-1); border-radius: 999px; }
.legend-bus { color: var(--orange-1); font-size: 1rem; }
.legend-school { color: var(--blue-1); font-size: 1rem; font-weight: 900; }

.leaders {
  margin-top: var(--space-6);
  display: grid;
  grid-template-columns: 1fr 1.12fr 1fr;
  grid-template-areas: "second first third";
  gap: var(--space-3);
  align-items: end;
}

.leader-card {
  position: relative;
  min-width: 0;
  padding: 1.25rem;
  background: var(--white);
  border: 1px solid var(--blue-4);
  border-radius: var(--radius-md);
  box-shadow: 0 0.7rem 2rem rgba(10, 70, 110, 0.07);
}

.leader-card[data-place="1"] { grid-area: first; padding-top: 1.6rem; color: var(--white); background: var(--blue-1); transform: translateY(-1.1rem); }
.leader-card[data-place="2"] { grid-area: second; }
.leader-card[data-place="3"] { grid-area: third; }

.leader-top, .race-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); }
.place-pill { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; font-weight: 850; }
.medal { width: 1.65rem; height: 1.65rem; display: grid; place-items: center; color: #4c3510; border-radius: 50%; font-size: 0.75rem; box-shadow: inset 0 0 0 2px rgba(255,255,255,0.35); }
.medal--gold { background: var(--gold); }
.medal--silver { background: var(--silver); color: #34454f; }
.medal--bronze { background: var(--bronze); color: #3e281c; }

.leader-name { margin-top: var(--space-3); font-size: clamp(1.2rem, 2.2vw, 1.7rem); overflow-wrap: anywhere; }
.leader-score { margin: 0.45rem 0 0; display: flex; align-items: baseline; gap: 0.55rem; }
.leader-percent { font-size: 2.2rem; font-weight: 900; line-height: 1; letter-spacing: -0.06em; }
.leader-count { color: #5b7b91; font-size: 0.85rem; }
.leader-card[data-place="1"] .leader-count { color: var(--blue-3); }

.mini-track { margin-top: 1.4rem; }
.field-heading { margin: var(--space-6) 0 var(--space-3); display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.field-heading span { color: #688497; font-size: 0.85rem; }
.race-list, .activity-list { padding: 0; margin: 0; list-style: none; }
.race-list { display: grid; gap: var(--space-3); }

.race-card {
  padding: 1.15rem 1.25rem 1.2rem;
  background: var(--white);
  border: 1px solid var(--blue-4);
  border-radius: var(--radius-md);
}

.race-rank { min-width: 2rem; color: var(--blue-2); font-size: 0.85rem; font-weight: 850; }
.race-identity { flex: 1; min-width: 0; }
.race-name { font-size: 1.1rem; overflow-wrap: anywhere; }
.race-count { margin: 0.25rem 0 0; color: #698497; font-size: 0.82rem; }
.race-percent { flex: 0 0 auto; font-size: 1.65rem; font-weight: 900; letter-spacing: -0.05em; }

.track-wrap { margin-top: 1rem; }
.track-labels { position: relative; height: 1rem; color: #7890a0; font-size: 0.65rem; }
.track-labels span { position: absolute; transform: translateX(-50%); }
.track-labels span:nth-child(1) { left: 25%; }
.track-labels span:nth-child(2) { left: 50%; }
.track-labels span:nth-child(3) { left: 75%; }
.track-labels span:nth-child(4) { right: 0; transform: none; font-weight: 800; }

.track {
  --progress: 0%;
  position: relative;
  height: 2.8rem;
  overflow: hidden;
  background: var(--blue-4);
  border: 1px solid var(--blue-3);
  border-radius: 0.7rem;
}

.track::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent calc(25% - 1px), rgba(10,70,110,0.2) 25%, transparent calc(25% + 1px), transparent calc(50% - 1px), rgba(10,70,110,0.2) 50%, transparent calc(50% + 1px), transparent calc(75% - 1px), rgba(10,70,110,0.2) 75%, transparent calc(75% + 1px));
}

.track::after {
  content: "";
  position: absolute;
  left: 0.4rem;
  right: 0.4rem;
  top: 50%;
  border-top: 2px dashed rgba(10, 70, 110, 0.18);
}

.track-fill {
  position: absolute;
  z-index: 1;
  inset: 0 auto 0 0;
  width: var(--progress);
  background: linear-gradient(90deg, var(--orange-3), var(--orange-2));
  border-right: 2px solid var(--orange-1);
  transition: width 1.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.leader-card[data-place="1"] .track { background: rgba(255,255,255,0.13); border-color: rgba(255,255,255,0.22); }
.leader-card[data-place="1"] .track::before, .leader-card[data-place="1"] .track::after { opacity: 0.5; }

.bus {
  width: 2.8rem;
  height: 1.5rem;
  display: flex;
  gap: 0.18rem;
  align-items: flex-start;
  justify-content: center;
  padding: 0.3rem 0.35rem 0;
  background: var(--bus-color, var(--orange-1));
  border: 2px solid var(--ink);
  border-radius: 0.35rem 0.6rem 0.25rem 0.25rem;
  box-shadow: 0 0.2rem 0 rgba(7, 47, 74, 0.15);
}

.bus--small { width: 2.55rem; height: 1.4rem; }
.bus-window { width: 0.68rem; height: 0.48rem; background: var(--orange-4); border: 1px solid var(--ink); border-radius: 0.1rem; }
.bus-wheel { position: absolute; bottom: -0.35rem; width: 0.55rem; height: 0.55rem; background: var(--ink); border: 0.13rem solid var(--blue-2); border-radius: 50%; }
.bus-wheel--left { left: 0.35rem; }
.bus-wheel--right { right: 0.3rem; }

.track-bus {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: clamp(0px, calc(var(--progress) - 1.4rem), calc(100% - 2.8rem));
  transform: translateY(-50%);
  transition: left 1.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.school {
  position: absolute;
  z-index: 4;
  right: 0.3rem;
  bottom: 0.35rem;
  width: 1.45rem;
  height: 1.25rem;
  background: var(--white);
  border: 2px solid var(--blue-1);
  border-radius: 0.08rem;
}

.school::before {
  content: "";
  position: absolute;
  left: -0.18rem;
  top: -0.55rem;
  width: 1.45rem;
  height: 1.45rem;
  background: var(--white);
  border: 2px solid var(--blue-1);
  border-width: 2px 2px 0 0;
  transform: rotate(-45deg) scale(0.62);
}

.school::after {
  content: "";
  position: absolute;
  left: 0.49rem;
  bottom: 0;
  width: 0.35rem;
  height: 0.6rem;
  background: var(--orange-1);
  border: 1px solid var(--blue-1);
}

.activity-list {
  max-height: 25.5rem;
  margin-top: 0.9rem;
  padding-right: 0.35rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  overflow-y: auto;
  scrollbar-color: var(--blue-3) transparent;
  scrollbar-width: thin;
}

.data-status {
  margin: 0.8rem 0 0;
  padding: 0.65rem 0.75rem;
  color: #456b84;
  background: var(--blue-4);
  border-radius: 0.65rem;
  font-size: 0.72rem;
  line-height: 1.4;
}

.data-status[data-state="ready"] {
  color: #356048;
  background: #e8f4ed;
}

.data-status[data-state="warning"] {
  color: #704832;
  background: var(--orange-3);
}

.data-status[data-state="error"] {
  color: #73392d;
  background: var(--orange-4);
  border: 1px solid var(--orange-2);
}

.activity-empty {
  padding: 1.25rem 0.25rem;
  color: #688497;
  font-size: 0.84rem;
  line-height: 1.5;
}

.activity-item {
  position: relative;
  min-width: 0;
  padding: 1rem 0.25rem 1rem 2.65rem;
  background: transparent;
  border-bottom: 1px solid var(--blue-4);
}

.activity-item:last-child { border-bottom: 0; }

.activity-icon {
  position: absolute;
  top: 1rem;
  left: 0;
  width: 1.8rem;
  height: 1.8rem;
  display: grid;
  place-items: center;
  color: var(--blue-1);
  background: var(--orange-3);
  border-radius: 50%;
  font-weight: 900;
}

.activity-item p { margin: 0; overflow-wrap: anywhere; }
.activity-sentence { font-size: 0.88rem; font-weight: 750; line-height: 1.45; }
.activity-school { color: var(--blue-1); }
.activity-note { margin-top: 0.4rem !important; color: #58768b; font-size: 0.78rem; line-height: 1.45; }
.activity-meta { margin-top: 0.55rem !important; display: flex; flex-wrap: wrap; gap: 0.35rem 0.8rem; color: #7690a1; font-size: 0.7rem; }
.county-tag { color: var(--blue-1); font-weight: 800; }

.site-footer {
  max-width: var(--content);
  margin: 0 auto;
  padding: 1.5rem var(--space-4) 2.5rem;
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  color: #6d8798;
  font-size: 0.78rem;
}

.site-footer p { margin: 0; }

.prototype-dialog {
  width: min(31rem, calc(100% - 2rem));
  padding: 2rem;
  color: var(--ink);
  background: var(--white);
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.prototype-dialog::backdrop { background: rgba(7, 47, 74, 0.72); backdrop-filter: blur(4px); }
.prototype-dialog h2 { font-size: 2rem; }
.prototype-dialog p:not(.eyebrow) { color: #56758a; }
.dialog-close { position: absolute; top: 0.8rem; right: 1rem; width: 2.5rem; height: 2.5rem; border: 0; background: transparent; font-size: 1.8rem; cursor: pointer; }
.secondary-button { margin-top: 0.75rem; color: var(--white); background: var(--blue-1); }

.meeting-filter {
  margin-top: var(--space-5);
  padding: 1rem;
  background: var(--white);
  border: 1px solid var(--blue-4);
  border-radius: var(--radius-md);
}
.meeting-filter-label {
  display: block;
  margin-bottom: 0.7rem;
  color: var(--blue-1);
  font-family: "Graphik-Semibold", "Graphik Web", Graphik, Arial, sans-serif;
  font-size: 0.82rem;
}
.meeting-filter-options { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.5rem; }
.meeting-button {
  min-width: 0;
  padding: 0.7rem 0.6rem;
  color: var(--blue-1);
  background: var(--blue-4);
  border: 1px solid transparent;
  border-radius: 0.75rem;
  cursor: pointer;
  text-align: left;
}
.meeting-button span, .meeting-button small { display: block; }
.meeting-button span { font-weight: 800; }
.meeting-button small { margin-top: 0.15rem; color: #607d90; font-size: 0.65rem; line-height: 1.25; }
.meeting-button:hover { border-color: var(--orange-2); }
.meeting-button:focus-visible { outline: 3px solid var(--orange-2); outline-offset: 2px; }
.meeting-button.is-active { color: var(--white); background: var(--blue-1); }
.meeting-button.is-active small { color: var(--blue-3); }
.meeting-filter-note { margin: 0.7rem 0 0; color: #688497; font-size: 0.72rem; }
.leaders { margin-top: var(--space-6); }
.leaders + .race-list { margin-top: var(--space-3); }
.race-list {
  overflow: hidden;
  gap: 0;
  background: var(--white);
  border: 1px solid var(--blue-4);
  border-radius: var(--radius-md);
  box-shadow: 0 0.7rem 2rem rgba(10, 70, 110, 0.06);
}
.race-card { border: 0; border-bottom: 1px solid var(--blue-4); border-radius: 0; }
.race-card:last-child { border-bottom: 0; }
.race-percent { text-align: right; white-space: nowrap; }
.race-percent small { display: block; color: #698497; font-size: 0.65rem; font-weight: 700; letter-spacing: 0; }
.track-fill {
  background: color-mix(in srgb, var(--race-color, var(--orange-1)) 28%, white);
  border-right-color: var(--race-color, var(--orange-1));
}

@media (max-width: 900px) {
  .hero-dashboard { grid-template-columns: 1fr; }
  .activity-panel { border-radius: 1.5rem; }
}

@media (max-width: 780px) {
  .national-card { grid-template-columns: 1fr; gap: var(--space-3); border-radius: 1.5rem; }
  .national-score { grid-row: 2; }
  .national-progress { grid-row: 3; }
  .primary-button { grid-row: 4; width: 100%; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .leaders { grid-template-columns: 1fr; grid-template-areas: "first" "second" "third"; }
  .leader-card[data-place="1"] { transform: none; }
  .meeting-filter-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  :root { --space-7: 3.5rem; }
  .site-header { min-height: 4.25rem; padding-inline: 1rem; }
  .brand span:last-child { font-size: 0.88rem; }
  .prototype-badge { display: none; }
  .hero, .race-section { padding-left: 1rem; padding-right: 1rem; }
  h2 { font-size: 2.25rem; }
  .national-card { padding: 1.35rem; }
  .national-message { font-size: 1.3rem; }
  .national-score { font-size: 4.25rem; }
  .legend { display: none; }
  .leaders { margin-top: var(--space-5); }
  .race-card { padding: 1rem; }
  .race-card-top { display: grid; grid-template-columns: auto 1fr auto; }
  .race-percent { font-size: 1.4rem; }
  .track { height: 2.65rem; }
  .track-labels { font-size: 0.58rem; }
  .activity-panel { padding: 1.25rem; }
  .activity-panel-header { flex-direction: column; gap: 0.5rem; }
  .activity-list { max-height: 23rem; }
  .site-footer { padding-inline: 1rem; flex-direction: column; }
  .meeting-filter { padding: 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
}
