/* Kansas Voter Map - bilingual, mobile-first
   Palette: #4a163b (deep plum), #efe7e7 (warm cream), #32d6e6 (cyan), #8d379b (purple)
*/

:root {
  --plum: #4a163b;
  --cream: #efe7e7;
  --cyan: #32d6e6;
  --purple: #8d379b;
  --plum-soft: #6b2856;
  --ink: #221019;
  --ink-soft: #5c4853;
  --line: #e2d4d4;
  --bg: #fbf6f6;
  --white: #ffffff;
  --shadow-sm: 0 1px 2px rgba(74, 22, 59, 0.08);
  --shadow-md: 0 6px 24px rgba(74, 22, 59, 0.12);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--plum); text-decoration-color: var(--cyan); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--purple); }

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  background: none;
}

img, svg { display: block; max-width: 100%; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  background: var(--plum);
  color: var(--white);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  z-index: 9999;
}
.skip-link:focus { left: 12px; top: 12px; }

/* ================ HEADER ================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--white);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.app-header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--plum);
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.brand:hover { color: var(--purple); }
.brand-mark {
  width: 36px; height: 36px;
  flex-shrink: 0;
}
.app-nav {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}
@media (max-width: 880px) {
  .app-nav { display: none; }
  .app-header-inner { gap: 10px; justify-content: space-between; padding: 10px 14px; }
  .brand { font-size: 0.95rem; }
  .brand-mark { width: 30px; height: 30px; }
}
@media (max-width: 540px) {
  .audio-btn span:last-child { display: none; }
  .audio-btn { padding: 7px 9px; }
  .lang-btn { padding: 5px 10px; font-size: 0.8rem; }
  .brand span { display: none; }
}
.app-nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 500;
  font-size: 0.95rem;
  transition: background 0.15s;
}
.app-nav a:hover { background: var(--cream); }

.lang-switch {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  background: var(--cream);
}
.lang-btn {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.lang-btn[aria-pressed="true"] {
  background: var(--plum);
  color: var(--white);
}

.audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--cream);
  color: var(--plum);
  border: 1px solid var(--line);
}
.audio-btn[aria-pressed="true"] { background: var(--cyan); color: var(--plum); border-color: var(--cyan); }

/* ================ HERO ================ */
.hero {
  background: linear-gradient(135deg, var(--plum) 0%, var(--purple) 100%);
  color: var(--white);
  padding: 56px 18px 80px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  right: -120px; top: -80px;
  width: 380px; height: 380px;
  border-radius: 50%;
  background: var(--cyan);
  opacity: 0.18;
  filter: blur(20px);
}
.hero-inner {
  max-width: 920px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}
.hero-badge {
  display: inline-block;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  margin-bottom: 18px;
}
.hero h1 {
  font-size: clamp(1.9rem, 5vw, 3rem);
  line-height: 1.1;
  margin: 0 0 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.hero p.lead {
  font-size: clamp(1rem, 2.4vw, 1.2rem);
  max-width: 640px;
  opacity: 0.95;
  margin: 0 0 28px;
}
.hero-cta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  transition: transform 0.1s, box-shadow 0.15s, background 0.15s;
  border: 2px solid transparent;
}
.btn-primary {
  background: var(--cyan);
  color: var(--plum);
}
.btn-primary:hover { background: var(--white); transform: translateY(-1px); }
.btn-ghost {
  background: transparent;
  color: var(--white);
  border-color: rgba(255,255,255,0.4);
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); }
.btn-block { width: 100%; justify-content: center; }

/* ================ SECTIONS ================ */
section {
  padding: 56px 18px;
}
.section-inner {
  max-width: 1280px;
  margin: 0 auto;
}
.section-head {
  max-width: 720px;
  margin-bottom: 32px;
}
.section-head h2 {
  font-size: clamp(1.5rem, 3.2vw, 2.1rem);
  margin: 0 0 10px;
  color: var(--plum);
  letter-spacing: -0.02em;
  font-weight: 700;
}
.section-head p {
  font-size: 1.05rem;
  color: var(--ink-soft);
  margin: 0;
}
.eyebrow {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--purple);
  margin-bottom: 8px;
}

/* ================ MAP SECTION ================ */
#map-section { background: var(--white); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.map-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}
@media (min-width: 980px) {
  .map-grid { grid-template-columns: 1.4fr 1fr; }
}
.map-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--cream);
  box-shadow: var(--shadow-sm);
}
#ks-map {
  height: 460px;
  width: 100%;
}
@media (min-width: 600px) { #ks-map { height: 540px; } }

.map-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--white);
}
.search-form {
  flex: 1;
  display: flex;
  gap: 8px;
  min-width: 240px;
}
.search-form input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  font-size: 1rem;
  font-family: inherit;
  background: var(--white);
  color: var(--ink);
}
.search-form input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(50, 214, 230, 0.25);
}
.search-form button {
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--plum);
  color: var(--white);
  font-weight: 600;
}
.search-form button:hover { background: var(--purple); }
.reset-btn {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--white);
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 500;
}
.reset-btn:hover { background: var(--cream); }

.search-msg {
  padding: 10px 14px;
  font-size: 0.92rem;
  color: var(--ink-soft);
}
.search-msg.error { color: #b53b5e; }
.search-msg.success { color: var(--plum); font-weight: 600; }

.legend {
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: var(--cream);
  flex-wrap: wrap;
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch {
  width: 14px; height: 14px;
  border-radius: 4px;
  border: 1.5px solid var(--plum);
}
.legend-swatch.county { background: var(--cream); }
.legend-swatch.selected { background: var(--cyan); border-color: var(--plum); }

/* ================ COUNTY PANEL ================ */
.county-panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  align-self: start;
  position: sticky;
  top: 80px;
}
.panel-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--plum);
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.panel-sub {
  color: var(--ink-soft);
  font-size: 0.92rem;
  margin: 0 0 18px;
}
.panel-empty {
  color: var(--ink-soft);
  font-size: 0.95rem;
  text-align: center;
  padding: 24px 8px;
  background: var(--cream);
  border-radius: var(--radius);
}
.info-row {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.info-row:last-child { border-bottom: 0; }
.info-icon {
  width: 28px; height: 28px;
  flex-shrink: 0;
  background: var(--cream);
  color: var(--plum);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.info-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--purple);
  margin-bottom: 2px;
}
.info-value { font-size: 0.95rem; line-height: 1.45; word-break: break-word; }
.info-value a { color: var(--plum); }

.panel-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.panel-actions .btn-pill {
  flex: 1;
  min-width: 140px;
  background: var(--plum);
  color: var(--white);
  text-align: center;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.panel-actions .btn-pill.secondary {
  background: var(--cream);
  color: var(--plum);
  border: 1.5px solid var(--plum);
}
.panel-actions .btn-pill:hover { background: var(--purple); color: var(--white); }
.panel-actions .btn-pill.secondary:hover { background: var(--plum); color: var(--white); }

.sources-block {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.sources-block h4 {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--purple);
  margin: 0 0 10px;
}
.sources-block ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sources-block li a {
  font-size: 0.9rem;
  color: var(--plum);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sources-block li a::before { content: "→"; color: var(--cyan); }
.sources-block li a:hover { color: var(--purple); }

/* ================ STATEWIDE INFO ================ */
.statewide {
  background: linear-gradient(135deg, var(--cream) 0%, #fff 100%);
}
.statewide-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
@media (min-width: 720px) { .statewide-grid { grid-template-columns: repeat(3, 1fr); } }
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.stat-card .icon-circle {
  width: 44px; height: 44px;
  background: var(--cyan);
  color: var(--plum);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 12px;
}
.stat-card h3 {
  font-size: 1.05rem;
  margin: 0 0 6px;
  color: var(--plum);
  font-weight: 700;
}
.stat-card .value {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 6px;
}
.stat-card .note {
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin: 0;
}
.id-list { background: var(--white); }
.id-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width: 720px) { .id-list ul { grid-template-columns: 1fr 1fr; } }
.id-list li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  background: var(--cream);
  border-radius: var(--radius);
}
.id-list li::before {
  content: "🪪";
  flex-shrink: 0;
}
.id-note {
  margin-top: 14px;
  padding: 14px;
  background: rgba(50, 214, 230, 0.12);
  border-left: 4px solid var(--cyan);
  border-radius: 8px;
  font-size: 0.95rem;
  color: var(--ink);
}
.id-note a { font-weight: 600; }

/* ================ GUIDE STEPS ================ */
.steps {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
@media (min-width: 720px) { .steps { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .steps { grid-template-columns: repeat(4, 1fr); } }

.step-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s;
}
.step-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.step-icon {
  width: 56px; height: 56px;
  background: var(--cream);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
}
.step-card h3 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--plum);
  font-weight: 700;
}
.step-card p { margin: 0; color: var(--ink-soft); font-size: 0.95rem; }
.step-card a {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--purple);
  text-decoration: none;
  margin-top: auto;
}
.step-card a::after { content: " →"; color: var(--cyan); }

/* ================ FAQ ================ */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 880px;
}
.faq-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.faq-item summary {
  padding: 16px 18px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1.02rem;
  color: var(--plum);
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 14px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+";
  font-weight: 400;
  font-size: 1.4rem;
  color: var(--purple);
  flex-shrink: 0;
  line-height: 1;
}
.faq-item[open] summary::after { content: "−"; }
.faq-item summary:hover { background: var(--cream); }
.faq-item .faq-body {
  padding: 0 18px 18px;
  color: var(--ink-soft);
  font-size: 0.97rem;
  line-height: 1.6;
}

/* ================ RIGHTS ================ */
.rights {
  background: linear-gradient(135deg, var(--plum) 0%, var(--purple) 100%);
  color: var(--white);
}
.rights .section-head h2 { color: var(--white); }
.rights ul {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  list-style: none;
  padding: 0;
  margin: 0;
}
@media (min-width: 720px) { .rights ul { grid-template-columns: 1fr 1fr; } }
.rights li {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.rights li::before {
  content: "✓";
  color: var(--cyan);
  font-weight: 700;
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* ================ PLAN ================ */
#plan-section { background: var(--cream); }
.plan-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}
@media (min-width: 980px) { .plan-grid { grid-template-columns: 1fr 1fr; } }

.plan-form, .plan-checklist {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.plan-form h3, .plan-checklist h3 {
  font-size: 1.2rem;
  color: var(--plum);
  margin: 0 0 16px;
  font-weight: 700;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
}
.field input, .field select {
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--white);
  color: var(--ink);
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(50, 214, 230, 0.25);
}
.plan-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.plan-actions button, .plan-actions a {
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  border: 1.5px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-save { background: var(--plum); color: var(--white); }
.btn-save:hover { background: var(--purple); }
.btn-secondary {
  background: var(--white);
  color: var(--plum);
  border-color: var(--plum);
}
.btn-secondary:hover { background: var(--plum); color: var(--white); }
.field-hint {
  margin: 6px 0 0;
  font-size: 0.82rem;
  color: var(--ink-soft, #6a5660);
  line-height: 1.4;
}
.plan-actions-secondary {
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px dashed rgba(74, 22, 59, 0.18);
}
.plan-actions-secondary .btn-pill {
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  border: 1.5px solid var(--cyan);
  background: var(--cyan);
  color: var(--plum);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.plan-actions-secondary .btn-pill:hover {
  background: var(--plum);
  color: var(--white);
  border-color: var(--plum);
}
.plan-actions-secondary .btn-pill.secondary {
  background: var(--white);
  color: var(--purple);
  border-color: var(--purple);
}
.plan-actions-secondary .btn-pill.secondary:hover {
  background: var(--purple);
  color: var(--white);
}
.plan-saved-msg {
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--purple);
  font-weight: 600;
  min-height: 1.2em;
}
.plan-checklist ul { list-style: none; padding: 0; margin: 0; }
.plan-checklist li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.plan-checklist li:last-child { border-bottom: 0; }
.checklist-box {
  width: 22px; height: 22px;
  flex-shrink: 0;
  border: 2px solid var(--plum);
  border-radius: 6px;
  background: var(--white);
}

/* ================ FOOTER ================ */
.app-footer {
  background: var(--ink);
  color: rgba(255,255,255,0.85);
  padding: 40px 18px;
  font-size: 0.92rem;
}
.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.app-footer a { color: var(--cyan); }
.hotline {
  display: inline-block;
  margin-top: 6px;
  padding: 8px 14px;
  background: rgba(50,214,230,0.18);
  border-radius: 999px;
  color: var(--cyan);
  font-weight: 600;
}

/* ================ LEAFLET CUSTOMIZATION ================ */
.leaflet-container {
  background: var(--cream);
  font-family: inherit;
}
.leaflet-tooltip.county-tip {
  background: var(--plum);
  color: var(--white);
  border: 0;
  border-radius: 6px;
  font-weight: 600;
  padding: 6px 10px;
  font-size: 0.85rem;
  box-shadow: var(--shadow-md);
}
.leaflet-tooltip.county-tip::before { border-top-color: var(--plum); }

/* ================ PRINT ================ */
@media print {
  .app-header, .hero, #map-section, #guide-section, #faq-section, .rights, .plan-form, .app-footer, .panel-actions, .plan-actions-secondary, .map-controls, .legend { display: none !important; }
  body { background: white; }
  .plan-checklist { box-shadow: none; border: 0; padding: 0; }
  .plan-checklist h3 { color: black; }
}

/* ================ FOCUS ================ */
:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}
