/* =========================================================
   Class Vote — tool-specific styles.
   Layered on /tools/_shared/tool.css.
   ========================================================= */

/* ---------- Setup ---------- */
.cv-setup {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-4);
}
.cv-field { min-width: 0; }
.cv-field-header,
.cv-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}
.cv-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
}
.cv-status {
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.cv-hint {
  margin: 0 0 var(--space-3) 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}
.cv-hint strong { color: var(--text-secondary); font-weight: 600; }
.cv-field textarea {
  width: 100%;
  resize: vertical;
  min-height: 150px;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-inset);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  line-height: 1.55;
  transition: var(--transition-colors);
}
.cv-field textarea::placeholder { color: var(--text-subtle); }
.cv-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.cv-suggest-label { margin: var(--space-3) 0 var(--space-2) 0; }

.cv-chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cv-chip {
  min-height: 32px;
  padding: 4px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--accent-soft-bg);
  color: var(--accent-soft-fg);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-colors);
}
.cv-chip:hover { border-color: var(--accent); }
.cv-chip:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; }

.cv-samples {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.cv-small {
  min-height: 36px;
  padding: var(--space-2) var(--space-3);
  font-size: 13px;
}
.cv-option-row { margin-bottom: var(--space-4); }

.cv-msg {
  margin: 0 0 var(--space-4) 0;
  padding: var(--space-2) var(--space-3);
  font-size: 14px;
  line-height: 1.5;
  color: var(--danger-soft-fg);
  background: var(--danger-soft-bg);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
}
.cv-msg:empty { display: none; }

.cv-actions { margin-bottom: var(--space-2); }
.cv-start {
  font-size: 16px;
  min-height: 52px;
}
.cv-paper {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: var(--space-2) var(--space-4);
  margin-top: var(--space-3);
  font-size: 13px;
}
.cv-paper-label { color: var(--text-muted); }

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}
.btn-link:hover { color: var(--accent-hover); text-decoration: underline; }

.cv-resume {
  margin-bottom: var(--space-5);
  padding: var(--space-4);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft-bg);
  color: var(--accent-soft-fg);
}
.cv-resume p { margin: 0 0 var(--space-3) 0; font-size: 14px; }
.cv-resume-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* ---------- Kiosk (the students' voting screen) ----------
   A fixed overlay over the whole page, so setup and results are
   never visible to a voter. */
.cv-kiosk {
  position: fixed;
  inset: 0;
  z-index: 1000;
  overflow-y: auto;
  background: var(--bg);
  color: var(--text);
  padding: clamp(16px, 4vw, 48px);
}
body.cv-locked { overflow: hidden; }
.cv-kiosk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  max-width: 880px;
  margin: 0 auto var(--space-6);
}
.cv-kiosk-progress {
  font-size: 14px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.cv-end {
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.cv-end.is-armed {
  border-color: var(--danger);
  background: var(--danger-soft-bg);
  color: var(--danger-soft-fg);
}
.cv-kiosk-panel {
  max-width: 880px;
  margin: 0 auto;
  text-align: center;
}
.cv-kiosk-title {
  margin: 0 0 var(--space-3) 0;
  font-size: clamp(26px, 3.4vw, 40px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.cv-kiosk-note {
  margin: 0 0 var(--space-5) 0;
  font-size: 16px;
  color: var(--text-muted);
}
.cv-names {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr));
  gap: var(--space-3);
  margin-top: var(--space-5);
}
.cv-name {
  min-height: 64px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 19px;
  font-weight: 600;
  cursor: pointer;
  overflow-wrap: anywhere;
  transition: var(--transition-colors);
}
.cv-name:hover { border-color: var(--accent); background: var(--accent-soft-bg); }
.cv-name:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 2px; }
.cv-big {
  min-height: 56px;
  padding: var(--space-3) var(--space-6);
  font-size: 18px;
}

.cv-ballot { text-align: left; }
.cv-ballot .cv-kiosk-title,
.cv-ballot > .cv-kiosk-note { text-align: center; }
.cv-ballot-cat {
  margin: 0 0 var(--space-5) 0;
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 16px);
  background: var(--surface);
}
.cv-ballot-cat legend {
  padding: 0 var(--space-2);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.cv-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr));
  gap: var(--space-2);
}
.cv-option { position: relative; cursor: pointer; }
.cv-option input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}
.cv-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: var(--space-2) var(--space-3);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-inset);
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  overflow-wrap: anywhere;
  transition: var(--transition-colors);
}
.cv-option.is-skip span {
  font-weight: 500;
  color: var(--text-muted);
  border-style: dashed;
}
.cv-option input:checked + span {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-fg, #FFFFFF);
}
.cv-option input:focus-visible + span { outline: 3px solid var(--accent-ring); outline-offset: 2px; }
.cv-ballot-msg:not(:empty) { text-align: center; }
.cv-ballot-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
  padding-bottom: var(--space-6);
}
.cv-done-mark {
  margin: var(--space-8, 48px) 0 var(--space-3) 0;
  font-size: 56px;
  line-height: 1;
  color: var(--success);
}

/* ---------- Paper tally ---------- */
.cv-tally,
.cv-results {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}
.cv-tally-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.cv-tally-cat {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-inset);
}
.cv-tally-cat h3 {
  margin: 0 0 var(--space-2) 0;
  font-size: 15px;
  font-weight: 700;
}
.cv-tally-row {
  display: grid;
  grid-template-columns: 1fr auto 2.4em auto;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 0;
  border-top: 1px solid var(--border);
}
.cv-tally-row:first-of-type { border-top: none; }
.cv-tally-name { font-size: 14px; overflow-wrap: anywhere; }
.cv-tally-num {
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.cv-tally-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.cv-tally-btn.is-plus { border-color: var(--accent); color: var(--accent); }
.cv-tally-btn:hover { background: var(--accent-soft-bg); }

/* ---------- Results ---------- */
.cv-results-actions { display: inline-flex; gap: var(--space-4); }
.cv-summary { margin: 0 0 var(--space-3) 0; }
.cv-reveal-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin-bottom: var(--space-4);
}
.cv-inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
}
.cv-inline-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.cv-results-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: var(--space-3);
}
.cv-result {
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-inset);
}
.cv-result.is-revealed {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-ring);
  animation: cvIn 0.35s ease both;
}
.cv-result-cat {
  margin: 0 0 var(--space-2) 0;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}
.cv-winner {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.cv-winner.is-empty { color: var(--text-muted); font-weight: 500; font-size: 17px; }
.cv-tag {
  display: inline-block;
  margin: var(--space-2) var(--space-2) 0 0;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-soft-fg);
  background: var(--accent-soft-bg);
  border-radius: var(--radius-pill);
}
.cv-tiebreak { margin-top: var(--space-2); }
.cv-drumroll {
  margin: 0;
  font-size: 17px;
  color: var(--text-muted);
}
.cv-drumroll::after {
  content: '';
  animation: cvDots 1.2s steps(4, end) infinite;
}
@keyframes cvDots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}
@keyframes cvIn {
  from { opacity: 0.4; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .cv-result.is-revealed { animation: none; }
}
.cv-bars {
  list-style: none;
  margin: var(--space-3) 0 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cv-bars li {
  display: grid;
  grid-template-columns: minmax(0, 7em) 1fr 2em;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
}
.cv-bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-bar-track {
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  overflow: hidden;
}
.cv-bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}
.cv-bar-num { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.cv-results-foot {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  margin-top: var(--space-5);
}
.cv-cert-hint { margin-top: var(--space-3); }

/* Projector view for the results. */
.cv-results.is-projecting {
  position: fixed;
  inset: 0;
  z-index: 1000;
  margin: 0;
  border: none;
  padding: clamp(20px, 4vw, 56px);
  overflow-y: auto;
  background: var(--bg);
}
.cv-results.is-projecting #btn-copy,
.cv-results.is-projecting .cv-results-foot,
.cv-results.is-projecting .cv-cert-hint { display: none; }
.cv-results.is-projecting .section-eyebrow { font-size: 16px; }
.cv-results.is-projecting .cv-results-list {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
  gap: var(--space-4);
}
.cv-results.is-projecting .cv-result-cat { font-size: 16px; }
.cv-results.is-projecting .cv-winner { font-size: clamp(28px, 3vw, 44px); }
.cv-results.is-projecting .cv-bars li { font-size: 16px; }

@media (max-width: 480px) {
  .cv-inline-check { margin-left: 0; }
  .cv-ballot-cat { padding: var(--space-3); }
}

/* ---------- Printed ballots ---------- */
.cv-print { display: none; }

/* Printing is only offered through Print ballots, which sets
   body.cv-printing, so everything but the slips is removed. */
@media print {
  body { background: #fff !important; color: #000 !important; }
  body.cv-printing > *:not(main),
  body.cv-printing main > *:not(#widget),
  body.cv-printing .widget-card > *:not(#print-area) { display: none !important; }
  body.cv-printing .widget-wrap,
  body.cv-printing .widget-card {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: none !important;
    max-width: none !important;
  }
  body.cv-printing .cv-print { display: block !important; }
  body:not(.cv-printing) .cv-print { display: none !important; }
  .cv-print-title {
    margin: 0 0 8pt 0;
    font-size: 9pt;
    color: #555;
  }
  .cv-slips {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
  }
  .cv-slip {
    break-inside: avoid;
    page-break-inside: avoid;
    padding: 10pt 12pt;
    border: 1px dashed #888;
    margin: -0.5px;
    font-size: 10.5pt;
    color: #000;
  }
  .cv-slip-head {
    margin: 0 0 6pt 0;
    font-size: 8pt;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #555;
  }
  .cv-slip-q { margin-bottom: 8pt; }
  .cv-slip-cat { margin: 0 0 3pt 0; font-weight: 700; }
  .cv-slip ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 2pt 12pt;
  }
  .cv-slip li::before {
    content: '';
    display: inline-block;
    width: 9pt;
    height: 9pt;
    margin-right: 4pt;
    border: 1px solid #000;
    vertical-align: -1pt;
  }
  .cv-slip-write {
    margin: 0;
    padding-bottom: 12pt;
    border-bottom: 1px solid #000;
    color: #555;
    font-size: 9pt;
  }
  .print-credit { margin-top: 10pt !important; font-size: 8.5pt !important; }
  @page { size: letter portrait; margin: 0.4in; }
}
