/* ============================================================
   Hawaii 2026 Elections
   style.css
   ============================================================ */

/* ── CSS Custom Properties ── */
:root {
  --ocean-deep:  #12343f;
  --ocean:       #1f5c6d;
  --seafoam:     #dbe9e3;
  --sand:        #f2e6cf;
  --sand-deep:   #d9c5a0;
  --sun:         #d5902f;
  --coral:       #c75945;
  --paper:       #fffdf8;
  --paper-muted: #f6f1e6;
  --ink:         #18252d;
  --ink-soft:    #52636e;
  --line:        #d9d4c5;
  --accent:      #c75945;
  --accent-light:#f7ddd7;

  --green:       var(--ocean-deep);
  --green-mid:   var(--ocean);
  --green-light: #9dc1b5;
  --green-bg:    #e6f0eb;
  --red:         var(--coral);
  --red-light:   #f1b2a7;
  --red-bg:      #fae2dd;
  --yellow:      var(--sun);
  --yellow-bg:   #fbefcf;
  --gray:        #9e9b93;
  --gray-light:  var(--line);
  --bg:          var(--paper-muted);
  --white:       var(--paper);
  --text:        var(--ink);
  --text-muted:  var(--ink-soft);

  --radius:      8px;
  --radius-lg:   18px;
  --shadow-sm:   0 2px 8px rgba(24, 37, 45, .06);
  --shadow:      0 14px 34px rgba(24, 37, 45, .1);
  --shadow-lg:   0 24px 60px rgba(18, 52, 63, .18);
  --transition:  180ms ease;
  --max-w:       1140px;
  --font-sans:   "Public Sans", "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  --font-serif:  "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
}

/* ── Reset / Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background:
    radial-gradient(circle at top left, rgba(213, 144, 47, .12), transparent 28%),
    radial-gradient(circle at top right, rgba(31, 92, 109, .1), transparent 30%),
    linear-gradient(180deg, #f7f1e5 0%, #fffdf8 22%, #f4efe3 100%);
  color: var(--text);
  line-height: 1.6;
  font-size: 1rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: .028;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition); }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
ul { list-style: none; }

/* ── Utility ── */
.hidden { display: none !important; }

.app-loading, .app-error {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem 2rem;
  text-align: center;
  font-size: 1.1rem;
  color: var(--text-muted);
}

.app-error {
  color: var(--red);
}

.section-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem 2rem;
}

.section-intro {
  color: var(--text-muted);
  margin-top: .55rem;
  margin-bottom: 1.5rem;
  max-width: 65ch;
  font-size: 1.02rem;
  line-height: 1.7;
}

.section-kicker {
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--ocean);
  margin-bottom: .5rem;
}

h2 {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text);
  line-height: 1.08;
}

/* ── Skip Link ── */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--paper);
  color: var(--ocean-deep);
  padding: .5rem 1rem;
  border-radius: var(--radius);
  z-index: 9999;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.skip-link:focus {
  top: .5rem;
}

/* ── Header ── */
.site-header {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 18%, rgba(217, 197, 160, .2), transparent 16%),
    radial-gradient(circle at 88% 24%, rgba(219, 233, 227, .18), transparent 20%),
    linear-gradient(160deg, #102e38 0%, #1b4f5f 48%, #275e5f 100%);
  color: #fff;
}

.site-header::before {
  content: "";
  position: absolute;
  inset: auto -12% 22% auto;
  width: 440px;
  height: 440px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 50%;
}

.site-header::after {
  content: "";
  position: absolute;
  inset: 3rem auto auto -6rem;
  width: 320px;
  height: 320px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 50%;
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3.7rem 2rem 1.65rem;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr);
  gap: 1.5rem 2rem;
  align-items: center;
  position: relative;
  z-index: 1;
}

.site-header h1 {
  font-family: var(--font-serif);
  font-size: clamp(2.8rem, 4.5vw, 4.2rem);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: .95;
  max-width: 8.5ch;
}

.header-copy {
  display: flex;
  flex-direction: column;
  gap: .95rem;
  max-width: 42rem;
}

.eyebrow,
.brief-kicker {
  font-size: .82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .2em;
  color: rgba(255, 245, 232, .76);
}

.hero-dek {
  max-width: 29rem;
  font-size: 1.08rem;
  line-height: 1.65;
  color: rgba(255, 248, 241, .84);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .85rem;
  margin-top: .35rem;
}

.hero-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: .8rem 1.4rem;
  border-radius: 6px;
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: .01em;
  text-decoration: none;
  transition: all 200ms cubic-bezier(.16, 1, .3, 1);
}

.hero-btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

.hero-btn:active {
  transform: scale(.98) translateY(0);
}

.hero-btn-primary {
  background: var(--sun);
  color: #2f2007;
  box-shadow: 0 8px 20px rgba(213, 144, 47, .22);
}

.hero-btn-primary:hover {
  background: #dfa043;
  box-shadow: 0 12px 28px rgba(213, 144, 47, .3);
}

.hero-btn-secondary {
  border: 1px solid rgba(255, 255, 255, .2);
  color: rgba(255, 248, 240, .9);
  background: rgba(255, 255, 255, .06);
  backdrop-filter: blur(8px);
}

.hero-btn-secondary:hover {
  background: rgba(255, 255, 255, .12);
  border-color: rgba(255, 255, 255, .35);
}

.header-brief {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 16px;
  padding: 1.25rem 1.35rem;
  box-shadow: 0 20px 50px rgba(18, 52, 63, .15), inset 0 1px 0 rgba(255, 255, 255, .08);
  backdrop-filter: blur(12px);
  justify-self: end;
  width: min(100%, 42rem);
  align-self: center;
}

.brief-copy {
  color: rgba(255, 248, 241, .8);
  line-height: 1.55;
  margin-top: .45rem;
  max-width: 24rem;
  font-size: 1rem;
}

.tagline {
  grid-column: 1 / -1;
  margin-top: .4rem;
  padding-top: .9rem;
  border-top: 1px solid rgba(255, 255, 255, .14);
  font-size: 1rem;
  color: rgba(255, 248, 241, .82);
  font-weight: 500;
}

.tagline a {
  color: #fff7ea;
  text-decoration: underline;
  text-decoration-color: rgba(255,255,255,.45);
}

.tagline a:hover {
  text-decoration-color: #fff;
}

.sticky-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--ocean-deep);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-sm);
}

.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: .8rem 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
}

.sticky-nav a {
  color: rgba(255,255,255,.88);
  padding: .68rem .95rem;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  border-radius: 6px;
  text-decoration: none;
  border: 1px solid rgba(255,255,255,.12);
  background: transparent;
  transition: all 200ms cubic-bezier(.16, 1, .3, 1);
}

.sticky-nav a:hover {
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.95);
  text-decoration: none;
  border-color: rgba(255,255,255,.2);
}

/* ── Stats Bar (inside header) ── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem;
  margin-top: .9rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: .3rem;
  padding: .7rem .85rem;
  min-height: 84px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .06);
  transition: background 200ms ease;
}

.stat-item:hover {
  background: rgba(255, 255, 255, .09);
}

.stat-num {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  line-height: .9;
  letter-spacing: -.02em;
}

.stat-alert .stat-num {
  color: #ffcabf;
}

.stat-label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: rgba(255, 255, 255, .72);
  font-weight: 600;
}

.stat-meta .stat-label {
  color: rgba(255, 255, 255, .72);
}

.stat-sub {
  font-size: .62rem;
  letter-spacing: .04em;
  color: rgba(255, 255, 255, .55);
  font-weight: 500;
  margin-top: .15rem;
}
.stat-sub:empty {
  display: none;
}

.stat-meta {
  grid-column: 1 / -1;
  min-height: auto;
}

/* ── Find My Races ── */
.find-section {
  position: relative;
  /* Lift above the following section so the candidate-search dropdown can
     overlay it. Each .section-inner is its own stacking context (the scroll
     fade-in animation leaves a transform on it), so the dropdown's z-index is
     otherwise trapped and the next section paints over it. */
  z-index: 20;
  background:
    linear-gradient(180deg, rgba(242, 230, 207, .76), rgba(255, 253, 248, .88)),
    var(--paper);
  border-bottom: 1px solid var(--line);
}

.find-section h2 {
  color: var(--ocean-deep);
}

.address-search {
  display: flex;
  gap: .75rem;
  max-width: 600px;
  position: relative;
}

/* Candidate-name typeahead dropdown */
.candidate-suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 1200;
  margin: 0;
  padding: .25rem;
  list-style: none;
  background: rgba(255, 253, 248, .99);
  border: 1px solid #cbbda1;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(24, 37, 45, .14);
  max-height: 340px;
  overflow-y: auto;
}

.candidate-suggest.hidden {
  display: none;
}

.candidate-suggest li {
  padding: .55rem .7rem;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: .1rem;
}

.candidate-suggest li.active,
.candidate-suggest li:hover {
  background: rgba(31, 92, 109, .1);
}

.candidate-suggest .suggest-name {
  font-weight: 600;
  color: var(--ink);
}

.candidate-suggest .suggest-name .suggest-match {
  background: rgba(213, 144, 47, .28);
  border-radius: 3px;
}

.candidate-suggest .suggest-meta {
  font-size: .8rem;
  color: var(--ink-soft);
}

.candidate-suggest .suggest-empty {
  padding: .55rem .7rem;
  color: var(--ink-soft);
  font-size: .9rem;
  cursor: default;
}

.address-search input {
  flex: 1;
  padding: .95rem 1.125rem;
  font-size: 1rem;
  border: 1px solid #cbbda1;
  border-radius: 8px;
  background: rgba(255, 253, 248, .95);
  transition: border-color var(--transition), box-shadow var(--transition);
  box-shadow: inset 0 1px 2px rgba(24, 37, 45, .03);
}

.address-search input:focus {
  outline: none;
  border-color: var(--ocean);
  box-shadow: 0 0 0 3px rgba(31, 92, 109, .1);
}

.address-search button {
  padding: .95rem 1.7rem;
  font-size: .95rem;
  font-weight: 700;
  color: #2f2007;
  background: var(--sun);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 200ms cubic-bezier(.16, 1, .3, 1);
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(213, 144, 47, .15);
}

.address-search button:hover {
  background: #dfa043;
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(213, 144, 47, .22);
}

.address-search button:active {
  transform: scale(.98) translateY(0);
}

.address-search button:disabled {
  opacity: .7;
  cursor: wait;
}

/* Loading spinner for address search button */
.address-search button .search-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(47, 32, 7, .25);
  border-top-color: #2f2007;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
  margin-right: .4rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Shake animation for empty submit */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

.address-search input.input-shake {
  animation: shake .4s ease;
  border-color: var(--coral);
}

.my-races-results {
  background: rgba(255, 253, 248, .96);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-top: 1.25rem;
  box-shadow: 0 8px 24px rgba(24, 37, 45, .06);
}

.my-races-results h3 {
  font-size: 1.1rem;
  margin-bottom: .75rem;
  color: var(--green);
}

/* Address search feedback messages */
.address-feedback {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  padding: .85rem 1rem;
  border-radius: var(--radius);
  font-size: .92rem;
  line-height: 1.45;
}

.address-feedback-icon {
  flex-shrink: 0;
  font-size: 1.15rem;
  line-height: 1.3;
}

.address-feedback--error {
  background: var(--red-bg);
  color: var(--coral);
  border: 1px solid var(--red-light);
}

.address-feedback--warning {
  background: var(--yellow-bg);
  color: #7a5a10;
  border: 1px solid #e0c97a;
}

.address-feedback--info {
  background: var(--green-bg);
  color: var(--ocean-deep);
  border: 1px solid var(--green-light);
}

.address-feedback strong {
  display: block;
  margin-bottom: .15rem;
}

/* ── Map Section ── */
.map-section {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.layer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.25rem;
}

.layer-option {
  display: flex;
  align-items: center;
  gap: .375rem;
  font-size: .78rem;
  cursor: pointer;
  padding: .55rem .85rem;
  border: 1px solid #d6cfbf;
  border-radius: 6px;
  background: rgba(255, 253, 248, .92);
  transition: all 200ms cubic-bezier(.16, 1, .3, 1);
  user-select: none;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.layer-option:has(input:checked) {
  background: var(--ocean-deep);
  border-color: var(--ocean-deep);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(18, 52, 63, .12);
}

.layer-option input[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.map-container {
  height: 520px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #dce6e2;
  box-shadow: var(--shadow-lg);
}

.map-legend, .party-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: .85rem;
  color: var(--text-muted);
  align-items: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.legend-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  display: inline-block;
  border: 1px solid rgba(0,0,0,0.1);
}

.party-legend {
  margin-bottom: 1rem;
  margin-top: 0;
}

/* ── Key Races Section ── */

.key-races-section {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.key-races-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
  min-height: 200px;
}

.key-races-divider {
  grid-column: 1 / -1;
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-soft);
  padding: .75rem 0 .25rem;
  border-top: 1px solid var(--line);
  margin-top: .5rem;
}

.key-race-card {
  display: block;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  text-decoration: none;
  color: var(--ink);
  transition: all 200ms cubic-bezier(.16, 1, .3, 1);
}

.key-race-card:hover {
  border-color: var(--ocean);
  box-shadow: 0 4px 16px rgba(18, 52, 63, .08);
  transform: translateY(-1px);
}

.key-race-header {
  display: flex;
  align-items: baseline;
  gap: .35rem .5rem;
  flex-wrap: wrap;
  margin-bottom: .5rem;
}

.key-race-header h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  width: 100%;
}

.key-race-candidates {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-bottom: .5rem;
}

.candidate-chip {
  display: inline-block;
  font-size: .78rem;
  padding: .2rem .55rem;
  border-radius: 3px;
  background: #e8e3d8;
  color: var(--ink);
}

.candidate-chip.chip-dem {
  background: var(--green-bg);
  color: var(--ocean-deep);
}

.candidate-chip.chip-rep {
  background: var(--red-bg);
  color: var(--coral);
}

.key-race-finance {
  font-size: .8rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.badge-level {
  background: var(--paper);
  color: var(--ink-soft);
  font-size: .72rem;
  padding: .15rem .45rem;
  border-radius: 3px;
  border: 1px solid var(--line);
}

/* ── Race Groups ── */

.race-group {
  margin-bottom: .75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.race-group-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  background: var(--paper-muted);
  cursor: pointer;
  font-size: .95rem;
  list-style: none;
}

.race-group-header::-webkit-details-marker {
  display: none;
}

.race-group-header::before {
  content: '▸';
  font-size: .85rem;
  transition: transform .15s;
  color: var(--ink-soft);
}

.race-group[open] > .race-group-header::before {
  transform: rotate(90deg);
}

.race-group-title {
  font-weight: 700;
}

.race-group-counts {
  font-size: .8rem;
  color: var(--ink-soft);
}

.race-group .race-table {
  border-top: 1px solid var(--line);
  border-radius: 0;
}

.race-group .race-table thead {
  display: none;
}

/* ── Race List Section ── */
.race-list-section {
  background: linear-gradient(180deg, rgba(242, 230, 207, .4), rgba(255, 253, 248, .98));
  border-bottom: 1px solid var(--line);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: flex-end;
}

.race-context {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: .55rem .8rem;
  margin-bottom: .95rem;
  padding: .55rem .75rem;
  border: 1px solid rgba(31, 92, 109, .14);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(219, 233, 227, .24), rgba(242, 230, 207, .28));
}

.race-context-text {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .35rem .55rem;
  min-width: 0;
}

.race-context-kicker {
  display: inline-flex;
  align-items: center;
  padding: .25rem .5rem;
  border-radius: 999px;
  background: rgba(31, 92, 109, .08);
  color: var(--ocean);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.race-context-copy {
  color: var(--ink);
  font-size: .92rem;
  font-weight: 600;
  line-height: 1.35;
}

.filter-bar label {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

.filter-bar select {
  padding: .68rem .92rem;
  font-size: .95rem;
  border: 1px solid #d6cfbf;
  border-radius: 8px;
  background: rgba(255, 253, 248, .96);
  color: var(--text);
  cursor: pointer;
  min-width: 160px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.filter-bar select:focus {
  outline: none;
  border-color: var(--ocean);
  box-shadow: 0 0 0 3px rgba(31, 92, 109, .1);
}

.table-wrapper {
  overflow-x: auto;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(24, 37, 45, .06);
  border: 1px solid var(--line);
}

.race-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  font-size: .95rem;
}

.race-table thead {
  background: linear-gradient(135deg, var(--ocean-deep), #22576a);
  color: #fffaf1;
}

.race-table th {
  padding: 1rem 1.25rem;
  text-align: left;
  font-weight: 700;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: background var(--transition);
}

.race-table th:hover {
  background: #163a28;
}

.sort-icon {
  display: inline-block;
  margin-left: .35rem;
  opacity: .7;
  font-style: normal;
}

.race-table tbody tr {
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.race-table tbody tr:last-child {
  border-bottom: none;
}

.race-table tbody tr:hover {
  background: rgba(31, 92, 109, .03);
}

.race-table tbody tr:focus-visible {
  outline: 3px solid rgba(213, 144, 47, .55);
  outline-offset: -3px;
  background: #f5efe1;
}

.race-table td {
  padding: .9rem 1.25rem;
  vertical-align: middle;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: .28em .72em;
  font-size: .74rem;
  font-weight: 700;
  border-radius: 4px;
  line-height: 1.3;
  white-space: nowrap;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.badge-contested {
  background: var(--green-bg);
  color: var(--green);
}

.badge-uncontested {
  background: var(--red-bg);
  color: var(--red);
}

.badge-empty {
  background: var(--gray-light);
  color: var(--text-muted);
}

.badge-incumbent {
  background: var(--accent-light);
  color: var(--accent);
}

.badge-withdrawn {
  background: var(--gray-light);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Withdrawn candidates: kept visible but struck through and dimmed,
   and excluded from candidate counts in the data layer. */
.candidate-withdrawn {
  opacity: .6;
}

.candidate-withdrawn h3 a,
.candidate-withdrawn h3 {
  text-decoration: line-through;
}

.opponent-chip.chip-withdrawn {
  opacity: .55;
  text-decoration: line-through;
}

.badge-party {
  background: var(--gray-light);
  color: var(--text-muted);
}

/* ── Race Detail ── */
.race-detail {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem 1.125rem;
  margin-bottom: 1.75rem;
  font-size: .9rem;
  font-weight: 600;
  color: var(--ocean);
  background: transparent;
  border: 1px solid rgba(31, 92, 109, .18);
  border-radius: 6px;
  cursor: pointer;
  transition: all 200ms cubic-bezier(.16, 1, .3, 1);
}

.back-btn:hover {
  background: var(--ocean);
  color: #fff;
  border-color: var(--ocean);
}

.back-btn:active {
  transform: scale(.98);
}

/* Breadcrumb trail above the back button on detail views */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  margin-bottom: .75rem;
  font-size: .82rem;
  line-height: 1.4;
}

.breadcrumb:empty {
  display: none;
}

.breadcrumb-link {
  color: var(--ocean);
  text-decoration: none;
  font-weight: 600;
}

.breadcrumb-link:hover {
  text-decoration: underline;
}

.breadcrumb-sep {
  color: rgba(31, 92, 109, .4);
}

.breadcrumb-current {
  color: var(--ocean);
  font-weight: 600;
  opacity: .65;
}

.race-detail-header {
  margin-bottom: 1.75rem;
}

.race-detail-header h2 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4vw, 3rem);
  margin-bottom: .5rem;
}

.race-detail-header .badge {
  margin-bottom: .75rem;
}

.detail-map-container {
  height: 280px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  margin-bottom: 2rem;
  overflow: hidden;
  background: #dce6e2;
  box-shadow: var(--shadow);
}

.race-detail-candidates {
  margin-bottom: 2.5rem;
}

/* ── Party Columns ── */
.party-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.party-column-header {
  font-size: 1.1rem;
  font-weight: 700;
  padding: .5rem .75rem;
  border-radius: var(--radius);
  margin-bottom: .75rem;
  text-align: center;
}

.party-column-header.party-democratic {
  background: #dbeafe;
  color: #1e40af;
}

.party-column-header.party-republican {
  background: #fee2e2;
  color: #991b1b;
}

.party-column-header.party-green {
  background: var(--green-bg);
  color: var(--green);
}

.party-column-header.party-libertarian {
  background: #fef9c3;
  color: #854d0e;
}

.party-column-header.party-nonpartisan,
.party-column-header.party-nonpartisan-special {
  background: var(--gray-light);
  color: var(--text);
}

.candidate-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.4rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px rgba(24, 37, 45, .04);
  transition: all 200ms cubic-bezier(.16, 1, .3, 1);
}

.candidate-card:hover {
  box-shadow: 0 6px 20px rgba(24, 37, 45, .08);
  border-color: var(--gray);
}

.candidate-card h3 {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 700;
  margin-bottom: .625rem;
  color: var(--text);
  line-height: 1.1;
}

.candidate-name-link {
  color: inherit;
  text-decoration: none;
}

.candidate-name-link:hover {
  color: var(--ocean);
}

.candidate-card .badge {
  margin-right: .4rem;
  margin-bottom: .625rem;
}

.candidate-card p {
  margin-bottom: .5rem;
  font-size: .9rem;
  color: var(--text-muted);
}

.candidate-card a {
  display: inline-block;
  margin-right: 1.25rem;
  margin-bottom: .25rem;
  font-size: .9rem;
}

.candidate-contact {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1.25rem;
  align-items: baseline;
}

.candidate-phone {
  display: inline-block;
  font-size: .9rem;
  color: var(--text-muted);
}

.candidate-finance-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px solid var(--line);
}

.fin-metric-card {
  background: var(--paper-muted);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 2px);
  padding: .5rem .625rem;
  display: flex;
  flex-direction: column;
  gap: .125rem;
}

.fin-metric-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  line-height: 1.2;
}

.fin-metric-value {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.fin-metric-card.fin-warchest .fin-metric-value {
  color: var(--green-mid);
}

.fin-date {
  font-size: .75rem;
  color: var(--text-muted);
  font-style: italic;
}

.fin-source {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  background: var(--gray-light);
  padding: .1rem .4rem;
  border-radius: 3px;
}

.my-race-item {
  padding: .625rem 0;
  border-bottom: 1px solid var(--gray-light);
  display: flex;
  align-items: center;
  gap: .625rem;
  flex-wrap: wrap;
}

.my-race-item:last-child {
  border-bottom: none;
}

.my-race-item a {
  font-weight: 600;
}

.my-race-item span {
  font-size: .9rem;
  color: var(--text-muted);
}

.my-race-item .badge {
  margin-left: .125rem;
}

.uncontested-banner {
  background: var(--yellow-bg);
  border: 1px solid rgba(213, 144, 47, .5);
  border-left: 5px solid var(--yellow);
  border-radius: 16px;
  padding: 1.1rem 1.25rem;
  margin-top: .75rem;
  margin-bottom: 1.5rem;
  color: #664d03;
  box-shadow: var(--shadow-sm);
}

.uncontested-banner p {
  font-weight: 600;
  margin-bottom: .25rem;
}

.uncontested-banner a {
  color: #664d03;
  text-decoration: underline;
  font-weight: 700;
}

.banner-guide {
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px solid rgba(102, 77, 3, .2);
}

.banner-guide h4 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: .5rem;
  color: #664d03;
}

.banner-guide-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .2rem .75rem;
  font-size: .9rem;
}

.banner-guide-dl dt {
  font-weight: 600;
  color: #664d03;
}

.banner-guide-dl dd {
  color: #664d03;
}

.banner-guide-note {
  font-size: .85rem;
  font-style: italic;
  margin-top: .4rem;
  margin-bottom: .25rem;
}

/* ── Contest Analysis Panel ── */

.analysis-panel {
  margin: 1.5rem 0;
  padding: 1.25rem;
  background: var(--paper-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.analysis-panel h3 {
  font-size: .9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-soft);
  margin: 0 0 .75rem;
}

.analysis-pills {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: 1rem;
}

.analysis-pill {
  display: inline-block;
  padding: .2rem .6rem;
  font-size: .75rem;
  border-radius: 12px;
  background: var(--seafoam);
  color: var(--ocean-deep);
  border: 1px solid var(--green-light);
}

.analysis-pill.pill-high {
  background: var(--accent-light);
  color: var(--coral);
  border-color: var(--red-light);
}

.analysis-pill.pill-medium {
  background: #fef3e2;
  color: #7c5a00;
  border-color: var(--sand-deep);
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .75rem;
}

.analysis-metric {
  text-align: center;
  padding: .5rem;
  background: var(--paper);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.analysis-metric.metric-warn {
  border-color: var(--sun);
  background: #fffcf5;
}

.metric-value {
  display: block;
  font-size: 1.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.metric-warn .metric-value {
  color: var(--coral);
}

.metric-label {
  display: block;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--ink-soft);
  margin-top: .15rem;
}

.metric-subtext {
  display: block;
  font-size: .65rem;
  color: var(--ink-soft);
  opacity: .7;
  margin-top: .1rem;
}

.key-race-factors {
  font-size: .7rem;
  color: var(--ink-soft);
  margin-top: .3rem;
  line-height: 1.4;
}

/* ── Candidate Profile ── */
.candidate-detail {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.candidate-profile-header {
  margin-bottom: 1rem;
}

.candidate-profile-header h2 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4vw, 3rem);
  margin-bottom: .5rem;
}

.candidate-profile-badges {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: .5rem;
}

.candidate-profile-filing {
  color: var(--text-muted);
  font-size: .95rem;
}

.candidate-profile-contests {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding: .75rem 1rem;
  background: var(--paper-muted);
  border-radius: var(--radius);
}

.candidate-profile-contest-label {
  font-weight: 600;
  font-size: .9rem;
  color: var(--text-muted);
}

.candidate-profile-contest-link {
  font-weight: 600;
  color: var(--ocean);
  text-decoration: none;
}

.candidate-profile-contest-link:hover {
  text-decoration: underline;
}

.candidate-profile-contact {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
  padding: .75rem 0;
  border-bottom: 1px solid var(--line);
}

.candidate-profile-contact .contact-item {
  color: var(--ocean);
  text-decoration: none;
  font-size: .95rem;
}

.candidate-profile-contact a.contact-item:hover {
  text-decoration: underline;
}

.candidate-profile-contact .contact-phone {
  color: var(--text-muted);
}

.candidate-profile-finance {
  margin-bottom: 2.5rem;
}

.candidate-profile-finance h3,
.candidate-profile-opponents h3,
.candidate-profile-history h3 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.candidate-profile-finance h4,
.candidate-profile-opponents h4,
.candidate-profile-history h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: .5rem;
}

.candidate-profile-opponents {
  margin-bottom: 2.5rem;
}

.candidate-profile-opponent-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.opponent-chip {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
}

.opponent-chip:hover {
  opacity: .85;
}

.opponent-warchest {
  font-size: .75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.candidate-profile-history {
  margin-bottom: 2.5rem;
}

.candidate-profile-link {
  display: block;
  margin-top: .75rem;
  font-size: .85rem;
  font-weight: 600;
  color: var(--ocean);
  text-decoration: none;
}

.candidate-profile-link:hover {
  text-decoration: underline;
}

@media (max-width: 768px) {
  .analysis-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── Finance ── */
.race-detail-finance {
  margin-bottom: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.race-detail-finance h3 {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 1.25rem;
  color: var(--text);
}

.finance-loading {
  display: flex;
  align-items: center;
  gap: .625rem;
  color: var(--text-muted);
  font-size: .95rem;
  padding: 1rem 0;
}

.loading-spinner {
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  border: 2.5px solid var(--gray-light);
  border-top-color: var(--green-mid);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.finance-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .75rem;
}

.finance-bar .bar-label {
  width: 180px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.finance-bar .bar-fill-wrap {
  flex: 1;
  height: 22px;
  background: #ebe3d2;
  border-radius: 100px;
  overflow: hidden;
}

.finance-bar .bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ocean), #8eb7ae);
  border-radius: 100px;
  transition: width .5s ease;
  min-width: 2px;
}

.finance-bar .bar-amount {
  width: 90px;
  font-size: .875rem;
  font-weight: 700;
  color: var(--text);
  text-align: right;
  flex-shrink: 0;
}

.contrib-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  margin-top: 1.25rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
}

.contrib-table th {
  text-align: left;
  padding: .625rem 1rem;
  background: #f3eddf;
  font-weight: 700;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

.contrib-table td {
  padding: .5rem 1rem;
  border-bottom: 1px solid var(--line);
}

.contrib-table tbody tr:last-child td {
  border-bottom: none;
}

.contrib-table tbody tr:hover {
  background: var(--bg);
}

/* ── How to Run Guide ── */
.guide-section {
  background: linear-gradient(180deg, rgba(219, 233, 227, .35), rgba(255, 253, 248, 1));
  border-bottom: 1px solid var(--line);
}

.guide-section h2 {
  color: var(--ocean-deep);
}

.guide-links {
  margin-bottom: 2.5rem;
  background: linear-gradient(135deg, rgba(219, 233, 227, .7), rgba(242, 230, 207, .76));
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  border: 1px solid rgba(31, 92, 109, .12);
  box-shadow: var(--shadow-sm);
}

.guide-links h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: .75rem;
  color: var(--green);
}

.resource-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: .625rem;
}

.resource-list li {
  font-size: .9rem;
  color: var(--text);
  line-height: 1.5;
}

.resource-list li a {
  font-weight: 600;
}

.guide-offices details {
  background: rgba(255, 253, 248, .96);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  margin-bottom: .625rem;
  overflow: hidden;
  transition: box-shadow var(--transition);
}

.guide-offices details[open] {
  box-shadow: var(--shadow);
  border-color: var(--gray);
}

.guide-offices summary {
  padding: 1.125rem 1.5rem;
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  transition: background var(--transition);
}

.guide-offices summary::-webkit-details-marker {
  display: none;
}

.guide-offices summary::after {
  content: "+";
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--text-muted);
  display: inline-block;
  transition: transform var(--transition);
  width: 1.5rem;
  text-align: center;
}

.guide-offices details[open] summary::after {
  content: "\2212";
}

.guide-offices summary:hover {
  background: #f4efe2;
}

.office-details {
  padding: 1rem 1.5rem 1.5rem;
  border-top: 1px solid var(--line);
}

.office-details dl {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: .5rem 1.25rem;
}

.office-details dt {
  font-weight: 700;
  color: var(--text);
  font-size: .875rem;
}

.office-details dd {
  color: var(--text-muted);
  font-size: .875rem;
  line-height: 1.5;
}

.guide-public-funding {
  margin-bottom: 2.5rem;
  padding: 1.5rem 1.75rem;
  background: var(--green-bg);
  border: 1px solid var(--green-light);
  border-radius: var(--radius-lg);
}

.guide-public-funding h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: .75rem;
  color: var(--ocean-deep);
}

.guide-public-funding p,
.guide-public-funding ol {
  font-size: .925rem;
  line-height: 1.6;
  color: var(--ink);
}

.guide-public-funding ol {
  padding-left: 1.25rem;
  margin: .75rem 0;
}

.guide-public-funding ol li {
  margin-bottom: .375rem;
}

.guide-pf-stats {
  font-weight: 600;
  color: var(--ocean);
  margin-top: .75rem;
}

/* ── Footer ── */
.site-footer {
  background: linear-gradient(180deg, #133540, #102a33);
  color: rgba(255,255,255,.8);
  text-align: center;
  padding: 2rem 2rem;
  font-size: .875rem;
}

.site-footer a {
  color: var(--green-light);
  font-weight: 600;
}

.site-footer a:hover {
  color: #fff;
  text-decoration: underline;
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.footer-credits {
  opacity: .7;
  font-size: .8rem;
}

.finance-source-note {
  font-size: .8rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 1.25rem;
  padding: .5rem .75rem;
  background: #f4efe1;
  border-radius: var(--radius);
  border-left: 3px solid var(--sand-deep);
}

/* ── Finance Detail Tables ── */
.finance-candidate-detail {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--gray-light);
}

.finance-candidate-detail h4 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: .375rem;
}

.finance-metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  margin-bottom: 1rem;
  max-width: 420px;
}

.finance-metric-grid .fin-metric-card {
  padding: .625rem .75rem;
}

.finance-metric-grid .fin-metric-value {
  font-size: 1.05rem;
}

.finance-no-filing {
  font-style: italic;
  color: var(--text-muted);
}

.finance-good-governance {
  background: var(--green-bg);
  border: 1px solid var(--green-light);
  border-radius: var(--radius);
  padding: .875rem 1.125rem;
  color: var(--ocean-deep);
  font-size: .95rem;
  line-height: 1.5;
}

.finance-good-governance strong {
  font-weight: 700;
}

.badge-no-fundraising {
  background: var(--green-bg);
  color: var(--ocean-deep);
  font-weight: 600;
}

.public-funding-section {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.public-funding-badge {
  padding: .625rem 1rem;
  border-radius: var(--radius);
  font-size: .9rem;
  line-height: 1.5;
}

.public-funding-badge strong {
  font-weight: 700;
}

.pf-soi {
  background: var(--yellow-bg);
  border: 1px solid var(--sand-deep);
  color: var(--ink);
}

.pf-affidavit {
  background: var(--green-bg);
  border: 1px solid var(--green-light);
  color: var(--ocean-deep);
}

.fundraiser-section {
  margin-top: 1.25rem;
}

.fundraiser-section h4 {
  font-size: .95rem;
  font-weight: 600;
  color: var(--ocean-deep);
  margin: 0 0 .5rem;
}

.fundraiser-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.fundraiser-item a {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .75rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  font-size: .875rem;
  transition: background .15s;
}

.fundraiser-item a:hover {
  background: var(--paper-muted);
}

.fundraiser-upcoming a {
  border-color: var(--ocean);
  background: #edf5f7;
}

.fundraiser-date {
  font-weight: 500;
}

.fundraiser-status {
  color: var(--ink-soft);
  font-size: .8rem;
  font-style: italic;
}

.fundraiser-upcoming-badge {
  background: var(--ocean);
  color: #fff;
  font-size: .7rem;
  font-weight: 600;
  padding: .125rem .5rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.fundraiser-session-badge {
  background: var(--yellow-bg);
  color: var(--sun);
  font-size: .7rem;
  font-weight: 600;
  padding: .125rem .5rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.fundraiser-pdf-icon {
  margin-left: auto;
  font-size: .7rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--paper-muted);
  padding: .125rem .375rem;
  border-radius: 3px;
}

.finance-detail-table {
  margin-bottom: .75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.finance-detail-table summary {
  padding: .75rem 1.25rem;
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  transition: background var(--transition);
  background: #f3eddf;
}

.finance-detail-table summary::-webkit-details-marker {
  display: none;
}

.finance-detail-table summary::after {
  content: "+";
  font-size: 1.1rem;
  color: var(--text-muted);
}

.finance-detail-table[open] summary::after {
  content: "\2212";
}

.finance-detail-table summary:hover {
  background: #ebe3d2;
}

.finance-detail-content {
  max-height: 400px;
  overflow-y: auto;
}

.finance-detail-loading {
  padding: .75rem 1.25rem;
  color: var(--text-muted);
  font-size: .9rem;
}

.finance-full-table {
  margin-top: 0;
  border: none;
  border-radius: 0;
}

.finance-full-table td {
  font-size: .8rem;
  padding: .4rem .75rem;
  white-space: nowrap;
}

.finance-full-table td:last-child {
  white-space: normal;
  min-width: 120px;
}

.finance-csc-link {
  display: block;
  padding: .625rem 1.25rem;
  font-size: .85rem;
  font-weight: 600;
  background: #f4efe1;
  border-top: 1px solid var(--line);
}

/* ── FEC Detail Sections ── */

.fec-geo-breakdown,
.fec-size-breakdown,
.fec-top-donors {
  margin: 1rem 0;
}

.fec-geo-breakdown h5,
.fec-size-breakdown h5,
.fec-top-donors h5 {
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: .5rem;
  color: var(--ink);
}

.stacked-bar {
  display: flex;
  height: 1.75rem;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: .35rem;
}

.stacked-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 600;
  color: #fff;
  min-width: 2px;
}

.stacked-segment.in-state {
  background: var(--ocean);
}

.stacked-segment.out-state {
  background: var(--sand-deep);
  color: var(--ink);
}

.geo-legend {
  font-size: .8rem;
  color: var(--ink-soft);
}

.size-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .35rem;
}

.size-row .size-label {
  width: 7.5rem;
  flex-shrink: 0;
  font-size: .8rem;
  color: var(--ink-soft);
  text-align: right;
}

.size-row .bar-fill-wrap {
  flex: 1;
  height: 1rem;
}

.size-row .bar-amount {
  font-size: .8rem;
  width: 8rem;
  text-align: right;
}

.bar-fill.size-small { background: var(--green-light); }
.bar-fill.size-mid   { background: var(--ocean); }
.bar-fill.size-large { background: var(--sun); }
.bar-fill.size-max   { background: var(--coral); }

/* ── Election History ── */

.race-detail-history {
  margin-top: 2rem;
  overflow-x: auto;
}

.race-detail-history h3 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  margin-bottom: 1rem;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
  margin-bottom: 1.25rem;
}

.history-table th {
  text-align: left;
  padding: .5rem .6rem;
  border-bottom: 2px solid var(--ocean-deep);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-soft);
  white-space: nowrap;
}

.history-table td {
  padding: .45rem .6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.history-table tr:last-child td {
  border-bottom: none;
}

.history-year {
  font-weight: 700;
  color: var(--ocean-deep);
}

.history-name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-votes {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.history-pct {
  font-weight: 600;
  color: var(--ocean);
}

.history-turnout {
  font-weight: 600;
  color: var(--ink-soft);
}

.history-redistricting-note {
  font-size: .82rem;
  color: var(--ink-soft);
  font-style: italic;
  margin-bottom: .75rem;
  padding: .5rem .75rem;
  background: var(--paper-muted);
  border-left: 3px solid var(--sun);
  border-radius: 0 4px 4px 0;
}

.history-predecessor,
.history-predecessor td {
  font-style: italic;
  opacity: .75;
}

.party-tag {
  display: inline-block;
  padding: .15rem .45rem;
  border-radius: 3px;
  color: #fff;
  font-size: .72rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.party-tag-sm {
  padding: .1rem .35rem;
  font-size: .68rem;
}

.history-primary-details {
  margin-top: .75rem;
}

.history-primary-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: .9rem;
  color: var(--ocean);
  padding: .5rem 0;
}

.history-primary-details summary:hover {
  color: var(--ocean-deep);
}

.history-primary-year {
  margin: 1rem 0;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--line);
}

.history-primary-year:last-child {
  border-bottom: none;
}

.history-primary-year h4 {
  font-size: .95rem;
  margin-bottom: .5rem;
  color: var(--ink);
}

.history-primary-party {
  margin-bottom: .75rem;
}

.history-primary-party > .party-tag {
  margin-bottom: .35rem;
}

.history-primary-row {
  display: grid;
  grid-template-columns: 180px 1fr 70px;
  align-items: center;
  gap: .5rem;
  padding: .2rem 0;
  font-size: .82rem;
}

.history-primary-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-primary-bar-wrap {
  height: 14px;
  background: var(--paper-muted);
  border-radius: 3px;
  overflow: hidden;
}

.history-primary-bar {
  height: 100%;
  border-radius: 3px;
  min-width: 2px;
  transition: width .3s ease;
}

.history-primary-votes {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

@media (max-width: 768px) {
  .history-table {
    font-size: .75rem;
  }
  .history-table th,
  .history-table td {
    padding: .35rem .4rem;
  }
  .history-name {
    max-width: 100px;
  }
  .history-primary-row {
    grid-template-columns: 140px 1fr 60px;
    font-size: .75rem;
  }
}

/* ── Vote Method Breakdown ── */

.history-methods {
  margin-top: 2rem;
}

.history-methods h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 1rem;
  color: var(--ink);
}

.method-year-block {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}
.method-year-block:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.method-year-block h5 {
  font-size: .85rem;
  font-weight: 600;
  margin: 0 0 .5rem;
  color: var(--ink-soft);
}

.method-year-block.history-predecessor {
  opacity: .7;
  font-style: italic;
}

.method-year-skip h5 {
  color: var(--ink-soft);
  font-weight: 400;
  font-style: italic;
}

.method-legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
  font-size: .75rem;
  color: var(--ink-soft);
}

.method-legend-item {
  display: flex;
  align-items: center;
  gap: .3rem;
}

.method-legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.method-candidate-row {
  display: grid;
  grid-template-columns: 180px 1fr 80px;
  align-items: center;
  gap: .5rem;
  padding: .25rem 0;
}

.method-candidate-name {
  font-size: .8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.method-candidate-votes {
  text-align: right;
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

.method-bar-wrap {
  position: relative;
  height: 18px;
  background: var(--paper-muted);
  border-radius: 3px;
  overflow: hidden;
}

.method-bar {
  display: flex;
  height: 100%;
  transition: width .3s ease;
}

.method-segment {
  height: 100%;
  min-width: 1px;
  transition: width .3s ease;
}

.method-bar-blank {
  background: repeating-linear-gradient(
    45deg,
    var(--line),
    var(--line) 3px,
    transparent 3px,
    transparent 6px
  );
}

.method-blank-row .method-candidate-name {
  color: var(--ink-soft);
  font-style: italic;
}

.method-blank-label {
  font-size: .75rem;
}

/* ── Precinct Drill-Down ── */

.history-precinct-details {
  margin-top: 1.5rem;
}

.history-precinct-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: .9rem;
  color: var(--ocean);
  padding: .5rem 0;
}
.history-precinct-details summary:hover {
  color: var(--ocean-deep);
}

.precinct-controls {
  margin: .75rem 0;
}

.precinct-year-select {
  margin-left: .5rem;
  padding: .3rem .5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  font-size: .85rem;
}

.precinct-map-container {
  height: 300px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  margin-bottom: 1rem;
}

.precinct-summary-row {
  margin-bottom: .75rem;
  font-size: .8rem;
  color: var(--ink-soft);
}

.precinct-block {
  margin-bottom: 1rem;
  padding: .75rem;
  background: var(--paper-muted);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.precinct-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: .4rem;
}

.precinct-name {
  font-weight: 600;
  font-size: .85rem;
  color: var(--ink);
}

.precinct-meta {
  font-size: .75rem;
  color: var(--ink-soft);
}

.precinct-candidate-row {
  grid-template-columns: 160px 1fr 70px;
}

@media (max-width: 768px) {
  .method-candidate-row {
    grid-template-columns: 120px 1fr 60px;
    font-size: .75rem;
  }
  .precinct-candidate-row {
    grid-template-columns: 100px 1fr 55px;
  }
  .precinct-header {
    flex-direction: column;
    gap: .2rem;
  }
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
.site-nav a:focus-visible,
.hero-btn:focus-visible,
.back-btn:focus-visible,
.breadcrumb-link:focus-visible {
  outline: 3px solid rgba(213, 144, 47, .65);
  outline-offset: 3px;
}

.layer-option:has(input:focus-visible) {
  box-shadow: 0 0 0 4px rgba(213, 144, 47, .22);
  border-color: var(--sun);
}

/* ── Leaflet popup override ── */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow) !important;
}

.leaflet-popup-content {
  font-family: inherit !important;
  font-size: .9rem !important;
  line-height: 1.5 !important;
  margin: 10px 14px !important;
}

.map-popup strong {
  font-size: .95rem;
}

.map-popup a {
  color: var(--accent);
  font-weight: 600;
}

/* ── Scroll Entry Animation ── */

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-inner {
  animation: fadeSlideIn 600ms cubic-bezier(.16, 1, .3, 1) both;
}

/* ── Mobile Bottom Navigation ── */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    background: var(--ocean-deep);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -4px 20px rgba(18, 52, 63, 0.25);
  }

  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.45rem 0;
    min-height: 56px;
    color: rgba(255, 255, 255, 0.55);
    text-decoration: none;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: color 200ms ease;
    -webkit-tap-highlight-color: transparent;
  }

  .bottom-nav-item:hover,
  .bottom-nav-item:focus {
    text-decoration: none;
    color: rgba(255, 255, 255, 0.85);
  }

  .bottom-nav-item.active {
    color: var(--sun);
  }

  .bottom-nav-item svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
  }

  .sticky-nav {
    display: none;
  }

  body {
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }
}

/* ── Mobile Responsive ── */
@media (max-width: 768px) {
  .header-inner {
    grid-template-columns: 1fr;
    padding: 2.8rem 1.25rem 1.4rem;
  }

  .site-header h1 {
    font-size: 2.35rem;
    max-width: none;
  }

  .hero-dek {
    font-size: 1rem;
    max-width: none;
  }

  .hero-actions {
    flex-direction: column;
  }

  .hero-btn {
    width: 100%;
  }

  .tagline {
    font-size: .95rem;
    padding-top: .9rem;
  }

  .section-inner {
    padding: 2rem 1.25rem;
  }

  h2 {
    font-size: 1.7rem;
  }

  .nav-inner {
    padding: .6rem 1.25rem;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .4rem;
  }

  .sticky-nav a {
    text-align: center;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    display: inline-flex;
    padding: .6rem .5rem;
    font-size: .68rem;
  }

  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-item {
    min-height: auto;
  }

  .stat-num {
    font-size: 2.1rem;
  }

  .stat-meta {
    grid-column: auto;
  }

  .address-search {
    flex-direction: column;
    max-width: none;
  }

  .address-search button {
    width: 100%;
  }

  .layer-controls {
    gap: .375rem;
  }

  .layer-option {
    font-size: .75rem;
    padding: .5rem .72rem;
  }

  .map-container {
    height: min(320px, 44vh);
    border-radius: var(--radius);
  }

  .filter-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .5rem;
  }

  .filter-bar label {
    gap: .2rem;
    font-size: .65rem;
  }

  .filter-bar select {
    width: 100%;
    min-width: unset;
    padding: .55rem .45rem;
    font-size: .82rem;
  }

  .race-context {
    flex-direction: column;
    align-items: stretch;
  }

  .race-context-text {
    align-items: flex-start;
  }

  .race-table {
    font-size: .9rem;
    background: transparent;
  }

  .table-wrapper {
    overflow: visible;
    border: none;
    box-shadow: none;
    background: transparent;
  }

  .race-table thead {
    display: none;
  }

  .race-table,
  .race-table tbody,
  .race-table tr,
  .race-table td {
    display: block;
    width: 100%;
  }

  .race-table tbody {
    display: grid;
    gap: .5rem;
  }

  .race-table tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: .2rem .5rem;
    padding: .7rem .9rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(255, 253, 248, .96);
    box-shadow: var(--shadow-sm);
  }

  .race-table td {
    padding: 0;
    margin: 0;
  }

  .race-table td::before {
    display: none;
  }

  .race-table td:nth-child(1) {
    grid-column: 1 / -1;
    font-family: var(--font-serif);
    font-size: 1.05rem;
    line-height: 1.2;
    color: var(--ink);
  }

  .race-table td:nth-child(2) {
    font-size: .8rem;
    color: var(--ink-soft);
  }

  .race-table td:nth-child(3) {
    justify-self: end;
  }

  .candidate-card {
    padding: 1.2rem;
  }

  .candidate-card h3 {
    font-size: 1.25rem;
  }

  .finance-bar {
    flex-wrap: wrap;
  }

  .finance-bar .bar-label {
    width: 100%;
  }

  .office-details dl {
    grid-template-columns: 1fr;
  }

  .detail-map-container {
    height: 220px;
  }

  .resource-list {
    grid-template-columns: 1fr;
  }

  .guide-links {
    padding: 1.25rem;
  }
}

@media (max-width: 360px) {
  .candidate-finance-summary,
  .finance-metric-grid {
    grid-template-columns: 1fr;
  }
}

/* Election-phase: competition-analysis callout + footer guide link (NIM-15) */
.guide-competition-callout {
  margin: 1rem 0 1.5rem;
  padding: .85rem 1rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-light);
  font-size: .95rem;
  color: var(--text);
}

.footer-guide-link a {
  font-weight: 600;
}
