/* Presidential elections (presidential-elections.php). A ruled ledger on the paper canvas: ink hairlines, serif figures, square cells.
   Party colour is only ever a band behind letters that are written out; the key says what each letter means. Tokens only (css/vf-tokens.css).
   Loads after css/archive-charts.css, which supplies the .ac-c-* colour classes and the tile-map pieces. */

.pe-main { padding-bottom: 96px; }
.pe-lead { max-width: 46rem; margin: 0 0 14px; color: var(--vf-ink); font: 600 1.3rem/1.38 var(--vf-font-head); }
.pe-h2 { margin: 0 0 12px; padding-top: 10px; border-top: 2px solid var(--vf-ink); color: var(--vf-ink); font: 700 1.35rem/1.2 var(--vf-font-head); }
.pe-h3 { margin: 26px 0 8px; color: var(--vf-ink); font: 700 1.1rem/1.25 var(--vf-font-head); }
.pe-fact { max-width: 62ch; margin: 0 0 10px; color: var(--vf-ink-2); font-size: .98rem; line-height: 1.5; }
.pe-callout { max-width: 62ch; margin: 0 0 18px; padding: 10px 14px; background: var(--vf-surface); color: var(--vf-ink); font-size: .98rem; line-height: 1.5; }
.pe-note { max-width: 70ch; margin: 8px 0 0; color: var(--vf-mute); font-size: .84rem; line-height: 1.5; }
.pe-actions { margin: 14px 0 6px; font-size: .95rem; }
.pe-actions a { display: inline-block; padding: 6px 0; color: var(--vf-blue-text); }
.pe-source { max-width: 70ch; margin: 6px 0 0; color: var(--vf-mute); font-size: .8rem; line-height: 1.45; overflow-wrap: anywhere; }
.pe-source a { color: var(--vf-blue-text); }
.pe-source code { font-size: .78rem; }
.pe-gap { color: var(--vf-ink-2); font-style: italic; }
.pe-dash { color: var(--vf-mute); }
.pe-pct { color: var(--vf-mute); font-variant-numeric: tabular-nums; font-size: .88em; }
.pe-fn { margin-left: 2px; color: var(--vf-mute); font-size: .7em; }

/* the strip of every election: a ruled sheet of cells, year above, party band with letters, surname below */
.pe-strip { margin: 0 0 6px; }
.pe-strip-list { position: relative; display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); margin: 0; padding: 0; list-style: none; border-top: 2px solid var(--vf-ink); border-left: 1px solid var(--vf-rule-strong); }
.pe-cell { border-right: 1px solid var(--vf-rule-strong); border-bottom: 1px solid var(--vf-rule-strong); background: var(--vf-surface); min-width: 0; }
.pe-cell a { display: flex; flex-direction: column; gap: 3px; height: 100%; min-height: 66px; padding: 6px 5px 6px; color: var(--vf-ink); text-decoration: none; }
.pe-cell a:hover .pe-nm { text-decoration: underline; text-underline-offset: 3px; }
.pe-cell a:focus-visible { outline: 3px solid var(--vf-blue); outline-offset: -3px; }
.pe-yr { color: var(--vf-ink-2); font: 700 .8rem/1 var(--vf-font-head); font-variant-numeric: tabular-nums; }
.pe-band { display: block; padding: 3px 0 2px; background: var(--ac-fill); color: var(--ac-on); font: 800 .72rem/1.15 var(--vf-font-body); letter-spacing: .06em; text-align: center; overflow: hidden; white-space: nowrap; }
.pe-nm { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--vf-ink-2); font-size: .72rem; line-height: 1.2; }
.pe-cell.ac-c-none .pe-band { background: var(--vf-surface-2); color: var(--vf-ink-2); box-shadow: inset 0 0 0 1px var(--vf-rule-strong); }
.pe-cell.pe-here { position: relative; background: var(--vf-surface-2); box-shadow: inset 0 0 0 3px var(--vf-ink); }
.pe-cell.pe-here .pe-yr { color: var(--vf-ink); }
.pe-key { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 10px 0 0; padding: 0; list-style: none; color: var(--vf-ink-2); font-size: .84rem; }
.pe-key li { display: inline-flex; align-items: center; gap: 7px; }
.pe-key-sw { min-width: 26px; padding: 2px 4px 1px; background: var(--ac-fill); color: var(--ac-on); font: 800 .7rem/1.2 var(--vf-font-body); letter-spacing: .05em; text-align: center; }
.pe-key .ac-c-none .pe-key-sw { background: var(--vf-surface-2); color: var(--vf-ink-2); box-shadow: inset 0 0 0 1px var(--vf-rule-strong); }

/* views: one pattern on every archive page, a ruled underline 44px tall */
.pe-tabs { margin: 18px 0 18px; border-bottom: 1px solid var(--vf-rule-strong); }
.pe-tabs ul, .pe-tabs ol { display: flex; flex-wrap: wrap; gap: 0 22px; margin: 0; padding: 0; list-style: none; }
.pe-tabs a { display: inline-flex; align-items: center; min-height: 44px; margin-bottom: -1px; padding: 0 0 2px; border-bottom: 3px solid transparent; color: var(--vf-ink-2); font: 700 .98rem/1.2 var(--vf-font-body); text-decoration: none; }
.pe-tabs a:hover { color: var(--vf-ink); border-bottom-color: var(--vf-rule-strong); }
.pe-tabs a[aria-current="page"] { color: var(--vf-ink); border-bottom-color: var(--vf-ink); }
.pe-tabs a:focus-visible { outline: 3px solid var(--vf-blue); outline-offset: 2px; }
.pe-pick { max-width: 640px; }

/* change map: two sides, three steps each. The fill is a tint of the party colour; the text on every tile says which side and how far. */
.pe-sd1 { --ac-fill: color-mix(in srgb, var(--vf-dem) 22%, var(--vf-surface)); --ac-on: var(--vf-ink); }
.pe-sd2 { --ac-fill: color-mix(in srgb, var(--vf-dem) 52%, var(--vf-surface)); --ac-on: var(--vf-ink); }
.pe-sd3 { --ac-fill: var(--vf-dem); --ac-on: var(--vf-on-navy); }
.pe-sr1 { --ac-fill: color-mix(in srgb, var(--vf-rep) 22%, var(--vf-surface)); --ac-on: var(--vf-ink); }
.pe-sr2 { --ac-fill: color-mix(in srgb, var(--vf-rep) 52%, var(--vf-surface)); --ac-on: var(--vf-ink); }
.pe-sr3 { --ac-fill: var(--vf-rep); --ac-on: var(--vf-on-navy); }
.pe-snone { --ac-fill: var(--vf-surface-2); --ac-on: var(--vf-mute); }
.pe-snone .ac-tile-r { stroke-dasharray: 3 2; stroke-opacity: .6; }
.pe-swingmap .ac-tv { font-size: 9.5px; }
.pe-swingmap .ac-tile:hover .ac-tile-r { stroke-opacity: .9; stroke-width: 2; }
.pe-swingmap a:focus-visible { outline: 3px solid var(--vf-blue); outline-offset: 2px; }

/* tables: stacked cards on a phone, a ruled ledger from tablet up */
.pe-scroll { overflow-x: auto; margin: 0 0 6px; }
.pe-scroll:focus-visible { outline: 3px solid var(--vf-blue); outline-offset: 2px; }
.pe-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.pe-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.pe-table tr { display: block; margin: 0 0 8px; padding: 10px 12px; border: 1px solid var(--vf-rule-strong); background: var(--vf-surface); }
.pe-table th[scope="row"] { display: block; margin: 0 0 4px; color: var(--vf-ink); font: 700 1rem var(--vf-font-head); text-align: left; }
.pe-table th[scope="row"] a { color: inherit; text-decoration-color: var(--vf-rule-strong); text-underline-offset: 3px; }
.pe-table td { display: block; padding: 2px 0; color: var(--vf-ink); font-size: .95rem; overflow-wrap: anywhere; }
.pe-table td::before { content: attr(data-label) ": "; color: var(--vf-mute); font-size: .75rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.pe-table td.pe-gapcell::before { content: none; }
.pe-table tfoot td::before { content: none; }
.pe-chip { display: inline-block; min-width: 24px; padding: 1px 4px; background: var(--ac-fill); color: var(--ac-on); font: 800 .68rem/1.3 var(--vf-font-body); letter-spacing: .05em; text-align: center; }
.pe-chip.ac-c-none { background: var(--vf-surface-2); color: var(--vf-ink-2); box-shadow: inset 0 0 0 1px var(--vf-rule-strong); }
.pe-table .pe-lead-cell { font-weight: 800; }

@media (min-width: 760px) {
  .pe-strip-list { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
  .pe-table thead { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .pe-table tr { display: table-row; margin: 0; padding: 0; border: 0; border-left: 0; background: transparent; }
  .pe-table th, .pe-table td { padding: 8px 10px; border-bottom: 1px solid var(--vf-rule); text-align: left; vertical-align: top; }
  .pe-table thead th { position: sticky; top: 0; background: var(--vf-surface); border-bottom: 2px solid var(--vf-ink); color: var(--vf-mute); font-size: .6875rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; vertical-align: bottom; }
  .pe-table thead th a { color: inherit; text-decoration: none; }
  .pe-table thead th a:hover { color: var(--vf-ink); text-decoration: underline; text-underline-offset: 3px; }
  .pe-table thead th[aria-sort] { color: var(--vf-ink); }
  .pe-table thead th[aria-sort="ascending"] a::after { content: " \2191"; }
  .pe-table thead th[aria-sort="descending"] a::after { content: " \2193"; }
  .pe-table th[scope="row"] { display: table-cell; margin: 0; font-size: .95rem; }
  .pe-table td { display: table-cell; font-size: .95rem; }
  .pe-table td.pe-n, .pe-table th.pe-n { text-align: right; }
  .pe-table td::before { content: none; }
  .pe-table tr.pe-none th, .pe-table tr.pe-none td { color: var(--vf-mute); }
  .pe-table tfoot td, .pe-table tfoot th { border-top: 2px solid var(--vf-ink); border-bottom: 0; font-weight: 800; }
  .pe-table td.pe-gapcell { text-align: left; }
}
@media print { .pe-tabs, .pe-pick { display: none; } .pe-cell.pe-here { box-shadow: inset 0 0 0 3px #000; } }

.pe-pick label { flex: 0 0 auto; }
.pe-pick select { flex: 0 1 180px; }
.pe-pick #pe-state { flex-basis: 260px; }

/* second paragraph under the title: body size, not a second headline */
body.newsroom-static main.nr-static-main > .section:first-child p.measure { max-width: 46rem; margin-top: 10px; color: var(--vf-ink-2) !important; font: 400 1.0625rem/1.55 var(--vf-font-body) !important; }
/* controls: square, ruled, 44px */
.pe-main .btn, .pe-main select, .pe-main input[type="search"], .pe-main input[type="number"], .pe-main input[type="text"] { border-radius: 0; min-height: 44px; }

/* phones: the strip of every election is one row that scrolls sideways, so the result comes first */
@media (max-width: 759px) {
  .pe-strip-list { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 76px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; }
  .pe-cell { scroll-snap-align: start; }
}
.pe-tabs a { display: inline-flex; align-items: center; min-height: 44px; padding-top: 0; padding-bottom: 0; }
