/*
 * home.css — the front door only. Shared rules stay in record.css; anything here that restyles a
 * shared class is scoped to body.home so no other page changes.
 *
 * Rules the pictures keep:
 *   - a party is always a position, a shape and a printed count as well as a colour
 *   - gold marks "yours" and nothing else inside a picture
 *   - nothing a visitor has to read is smaller than 12px
 *   - graphics hold 3:1 against the surface they sit on; text holds 4.5:1
 */

/* ── Helpers ─────────────────────────────────────────────────────────── */
.vh { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 20; background: var(--paper); color: var(--ink); font-weight: 700; font-size: 14px; padding: 10px 14px; border-radius: 4px; }
.skip:focus { top: 8px; }

body.home {
  --dem-fill: var(--dem); --rep-fill: var(--rep); --ind-fill: #98a1ae; --oth-fill: #d9c9a3; --viz-ground: var(--ink);
  --paper-hi: #fff;
  /* The map: land, the line between states, and land under the pointer. */
  --map-land: #1a2029; --map-land-hi: #26303d; --map-edge: #0b0e12; --map-chip: #1a2029;
  /* "How many seats": one neutral hue in five steps. */
  --step-1: #1d2430; --step-2: #2b3546; --step-3: #3d4b63; --step-4: #526380; --step-5: #a9b9d3;
  /* The atmosphere behind the search and the map: near the ground colour, never a party colour. */
  --atmos-1: #0e1116; --atmos-2: #141a23; --atmos-3: #1a2130; --atmos-4: #1c1a17; --atmos-grain: 0.035;
  /* Marks on the paper-coloured hover labels. */
  --tip-dem: #2c62b0; --tip-rep: #b23632; --tip-ind: #5b6472; --tip-oth: #7a6a3f;
  --card-glass: rgba(18, 23, 31, .94);
}

/* The masthead, the banner and the footer are the shared site shell in record.css. */

/* ── Search: one row, no paragraph ───────────────────────────────────── */
.home section.finder { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 30px; align-items: start; padding: 18px 22px 0; }
.home .finder h1 { margin: 9px 0 0; font-size: 28px; line-height: 1.15; white-space: nowrap; }
.home .find { min-width: 0; }
.home #reps-flash, .home #reps-results { grid-column: 1 / -1; }
.home .searchbox input { padding: 13px 14px; }
.find-under { position: relative; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; }
.find-stored { font-family: var(--mono); font-size: 12.5px; color: var(--paper-mute); margin-right: auto; }
.home .locate-btn { margin-top: 0; padding: 7px 12px; font-size: 12px; width: auto; min-height: 0; }
/* .btn is display:inline-flex, which would beat the hidden attribute. */
.home #reps-locate[hidden] { display: none; }

/* The lookup's answer: how it was found, and the quieter group of House candidates. */
.home .basis-tag { font-family: var(--mono); font-size: 12px; letter-spacing: .02em; color: var(--paper-dim); padding: 2px 8px; border: 1px solid var(--line-2); border-radius: 10px; }
.home .reps-cands { margin-top: 20px; padding-top: 14px; border-top: 1px dashed var(--line-2); }
.home .reps-cands h3 { margin: 0 0 10px; font-family: var(--sans); font-size: 15px; font-weight: 700; color: var(--paper-dim); }
.home .reps-head { margin: 18px 0 0; padding-bottom: 8px; gap: 6px 12px; align-items: center; justify-content: flex-start; }
.home .reps-note { margin: 8px 0 12px; max-width: 72ch; font-size: 13.5px; line-height: 1.45; color: var(--paper-dim); }
.home .reps-cands .reps-note { margin-top: 0; }

/* One member, one row: the whole row is the link to the record. */
.rep-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
.rep-row { --accent: var(--paper-mute); --accent-ink: var(--paper-dim); position: relative; display: flex; align-items: center; gap: 12px; min-height: 76px; padding: 10px 12px 10px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; color: var(--paper); text-decoration: none; transition: border-color .2s, background-color .2s; }
.rep-row.dem { --accent: var(--dem); --accent-ink: var(--dem-ink); }
.rep-row.rep { --accent: var(--rep); --accent-ink: var(--rep-ink); }
.rep-row::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 2px 2px 0; background: var(--accent); }
.rep-row:hover { border-color: var(--line-2); background: var(--panel-2); }
.rep-row:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.rep-face { flex: none; width: 56px; height: 56px; border-radius: 4px; overflow: hidden; background: var(--ink-2); border: 1px solid var(--line-2); }
.rep-face img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.rep-face--none { display: grid; place-items: center; font-family: var(--sans); font-weight: 800; font-size: 19px; color: var(--paper-mute); }
.rep-who { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.rep-name { font-family: var(--sans); font-weight: 700; font-size: 16px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rep-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-family: var(--mono); font-size: 12px; line-height: 1.3; }
.rep-chip { padding: 1px 7px; border: 1px solid var(--accent); border-radius: 9px; color: var(--accent-ink); }
.rep-seat { color: var(--paper-mute); }
.rep-go { flex: none; display: grid; place-items: center; color: var(--paper-mute); transition: color .2s, transform .2s; }
.rep-row:hover .rep-go, .rep-row:focus-visible .rep-go { color: var(--paper); transform: translateX(2px); }
@media (min-width: 700px) { .rep-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1041px) { .rep-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* "?" opens the long explanation; it is never shown unasked. */
details.q > summary { list-style: none; cursor: pointer; display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 9px; border: 1px solid var(--line-2); border-radius: 15px; color: var(--paper-dim); font-family: var(--sans); font-weight: 700; font-size: 13px; }
details.q > summary::-webkit-details-marker { display: none; }
#search-help > summary { position: relative; }
#search-help > summary::after { content: ""; position: absolute; inset: calc(50% - 22px); }
details.q--words > summary { display: inline-flex; align-items: center; gap: 7px; font-family: var(--sans); font-weight: 600; font-size: 12.5px; }
details.q > summary:hover, details.q[open] > summary { color: var(--paper); border-color: var(--paper-mute); background: var(--panel-2); }
#search-help > .q-body { position: absolute; z-index: 6; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 12px 14px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px; font-size: 13px; line-height: 1.55; color: var(--paper-dim); box-shadow: 0 18px 40px -18px rgba(0,0,0,.9); }
.home .q-body a, .home .src a, .home .chart-sub a, .home .state a { color: var(--paper); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--paper-mute); }
.home .q-body a:hover, .home .src a:hover, .home .chart-sub a:hover { text-decoration-color: var(--paper); }

/* ── The frame every picture shares: headline, counts, picture, source ─── */
.home main > section:not(.finder) { max-width: 1180px; margin-left: auto; margin-right: auto; padding: 0 22px; }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px 18px; flex-wrap: wrap; }
.home main h2 { margin: 0; font-family: var(--sans); font-weight: 800; font-size: 21px; line-height: 1.2; letter-spacing: -.005em; color: var(--paper); }
.chart-sub { margin: 6px 0 12px; max-width: 92ch; font-size: 14px; line-height: 1.5; color: var(--paper-dim); }
.src { margin-top: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; font-family: var(--mono); font-size: 12px; line-height: 1.6; color: var(--paper-mute); }
.src > span { flex: 1 1 100%; }
.src b { color: var(--paper-dim); font-weight: 500; }
.src details.q[open] { flex: 1 1 100%; }
.src dl.q-body { margin: 10px 0 0; padding: 12px 14px; background: var(--ink-2); border: 1px solid var(--line); border-radius: 6px; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; font-family: var(--sans); font-size: 13.5px; color: var(--paper-dim); }
.src dl.q-body dt { color: var(--paper); font-weight: 700; }
.src dl.q-body dd { margin: 0; }
.home .state { font-size: 13px; }

/* Direct labels: mark, count, name. */
.key { margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 13px; color: var(--paper-dim); }
.key-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.key-item b { color: var(--paper); font-weight: 700; font-variant-numeric: tabular-nums; }
/* The map's key is also its filter: a pressed party dims every other mark. */
.key-btn { border: 1px solid transparent; background: transparent; color: inherit; font: inherit; padding: 3px 8px; margin: -3px -8px; border-radius: 4px; cursor: pointer; }
.key-btn + .key-btn { margin-left: 10px; }
.key-btn:hover { border-color: var(--line-2); color: var(--paper); }
.key-btn[aria-pressed="true"] { border-color: var(--paper-mute); background: var(--panel); color: var(--paper); }
.usmap[data-only] .sd-mark, .usmap[data-only] .sd-vac { opacity: .16; transition: opacity 160ms ease-out; }
.usmap[data-only="dem"] .sd-mark.dem, .usmap[data-only="rep"] .sd-mark.rep, .usmap[data-only="ind"] .sd-mark.ind, .usmap[data-only="oth"] .sd-mark.oth { opacity: 1; }
.viz-glyph { flex: none; vertical-align: -1px; }
.viz-glyph.dem, .viz-bar__seg.dem, .viz-dot.dem .viz-dot__mark { fill: var(--dem-fill); }
.viz-glyph.rep, .viz-bar__seg.rep, .viz-dot.rep .viz-dot__mark { fill: var(--rep-fill); }
.viz-glyph.ind, .viz-bar__seg.ind, .viz-dot.ind .viz-dot__mark { fill: var(--ind-fill); }
.viz-glyph.oth, .viz-bar__seg.oth, .viz-dot.oth .viz-dot__mark { fill: var(--oth-fill); }
.viz-bar { display: block; border-radius: 2px; overflow: hidden; }
.viz-bar__gap { fill: var(--viz-ground); }
.viz-bar__none { fill: none; stroke: var(--paper-mute); stroke-dasharray: 3 3; }

/* ── Second half of the first screen: the map and its card ───────────── */
.home section.nation { margin-top: 24px; }
.nation-map { display: flex; flex-direction: column; min-width: 0; }
.nation-map > .chart-head { align-items: center; }
.map-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; min-width: 0; }
/* The one line above the map: what a mark means, and the marks themselves. */
.map-read { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 20px; margin: 8px 0 2px; }
.map-read .chart-sub { margin: 0; }
.map-read .key { margin: 0; }
.pick { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pick label, .filters label { font-family: var(--mono); font-size: 12px; letter-spacing: .04em; color: var(--paper-mute); white-space: nowrap; }
.home .dir-state { font-size: 13px; padding: 8px 10px; min-width: 0; max-width: 100%; }
.layers { display: inline-flex; border: 1px solid var(--line-2); border-radius: 5px; overflow: hidden; }
.layer { border: 0; background: transparent; color: var(--paper-dim); font-family: var(--sans); font-weight: 600; font-size: 13px; padding: 8px 13px; cursor: pointer; }
.layer + .layer { border-left: 1px solid var(--line-2); }
.layer:hover { color: var(--paper); background: var(--panel); }
.layer.is-on { background: var(--paper); color: var(--ink); }
.layer:focus-visible { outline-offset: -3px; }

/* ── The map ─────────────────────────────────────────────────────────── */
.usmap-stage { position: relative; }
.map-small { display: none; }
.usmap { position: relative; margin: 0 -6px; }
.usmap-svg { display: block; width: 100%; height: auto; overflow: hidden; }
.usmap-world { transform-origin: 0 0; transition: transform 300ms cubic-bezier(.2, .75, .25, 1); }
.usmap-world.is-still { transition: none; }
/* Zoomed in, the neighbours run off the frame: fade the frame's edges so no state is cut by a hard line. */
.usmap.is-zoomed .usmap-svg {
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent), linear-gradient(180deg, transparent, #000 6%, #000 94%, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent), linear-gradient(180deg, transparent, #000 6%, #000 94%, transparent);
  mask-composite: intersect;
}
.usmap-lift, .usmap-dots, .usmap-rings, .usmap-nums { pointer-events: none; }
.st { cursor: pointer; outline: none; }
.st-shape { fill: var(--map-land); stroke: var(--map-edge); stroke-width: 1; stroke-linejoin: round; vector-effect: non-scaling-stroke; transition: fill 160ms ease-out, opacity 240ms ease-out; }
.st:hover .st-shape, .st.is-lift .st-shape { fill: var(--map-land-hi); }
/* The state's name is the link's text: read by a screen reader and a search engine, not painted. */
.st-name { fill: transparent; font-size: 1px; pointer-events: none; }
/* Places too small to point at carry a chip with their code, joined to the shape by a hairline. */
.st-lead { fill: none; stroke: var(--line-2); stroke-width: 1; vector-effect: non-scaling-stroke; }
.st-chip-box { fill: var(--map-chip); stroke: var(--line-2); stroke-width: 1; vector-effect: non-scaling-stroke; transition: fill 160ms ease-out, stroke 160ms ease-out; }
.st-code { font-family: var(--mono); font-weight: 600; font-size: 11.5px; fill: var(--paper-dim); text-anchor: middle; }
.st:hover .st-chip-box, .st.is-lift .st-chip-box { fill: var(--map-land-hi); stroke: var(--paper-mute); }
.st:hover .st-code, .st.is-lift .st-code { fill: var(--paper); }
.st:focus-visible .st-chip-box { stroke: var(--focus); stroke-width: 2.5; }
.st.is-on .st-chip-box { stroke: var(--paper); stroke-width: 1.6; }
.st.is-yours .st-chip-box { stroke: var(--gold); stroke-width: 2; }
/* Lift: under the pointer or the focus a copy of the state rises above its neighbours, with its marks. */
.st-liftshape { fill: var(--map-land-hi); stroke: var(--paper-mute); stroke-width: 1.2; vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 calc(3px / var(--k, 1)) calc(4px / var(--k, 1)) rgba(0, 0, 0, .5)); animation: st-lift 160ms ease-out forwards; }
.st-liftshape.is-key { stroke: var(--focus); stroke-width: 2.5; }
@keyframes st-lift { from { transform: none; } to { transform: translateY(calc(-2px / var(--k, 1))); } }
.sd { transition: transform 160ms ease-out, opacity 240ms ease-out; }
.sd.is-lift { transform: translateY(calc(-2px / var(--k, 1))); }
.sd.is-new { animation: sd-in 180ms ease-out backwards; }
/* Only a start frame: each mark eases to its own resting opacity, dimmed or not. */
@keyframes sd-in { from { opacity: 0; transform: translateY(3px); } }
.sd-mark.dem { fill: var(--dem-fill); }
.sd-mark.rep { fill: var(--rep-fill); }
.sd-mark.ind { fill: var(--ind-fill); }
.sd-mark.oth { fill: var(--oth-fill); }
.sd-vac { fill: none; stroke: var(--paper-mute); stroke-width: .9; }
.st-ring { fill: none; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.st-ring--yours { stroke: var(--gold); stroke-width: 3.5; }
.st-ring--on { stroke: var(--paper); stroke-width: 1.6; }
/* A chosen state: the others step back. */
.usmap.has-pick .st:not(.is-on) .st-shape { opacity: .5; }
.usmap.has-pick .st:not(.is-on) .st-chip { opacity: .55; }
.usmap.has-pick .sd:not(.is-on) { opacity: .24; }
.map-tip { position: absolute; z-index: 4; pointer-events: none; display: grid; gap: 2px; max-width: 280px; padding: 8px 11px 9px; background: var(--paper); color: var(--ink);
  border-radius: 6px; font-size: 13px; line-height: 1.35; white-space: nowrap; box-shadow: 0 12px 28px -12px rgba(0, 0, 0, .8); animation: tip-in 160ms ease-out both; }
@keyframes tip-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.map-tip b { font-size: 14px; }
.map-tip .key--tip { margin: 2px 0 0; gap: 2px 12px; font-size: 12.5px; color: var(--ink); }
.map-tip .key--tip b { color: var(--ink); }
.map-tip .tip-gap { font-size: 12.5px; }
.map-tip .viz-glyph.dem { fill: var(--tip-dem); }
.map-tip .viz-glyph.rep { fill: var(--tip-rep); }
.map-tip .viz-glyph.ind { fill: var(--tip-ind); }
.map-tip .viz-glyph.oth { fill: var(--tip-oth); }

/* "How many seats": one neutral hue in five steps, and the number is printed where it fits. */
.usmap[data-layer="seats"] .usmap-dots { display: none; }
.usmap[data-layer="seats"] .st[data-step="1"] .st-shape, .usmap[data-layer="seats"] .st[data-step="1"] .st-chip-box, .step-chip[data-step="1"] { fill: var(--step-1); background: var(--step-1); }
.usmap[data-layer="seats"] .st[data-step="2"] .st-shape, .usmap[data-layer="seats"] .st[data-step="2"] .st-chip-box, .step-chip[data-step="2"] { fill: var(--step-2); background: var(--step-2); }
.usmap[data-layer="seats"] .st[data-step="3"] .st-shape, .usmap[data-layer="seats"] .st[data-step="3"] .st-chip-box, .step-chip[data-step="3"] { fill: var(--step-3); background: var(--step-3); }
.usmap[data-layer="seats"] .st[data-step="4"] .st-shape, .usmap[data-layer="seats"] .st[data-step="4"] .st-chip-box, .step-chip[data-step="4"] { fill: var(--step-4); background: var(--step-4); }
.usmap[data-layer="seats"] .st[data-step="5"] .st-shape, .usmap[data-layer="seats"] .st[data-step="5"] .st-chip-box, .step-chip[data-step="5"] { fill: var(--step-5); background: var(--step-5); }
.usmap[data-layer="seats"] .st-code { font-size: 10.5px; fill: var(--paper); }
.usmap[data-layer="seats"] .st[data-step="5"] .st-code { fill: var(--ink); }
.st-num { font-family: var(--sans); font-weight: 800; font-size: 13px; fill: var(--paper); text-anchor: middle; }
.st-num--5 { fill: var(--ink); }
.step-chip { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--paper-mute); }

/* The card: whole Congress until a state is chosen. */
.nation-card { position: relative; margin-top: 12px; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; background: var(--ink-2); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px 20px; --viz-ground: var(--ink-2); }
/* The whole Congress: the words on the left, the two chambers on the right. */
.nation-card.is-sum { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 0 44px; padding: 20px 24px 22px; }
.card-bars { padding-top: 26px; }
.card-big { margin: 6px 0 4px; display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 8px; }
.card-big-n { font-family: var(--sans); font-weight: 800; font-size: 46px; line-height: 1; letter-spacing: -.025em; font-variant-numeric: tabular-nums; color: var(--paper); }
.card-big > span { font-size: 16px; font-weight: 600; color: var(--paper-dim); }
.card-left { margin: 2px 0 12px; font-size: 13.5px; line-height: 1.5; color: var(--paper-dim); }
.card-left > summary { cursor: pointer; width: fit-content; color: var(--paper-dim); text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; }
.card-left > summary:hover, .card-left[open] > summary { color: var(--paper); }
.left-list { margin: 8px 0 6px; padding-left: 18px; }
.left-list li { margin: 2px 0; }
.left-list a { color: var(--paper); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--paper-mute); }
.left-why { margin: 6px 0 0; font-size: 12.5px; color: var(--paper-mute); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-kind { margin: 0; font-family: var(--mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--paper-mute); }
.card-close { border: 1px solid var(--line-2); background: transparent; color: var(--paper-dim); font-family: var(--sans); font-weight: 600; font-size: 12px; padding: 5px 10px; border-radius: 4px; cursor: pointer; }
.card-close::before { content: "← "; }
.card-close:hover { color: var(--paper); border-color: var(--paper-mute); }
.home .nation-card h2 { margin-top: 4px; font-size: 30px; letter-spacing: -.015em; }
.card-line { margin: 6px 0 14px; font-size: 15px; line-height: 1.45; color: var(--paper-dim); }
.pbar { margin: 0 0 16px; }
.pbar-title { margin: 0 0 6px; font-family: var(--mono); font-size: 12px; letter-spacing: .04em; color: var(--paper-dim); }
.key--bar { margin-top: 7px; }
.card-note { margin: 0 0 12px; padding-left: 11px; border-left: 2px solid var(--line-2); font-size: 13px; line-height: 1.5; color: var(--paper-mute); }
.card-note--gap { border-left-style: dashed; border-left-color: var(--paper-mute); color: var(--paper-dim); }
.card-actions { margin: 0 0 4px; display: flex; flex-wrap: wrap; gap: 8px; }
.home .nation-card .btn { font-size: 12px; padding: 9px 13px; letter-spacing: .03em; }
.home .nation-card .card-open { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.home .nation-card .card-open:hover { background: var(--paper-hi); }
.share { margin: 10px 0 4px; padding: 12px 14px; background: var(--panel); border: 1px dashed var(--line-2); border-radius: 6px; }
.share-text { margin: 0 0 10px; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; color: var(--paper); white-space: pre-wrap; overflow-wrap: anywhere; }
.share-done { margin-left: 10px; font-family: var(--mono); font-size: 12px; color: var(--paper-dim); }
.faces { margin-top: 18px; }
.faces-h { margin: 0 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); font-family: var(--mono); font-weight: 500; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--paper-mute); }
.faces-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 12px; }
.face { display: flex; align-items: center; gap: 10px; padding: 5px; border-radius: 5px; min-height: 54px; }
.face:hover { background: var(--panel); }
.face:hover .face-name { text-decoration: underline; text-underline-offset: 3px; }
.face-pic { flex: none; width: 40px; height: 49px; border-radius: 3px; overflow: hidden; background: var(--panel-2); border: 1px solid var(--line-2); display: grid; place-items: center; font-family: var(--sans); font-weight: 700; font-size: 13px; color: var(--paper-dim); }
.face-pic img { width: 100%; height: 100%; object-fit: cover; object-position: center 20%; display: block; }
.face-words { min-width: 0; display: grid; gap: 2px; }
.face-name { font-weight: 600; font-size: 14px; line-height: 1.25; color: var(--paper); overflow-wrap: anywhere; }
.face-sub { display: flex; flex-wrap: wrap; gap: 0 9px; font-size: 12.5px; line-height: 1.35; color: var(--paper-mute); }
.face-seat, .face-party { white-space: nowrap; }
.face-party { color: var(--paper-dim); }
.wordq { margin-left: 8px; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-2); background: transparent; color: var(--paper-dim); font-family: var(--sans); font-weight: 700; font-size: 12px; cursor: pointer; padding: 0; }
.wordq:hover, .wordq[aria-expanded="true"] { color: var(--paper); border-color: var(--paper-mute); }
.wordq-a { display: block; margin-top: 8px; font-family: var(--sans); font-size: 13px; line-height: 1.5; letter-spacing: 0; text-transform: none; color: var(--paper-dim); }

/* Wide screens: a chosen state's card lies over the right of the map, at most as tall as the map, and scrolls
   inside, so the page does not move; the state itself fills the rest. */
@media (min-width: 901px) {
  /* The whole country at full column width ran 660 px tall; a little narrower keeps it the page's
     largest thing and leaves room for what is new below. */
  .usmap-stage > .usmap { max-width: 1000px; margin: 0 auto; }
  /* The source line and its two controls share a row when they fit. */
  .nation .src > span { flex: 1 1 auto; width: auto; }
  .usmap-stage .nation-card.is-state { position: absolute; z-index: 3; top: 6px; right: 0; max-height: calc(100% - 12px); width: min(39%, 450px); margin: 0; overflow: auto;
    background: var(--card-glass); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: 0 24px 60px -30px rgba(0, 0, 0, .9);
    animation: card-in 240ms ease-out both; }
  @keyframes card-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
}

/* ── Latest in Congress: three short columns, newest first ─────────────── */
.home section.latest { margin-top: 40px; }
.latest .chart-head { align-items: baseline; justify-content: flex-start; }
.latest-sub { margin: 0; font-family: var(--mono); font-size: 12px; color: var(--paper-mute); }
.lt-cols { margin-top: 14px; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1.3fr) minmax(0, 1fr); gap: 0 28px; }
.lt-col { min-width: 0; border-top: 2px solid var(--line-2); padding-top: 10px; }
.lt-src a { white-space: nowrap; }
.home .lt-col h3 { margin: 0; font-family: var(--sans); font-weight: 800; font-size: 15px; line-height: 1.3; letter-spacing: .01em; color: var(--paper); }
.lt-meta { margin: 3px 0 6px; font-family: var(--mono); font-size: 12px; line-height: 1.5; color: var(--paper-mute); }
.lt-meta .lt-date { font-family: inherit; color: var(--paper-dim); }
.lt-meta a { color: var(--paper-dim); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); }
.lt-meta a:hover { color: var(--paper); text-decoration-color: var(--paper); }
.lt-meta.is-stale .lt-stale { color: var(--gold); }
.lt-meta.is-off { color: var(--paper-dim); }
.lt-list { list-style: none; margin: 0; padding: 0; }
.lt-list li + li { border-top: 1px solid var(--line); }
.lt-link { display: flex; align-items: center; gap: 9px; min-height: 35px; padding: 4px 6px; margin: 0 -6px; border-radius: 4px; color: var(--paper); font-size: 13.5px; line-height: 1.3; white-space: nowrap; }
.lt-link:hover { background: var(--panel); }
.lt-link:hover .lt-what { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--paper-mute); }
.lt-link:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; }
.lt-date { flex: none; min-width: 46px; font-family: var(--mono); font-size: 12px; color: var(--paper-mute); font-variant-numeric: tabular-nums; }
/* A column with a row from an earlier year: every date takes the year form's width (11 mono characters). */
.lt-list.has-year .lt-date { min-width: 11ch; }
.lt-tag { flex: none; font-family: var(--mono); font-size: 12px; color: var(--paper-dim); }
.lt-what { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.lt-what b { font-weight: 700; }
.lt-act { flex: none; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; color: var(--paper-mute); }
.lt-link.is-out .lt-what::after { content: " \2197"; color: var(--paper-mute); }
.lt-yn { flex: none; display: inline-flex; align-items: center; gap: 6px; }
.lt-yn-bar { display: block; width: 34px; height: 7px; border-radius: 2px; background: var(--paper-mute); overflow: hidden; }
/* Yes and no meet at a 2 px gap in the page colour: each part stands off the page (paper 16:1, mute 6:1)
   and from each other, where the two fills alone are 2.6:1. The counts beside it carry the numbers. */
.lt-yn-y { display: block; height: 100%; background: var(--paper); box-shadow: 2px 0 0 var(--ink); }
.lt-yn-n { font-family: var(--mono); font-size: 12px; color: var(--paper-dim); font-variant-numeric: tabular-nums; }
.lt-result { flex: none; padding: 1px 6px; border: 1px solid var(--line-2); border-radius: 3px; font-family: var(--mono); font-size: 12px; color: var(--paper-dim); }

/* ── On file: one slim row of counts ─────────────────────────────────── */
.home section.onfile { margin-top: 30px; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 16px; padding-top: 14px;
  /* The rule spans the text column, not the section's side padding. */
  background: linear-gradient(var(--line), var(--line)) no-repeat 22px 0 / calc(100% - 44px) 1px; }
.home section.onfile h2 { font-family: var(--mono); font-weight: 500; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--paper-mute); }
.onfile-counts { margin: 0; flex: 1 1 0; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 18px; font-size: 13.5px; color: var(--paper-dim); }
.onfile-n { font-weight: 800; color: var(--paper); font-variant-numeric: tabular-nums; }
a.onfile-item { color: var(--paper-dim); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); }
a.onfile-item:hover { color: var(--paper); text-decoration-color: var(--paper); }
.onfile-read { font-family: var(--mono); font-size: 12px; color: var(--paper-mute); }
.onfile-wait { font-size: 13px; }

/* ── The same numbers as a table, closed under the map ────────────────── */
.home #csv { font-size: 12px; padding: 8px 13px; }
.src .tablefold { order: 1; }
.src .tablefold[open] { flex: 1 1 100%; order: 3; }
.src details.q--words { order: 2; }
.tablefold .tablewrap, .table-foot { font-family: var(--sans); }
.table-foot { margin: 10px 0 0; }
/* The table is the map's text equivalent: always in the page, closed until asked for. */
.tablefold > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; min-height: 30px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 15px; color: var(--paper-dim); font-family: var(--sans); font-weight: 600; font-size: 12.5px; width: fit-content; }
.tablefold > summary::-webkit-details-marker { display: none; }
.tablefold > summary::before { content: "+"; font-family: var(--mono); font-size: 14px; line-height: 1; color: var(--paper-mute); }
.tablefold[open] > summary::before { content: "\2212"; }
.tablefold > summary:hover { background: var(--panel-2); color: var(--paper); }
.tablefold[open] > summary { margin-bottom: 12px; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.statetable { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 14px; }
.statetable caption { caption-side: top; text-align: left; padding: 12px 14px; font-size: 13px; color: var(--paper-mute); border-bottom: 1px solid var(--line); }
.statetable caption span { display: block; position: sticky; left: 14px; max-width: calc(100vw - 54px); }
.statetable th, .statetable td { padding: 9px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.statetable tbody tr:last-child > * { border-bottom: 0; }
.statetable thead th { position: sticky; top: 0; background: var(--ink-2); font-family: var(--mono); font-weight: 500; font-size: 12px; letter-spacing: .04em; color: var(--paper-dim); white-space: nowrap; vertical-align: bottom; }
.statetable thead button { all: unset; cursor: pointer; font: inherit; letter-spacing: inherit; color: var(--paper); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--paper-mute); }
.statetable thead button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.statetable thead th[aria-sort="ascending"] button::after { content: " ↑"; }
.statetable thead th[aria-sort="descending"] button::after { content: " ↓"; }
.statetable tbody th { font-weight: 600; color: var(--paper); }
.statetable tbody th a { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); }
.statetable tbody th a:hover { text-decoration-color: var(--paper); }
.statetable .num { text-align: right; font-variant-numeric: tabular-nums; }
.statetable tbody tr:hover > * { background: var(--ink-2); }
.cell-sub { display: block; font-family: var(--mono); font-weight: 400; font-size: 12px; color: var(--paper-mute); }
.cell-party { min-width: 230px; }
.cell-bar { display: block; width: 100%; max-width: 220px; margin: 5px 0 5px; }
.cell-words { display: block; font-size: 13px; color: var(--paper-dim); }
.cell-gap { color: var(--paper); }

/* ── Narrower than the two-column frame ──────────────────────────────── */
@media (max-width: 1040px) {
  .home section.finder { grid-template-columns: minmax(0, 1fr); }
  .home .finder h1 { margin: 0 0 8px; white-space: normal; }
}
@media (max-width: 900px) {
  .home section.nation { margin-top: 14px; }
  .nation-card { scroll-margin-top: 10px; }
  .nation-card.is-sum { grid-template-columns: minmax(0, 1fr); }
  .card-bars { padding-top: 6px; }
  .lt-cols { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .home section.latest { margin-top: 32px; }
}
@media (max-width: 620px) {
  .home section.finder { padding: 10px 12px 0; }
  .home .finder h1 { font-size: 22px; margin-bottom: 6px; }
  .home .searchbox input { padding: 12px 10px; }
  .home .searchbox .ic { padding-left: 12px; }
  .home .searchbox button { padding: 0 16px; }
  .find-under { gap: 4px 10px; margin-top: 6px; }
  /* "Your address is never stored." and the "?" share one row: text left, button right. */
  .find-stored { flex: 1 1 0; min-width: 0; }
  .home .locate-btn { min-height: 40px; }
  details.q > summary { min-width: 36px; height: 36px; border-radius: 18px; }
  .home main > section:not(.finder) { padding: 0 12px; }
  .home main h2 { font-size: 18px; }
  .home section.nation { margin-top: 10px; }
  .nation-map h2 { margin-top: 0; font-size: 16px; }
  .map-tools { width: 100%; }
  /* The place picker and the layer switch share one row; the picker's label stays for screen
     readers, and its first choice ("Whole country") says what it shows. */
  .map-tools { flex-wrap: nowrap; gap: 8px; }
  .pick { gap: 8px; flex: 1 1 0; }
  .pick label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .pick .dir-state { flex: 1 1 auto; min-width: 0; min-height: 38px; }
  .layers { flex: none; }
  .layer { padding: 8px 9px; min-height: 38px; font-size: 12.5px; }
  .map-read { margin-top: 10px; }
  .usmap { margin: 4px -4px 0; }
  /* On a phone the whole country's marks are a pixel or two each: they read as each state's colour
     mix, and a chosen state zooms in to show them one by one. Seat numbers wait for the zoom. */
  .usmap:not(.is-zoomed) .usmap-nums { display: none; }
  /* The whole country on a phone: no chips or leader lines (the buttons under the map name those
     places); a chip comes back while its place is focused, lifted or chosen. The marks grow to fill
     their slots, so each state reads as its delegation's colours; a tap zooms in to one mark each. */
  .usmap:not(.is-zoomed) .st:not(.is-on):not(.is-lift):not(:focus-visible) .st-chip,
  .usmap:not(.is-zoomed) .sd--chip:not(.is-on):not(.is-lift) { display: none; }
  .usmap:not(.is-zoomed) .sd-mark { transform-box: fill-box; transform-origin: center; transform: scale(1.3); }
  .usmap:not(.is-zoomed) .sd-vac { stroke-width: 1.2; }
  .map-small { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
  .map-small-b { min-width: 44px; min-height: 32px; padding: 0 8px; border: 1px solid var(--line-2); border-radius: 4px; background: var(--panel); color: var(--paper); font-family: var(--mono); font-size: 13px; cursor: pointer; }
  .map-small-b[aria-pressed="true"] { background: var(--paper); color: var(--ink); border-color: var(--paper); }
  .map-small-b:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
  .card-big-n { font-size: 34px; }
  .nation-card { padding: 16px 14px 18px; }
  .home .nation-card h2 { font-size: 26px; }
  .lt-link { gap: 7px; min-height: 29px; padding: 3px 6px; font-size: 13px; }
  .lt-cols { margin-top: 8px; gap: 12px; }
  .home section.latest { margin-top: 14px; }
  /* On a phone the directory is one tap away in the header and under "On file"; the whole-Congress
     card drops its own button. A chosen state's card keeps its actions. */
  .nation-card.is-sum .card-actions { display: none; }
  .lt-col { padding-top: 8px; }
  .lt-meta { margin: 2px 0 4px; }
  /* Three rows a column on a phone; the source list and the record hold the rest. */
  .lt-list li:nth-child(n+4) { display: none; }
  /* Card bars: the count and its mark sit on the title line; the party names stay for screen readers. */
  .pbar { margin-bottom: 12px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 10px; }
  .pbar-title { margin-bottom: 5px; }
  .pbar-bar { order: 3; flex: 1 1 100%; }
  .key--bar { margin: 0 0 5px auto; gap: 2px 10px; font-size: 12.5px; }
  .key--bar .key-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .key-item { gap: 4px; }
  .map-read .key { gap: 4px 10px; font-size: 12.5px; }
  .key-btn { padding: 3px 5px; margin: -3px -5px; }
  .card-bars { padding-top: 2px; }
  .home section.onfile { margin-top: 20px; gap: 2px 12px; background-position: 12px 0; background-size: calc(100% - 24px) 1px; }
  .onfile-counts { flex-basis: 100%; gap: 0 14px; font-size: 13px; line-height: 1.45; }
  .nation .src > span { font-size: 12px; line-height: 1.45; }
  .lt-date { min-width: 42px; }
  .lt-list.has-year:not(.has-year-3) .lt-date { min-width: 42px; }
  .lt-act { display: none; }
  .lt-yn-bar { width: 24px; }
  .key-btn + .key-btn { margin-left: 4px; }
  .src dl.q-body { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .src dl.q-body dd { margin-bottom: 8px; }
}
@media (max-width: 359px) {
  .faces-list { grid-template-columns: minmax(0, 1fr); }
}

/* ── Atmosphere: a slow mesh gradient behind the search and the map (fx.js) ── */
/* The canvas is painted under everything, fades out before the second screen, and takes no input.
   Under it sits the same light as a still CSS gradient, for a browser without WebGL. */
.atmos { position: absolute; z-index: -1; left: 0; top: 0; width: 100%; height: 1240px; display: block; pointer-events: none;
  background:
    radial-gradient(55% 45% at 16% 10%, var(--atmos-4), transparent 72%),
    radial-gradient(50% 50% at 84% 18%, var(--atmos-3), transparent 70%),
    radial-gradient(60% 50% at 55% 82%, var(--atmos-2), transparent 70%),
    var(--atmos-1);
  -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 58%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0, #000 58%, transparent 100%); }
@media (max-width: 900px) { .atmos { height: 1000px; } }

/* ── Light: the same page on paper, for a reader whose system asks for it ──
   Scoped to the home page; every other page keeps the dark record. Text holds 4.5:1 and marks 3:1
   on each surface below (checked by script for this change). */
@media (prefers-color-scheme: light) {
  body.home {
    color-scheme: light;
    --ink: #f4f2ec; --ink-2: #ebe8e0; --panel: #ffffff; --panel-2: #f6f4ee;
    --line: #dcd8cd; --line-2: #c3bdb0;
    --paper: #15181d; --paper-dim: #3c424c; --paper-mute: #575f6c; --paper-hi: #000;
    --gold: #7a5d18; --gold-dim: #a88a45; --focus: #7a5d18;
    --dem: #2f6bc0; --dem-ink: #1f4f94; --rep: #b83c38; --rep-ink: #8f2a27; --ind: #6b7380;
    --dem-fill: #2f6bc0; --rep-fill: #b83c38; --ind-fill: #687080; --oth-fill: #806d36;
    --map-land: #e4dfd3; --map-land-hi: #d6d0c1; --map-edge: #f9f8f4; --map-chip: #ebe7dd;
    --step-1: #ebe7de; --step-2: #d3d7de; --step-3: #b2bccb; --step-4: #8292a9; --step-5: #34445e;
    --atmos-1: #f4f2ec; --atmos-2: #eee9df; --atmos-3: #e6e8ea; --atmos-4: #f0e7d3; --atmos-grain: 0.028;
    --tip-dem: #7fa9e6; --tip-rep: #ec8a86; --tip-ind: #b3bac5; --tip-oth: #d9c9a3;
    --card-glass: rgba(250, 249, 245, .95);
    background-image: none;
  }
  body.home .searchbox button:hover, body.home .btn:not(.btn--ghost):hover { background: #5e4710; }
  body.home .searchbox, body.home .map-tip, body.home #search-help > .q-body { box-shadow: 0 14px 34px -22px rgba(40, 32, 12, .45); }
  body.home .usmap-stage .nation-card.is-state { box-shadow: 0 24px 60px -34px rgba(40, 32, 12, .5); }
  body.home .st-liftshape { filter: drop-shadow(0 calc(3px / var(--k, 1)) calc(4px / var(--k, 1)) rgba(40, 32, 12, .28)); }
  body.home .receipts { background: rgba(0, 0, 0, .035); }
  body.home .seal { background: repeating-conic-gradient(from 0deg, transparent 0 14deg, rgba(122, 93, 24, .12) 14deg 15deg); }
}

/* ── Reduced motion: every change is immediate, and nothing moves on its own ── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .usmap-world, .st-shape, .st-chip-box, .sd { transition: none; }
  .st-liftshape, .sd.is-new, .map-tip, .usmap-stage .nation-card.is-state { animation: none; }
  .sd.is-lift { transform: none; }
  .rep-row, .rep-go { transition: none; }
  .rep-row:hover .rep-go, .rep-row:focus-visible .rep-go { transform: none; }
}

/* One waking line on the page: while a lookup waits on a waking record (home.js lookupWaking),
   the map card's own waking line steps aside. */
body.lookup-waking #state-card .cc-wake { display: none; }
