/* Election returns content area.
 *
 * Scoped under .returns so it cannot collide with the partner's header and
 * footer styles, which are imported wholesale from their site. Colors come
 * from custom properties the build writes from the partner's brand tokens.
 */

/* The partner's utility bundle ships a site-wide h1..h6{text-align:center
 * !important}. That reads fine on their marketing pages, but centered race
 * titles over left-aligned candidate rows do not. The content area asserts
 * its own alignment; !important is needed only to beat theirs. */
.returns h1,
.returns h2 { text-align: left !important; }

.returns {
  max-width: 68rem;
  margin: 0 auto;
  padding: 2.5rem 1rem 3.5rem;
  font-family: var(--brand-body-font, system-ui, sans-serif);
  color: var(--brand-ink, #1a1a1a);
}

.returns-head h1 {
  font-family: var(--brand-display-font, var(--brand-body-font, system-ui, sans-serif));
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  line-height: 1.1;
  margin: 0 0 .5rem;
  color: var(--brand-ink, #1a1a1a);
}

.returns-updated {
  margin: 0 0 2rem;
  color: var(--brand-muted, #555);
  font-size: .95rem;
}

.returns-refresh::before { content: " · "; }

.race-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
  gap: 1.25rem;
}

.race {
  border: 1px solid var(--brand-rule, #ddd);
  border-top: 4px solid var(--brand-primary, #333);
  border-radius: .375rem;
  padding: 1.1rem 1.15rem 1.25rem;
  background: #fff;
}

.race-title {
  font-family: var(--brand-display-font, inherit);
  font-size: 1.15rem;
  margin: 0 0 .15rem;
}

.race-meta {
  margin: 0 0 .9rem;
  font-size: .82rem;
  color: var(--brand-muted, #555);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}

.status {
  display: inline-block;
  padding: .1rem .5rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* Status colors are deliberately not the brand palette: "called" must read as
 * a result, not as decoration, and must stay distinguishable if a partner's
 * primary color happens to be green or grey. */
.status[data-status="pre"]     { background: #eceff1; color: #37474f; }
.status[data-status="partial"] { background: #fff3cd; color: #7a5b00; }
.status[data-status="called"]  { background: #e3f4e7; color: #1b5e20; }

.candidates { list-style: none; margin: 0; padding: 0; }

.candidate {
  display: grid;
  grid-template-columns: .6rem 1fr auto;
  align-items: baseline;
  gap: .55rem;
  padding: .4rem 0;
  border-top: 1px solid var(--brand-rule, #eee);
}
.candidate:first-child { border-top: 0; }

.candidate-swatch {
  width: .6rem;
  height: .6rem;
  border-radius: 50%;
  background: var(--party-other);
  align-self: center;
}
.candidate[data-party="Dem"]   .candidate-swatch { background: var(--party-dem); }
.candidate[data-party="Rep"]   .candidate-swatch { background: var(--party-rep); }
.candidate[data-party="Lib"]   .candidate-swatch { background: var(--party-lib); }
.candidate[data-party="Green"] .candidate-swatch { background: var(--party-green); }
.candidate[data-party="Ind"]   .candidate-swatch { background: var(--party-ind); }

.candidate-name { font-weight: 600; }
.candidate-party { color: var(--brand-muted, #555); font-weight: 400; font-size: .85em; }

.candidate-numbers {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.candidate-percent { font-weight: 700; }
.candidate-votes { display: block; font-size: .8rem; color: var(--brand-muted, #555); }

.candidate-winner { position: relative; }
/* The check is decorative; .winner-label carries the meaning for screen readers. */
.candidate-winner .candidate-name::after { content: " ✓"; color: #1b5e20; }
.winner-label {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.race-empty { margin: .25rem 0 0; color: var(--brand-muted, #555); font-size: .9rem; }

.bar {
  grid-column: 1 / -1;
  height: 4px;
  background: var(--brand-rule, #eee);
  border-radius: 2px;
  overflow: hidden;
}
.bar-fill { display: block; height: 100%; background: var(--party-other); }
.candidate[data-party="Dem"] .bar-fill   { background: var(--party-dem); }
.candidate[data-party="Rep"] .bar-fill   { background: var(--party-rep); }
.candidate[data-party="Lib"] .bar-fill   { background: var(--party-lib); }
.candidate[data-party="Green"] .bar-fill { background: var(--party-green); }
.candidate[data-party="Ind"] .bar-fill   { background: var(--party-ind); }

.returns-attribution {
  margin-top: 2.5rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--brand-rule, #ddd);
  font-size: .82rem;
  color: var(--brand-muted, #555);
}
.returns-attribution p { margin: 0 0 .35rem; }
.returns-sources a { color: inherit; }

@media (max-width: 30rem) {
  .race-grid { grid-template-columns: 1fr; }
}


/* ---- Partner header fallback (narrow screens) ----------------------------
 * The partner's header collapses to a hamburger through their own JavaScript
 * (sp-scripts.min.js). These sites deliberately ship no partner JS, so that
 * never runs: the full nav stays expanded, the flex row refuses to wrap, and
 * the logo column is squeezed until the logo renders about 50px wide and
 * illegible. Their CSS media queries only adjust text alignment, so CSS alone
 * cannot reproduce the hamburger — this makes the header legible instead by
 * letting it wrap. A deliberate divergence from their mobile layout. */
@media (max-width: 640px) {
  .partner-header .sp-el-row { flex-wrap: wrap !important; }
  .partner-header .sp-el-col { width: 100% !important; flex: 0 0 100% !important; }
  .partner-header .sp-image-wrapper img { width: min(260px, 70vw) !important; }
  .partner-footer .sp-el-row { flex-wrap: wrap !important; }
  .partner-footer .sp-el-col { width: 100% !important; flex: 0 0 100% !important; }
}

.status[data-status="unparsed"] { background: #fff3cd; color: #7a5b00; }

/* State-specific voter assistance sits above, separately from, election data. */
.returns .voter-help { padding: 1rem 0 2.75rem; margin-bottom: 2.5rem; border-bottom: 2px solid var(--brand-rule); }
.returns .voter-help-eyebrow { color: var(--brand-muted); text-transform: uppercase; letter-spacing: .13em; font-size: .78rem; font-weight: 700; margin: 0 0 1.1rem; }
.returns .voter-help h1 { font-family: var(--brand-display-font); font-size: clamp(2.6rem, 6vw, 4.7rem); line-height: 1.02; font-weight: 700; margin: 0 0 1.4rem; color: var(--brand-ink); }
.returns .voter-help h1 span { color: #a83917; }
.returns .voter-help > p:not(.voter-help-eyebrow) { max-width: 54rem; line-height: 1.7; margin: 0 0 1rem; }
.returns .voter-help .voter-help-lead { font-size: 1.2rem; font-weight: 700; }
.returns .voter-help-contact { padding: 1.5rem; background: #fff7ed; border: 1px solid #e7cbb4; border-radius: .4rem; margin: 1.7rem 0; }
.returns .voter-help-contact h2 { font-family: var(--brand-display-font); font-size: 1.7rem; line-height: 1.2; margin: 0 0 .5rem; }
.returns .voter-help-contact p { line-height: 1.6; margin: .5rem 0 1rem; }
.returns .hotline-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .75rem; list-style: none; padding: 0; margin: 1rem 0; }
.returns .hotline-grid li { margin: 0; padding: 0; }
.returns .hotline-grid a { display: flex; flex-direction: column; gap: .25rem; background: #fff; border: 1px solid #d7bba4; border-radius: .3rem; padding: 1rem 1.1rem; color: #171717; text-decoration: none; }
.returns .hotline-grid a:hover { background: #fff1df; border-color: #a83917; }
.returns .hotline-language { font-size: .8rem; color: #535353; }
.returns .hotline-grid strong { font-size: 1.2rem; font-weight: 700; }
.returns .hotline-digits { font-size: .9rem; font-variant-numeric: tabular-nums; color: #a83917; }
.returns .hotline-digits span { float: right; }
.returns .voter-help .voter-help-small { font-size: .8rem; margin-bottom: 0; }
.returns .voter-help a:not(.hotline-grid a) { color: #8d3015; text-decoration: underline; text-underline-offset: 3px; }
.returns .voter-help-actions { display: flex; flex-wrap: wrap; gap: .8rem 1.5rem; font-size: .9rem; font-weight: 600; }
.returns .chat-widget { position: fixed; right: 20px; bottom: 20px; z-index: 2147483000; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; pointer-events: none; }
.returns .chat-widget > * { pointer-events: auto; }
.returns .chat-panel { width: 400px; height: min(600px, calc(100vh - 110px)); border-radius: 16px; overflow: hidden; background: #fff; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.returns .chat-panel[hidden] { display: none; }
.returns .chat-panel { position: relative; }
.returns .chat-panel::before { content: "Loading VOTE-E…"; position: absolute; inset: 0; display: grid; place-items: center; color: #5b2a9e; font-weight: 600; }
.returns .chat-panel iframe { position: relative; display: block; width: 100%; height: 100%; border: 0; }
.returns .chat-launcher { display: inline-flex; align-items: center; gap: .5rem; padding: .8rem 1.2rem; border-radius: 999px; background: #5b2a9e; color: #fff; font-weight: 700; font-size: 1rem; text-decoration: none; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.returns .chat-launcher:hover { background: #4a2182; }
.returns .chat-launcher svg { width: 22px; height: 22px; }
.returns .chat-icon-open { fill: currentColor; }
.returns .chat-icon-close { display: none; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }
.returns .chat-launcher.is-open .chat-icon-open { display: none; }
.returns .chat-launcher.is-open .chat-icon-close { display: block; }
@media(max-width: 480px) {
  .returns .chat-widget { right: 12px; bottom: 12px; left: 12px; }
  .returns .chat-panel { width: 100%; height: calc(100dvh - 90px); }
}
.returns .voter-help-dates { margin: 1.7rem 0; }
.returns .voter-help-dates h2 { font-family: var(--brand-display-font); font-size: 1.5rem; line-height: 1.2; margin: 0 0 .75rem; }
.returns .voter-help-dates ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; list-style: none; margin: 0; padding: 0; }
.returns .voter-help-dates li { display: flex; flex-direction: column; gap: .2rem; margin: 0; padding: 1rem 1.1rem; border: 1px solid var(--brand-rule, #ddd); border-left: 4px solid #a83917; border-radius: .3rem; background: #fff; }
.returns .voter-help-date-label { color: var(--brand-muted); text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; font-weight: 700; }
.returns .voter-help-dates strong { font-size: 1.25rem; }
.returns .voter-help-date-note { font-size: .85rem; color: var(--brand-muted); }
@media(max-width: 580px) { .returns .voter-help-dates ul { grid-template-columns: 1fr; } }
.returns .voter-help-resources { margin-top: 2rem; }
.returns .voter-help-resources h2 { font-family: var(--brand-display-font); font-size: 1.5rem; line-height: 1.2; margin: 0 0 .6rem; }
.returns .voter-help-resources ul { margin: 0; padding-left: 1.2rem; line-height: 1.9; }
.returns .voter-help-sources { font-size: .8rem; color: #535353; margin-top: 1.5rem; line-height: 1.6; }
.returns .voter-help-sources summary { cursor: pointer; padding: .4rem 0; }
.returns a:focus-visible, .returns summary:focus-visible { outline: 3px solid #8d3015; outline-offset: 4px; }
.returns .returns-head h2 { font-family: var(--brand-display-font); font-size: clamp(1.75rem,4vw,2.75rem); line-height: 1.1; margin: 0 0 .5rem; }
.returns h3 { text-align: left !important; }
@media(max-width: 580px) {
  .returns .hotline-grid { grid-template-columns: 1fr; }
  .returns .voter-help-contact { padding: 1rem; }
}
.returns .voter-help-quick { margin: 0 0 1.3rem; }
@media(max-width: 640px) {
  .state-new-mexico .partner-header #sp-yf72e5g2qmb6 { padding: 16px 12px !important; }
  .state-new-mexico .partner-header #sp-rtm87jrxco6 { gap: 10px !important; }
  .state-new-mexico .partner-header .sp-el-block { margin: 0 !important; padding: 0 !important; }
  .state-new-mexico .partner-header #menu-header { display: flex !important; flex-direction: row !important; flex-wrap: wrap; justify-content: center; gap: 18px; padding: 8px 0 !important; }
  .state-new-mexico .partner-header #menu-header > li { width: auto !important; margin: 0 !important; padding: 0 !important; }
  .state-new-mexico .partner-header #menu-header > li > a { font-size: 13px !important; line-height: 1.5 !important; padding: 4px 0 !important; }
  .state-new-mexico .partner-header #sp-ymqudpwvgiz { padding: 10px 20px !important; font-size: 13px !important; }
  .state-new-mexico .returns { padding-top: 1.5rem; }
}
