/* =========================================================
   THEME — BALLOT
   The page is a paper ballot lying in a voting booth.
   Answers are marked the way real ballots are: a filled
   oval for yes, an empty oval for no. The state name is a
   rubber stamp, the dropdown is a write-in line, and the
   registration link is a tear-off stub.
   Typeface: Archivo, at extra-condensed and semi-condensed widths.
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Archivo:wdth,wght@62..125,400..900&display=swap');

:root {
    --booth: #1d2b45;
    --booth-dark: #141f34;
    --paper: #eef2e4;
    --paper-edge: #dde3cf;
    --ink: #000;
    --ink-soft: #3b4236;
    --rule: #9aa38c;
    --stamp: #b3202a;
    --marker: #f5e15a;
    --link: #1f4fa3;
}

*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    color-scheme: light;
    background: var(--booth);
}

/* The voting-booth curtain: soft vertical pleats */
body {
    margin: 0;
    min-height: 100vh;
    padding: 3rem 1.5rem 4rem;
    font-family: 'Archivo', 'Arial Narrow', system-ui, sans-serif;
    font-stretch: 87.5%;
    font-variation-settings: "wdth" 87.5;
    line-height: 1.5;
    color: var(--ink);
    background:
        repeating-linear-gradient(90deg,
            rgba(255, 255, 255, .035) 0 22px,
            rgba(0, 0, 0, .10) 22px 46px,
            rgba(255, 255, 255, .02) 46px 70px),
        linear-gradient(180deg, var(--booth) 0%, var(--booth-dark) 100%);
    -webkit-font-smoothing: antialiased;
}

/* ---------- The ballot sheet ---------- */

.container {
    position: relative;
    max-width: 1060px;
    margin: 0 auto;
    padding: 3rem 3.25rem 2.5rem 4.75rem;
    font-size: .8125rem;          /* the closing "Data and values…" note: fine print */
    color: var(--ink-soft);
    background-color: var(--paper);
    /* Scanner timing marks down the left edge, as on optical-scan ballots */
    background-image: linear-gradient(to bottom, var(--ink) 0 6px, transparent 6px 28px);
    background-size: 18px 28px;
    background-position: 1.6rem 3rem;
    background-repeat: repeat-y;
    border-radius: 2px;
    box-shadow:
        0 0 0 1px var(--paper-edge),
        0 2px 0 var(--paper-edge),
        0 30px 60px rgba(0, 0, 0, .45),
        0 8px 18px rgba(0, 0, 0, .3);
}

/* ---------- Masthead ---------- */

.container > h1:first-of-type {
    margin: 0 0 2.25rem;
    padding: 0 0 1rem;
    border-bottom: 6px solid var(--ink);
    box-shadow: 0 3px 0 var(--paper), 0 5px 0 var(--ink);   /* thick-thin ballot rule */
    font-stretch: 62%;
    font-variation-settings: "wdth" 62;
    font-weight: 900;
    font-size: clamp(2.5rem, 8vw, 5.5rem);
    line-height: .9;
    letter-spacing: -.005em;
    text-align: left;
    color: var(--ink);
}

/* ---------- Instructions line ---------- */

h2 {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: .5rem 1.5rem;
    margin: 0 0 .25rem;
    padding: 0;
    border: 0;
    font-stretch: 75%;
    font-variation-settings: "wdth" 75;
    font-weight: 800;
    font-size: 1.375rem;
    color: var(--ink);
}

.suggestion-link a {
    font-stretch: 87.5%;
    font-variation-settings: "wdth" 87.5;
    font-weight: 500;
    font-size: .9375rem;
    color: var(--link);
}

/* ---------- Write-in line (state picker) ---------- */

#state-select {
    width: 100%;
    margin: 0;
    padding: .55rem 2.75rem .45rem .1rem;
    font: inherit;
    font-stretch: 75%;
    font-variation-settings: "wdth" 75;
    font-weight: 700;
    font-size: 1.75rem;
    color: var(--ink);
    background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='square'%3E%3Cpath d='M5 8l6 6 6-6'/%3E%3C/svg%3E") no-repeat right .25rem center;
    border: 0;
    border-bottom: 3px solid var(--ink);
    border-radius: 0;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}
#state-select:hover { background-color: rgba(245, 225, 90, .35); }
#state-select:focus { outline: none; background-color: rgba(245, 225, 90, .55); }
#state-select:focus-visible { outline: 3px solid var(--link); outline-offset: 4px; }

/* ---------- Rubber-stamped state name ---------- */

#state-select ~ h1 {
    display: inline-block;
    margin: 2.5rem 0 2.5rem .5rem;
    padding: .2em .45em .1em;
    font-stretch: 62%;
    font-variation-settings: "wdth" 62;
    font-weight: 900;
    font-size: clamp(2.5rem, 7vw, 4.25rem);
    line-height: 1;
    letter-spacing: .02em;
    text-transform: uppercase;
    text-align: left;
    color: var(--stamp);
    border: 5px solid var(--stamp);
    outline: 2px solid var(--stamp);
    outline-offset: 4px;
    border-radius: 6px;
    transform: rotate(-3deg);
    mix-blend-mode: multiply;
    /* uneven ink, like a real rubber stamp */
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.7' numOctaves='3' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -3.2 2.5'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.7' numOctaves='3' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -3.2 2.5'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
    animation: stamp .35s cubic-bezier(.2, .9, .3, 1.3) both;
}

/* The one moment of motion: the stamp lands when a state loads */
@keyframes stamp {
    0%   { opacity: 0; transform: rotate(-3deg) scale(1.6); }
    100% { opacity: 1; transform: rotate(-3deg) scale(1); }
}

/* ---------- Tear-off stub (registration link) ---------- */

h4 {
    position: relative;
    margin: 0 0 2.5rem;
    padding: 1.1rem 0 0 2rem;
    border: 0;
    border-top: 2px dashed var(--ink);
    font-stretch: 87.5%;
    font-variation-settings: "wdth" 87.5;
    font-weight: 400;
    font-size: .9375rem;
    color: var(--ink-soft);
    overflow-wrap: anywhere;
}

/* Scissors sitting on the cut line */
h4::before {
    content: "✂";
    position: absolute;
    left: 0;
    top: -.85rem;
    padding-right: .35rem;
    background: var(--paper);
    font-size: 1.15rem;
    line-height: 1.4;
    color: var(--ink);
}

h4 a {
    margin-right: .25rem;
    font-stretch: 75%;
    font-variation-settings: "wdth" 75;
    font-weight: 800;
    font-size: 1.375rem;
    color: var(--ink);
    text-decoration: underline;
    text-decoration-thickness: 3px;
    text-underline-offset: 4px;
    text-decoration-color: var(--stamp);
}
h4 a:hover { color: var(--stamp); }

/* ---------- Links ---------- */

a {
    color: var(--link);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}
a:hover { color: var(--stamp); }
a:focus-visible { outline: 3px solid var(--link); outline-offset: 3px; }

/* ---------- Ballot columns ---------- */

.flex-container {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    align-items: start;
    margin: 0 0 2rem;
    border-top: 3px solid var(--ink);
    border-bottom: 3px solid var(--ink);
}

.flex-item {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 0;
    min-width: 0;
    padding: 1.25rem 1.75rem 1.5rem 0;
}

/* Vertical ballot rule between the two columns */
.flex-item + .flex-item {
    align-self: stretch;
    padding: 1.25rem 0 1.5rem 1.75rem;
    border-left: 2px solid var(--ink);
}

.table-responsive {
    overflow-x: auto;
    margin: 0 0 1.5rem;
}
.table-responsive:last-child { margin-bottom: 0; }

/* ---------- Ballot races (tables) ---------- */

table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    background: transparent;
    box-shadow: none;
    font-size: 1rem;
    color: var(--ink);
}

/* Black heading band, like a race header on a ballot */
th {
    padding: .5rem .75rem .45rem;
    background: var(--ink);
    color: var(--paper);
    text-align: left;
    font-stretch: 62%;
    font-variation-settings: "wdth" 62;
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: .01em;
    line-height: 1.15;
}

td {
    padding: .55rem .75rem;
    border-bottom: 1px solid var(--rule);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }

td:first-child {
    font-weight: 500;
}

tr:nth-child(even) { background: transparent; }

/* Hovered row gets a highlighter stroke across the label */
tbody tr:hover { background: transparent; }
tbody tr:hover td:first-child {
    background: linear-gradient(transparent 18%, rgba(245, 225, 90, .85) 18%, rgba(245, 225, 90, .85) 86%, transparent 86%);
}

td:last-child {
    width: 1%;
    white-space: nowrap;
    text-align: center;
    font-weight: 700;
    font-stretch: 75%;
    font-variation-settings: "wdth" 75;
    font-size: 1.125rem;
}

/* ---------- The ovals ---------- */

/* Yes: a filled-in oval. The check mark stays in the page for
   screen readers and copy/paste; it just isn't drawn. */
.table-responsive .check {
    display: inline-block;
    width: 2.1rem;
    height: 1.15rem;
    vertical-align: middle;
    border: 2px solid var(--ink);
    border-radius: 50%;
    background:
        radial-gradient(ellipse at 40% 45%, #1c1c1c 0 55%, transparent 56%),
        var(--ink);
    color: transparent;
    font-size: .75rem;
    line-height: 1;
    overflow: hidden;
    transform: rotate(-4deg);
}

/* No: an empty oval */
td:last-child:empty::after {
    content: "";
    display: inline-block;
    width: 2.1rem;
    height: 1.15rem;
    vertical-align: middle;
    border: 2px solid var(--ink);
    border-radius: 50%;
}

.table-responsive .cross { color: var(--stamp); }

/* ---------- Mobile ---------- */

@media (max-width: 800px) {
    body { padding: 1rem .6rem 2.5rem; }

    .container {
        padding: 2rem 1.25rem 1.75rem 2.75rem;
        background-size: 12px 26px;
        background-position: .9rem 2rem;
    }

    .container > h1:first-of-type { font-size: clamp(1.9rem, 9.4vw, 3rem); }

    h2 { flex-direction: column; align-items: flex-start; }
    .suggestion-link { margin-top: 0; }

    #state-select { font-size: 1.5rem; }
    h4 { padding-left: 1.5rem; }

    .flex-container { grid-template-columns: 1fr; }
    .flex-item,
    .flex-item + .flex-item {
        padding: 1.25rem 0;
        border-left: 0;
    }
    .flex-item + .flex-item { border-top: 2px solid var(--ink); }

    td { padding: .5rem .5rem; }
    th { padding: .45rem .5rem .4rem; }
}

@media (prefers-reduced-motion: reduce) {
    #state-select ~ h1 { animation: none; }
}