:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #dde1e7;
  --text: #17212d;
  --muted: #5c6672;
  /* True US flag colors (2001 federal spec / Wikipedia flag infobox),
     not a custom-mixed navy/crimson -- the masthead below and the
     accent usages throughout are built to actually read as the flag's
     colors, not just "a blue" and "a red". */
  --navy: #3c3b6e;
  --navy-deep: #26254a;
  --crimson: #b22234;
  --crimson-deep: #8a1a28;
  --deferred: #6b7280;
  --deferred-fill: #bcc2cb;
  --deferred-fill-hover: #98a0ac;
  --accent: var(--navy);
  --accent-hover: var(--navy-deep);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  --shadow-card: 0 1px 2px rgba(15, 25, 40, 0.07);
  --shadow-card-hover: 0 4px 10px rgba(15, 25, 40, 0.12);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
}
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.wrap { max-width: 860px; margin: 0 auto; padding: 1.75rem 1.5rem 2.5rem; }

/* Full-bleed masthead: this, not a decorative rule, is what actually
   carries the flag's red/white/blue on every screen -- navy band, white
   wordmark, a real red stripe as the hard edge into the white content
   area below. */
.masthead {
  background: var(--crimson);
  padding: 1.6rem 1.5rem 1.4rem;
}
.masthead-inner { max-width: 860px; margin: 0 auto; display: flex; align-items: baseline; gap: 0.55rem; }
.masthead .star { color: rgba(255, 255, 255, 0.75); font-size: 1.1rem; }
h1 {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.01em;
  color: #ffffff;
}
.old-glory-stripe { height: 6px; background: var(--navy); }
.tagline {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 1rem 0 1.75rem;
}
#breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
}
.crumb {
  background: none;
  border: none;
  padding: 0.15rem 0.3rem;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  border-radius: 4px;
}
.crumb:hover { background: rgba(122, 59, 46, 0.1); text-decoration: underline; }
.crumb:disabled { color: var(--text); cursor: default; font-weight: bold; }
.crumb:disabled:hover { background: none; text-decoration: none; }
.sep { color: var(--muted); }

.link-list { display: flex; flex-direction: column; gap: 0.5rem; }
.link-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1.1rem;
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text);
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.link-item:hover {
  border-color: var(--accent);
  transform: translateX(2px);
  box-shadow: var(--shadow-card-hover);
}
.link-item .label { font-weight: 600; }
.link-item .sub { color: var(--muted); font-size: 0.85rem; margin-left: 1rem; white-space: nowrap; }

.leaf-list { display: flex; flex-direction: column; gap: 0.75rem; }
.leaf-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--party-color, var(--accent));
  border-radius: 8px;
  padding: 0.9rem 1.1rem;
  box-shadow: var(--shadow-card);
}
.leaf-card.party-republican { --party-color: var(--crimson); }
.leaf-card.party-democratic { --party-color: var(--navy); }
.leaf-card.party-libertarian { --party-color: #a3821a; }
.leaf-card.party-other { --party-color: #6b6b6b; }

.kv { display: flex; padding: 0.15rem 0; font-size: 0.95rem; }
.kv .k { color: var(--muted); width: 7rem; flex-shrink: 0; }
.kv .v { font-weight: 600; }
.kv .v.party-value { color: var(--party-color, var(--text)); }
.party-badge {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--party-color, var(--accent));
  margin-right: 0.4rem;
}

.loading, .empty, .error { color: var(--muted); font-style: italic; }
.error { color: #a33; }

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1.1rem;
  font: inherit;
  font-size: 1rem;
  text-align: left;
  color: var(--text);
  cursor: default;
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.status-row.link-item { cursor: pointer; }
.status-row.link-item:hover { border-color: var(--accent); transform: translateX(2px); box-shadow: var(--shadow-card-hover); }
.status-row .label { font-weight: 600; display: flex; align-items: center; gap: 0.55rem; }
.status-row .sub { color: var(--muted); font-size: 0.85rem; margin-left: 1rem; white-space: nowrap; }
.status-pill {
  display: inline-flex;
  align-items: center;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
  overflow: hidden;
  white-space: nowrap;
  flex-shrink: 0;
  transition: width 0.16s ease;
}
.status-pill.live { background: var(--navy); }
.status-pill.deferred { background: var(--deferred); }
.status-pill .pill-text {
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  padding-left: 0.4rem;
  opacity: 0;
  transition: opacity 0.1s ease;
}
.status-pill:hover { padding-right: 0.5rem; }
.status-pill.live:hover { width: 2.5rem; }
.status-pill.deferred:hover { width: 4rem; }
.status-pill:hover .pill-text { opacity: 1; }

/* Map/List toggle for the state-selection step (depth 1) */
.view-tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.view-tab {
  padding: 0.5rem 1.2rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.view-tab:hover:not(.active) { border-color: var(--navy); color: var(--navy); }
.view-tab.active { background: var(--navy); border-color: var(--navy); color: #fff; }

.map-wrap {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.map-svg { width: 100%; height: auto; display: block; }
.map-svg path.state {
  stroke: #ffffff;
  stroke-width: 1.5;
  stroke-linejoin: round;
  fill: var(--deferred-fill);
  cursor: default;
  transition: fill 0.12s ease, filter 0.12s ease;
}
.map-svg path.state.live { fill: var(--navy); cursor: pointer; }
.map-svg path.state.live:hover { fill: var(--navy-deep); filter: drop-shadow(0 2px 5px rgba(15, 25, 40, 0.35)); }
.map-svg path.state.deferred:hover { fill: var(--deferred-fill-hover); }

.map-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--navy-deep);
  color: #fff;
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  font-size: 0.82rem;
  line-height: 1.4;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
  opacity: 0;
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px));
  transition: opacity 0.1s ease;
  z-index: 10;
}
.map-tooltip.visible { opacity: 1; }
.map-tooltip .tt-name { font-weight: 700; }
.map-tooltip .tt-sub { opacity: 0.85; font-size: 0.75rem; margin-top: 0.1rem; }

.map-legend { display: flex; gap: 1.5rem; margin-top: 0.9rem; font-size: 0.85rem; color: var(--muted); }
.map-legend .dot { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 50%; margin-right: 0.4rem; }
.map-legend .dot.live { background: var(--navy); }
.map-legend .dot.deferred { background: var(--deferred-fill); }

.view-page-link {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin: -0.3rem 0 0.3rem 0.2rem;
}
.view-page-link:hover { color: var(--accent); }
