:root {
  --ink: #111916;
  --muted: #5d6863;
  --paper: #f6f1e8;
  --white: #fffdf8;
  --line: #ded6c7;
  --green: #176f54;
  --green-dark: #0f4435;
  --mint: #dff0e8;
  --gold: #d89a26;
  --coral: #d25f46;
  --blue: #3a73a3;
  --shadow: 0 24px 80px rgba(17, 25, 22, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(223, 240, 232, 0.9), rgba(246, 241, 232, 0) 460px),
    var(--paper);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
select {
  font: inherit;
}

.map-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid rgba(222, 214, 199, 0.72);
  background: rgba(255, 253, 248, 0.9);
  backdrop-filter: blur(18px);
}

.brand,
.map-header nav {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-weight: 900;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: var(--white);
  background: var(--green-dark);
}

.map-header nav {
  color: var(--muted);
  font-size: 0.92rem;
}

.map-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.45fr);
  gap: clamp(28px, 5vw, 70px);
  align-items: end;
  padding: 64px clamp(18px, 5vw, 72px) 28px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--coral);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 980px;
  margin: 0;
  font-size: clamp(3.2rem, 7.8vw, 7.8rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.map-hero p:not(.eyebrow),
.section-heading p,
.panel-heading p,
.map-note,
.vote-card p,
.official-card p {
  color: var(--muted);
  line-height: 1.6;
}

.map-hero p:not(.eyebrow) {
  max-width: 760px;
  font-size: 1.08rem;
}

.stat-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.stat-panel div {
  display: grid;
  gap: 4px;
  padding: 18px;
  border-left: 1px solid var(--line);
}

.stat-panel div:first-child {
  border-left: 0;
}

.stat-panel strong {
  color: var(--green);
  font-size: 1.9rem;
  line-height: 1;
}

.stat-panel span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.map-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.34fr) minmax(0, 1fr);
  gap: 18px;
  padding: 18px clamp(18px, 5vw, 72px) 72px;
}

.state-panel,
.map-card,
.vote-card,
.official-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow);
}

.state-panel {
  align-self: start;
  display: grid;
  gap: 22px;
  padding: 22px;
  position: sticky;
  top: 82px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 4.4rem);
  line-height: 0.98;
}

.panel-heading h2 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 3.2rem);
  line-height: 1;
}

.selector-group {
  display: grid;
  gap: 8px;
}

.selector-group label {
  color: var(--green-dark);
  font-weight: 900;
}

select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--white);
  font-weight: 800;
}

.district-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  padding-right: 4px;
}

.county-panel {
  display: grid;
  gap: 10px;
}

.mini-heading {
  display: grid;
  gap: 4px;
}

.mini-heading span {
  color: var(--green-dark);
  font-weight: 900;
}

.mini-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.county-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}

.municipality-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}

.district-button,
.county-button,
.municipality-button,
.tool-button,
.official-card,
.vote-row,
.money-row {
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.district-button,
.county-button,
.municipality-button,
.tool-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--white);
  font-weight: 900;
  cursor: pointer;
}

.district-button:hover,
.district-button.active,
.county-button:hover,
.county-button.active,
.municipality-button:hover,
.municipality-button.active,
.tool-button:hover,
.tool-button.active {
  border-color: var(--green);
  background: var(--mint);
}

.county-button,
.municipality-button {
  display: grid;
  gap: 3px;
  border-radius: 8px;
  padding: 10px;
  text-align: left;
}

.county-button strong,
.municipality-button strong {
  font-size: 0.9rem;
}

.county-button span,
.municipality-button span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.map-card {
  min-width: 0;
  padding: 18px;
}

.map-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.tool-button {
  padding: 0 18px;
}

.map-shell {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(17, 25, 22, 0.04) 1px, transparent 1px),
    linear-gradient(0deg, rgba(17, 25, 22, 0.04) 1px, transparent 1px),
    #f8f4ec;
  background-size: 34px 34px;
}

#usMap {
  display: block;
  width: 100%;
  height: 520px;
}

.state-shape {
  fill: #dff0e8;
  stroke: #fffdf8;
  stroke-width: 1;
  cursor: pointer;
}

.state-shape:hover,
.state-shape.active {
  fill: #d89a26;
}

.state-boundary {
  fill: none;
  stroke: rgba(17, 25, 22, 0.2);
  stroke-linejoin: round;
  pointer-events: none;
}

.map-fallback {
  display: grid;
  grid-template-columns: repeat(11, minmax(42px, 1fr));
  grid-template-rows: repeat(7, 58px);
  gap: 8px;
  padding: 16px;
  min-height: 0;
  align-content: start;
}

.state-tile {
  display: grid;
  gap: 2px;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--green-dark);
  font-weight: 900;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(17, 25, 22, 0.06);
}

.state-tile:hover,
.state-tile.active {
  border-color: var(--green);
  background: var(--gold);
  color: var(--ink);
}

.state-tile span {
  color: var(--muted);
  font-size: 0.68rem;
}

.state-tile:hover span,
.state-tile.active span {
  color: var(--ink);
}

.map-note {
  margin: 14px 0 0;
  font-size: 0.92rem;
}

.officials-section {
  padding: 0 clamp(18px, 5vw, 72px) 72px;
}

.section-heading {
  max-width: 820px;
  margin-bottom: 24px;
}

.officials-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(280px, 0.58fr);
  gap: 18px;
  align-items: start;
}

.official-list {
  display: grid;
  gap: 12px;
}

.official-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 18px;
  cursor: pointer;
}

.official-card:hover,
.official-card.active {
  transform: translateY(-2px);
  border-color: var(--green);
}

.official-card h3 {
  margin: 0 0 6px;
  font-size: 1.12rem;
}

.official-card p {
  margin: 0;
}

.office-chip,
.vote-kicker,
.vote-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--white);
  background: var(--green);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.office-chip.senate {
  background: var(--blue);
}

.office-chip.house {
  background: var(--coral);
}

.office-chip.county {
  background: var(--gold);
  color: var(--ink);
}

.office-chip.local {
  background: var(--green-dark);
}

.vote-card {
  position: sticky;
  top: 82px;
  display: grid;
  gap: 14px;
  padding: 22px;
}

.vote-card h3 {
  margin: 0;
  font-size: 1.6rem;
}

.vote-card p {
  margin: 0;
}

.vote-list {
  display: grid;
  gap: 10px;
}

.vote-row {
  display: grid;
  width: 100%;
  text-align: left;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
}

.vote-row:hover,
.vote-row.active {
  border-color: var(--green);
  background: #f6fbf8;
}

.vote-row strong {
  line-height: 1.3;
}

.vote-row span {
  color: var(--muted);
  font-size: 0.9rem;
}

.vote-badge.pass {
  background: var(--green);
}

.vote-badge.reject {
  background: var(--coral);
}

.backer-panel {
  display: grid;
  gap: 12px;
  padding-top: 4px;
}

.backer-heading {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.backer-heading h4 {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.28;
}

.backer-heading p,
.source-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.money-bars {
  display: grid;
  gap: 8px;
}

.money-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.money-row strong,
.money-row span {
  display: block;
}

.money-row span,
.source-note {
  color: var(--muted);
  font-size: 0.88rem;
}

.money-row b {
  color: var(--green-dark);
  white-space: nowrap;
}

@media (max-width: 920px) {
  .map-hero,
  .map-workspace,
  .officials-layout {
    grid-template-columns: 1fr;
  }

  .state-panel,
  .vote-card {
    position: static;
  }
}

@media (max-width: 560px) {
  .map-header {
    padding: 10px 14px;
  }

  .brand span:last-child {
    display: none;
  }

  .map-header nav {
    gap: 10px;
    font-size: 0.82rem;
  }

  .map-hero {
    padding: 34px 18px 18px;
  }

  h1 {
    font-size: clamp(2.75rem, 14vw, 4.15rem);
  }

  .stat-panel {
    box-shadow: 0 16px 42px rgba(17, 25, 22, 0.1);
  }

  .stat-panel div {
    padding: 14px 10px;
    text-align: center;
  }

  .stat-panel strong {
    font-size: 1.55rem;
  }

  .map-workspace,
  .officials-section {
    padding-inline: 18px;
  }

  .state-panel,
  .map-card,
  .vote-card,
  .official-card {
    box-shadow: 0 16px 42px rgba(17, 25, 22, 0.1);
  }

  .state-panel,
  .map-card,
  .vote-card {
    padding: 16px;
  }

  .district-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-height: 220px;
  }

  .district-button,
  .tool-button {
    min-height: 46px;
  }

  .map-shell {
    min-height: 330px;
  }

  #usMap {
    height: 330px;
  }

  .map-fallback {
    grid-template-columns: repeat(11, minmax(22px, 1fr));
    grid-template-rows: repeat(7, minmax(44px, 1fr));
    gap: 4px;
    min-height: 360px;
    padding: 8px;
  }

  .state-tile {
    min-height: 44px;
    border-radius: 6px;
    font-size: 0.72rem;
  }

  .state-tile span {
    display: none;
  }

  .map-toolbar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .official-card {
    grid-template-columns: 1fr;
  }

  .money-row {
    grid-template-columns: 1fr;
  }
}
