/* Self-hosted (no CDN, per the anonymity requirement): Lustria for titles,
   Lato for body - a conservative serif/sans pairing suited to a formal body. */
@font-face { font-family: 'Lustria'; src: url('/fonts/lustria-400.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Lato'; src: url('/fonts/lato-300.woff2') format('woff2'); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: 'Lato'; src: url('/fonts/lato-400.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Lato'; src: url('/fonts/lato-400-italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'Lato'; src: url('/fonts/lato-700.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Lato'; src: url('/fonts/lato-900.woff2') format('woff2'); font-weight: 900; font-style: normal; font-display: swap; }

:root {
  --serif: 'Lustria', Georgia, 'Times New Roman', serif;
  --sans: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --bg: #f4f5f8;
  --panel: #ffffff;
  --ink: #1a1d24;
  --muted: #616b7a;
  --line: #e2e5ea;
  --field: #f7f8fa;
  /* Cividis-based palette: BLUE = active/positive, GOLD = attention/negative.
     Blue and gold stay distinguishable under all forms of color blindness,
     unlike the green/red they replace. */
  --accent: #235e9c;      /* cividis blue; primary actions, selection, "live/open" */
  --accent-ink: #ffffff;
  --accent-soft: #e6eef7;
  --ok: #235e9c;          /* positive indicators share the blue */
  --ok-soft: #e6eef7;
  --warn: #7a5800;        /* cividis gold; readable as small text on white (~6:1) */
  --warn-soft: #f7ebc2;
  --err: #7a5800;         /* attention/negative also gold (blue vs gold, not red) */
  --err-soft: #f7ebc2;
  --shadow: 0 1px 2px rgba(20,29,47,.05);
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --panel: #181c24;
    --ink: #eef1f6;
    --muted: #9aa4b4;
    --line: #2a303c;
    --field: #212734;
    --accent: #6aa5da;      /* cividis blue, lightened for dark backgrounds */
    --accent-ink: #0a0f16;
    --accent-soft: #183149;
    --ok: #6aa5da;
    --ok-soft: #183149;
    --warn: #e3c451;        /* cividis gold; high contrast on dark */
    --warn-soft: #2a2612;
    --err: #e3c451;
    --err-soft: #2a2612;
    --shadow: 0 1px 2px rgba(0,0,0,.28);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  font-weight: 400;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 40px 24px 0; }
.narrow { max-width: 640px; margin-left: auto; margin-right: auto; }

/* Titles are set in the serif; the serif has a single weight, so headings are
   distinguished by size and the typeface itself, not by bolding. */
h1, h2, h3, .brand-title, .motion-title, .card-title, .section-head, .hero-inner h1 {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: 0;
}
h1 { font-size: 1.7rem; line-height: 1.2; margin: 0 0 6px; }
.sub { color: var(--muted); margin: 0 0 24px; font-size: 1rem; }
.lead { font-size: 1.08rem; margin: 0 0 14px; line-height: 1.55; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin: 16px 0;
  box-shadow: var(--shadow);
}
.card.narrow { margin-left: auto; margin-right: auto; } /* keep it horizontally centered */
.center { text-align: center; }

/* motion */
.open-tag {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--ok); font-weight: 700; font-size: 0.9rem; margin-bottom: 12px;
}
.motion-title { font-size: 1.28rem; font-weight: 700; line-height: 1.25; margin: 0 0 10px; letter-spacing: -0.01em; }
.motion-title:focus { outline: none; } /* focus is moved here programmatically; the SR announcement conveys it */
.motion-body { color: var(--muted); white-space: pre-wrap; margin: 0 0 20px; }

/* option buttons */
.opts { display: flex; flex-direction: column; gap: 12px; margin: 6px 0 4px; }
button {
  font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent;
  padding: 12px 16px; border-radius: 8px; border: 1.5px solid var(--line);
  background: var(--field); color: var(--ink); font-weight: 600;
}
button:active { transform: scale(.99); }
.opt { -webkit-tap-highlight-color: transparent; }
.opt {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 18px 18px; text-align: left;
  border-radius: 8px; border: 1.5px solid var(--line); background: var(--field);
  color: var(--ink); font-size: 1.08rem; font-weight: 500;
  transition: border-color .12s ease, background .12s ease, transform .06s ease;
}
.opt:hover { border-color: var(--accent); }
.opt:active { transform: scale(.99); }
.opt.selected { border-color: var(--accent); background: var(--accent-soft); }
.opt-label { text-transform: capitalize; }
.opt .mark { color: var(--accent); font-weight: 700; font-size: 0.9rem; white-space: nowrap; }
.vote-help { margin: 14px 2px 0; font-size: 0.92rem; }

.primary {
  display: block; width: 100%; padding: 17px; margin-top: 8px;
  border: none; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  font-size: 1.08rem; font-weight: 600; letter-spacing: .01em;
}
.primary:active { transform: scale(.99); }

/* inputs */
input[type=text], input[type=password], textarea {
  width: 100%; padding: 16px; font: inherit;
  border-radius: 8px; border: 1.5px solid var(--line); background: var(--field); color: var(--ink);
  margin: 4px 0 2px;
}
textarea { font-family: inherit; min-height: 84px; resize: vertical; }
/* the credential field: centered, spaced, upper-cased for legibility */
.code-input { text-align: center; letter-spacing: 0.12em; text-transform: uppercase; font-size: 1.2rem; }
.code-input::placeholder { text-transform: none; letter-spacing: 0.08em; }
input:focus, textarea:focus, .opt:focus-visible, button:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
/* a smaller heading used inside cards (console sections, list items, results) */
.card-title { font-size: 1.12rem; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.footnote { margin-top: 32px; }

/* status banners */
.status {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 15px; border-radius: 12px; margin: 0 0 16px; font-size: 0.95rem; font-weight: 500;
}
/* Glyph inherits the banner's semantic color - no white-on-color, so it stays
   legible on the gold attention state and adapts to light/dark. */
.status-ico { flex: none; font-size: 1.05rem; font-weight: 800; line-height: 1; }
.status.ok { background: var(--ok-soft); color: var(--ok); }
.status.warn { background: var(--warn-soft); color: var(--warn); }
.status.err { background: var(--err-soft); color: var(--err); }

/* waiting state */
.waiting { padding: 34px 22px; }
.pulse {
  width: 44px; height: 44px; border-radius: 50%; margin: 0 auto 16px;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
  70% { box-shadow: 0 0 0 18px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

.muted { color: var(--muted); }
a { color: var(--accent); }

/* ---- homepage ---- */
.primary { text-align: center; text-decoration: none; }
.hero { text-align: center; }
.hero .primary { margin-top: 16px; }
.hero-note { margin: 14px 4px 0; font-size: 0.92rem; }
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 11px; }
.steps li { padding-left: 4px; }
.steps li::marker { color: var(--accent); font-weight: 700; }
.anon { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.anon li { line-height: 1.5; }
.tag { display: inline-block; font-size: 0.82rem; font-weight: 700;
  padding: 2px 10px; border-radius: 4px; margin-right: 8px; vertical-align: middle; }
.tag.yes { color: var(--ok); background: var(--ok-soft); }
.tag.no { color: var(--err); background: var(--err-soft); }
/* ===== site header ===== */
.site-header { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--panel) 90%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.header-inner { max-width: 1080px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { font-family: var(--serif); font-size: 1.2rem; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--accent); }
.header-right { display: flex; align-items: center; gap: 14px; }
.btn-ghost { text-decoration: none; font-weight: 600; font-size: 0.95rem; color: var(--accent); padding: 10px 18px; border: 1.5px solid var(--line); border-radius: 8px; white-space: nowrap; }
.btn-ghost:hover { border-color: var(--accent); }

/* ===== masthead (homepage) - a formal notice, not a marketing hero ===== */
.hero { border-bottom: 1px solid var(--line); }
.hero-inner { max-width: 680px; margin: 0 auto; padding: 60px 24px 52px; text-align: center; }
.hero-eyebrow { font-family: var(--serif); font-style: italic; color: var(--muted); font-size: 1rem; margin: 0 0 14px; }
.hero-inner h1 { font-size: 2rem; line-height: 1.22; margin: 0 0 18px; }
.hero-lead { font-size: 1.1rem; color: var(--muted); margin: 0 auto 30px; line-height: 1.65; max-width: 560px; }
.hero-cta { display: inline-block; width: auto; padding: 14px 34px; font-size: 1.05rem; }
.hero-note { color: var(--muted); font-size: 0.92rem; margin-top: 22px; }

/* ===== homepage: announcement document ===== */
.doc { max-width: 760px; margin: 0 auto; }
.doc h1 { font-size: 2rem; line-height: 1.2; margin: 0 0 20px; }
.announce { font-size: 1.12rem; line-height: 1.7; margin: 0 0 22px; }
.cred-note { font-family: var(--serif); font-style: italic; color: var(--muted); margin: 0 0 26px; }
.doc-actions { margin: 4px 0 34px; }
.doc-actions .primary { display: inline-block; width: auto; padding: 13px 32px; font-size: 1.02rem; }
.section-head { font-size: 1.4rem; margin: 34px 0 14px; }
.agenda { margin: 0; padding-left: 1.4em; }
.agenda li { padding: 6px 0 6px 4px; line-height: 1.5; border-bottom: 1px solid var(--line); }
.agenda li:last-child { border-bottom: 0; }
.callout { background: var(--field); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; padding: 20px 22px; margin: 8px 0 0; }
.callout p { margin: 0 0 12px; line-height: 1.65; color: var(--ink); }
.callout p:last-child { margin-bottom: 0; }
.callout .muted { color: var(--muted); }

/* ===== sections (older two-column layout, still used if present) ===== */
.features { display: grid; gap: 28px; padding: 12px 0; }
@media (min-width: 820px) { .features { grid-template-columns: 1fr 1fr; align-items: start; } }

/* ===== site footer - three collapsed accordions, spread horizontally ===== */
.site-footer { background: var(--field); border-top: 1px solid var(--line); margin-top: 48px; }
.footer-inner { max-width: 1080px; margin: 0 auto; padding: 18px 24px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 36px; align-items: start; }
@media (max-width: 700px) { .footer-inner { grid-template-columns: 1fr; gap: 2px; } }
.foot-acc summary {
  font-family: var(--serif); font-size: 1.02rem; color: var(--ink);
  padding: 10px 0; cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: 9px;
}
.foot-acc summary::-webkit-details-marker { display: none; }
.foot-acc summary::before { content: '+'; color: var(--muted); font-size: 1.15rem; font-family: var(--sans); width: 0.8em; flex: none; text-align: center; }
.foot-acc[open] summary::before { content: '\2013'; }
.foot-acc summary:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); border-radius: 4px; }
.foot-acc-body { padding: 0 0 8px; }
.foot-acc-body p { color: var(--muted); font-size: 0.9rem; line-height: 1.6; margin: 0; }

/* ---- chair / clerk console ---- */
.big { font-size: 2.6rem; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.quorum { display: flex; align-items: center; justify-content: center; gap: 14px; }
.quorum .label { text-align: left; color: var(--muted); font-size: 0.92rem; }
.row { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; }

.badge { font-size: 0.9rem; font-weight: 700; }
.badge.open { color: var(--ok); }
.badge.closed { color: var(--muted); }
.badge.draft { color: var(--warn); }

.btn {
  padding: 12px 16px; border-radius: 8px; border: 1.5px solid var(--line);
  background: var(--field); color: var(--ink); font-weight: 600; font-size: 0.98rem; margin-top: 8px;
}
.btn.wide { display: block; width: 100%; }
.btn.go { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* result bars */
.bars { margin: 14px 0 6px; display: flex; flex-direction: column; gap: 10px; }
.bar-row { }
.bar-top { display: flex; justify-content: space-between; font-size: 0.95rem; margin-bottom: 5px; }
.bar-top span:first-child { text-transform: capitalize; }
.bar-top .n { font-variant-numeric: tabular-nums; font-weight: 700; }
.bar-track { height: 12px; border-radius: 999px; background: var(--field); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width .35s ease; }
.tallyfoot { display: flex; justify-content: space-between; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.9rem; }
.tallyfoot b { color: var(--ink); font-variant-numeric: tabular-nums; }

table { width: 100%; border-collapse: collapse; }
td, th { padding: 9px 6px; border-bottom: 1px solid var(--line); text-align: left; font-weight: 400; }
td.n { text-align: right; font-variant-numeric: tabular-nums; }
code { background: var(--field); padding: 1px 6px; border-radius: 6px; font-size: 0.9em; }

/* ---- header + connection indicator ---- */
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.topbar h1 { flex: 1; }
.conn {
  flex: none; display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 11px; border-radius: 999px; font-size: 0.8rem; font-weight: 600;
  border: 1px solid var(--line); background: var(--panel); white-space: nowrap; margin-top: 3px;
}
.conn .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.conn.live { color: var(--ok); }
.conn.live .dot { background: var(--ok); animation: live 1.5s ease-out infinite; }
.conn.reconnecting, .conn.connecting { color: var(--warn); }
.conn.reconnecting .dot, .conn.connecting .dot { background: var(--warn); animation: blink 1s steps(2,start) infinite; }
.conn.offline { color: var(--err); }
.conn.offline .dot { background: var(--err); }
/* An expanding, fading ring - the "heartbeat" that shows the connection is live. */
@keyframes live {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); }
  70%  { box-shadow: 0 0 0 9px color-mix(in srgb, var(--ok) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 0%, transparent); }
}
@keyframes blink { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .conn .dot { animation: none !important; } }

/* ---- session bar (chair) ---- */
.session-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.session-title { font-size: 1.1rem; font-weight: 700; }
.section-label { font-family: var(--serif); font-size: 0.95rem; font-style: italic; color: var(--muted); margin: 26px 2px 8px; }
.session-bar .section-label { margin: 0 0 2px; }

/* ---- published results (voter) ---- */
.result-card { position: relative; }
.result-tag { color: var(--muted); font-family: var(--serif); font-style: italic; font-size: 0.9rem; margin-bottom: 6px; }
.badge.pub { color: var(--accent); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.btn-row .btn { margin-top: 0; }
.btn.go { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pub-note { color: var(--ok); font-size: 0.85rem; font-weight: 600; }

/* ---- clerk console ---- */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.95rem; }
.mt { margin-top: 12px; }
.addr { font-size: 0.85rem; }
.d-sent { color: var(--ok); font-weight: 600; }
.d-failed { color: var(--err); font-weight: 600; }
.d-pending { color: var(--muted); }

/* ---- laptop layout: wider console, motions in two columns ---- */
body.console .wrap { max-width: 940px; }
.console-tag { color: var(--muted); font-size: 0.9rem; font-weight: 600; }

/* ---- officer console tabs (chronological) ---- */
.tabbar { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.tab-btn {
  background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0;
  padding: 12px 18px; margin-bottom: -1px; cursor: pointer;
  font-family: var(--serif); font-size: 1.05rem; color: var(--muted);
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--ink); border-bottom-color: var(--accent); }
.tab-btn:active { transform: none; }
.hidden { display: none; }
@media (min-width: 780px) {
  body.console #motions { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  body.console #motions .card { margin: 0; }
}

/* ---- laptop layout: voter page uses the width (motion | results) ---- */
@media (min-width: 900px) {
  .vote-cols.has-side { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: 24px; align-items: start; }
  .vote-cols:not(.has-side) { max-width: 640px; }           /* a lone motion stays a sensible form width */
  .vote-side .section-label:first-child { margin-top: 6px; }
}
