/* Four Counts: a notice posted on a board, and a cut-up ballot slip.
   Square corners, hairline rules, no shadows, no gradients. Light only. */

:root {
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; border-radius: 0; }
[hidden] { display: none !important; }

html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
main { max-width: 40rem; margin: 0 auto; padding: 20px 16px 56px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; margin: 0; }
p { margin: 0 0 .6em; }

/* Top line: wordmark left, the form's name right. */
.topline {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding-bottom: 10px; margin-bottom: 18px; border-bottom: 2px solid var(--ink);
}
.topline h1, .topline p { font-size: 1rem; font-weight: 700; margin: 0; }
.wm { display: block; height: 30px; width: auto; }
.caps { font-variant-caps: all-small-caps; letter-spacing: .08em; }
.topline .caps { font-size: 1.125rem; line-height: 1.3; text-align: right; text-wrap: balance; }
.num { color: var(--c-earth); font-weight: 700; }
.soft { color: var(--ink-soft); }
.lede { margin-bottom: 22px; }

/* Form. */
.field { margin: 0 0 24px; padding: 0; border: 0; min-width: 0; }
label, legend { display: block; font-weight: 700; margin: 0 0 6px; padding: 0; }
label .num, legend .num { margin-right: .35em; }
input[type="text"], input[type="number"], textarea, select {
  display: block; width: 100%; margin: 0;
  font: inherit; color: var(--ink); background: var(--bg);
  border: 2px solid var(--ink); padding: 10px 12px; min-height: 48px;
}
textarea { resize: vertical; line-height: 1.4; }
.hint { font-size: .875rem; color: var(--ink-soft); margin: 6px 0 0; }
.note { font-size: .875rem; margin: 8px 0 0; }
.error, .errors li { color: var(--error); }
.errors { list-style: none; padding: 0; margin: 10px 0; font-size: .9375rem; }
.errors li { margin: 0 0 4px; }
.errors li.soft { color: var(--ink-soft); }
.record-error { margin: 0 0 16px; }

.choices { display: grid; grid-template-columns: 1fr 1fr; }
.choice {
  display: flex; align-items: center; gap: 8px; margin: 0;
  min-height: 48px; padding: 8px 10px; border: 2px solid var(--ink);
  font-weight: 400; cursor: pointer;
}
.choice + .choice { border-left: 0; }
.choice input {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0;
  width: 20px; height: 20px; border: 2px solid var(--ink); background: var(--bg);
  display: grid; place-content: center;
}
.choice input::before { content: ""; width: 10px; height: 10px; background: var(--ink); visibility: hidden; }
.choice input:checked::before { visibility: visible; }

.select { position: relative; }
.select select { appearance: none; -webkit-appearance: none; padding-right: 44px; cursor: pointer; }
.select::after {
  content: ""; position: absolute; right: 16px; top: 50%; margin-top: -3px; pointer-events: none;
  border: 6px solid transparent; border-bottom: 0; border-top-color: var(--ink);
}

/* Buttons: rectangles with a 2px ink border. */
button {
  font: inherit; font-weight: 700; margin: 0; cursor: pointer;
  min-height: 48px; padding: 10px 20px;
  border: 2px solid var(--ink); background: transparent; color: var(--ink);
}
button.primary { background: var(--ink); color: var(--bg); }
button:disabled { cursor: not-allowed; border-color: var(--ink-soft); background: transparent; color: var(--ink-soft); }
:focus-visible { outline: 3px solid var(--c-earth); outline-offset: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
.actions.split { justify-content: space-between; }

/* Cover and ready: nothing but the line and the button. */
.cover { min-height: calc(100vh - 76px); display: flex; flex-direction: column; justify-content: center; }
.cover-title { font-size: 2rem; margin-bottom: 10px; }
.cover-text { font-size: 1.125rem; }

/* Ballot. */
.matter-title { font-size: 1.5rem; margin: 2px 0 12px; overflow-wrap: anywhere; }
.rows { display: grid; gap: 10px; margin: 16px 0; }
.row {
  display: flex; align-items: center; gap: 14px; width: 100%;
  min-height: 60px; padding: 10px 12px; text-align: left;
  font-weight: 400; font-size: 1.125rem;
}
.row .box {
  flex: none; width: 36px; height: 36px; border: 2px solid var(--ink);
  display: grid; place-items: center; font-weight: 700;
}
.row[aria-pressed="true"] .box { background: var(--ink); color: var(--bg); }
.row .name { overflow-wrap: anywhere; }

/* Paper. */
.step { font-size: 1.0625rem; margin: 26px 0 10px; padding-top: 14px; border-top: 1px solid var(--ink); }
.step .num { margin-right: .35em; }
.key { display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 2px 12px; margin: 10px 0 16px; }
.key dt { font-family: var(--mono); font-weight: 700; }
.key dd { margin: 0; overflow-wrap: anywhere; }
.key-line { margin: 0 0 10px; }
.key-line .pair { display: inline-block; margin-right: 1.25em; overflow-wrap: anywhere; }
#lines { font-family: var(--mono); }
#mismatch { font-size: .9375rem; margin: 10px 0 0; }

/* The declaration. */
.sheet-bar { padding-bottom: 14px; margin-bottom: 20px; border-bottom: 1px solid var(--ink); }
.sheet-bar .actions { margin-top: 0; }
.sheet-bar label { font-size: .875rem; font-weight: 400; color: var(--ink-soft); }
#record-link { font-family: var(--mono); font-size: .8125rem; min-height: 40px; padding: 6px 8px; border-width: 1px; }

.declaration .topline { margin-bottom: 0; }
.declaration .part { padding: 16px 0; border-top: 1px solid var(--ink); }
.declaration .topline + .part { border-top: 0; }
.declaration h2 { font-size: 1rem; margin-bottom: 8px; }
.matter h1 { font-size: 1.75rem; margin: 0 0 10px; overflow-wrap: anywhere; }
.small { font-size: .8125rem; margin: 0 0 2px; }

.binding { margin: 0 0 12px; }
.counts { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ink); }
.count {
  display: grid; grid-template-columns: 4.5rem minmax(0, 1fr) minmax(0, 14rem); gap: 4px 14px;
  padding: 12px 0; border-bottom: 1px solid var(--ink);
}
.count-num .num { font-size: 1.25rem; line-height: 1.2; margin-right: .3em; }
.count-num .label { font-size: .875rem; }
.count-rule h3 { font-size: 1.0625rem; margin-bottom: 3px; }
.rule { font-size: .875rem; margin: 0; }
.win { font-size: 1.125rem; line-height: 1.5; margin: 0 0 2px; overflow-wrap: anywhere; }
mark {
  background: var(--c-mustard); color: var(--ink); font-weight: 700; padding: 1px 5px;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.fig { font-size: .875rem; margin: 0; }
.agreement { margin: 14px 0 0; font-weight: 700; }

.dec { font-size: .875rem; overflow-wrap: anywhere; }
.dec-name { font-weight: 700; }
.notices { list-style: none; margin: 0; padding: 0; font-size: .875rem; }
.notices li { margin: 0 0 6px; }
.record {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px 18px;
  font-family: var(--mono); font-size: .9375rem;
}
.rejected p { font-size: .9375rem; margin-bottom: 2px; }

.working summary { cursor: pointer; font-weight: 700; padding: 12px 0; }
.working h3 { font-size: .9375rem; margin: 14px 0 6px; }
.working p { font-size: .875rem; }
.working table { border-collapse: collapse; font-size: .875rem; margin: 0 0 8px; }
.working th, .working td { border: 1px solid var(--ink); padding: 4px 8px; text-align: left; font-weight: 400; }
.working thead th { font-weight: 700; }
.working td { text-align: right; min-width: 2.5em; }
.scroll { overflow-x: auto; }

.sheet-foot .wm { height: 24px; margin-bottom: 8px; }

@media (max-width: 34rem) {
  .count { grid-template-columns: 4.5rem minmax(0, 1fr); }
  .count-result { grid-column: 2; }
}

/* Ballot slips exist only on paper. */
.slips { display: none; }

@page { size: A4; margin: 15mm; }

@media print {
  :root { --bg: #fff; }
  html { font-size: 10pt; }
  html, body { background: #fff; }
  main { max-width: none; padding: 0; }
  .sheet-bar, .working, button { display: none !important; }
  .num { color: var(--ink); }
  .wm { filter: grayscale(1); }
  mark { background: none; border: 1px solid var(--ink); padding: 0 4px; }
  .count { break-inside: avoid; grid-template-columns: 4.5rem minmax(0, 1fr) minmax(0, 14rem); }
  .count-result { grid-column: auto; }
  .declaration h2 { break-after: avoid; }
  .sheet-foot { break-inside: avoid; }

  body[data-screen="paper"] main { display: none; }
  body[data-screen="paper"] .slips { display: block; }
  .slip-page {
    display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 86mm;
    border-top: 1px dashed #000; border-left: 1px dashed #000;
    break-after: page;
  }
  .slip-page:last-child { break-after: auto; }
  .slip {
    display: flex; flex-direction: column; overflow: hidden;
    padding: 5mm 6mm; font-size: 9pt; line-height: 1.3;
    border-right: 1px dashed #000; border-bottom: 1px dashed #000;
  }
  .slip-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 4mm; margin-bottom: 3mm; }
  .slip-title { font-weight: 700; font-size: 11pt; margin: 0; }
  .slip-matter { margin: 1mm 0 0; overflow-wrap: anywhere; }
  .official { display: flex; flex-direction: column; align-items: center; gap: 1mm; font-size: 6.5pt; flex: none; }
  .official-box { width: 14mm; height: 14mm; border: 1px solid #000; }
  .slip-key { display: grid; grid-template-columns: 5mm 1fr; align-items: baseline; gap: 0 2mm; margin: 0 0 3mm; }
  .slip-key dt { font-family: var(--mono); font-weight: 700; }
  .slip-key dd { margin: 0; overflow-wrap: anywhere; }
  .slip-rule { margin: 0 0 2mm; }
  .slip-boxes { display: flex; gap: 1.5mm; margin-top: auto; }
  .slip-cell { display: flex; flex-direction: column; align-items: center; gap: .5mm; font-size: 6.5pt; }
  .slip-box { width: 7.5mm; height: 7.5mm; border: 1px solid #000; }
}
