/* ==========================================================================
   elections.css — shared design system for the Caldwell County Elections
   subdomain (elections.caldwellcountytx.site) and the elections-* pages.

   Design goals, in priority order, because this is an elections office:
     1. A voter must be able to answer "when, where, am I registered, what's
        on my ballot" within one screen of the page landing.
     2. Everything must survive being read on a phone in a parking lot.
     3. WCAG 2.1 AA at minimum — this is ADA Title II regulated content.
        Never dim text with opacity; use --cc-gold-text (#7a5c00) for gold
        text on light backgrounds (the bright gold fails contrast as text).

   Loaded after style.css, so it can lean on the county design tokens.
   ========================================================================== */

/* ── Hero: the "next election" banner ─────────────────────────────────── */
.el-hero {
  background: linear-gradient(135deg, var(--cc-blue-dark) 0%, var(--cc-blue) 55%, var(--cc-blue-mid) 100%);
  color: #fff;
  padding: 2.75rem 0 2.25rem;
  position: relative;
  overflow: hidden;
}
.el-hero::after {  /* subtle seal watermark; decorative only */
  content: "";
  position: absolute;
  right: -60px; top: 50%;
  width: 320px; height: 320px;
  transform: translateY(-50%);
  background: var(--img-seal) center/contain no-repeat;
  opacity: .07;
  pointer-events: none;
}
.el-hero-inner { position: relative; z-index: 1; }
.el-hero-eyebrow {
  display: inline-block;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--cc-gold-light);
  background: rgba(0, 0, 0, .28);
  border: 1px solid rgba(245, 230, 196, .45);
  border-radius: 999px;
  padding: .3rem .85rem;
  margin-bottom: .9rem;
}
.el-hero h1 {
  color: #fff;
  font-size: clamp(1.7rem, 4.2vw, 2.6rem);
  line-height: 1.15;
  margin: 0 0 .4rem;
}
.el-hero-date {
  font-size: clamp(1rem, 2.2vw, 1.2rem);
  color: var(--cc-gold-light);
  font-weight: 600;
  margin: 0 0 1.25rem;
}
.el-hero-note { color: #e8f0f8; max-width: 60ch; margin: 0; }

/* Countdown — populated by js/elections-ui.js, degrades to static text */
.el-countdown {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin: 1.35rem 0 0;
  padding: 0;
  list-style: none;
}
.el-countdown li {
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: var(--radius);
  padding: .6rem .95rem;
  min-width: 5.2rem;
  text-align: center;
}
.el-countdown .num {
  display: block;
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.el-countdown .lbl {
  display: block;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #dce8f4;
  margin-top: .15rem;
}

/* ── Quick actions: the four things voters actually came for ──────────── */
.el-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.el-action {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  background: #fff;
  border: 1px solid var(--cc-gray-mid);
  border-left: 4px solid var(--cc-gold);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  text-decoration: none;
  color: var(--cc-text);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  height: 100%;
}
.el-action:hover,
.el-action:focus-visible {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-left-color: var(--cc-blue);
}
.el-action strong {
  font-size: 1.02rem;
  color: var(--cc-blue);
  line-height: 1.3;
}
.el-action span { font-size: .875rem; color: var(--cc-text-light); line-height: 1.45; }
.el-action .el-action-ext {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--cc-gold-text);
  margin-top: auto;
  padding-top: .5rem;
}

/* ── Stat strip: registered voters, population, precincts ─────────────── */
.el-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
  gap: 1px;
  background: var(--cc-gray-mid);
  border: 1px solid var(--cc-gray-mid);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 0;
}
.el-stat { background: #fff; padding: 1.15rem 1.25rem; text-align: center; margin: 0; }
.el-stat dt {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--cc-text-light);
  font-weight: 600;
  margin: 0 0 .3rem;
}
.el-stat dd {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--cc-blue);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.el-stat .el-stat-asof { display: block; font-size: .72rem; font-weight: 500; color: var(--cc-text-light); margin-top: .2rem; }

/* ── Key-dates table: collapses to labelled cards on phones ───────────── */
.el-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.el-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--cc-gray-mid);
  border-radius: var(--radius);
  overflow: hidden;
}
.el-table caption {
  caption-side: top;
  text-align: left;
  font-weight: 700;
  color: var(--cc-blue);
  padding: 0 0 .6rem;
  font-size: 1rem;
}
.el-table th,
.el-table td {
  padding: .75rem .95rem;
  text-align: left;
  border-bottom: 1px solid var(--cc-gray-mid);
  vertical-align: top;
  line-height: 1.45;
}
.el-table thead th {
  background: var(--cc-blue);
  color: #fff;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: none;
}
.el-table tbody tr:last-child th,
.el-table tbody tr:last-child td { border-bottom: none; }
.el-table tbody tr:nth-child(even) td,
.el-table tbody tr:nth-child(even) th { background: var(--cc-blue-xlight); }
.el-table tbody th { font-weight: 600; color: var(--cc-text); }
.el-table .el-date-cell { white-space: nowrap; font-weight: 700; color: var(--cc-blue); }
.el-table .el-pct {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--cc-blue);
  white-space: nowrap;
}

/* Row highlight for a deadline that has already passed */
.el-table tr.is-past th,
.el-table tr.is-past td { color: var(--cc-text-light); }
.el-table tr.is-past .el-date-cell { color: var(--cc-text-light); }
.el-past-tag {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--cc-gray);
  color: var(--cc-text-light);
  border: 1px solid var(--cc-gray-mid);
  border-radius: 4px;
  padding: .1rem .4rem;
  margin-left: .45rem;
  vertical-align: middle;
}

@media (max-width: 620px) {
  .el-table.el-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .el-table.el-stack,
  .el-table.el-stack tbody,
  .el-table.el-stack tr,
  .el-table.el-stack th,
  .el-table.el-stack td { display: block; width: 100%; }
  .el-table.el-stack tr {
    border-bottom: 2px solid var(--cc-gray-mid);
    padding: .35rem 0;
  }
  .el-table.el-stack tr:last-child { border-bottom: none; }
  .el-table.el-stack th,
  .el-table.el-stack td { border-bottom: none; padding: .3rem .9rem; }
  .el-table.el-stack tbody tr:nth-child(even) td,
  .el-table.el-stack tbody tr:nth-child(even) th { background: transparent; }
  .el-table.el-stack td[data-label]::before {
    content: attr(data-label) ": ";
    font-weight: 700;
    color: var(--cc-blue);
  }
}

/* ── Polling-location cards ───────────────────────────────────────────── */
.el-locs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(270px, 100%), 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.el-loc {
  background: #fff;
  border: 1px solid var(--cc-gray-mid);
  border-top: 4px solid var(--cc-blue);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.el-loc.is-main { border-top-color: var(--cc-gold); }
.el-loc-pcts {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin: 0 0 .1rem;
  padding: 0;
  list-style: none;
}
.el-loc-pcts li {
  font-size: .78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--cc-blue-light);
  color: var(--cc-blue);
  border: 1px solid #c3d6e8;
  border-radius: 4px;
  padding: .12rem .42rem;
}
.el-loc h3 { margin: 0; font-size: 1.05rem; color: var(--cc-blue); line-height: 1.3; }
.el-loc-addr { margin: 0; font-size: .9rem; color: var(--cc-text-light); line-height: 1.5; }
.el-loc-map {
  margin-top: auto;
  padding-top: .5rem;
  font-size: .85rem;
  font-weight: 600;
}
.el-loc-badge {
  align-self: flex-start;
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--cc-gold-light);
  color: var(--cc-gold-text);
  border: 1px solid #e0c98c;
  border-radius: 4px;
  padding: .15rem .45rem;
}

/* ── Callouts / notices ───────────────────────────────────────────────── */
.el-callout {
  border: 1px solid var(--cc-gray-mid);
  border-left: 5px solid var(--cc-blue);
  background: var(--cc-blue-xlight);
  border-radius: var(--radius);
  padding: 1.05rem 1.2rem;
  margin: 1.25rem 0;
}
.el-callout > :first-child { margin-top: 0; }
.el-callout > :last-child { margin-bottom: 0; }
.el-callout h2,
.el-callout h3 { margin: 0 0 .45rem; font-size: 1.02rem; color: var(--cc-blue); }
.el-callout.is-warn { border-left-color: var(--cc-gold); background: #fdf7e8; }
.el-callout.is-warn h2,
.el-callout.is-warn h3 { color: var(--cc-gold-text); }
.el-callout.is-legal {
  border-left-color: var(--cc-red);
  background: #fdf1f1;
}
.el-callout.is-legal h2,
.el-callout.is-legal h3 { color: var(--cc-red); }
.el-callout cite { display: block; margin-top: .5rem; font-size: .82rem; color: var(--cc-text-light); font-style: normal; }

/* ── Numbered steps ───────────────────────────────────────────────────── */
.el-steps { counter-reset: elstep; list-style: none; margin: 0; padding: 0; display: grid; gap: .85rem; }
.el-steps > li {
  counter-increment: elstep;
  position: relative;
  padding: .95rem 1.1rem .95rem 3.4rem;
  background: #fff;
  border: 1px solid var(--cc-gray-mid);
  border-radius: var(--radius);
  line-height: 1.55;
}
.el-steps > li::before {
  content: counter(elstep);
  position: absolute;
  left: 1rem; top: .95rem;
  width: 1.75rem; height: 1.75rem;
  border-radius: 50%;
  background: var(--cc-blue);
  color: #fff;
  font-weight: 800;
  font-size: .92rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.el-steps > li > strong { display: block; color: var(--cc-blue); margin-bottom: .15rem; }

/* ── FAQ / disclosure ─────────────────────────────────────────────────── */
.el-faq { display: grid; gap: .6rem; }
.el-faq details {
  background: #fff;
  border: 1px solid var(--cc-gray-mid);
  border-radius: var(--radius);
  overflow: hidden;
}
.el-faq summary {
  cursor: pointer;
  padding: .9rem 1.1rem;
  font-weight: 600;
  color: var(--cc-blue);
  list-style: none;
  display: flex;
  align-items: center;
  gap: .6rem;
  line-height: 1.4;
}
.el-faq summary::-webkit-details-marker { display: none; }
.el-faq summary::before {
  content: "";
  flex: 0 0 auto;
  width: .55rem; height: .55rem;
  border-right: 2px solid var(--cc-gold-text);
  border-bottom: 2px solid var(--cc-gold-text);
  transform: rotate(-45deg);
  transition: transform var(--transition);
}
.el-faq details[open] > summary::before { transform: rotate(45deg); }
.el-faq summary:hover { background: var(--cc-blue-xlight); }
.el-faq summary:focus-visible { box-shadow: var(--focus-ring-light); outline: none; }
.el-faq .el-faq-body { padding: 0 1.1rem 1.05rem; border-top: 1px solid var(--cc-gray-mid); padding-top: .9rem; }
.el-faq .el-faq-body > :first-child { margin-top: 0; }
.el-faq .el-faq-body > :last-child { margin-bottom: 0; }

/* ── Document link lists ──────────────────────────────────────────────── */
.el-docs { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.el-docs li { margin: 0; }
.el-docs a {
  display: flex;
  align-items: baseline;
  gap: .55rem;
  padding: .6rem .8rem;
  background: #fff;
  border: 1px solid var(--cc-gray-mid);
  border-radius: 6px;
  text-decoration: none;
  color: var(--cc-blue);
  font-size: .93rem;
  line-height: 1.45;
  transition: background var(--transition), border-color var(--transition);
  /* Document names are raw filenames with no spaces (e.g.
     "2026JointPrimaryRunoffMay26-UnofficialRecon") and cannot wrap on their
     own — they bled past the viewport at 320px. */
  overflow-wrap: anywhere;
  min-width: 0;
}
.el-docs a:hover,
.el-docs a:focus-visible { background: var(--cc-blue-xlight); border-color: var(--cc-blue-mid); text-decoration: underline; }
.el-docs a .el-doc-type {
  flex: 0 0 auto;
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .05em;
  color: var(--cc-gold-text);
  background: var(--cc-gold-light);
  border-radius: 3px;
  padding: .1rem .35rem;
  text-transform: uppercase;
}

/* ── Section scaffolding ──────────────────────────────────────────────── */
.el-section { padding: 2.5rem 0; }
.el-section:nth-of-type(even) { background: var(--cc-gray); }
.el-section > .container > h2 {
  font-size: clamp(1.3rem, 2.8vw, 1.7rem);
  color: var(--cc-blue);
  margin: 0 0 .4rem;
}
.el-section-lede { color: var(--cc-text-light); max-width: 68ch; margin: 0 0 1.5rem; line-height: 1.6; }
.el-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 1.5rem; align-items: start; }
.el-card {
  background: #fff;
  border: 1px solid var(--cc-gray-mid);
  border-radius: var(--radius);
  padding: 1.3rem 1.4rem;
  box-shadow: var(--shadow-sm);
}
.el-card > :first-child { margin-top: 0; }
.el-card > :last-child { margin-bottom: 0; }
.el-card h3 { color: var(--cc-blue); margin: 0 0 .6rem; font-size: 1.1rem; }

/* Contact block */
.el-contact { display: grid; gap: .3rem; margin: 0; }
.el-contact div { display: flex; gap: .5rem; flex-wrap: wrap; line-height: 1.6; }
.el-contact dt { font-weight: 700; color: var(--cc-blue); min-width: 4.5rem; }
.el-contact dd { margin: 0; }

/* Jump / on-this-page nav */
.el-jump { background: #fff; border: 1px solid var(--cc-gray-mid); border-radius: var(--radius); padding: 1rem 1.15rem; margin-bottom: 1.75rem; }
.el-jump h2 { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--cc-text-light); margin: 0 0 .6rem; }
.el-jump ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .45rem .85rem; }
.el-jump a { font-size: .92rem; font-weight: 600; }

/* Related-pages footer nav */
.el-related { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: .7rem; list-style: none; margin: 0; padding: 0; }
.el-related a {
  display: block;
  padding: .75rem .9rem;
  background: #fff;
  border: 1px solid var(--cc-gray-mid);
  border-radius: 6px;
  text-decoration: none;
  color: var(--cc-blue);
  font-weight: 600;
  font-size: .93rem;
  transition: background var(--transition), border-color var(--transition);
}
.el-related a:hover,
.el-related a:focus-visible { background: var(--cc-blue-light); border-color: var(--cc-blue-mid); }

/* Print: voters print polling locations and key dates */
@media print {
  .el-hero { background: none; color: #000; padding: 0 0 1rem; }
  .el-hero::after { display: none; }
  .el-hero h1, .el-hero-date, .el-hero-note { color: #000; }
  .el-countdown, .el-jump, .el-related { display: none; }
  .el-section { padding: .75rem 0; background: none !important; }
  .el-loc, .el-card, .el-table { box-shadow: none; break-inside: avoid; }
  .el-faq details { break-inside: avoid; }
  .el-faq details:not([open]) .el-faq-body { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  .el-action, .el-docs a, .el-related a, .el-faq summary::before { transition: none; }
  .el-action:hover, .el-action:focus-visible { transform: none; }
}

/* Narrowest phones: the nowrap on date cells overflows the stacked cell
   (measured "Tuesday, November 3, 2026" needing 279px in a 270px box at a
   320px viewport). Below 380px let dates wrap rather than clip. */
@media (max-width: 380px) {
  .el-table .el-date-cell { white-space: normal; }
}

/* ── Results tables ─────────────────────────────────────────────────────
   One table per contest. The bar is decoration only: the vote count and
   the percentage are always present as text, so nothing is conveyed by
   length or colour alone (WCAG 1.4.1).                                    */
.el-race {
  margin: 0 0 1.6rem;
  /* Border-collapse plus 1px borders can push a 100%-width table a couple of
     pixels past a 320px viewport. Same scroll affordance the other tables use. */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.el-rtable { max-width: 100%; }
.el-race:last-child { margin-bottom: 0; }
.el-rtable { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--cc-gray-mid); border-radius: var(--radius); overflow: hidden; }
.el-rtable caption {
  caption-side: top;
  text-align: left;
  padding: 0 0 .5rem;
  color: var(--cc-blue);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.35;
}
.el-rtable caption .el-votefor {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--cc-text-light);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: .15rem;
}
.el-rtable th, .el-rtable td { padding: .5rem .8rem; border-bottom: 1px solid var(--cc-gray-mid); vertical-align: middle; }
.el-rtable thead th {
  background: var(--cc-blue-xlight);
  color: var(--cc-blue);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  text-align: left;
  border-bottom: 1px solid var(--cc-gray-mid);
}
.el-rtable thead th.num, .el-rtable td.num { text-align: right; }
.el-rtable tbody tr:last-child th, .el-rtable tbody tr:last-child td { border-bottom: none; }
.el-rtable tbody th { font-weight: 600; color: var(--cc-text); text-align: left; }
.el-rtable td.num { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--cc-blue); white-space: nowrap; }
.el-share { min-width: 8.5rem; }
.el-share-wrap { display: flex; align-items: center; gap: .55rem; }
.el-bar {
  flex: 1 1 auto;
  height: .55rem;
  min-width: 2px;
  border-radius: 3px;
  background: var(--cc-gray);
  overflow: hidden;
  position: relative;
}
.el-bar::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--pct, 0%);
  background: var(--cc-blue-mid);
  border-radius: 3px;
}
.el-race--lead .el-bar::before { background: var(--cc-blue); }
.el-pct { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--cc-text); min-width: 3.6rem; text-align: right; }
.el-rtable tfoot td, .el-rtable tfoot th {
  background: var(--cc-blue-xlight);
  font-size: .82rem;
  color: var(--cc-text-light);
  border-top: 1px solid var(--cc-gray-mid);
}

/* Status badge for an election's certification state */
.el-status {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-radius: 999px;
  padding: .22rem .7rem;
  border: 1px solid;
}
.el-status--unofficial { background: #fdf7e8; color: var(--cc-gold-text); border-color: #e0c98c; }
.el-status--official { background: #eaf5ec; color: #1e5b2e; border-color: #a8cfb2; }

.el-report-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .5rem .9rem;
  margin: 0 0 .9rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--cc-gray-mid);
}
.el-report-head h3 { margin: 0; font-size: 1.05rem; color: var(--cc-blue); }
.el-report-meta { font-size: .84rem; color: var(--cc-text-light); }

@media (max-width: 560px) {
  .el-rtable th, .el-rtable td { padding: .45rem .55rem; }
  .el-share { min-width: 6rem; }
  .el-pct { min-width: 3.2rem; font-size: .88rem; }
  .el-bar { display: none; }   /* numbers carry the meaning; bar is decoration */
}
