/* Look: a polling-station ballot paper. Heavy black rules, square corners,
   Arial-style type, and a box on the right of each option where the X goes. */

:root {
  --ink: #16181b;
  --paper: #ffffff;
  --desk: #d5dbe0;
  --muted: #4d545b;
  --soft: #c3cad1;
  --wash: #eef1f3;
  --danger: #a3201f;
  --focus: #ffdd00;
}

* { box-sizing: border-box; }

html { background: var(--desk); }

body {
  margin: 0;
  padding: 0 1rem;
  font: 1.0625rem/1.55 "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--ink);
}

a { color: var(--ink); text-underline-offset: 0.15em; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 0;
  box-shadow: 0 0 0 6px var(--ink);
}

.sheet {
  max-width: 46rem;
  margin: 2rem auto;
  background: var(--paper);
  border: 3px solid var(--ink);
}

/* ---------- masthead ---------- */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 3px solid var(--ink);
}

.brand {
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.brand small {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.9rem;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--muted);
}

.who { display: flex; align-items: center; gap: 0.75rem; font-size: 0.95rem; }
.who-name { font-weight: 700; }

main { padding: 1.5rem 1.5rem 2rem; min-height: 20rem; }

footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--soft);
  font-size: 0.85rem;
  color: var(--muted);
}
footer p { margin: 0 0 0.5rem; max-width: 60ch; }
footer p:last-child { margin: 0; }

/* ---------- type ---------- */

h1 {
  margin: 0 0 1rem;
  font-size: 2rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
h2 {
  margin: 2rem 0 0;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--ink);
  font-size: 1.15rem;
}
p { max-width: 62ch; }
.loading { color: var(--muted); }
.lede { white-space: pre-wrap; max-width: 62ch; }
.status-line { margin: -0.5rem 0 1.25rem; color: var(--muted); }

/* ---------- buttons ---------- */

.btn, .linkbtn {
  font: inherit;
  cursor: pointer;
}
.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border: 2px solid var(--ink);
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}
.btn:hover { background: #343a40; }
.btn.alt { background: var(--paper); color: var(--ink); }
.btn.alt:hover { background: var(--wash); }
.btn.danger { background: var(--paper); color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: #fbeeee; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--ink); text-decoration: underline; }

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1.5rem 0 0; }

/* ---------- lists of referendums ---------- */

.rows { display: block; }
.row {
  display: block;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--soft);
  text-decoration: none;
}
.row:hover .row-title { text-decoration: underline; }
.row-title { display: block; font-size: 1.15rem; font-weight: 700; }
.row-meta { display: block; font-size: 0.9rem; color: var(--muted); }

/* ---------- notices ---------- */

.notice {
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  border-left: 6px solid var(--ink);
  background: var(--wash);
  max-width: none;
}
.notice.error { border-left-color: var(--danger); }
.notice p { margin: 0 0 0.6rem; }
.notice p:last-child { margin: 0; }

/* ---------- the ballot ---------- */

.ballot { margin: 1.75rem 0 0; padding: 0; border: 0; }
.ballot legend { padding: 0; margin-bottom: 0.75rem; font-weight: 700; font-size: 1.15rem; }

.choice {
  position: relative;
  display: flex;
  align-items: stretch;
  border: 2px solid var(--ink);
  margin-top: -2px;
  cursor: pointer;
}
.choice:first-of-type { margin-top: 0; }
.choice:hover { background: var(--wash); }
.choice .label { flex: 1; padding: 1rem; font-size: 1.15rem; font-weight: 700; }
.choice .box { position: relative; flex: 0 0 4.5rem; border-left: 2px solid var(--ink); background: var(--paper); }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice input:focus-visible ~ .box { outline: 3px solid var(--focus); outline-offset: -5px; box-shadow: inset 0 0 0 5px var(--ink); }

.choice .box::before,
.choice .box::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 62%;
  height: 5px;
  background: var(--ink);
  transform: translate(-50%, -50%) rotate(45deg) scaleX(0);
  transition: transform 0.12s ease-out;
}
.choice .box::after { transform: translate(-50%, -50%) rotate(-45deg) scaleX(0); }
.choice input:checked ~ .box::before { transform: translate(-50%, -50%) rotate(45deg) scaleX(1); }
.choice input:checked ~ .box::after { transform: translate(-50%, -50%) rotate(-45deg) scaleX(1); transition-delay: 0.08s; }

.ballot-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-top: 1.25rem; }
.ballot-foot small { color: var(--muted); }

/* ---------- results ---------- */

.results { margin: 1.5rem 0 0; padding: 0; list-style: none; }
.results li { margin: 0 0 1.1rem; }
.result-head { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.result-head .name { font-size: 1.1rem; }
.result-head .figure { font-variant-numeric: tabular-nums; white-space: nowrap; }
.results .lead .name, .results .lead .figure { font-weight: 700; }
.bar { height: 1.15rem; margin-top: 0.3rem; background: var(--wash); border: 1px solid var(--soft); }
.bar i { display: block; height: 100%; background: #7b838a; }
.results .lead .bar i { background: var(--ink); }

/* ---------- administration ---------- */

.admin { margin-top: 2.5rem; padding: 1rem 1.25rem 1.25rem; border: 2px dashed var(--ink); }
.admin h2 { margin: 0 0 0.5rem; padding: 0; border: 0; font-size: 1.05rem; }
.admin p { margin: 0; }

/* ---------- editor form ---------- */

.field { margin: 0 0 1.4rem; }
.field > label, .field > .field-title { display: block; margin-bottom: 0.3rem; font-weight: 700; }
.hint { margin: 0 0 0.4rem; font-size: 0.9rem; color: var(--muted); }

input[type="text"], textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  font: inherit;
  color: var(--ink);
}
textarea { min-height: 9rem; resize: vertical; }

.option-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.option-row .btn { padding: 0.5rem 0.8rem; }

@media (max-width: 34rem) {
  body { padding: 0; }
  .sheet { margin: 0; border-width: 0 0 3px; }
  .masthead, main, footer { padding-left: 1rem; padding-right: 1rem; }
  .choice .box { flex-basis: 3.5rem; }
  h1 { font-size: 1.65rem; }
}

@media (prefers-reduced-motion: reduce) {
  .choice .box::before, .choice .box::after { transition: none; }
}
