/* Classroom voting: shared styles. Palette and type follow the course slides
   (Jost; SWPS red #c5050c / #9B0000; link blue #0479A8; text #333). */

:root {
  --red: #c5050c;
  --red-dark: #9b0000;
  --blue: #0479a8;
  --bar: #0479a8;
  --text: #333333;
  --muted: #6b6b6b;
  --bg: #ffffff;
  --surface: #f5f5f4;
  --track: #ecebe9;
  --line: #dddcd9;
  --open: #1f7a45;
  --warn: #9a5b00;
  --on-accent: #ffffff;
  color-scheme: light;
}

/* Phones follow the system theme; the projected presenter view stays light. */
@media (prefers-color-scheme: dark) {
  body.student {
    --red: #ff6b6b;
    --red-dark: #ff8a8a;
    --blue: #3a93c4;
    --bar: #3a93c4;
    --text: #ececea;
    --muted: #a3a3a0;
    --bg: #1a1a19;
    --surface: #242423;
    --track: #2e2e2c;
    --line: #3a3a38;
    --open: #4cc38a;
    --warn: #e0a53a;
    color-scheme: dark;
  }
}

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

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Jost", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 400;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

button, input, select { font: inherit; color: inherit; }

[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Result bars (shared) ---------- */

.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.9em; }

.result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "label value" "track track";
  column-gap: 0.75em;
  row-gap: 0.3em;
  align-items: baseline;
}

.result-label { grid-area: label; }
.result-value { grid-area: value; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.result-value strong { color: var(--text); font-weight: 600; }

.result-track {
  grid-area: track;
  height: 20px;
  background: var(--track);
  border-radius: 0 4px 4px 0;
  overflow: hidden;
}

.result-bar {
  display: block;
  height: 100%;
  width: 0;
  background: var(--bar);
  border-radius: 0 4px 4px 0;
  transition: width 700ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* The correct answer, shown once results are revealed: bold plus a tick, so it is
   never signalled by weight alone. */
.result-row.correct .result-label,
.result-row.correct .result-value,
.result-row.correct .result-value strong { font-weight: 600; color: var(--text); }
.tick { color: var(--open); font-weight: 600; margin-right: 0.35em; }

.tag {
  display: inline-block;
  margin-left: 0.4em;
  padding: 0.05em 0.5em;
  border-radius: 999px;
  border: 1px solid var(--blue);
  color: var(--blue);
  font-size: 0.75em;
  font-weight: 500;
  vertical-align: 0.1em;
}

/* ---------- Student (phone) ---------- */

body.student { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.s-top {
  border-top: 4px solid var(--red);
  padding: 12px 16px 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.s-main {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
}

.s-meta {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px;
  font-size: 0.8rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
}
.s-meta .s-section { color: var(--red); font-weight: 500; }

.s-label { font-size: 1.5rem; font-weight: 500; margin: 0.35em 0 0.2em; line-height: 1.2; }
.s-text { font-size: 1.05rem; margin: 0 0 0.8em; }
.s-prompt { font-size: 1.2rem; font-weight: 600; color: var(--red-dark); margin: 0 0 0.9em; }

.s-options { display: grid; gap: 10px; }

.s-option {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 58px;
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
  font-size: 1.1rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 120ms, border-color 120ms, transform 80ms;
}
.s-option:active { transform: scale(0.985); }
.s-option:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.s-radio {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--muted); display: grid; place-items: center;
}

.s-option[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: var(--on-accent); font-weight: 500; }
.s-option[aria-pressed="true"] .s-radio { border-color: var(--on-accent); }
.s-option[aria-pressed="true"] .s-radio::after {
  content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--on-accent);
}
.s-option.pending { opacity: 0.6; }

.s-note { font-size: 0.9rem; color: var(--muted); margin: 14px 0 0; min-height: 1.4em; }
.s-note.ok { color: var(--open); }
.s-note.bad { color: var(--warn); }

.s-closed {
  padding: 14px 16px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--line); margin-bottom: 18px;
}
.s-closed strong { font-weight: 600; }

.s-waiting {
  min-height: 60vh; display: grid; place-content: center; text-align: center; gap: 10px;
}
.s-waiting h1 { font-size: 1.4rem; font-weight: 500; margin: 0; }
.s-waiting p { margin: 0; color: var(--muted); }

.pulse {
  width: 14px; height: 14px; border-radius: 50%; background: var(--red); margin: 0 auto 6px;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.25; transform: scale(0.85); } 50% { opacity: 1; transform: scale(1.1); } }

.s-banner {
  position: fixed; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 6px 14px; border-radius: 999px; font-size: 0.85rem;
}

body.student .results { font-size: 1rem; }

@media (prefers-reduced-motion: reduce) {
  .pulse { animation: none; opacity: 1; }
  .result-bar { transition: none; }
}

/* ---------- Presenter (projector) ---------- */

body.presenter {
  font-size: clamp(14px, 1.12vw, 24px);
  font-weight: 300;
}

/* Only the projector view is locked to the screen height; the sign-in and poll
   list pages scroll normally. */
.p-app { height: 100vh; overflow: hidden; display: grid; grid-template-rows: auto 1fr auto; }

.p-top {
  display: flex; align-items: center; justify-content: space-between; gap: 1em;
  padding: 0.7em 1.6em;
  border-top: 5px solid var(--red);
  border-bottom: 1px solid var(--line);
}
.p-heading { display: flex; flex-direction: column; line-height: 1.25; }
.p-course { color: var(--muted); font-size: 0.9em; }
.p-poll { font-weight: 500; }

.p-join-chip {
  display: flex; align-items: center; gap: 0.8em;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  padding: 0.35em 0.8em 0.35em 0.35em; cursor: pointer;
}
.p-join-chip .qr { width: 3.8em; height: 3.8em; }
.p-join-chip span { font-size: 1.1em; }
.p-join-chip strong { font-weight: 600; color: var(--text); }

.qr svg { display: block; width: 100%; height: 100%; }

.p-main {
  overflow: auto;
  width: 100%; max-width: 72em; margin: 0 auto;
  padding: 2.2em 2.4em 1.4em;
  display: flex; flex-direction: column;
}

.p-meta {
  display: flex; justify-content: space-between; gap: 1em;
  text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.95em; color: var(--muted);
}
.p-section { color: var(--red); font-weight: 500; }

.p-label { font-size: 2.6em; font-weight: 500; margin: 0.25em 0 0.2em; line-height: 1.15; }
.p-text { font-size: 1.75em; line-height: 1.4; margin: 0 0 0.5em; max-width: 38em; }
.p-prompt { font-size: 1.9em; font-weight: 500; color: var(--red-dark); margin: 0 0 0.7em; }

.p-status { display: flex; align-items: center; gap: 1.2em; margin-bottom: 1.1em; min-height: 2.2em; }

.pill {
  display: inline-flex; align-items: center; gap: 0.5em;
  padding: 0.3em 0.9em; border-radius: 999px; font-weight: 500; font-size: 1.05em;
  border: 1px solid var(--line); color: var(--muted);
}
.pill::before { content: ""; width: 0.6em; height: 0.6em; border-radius: 50%; background: currentColor; }
.pill.open { color: var(--open); border-color: var(--open); }
.pill.open::before { animation: pulse 1.6s ease-in-out infinite; }
.pill.closed { color: var(--red-dark); border-color: var(--red-dark); }
.pill.revealed, .pill.done { color: var(--blue); border-color: var(--blue); }

.p-count { font-size: 1.5em; font-variant-numeric: tabular-nums; }
.p-count strong { font-weight: 600; }

.p-main .results { font-size: 1.45em; gap: 0.75em; max-width: 44em; }
.p-main .result-track { height: 24px; }
.p-main .result-value { min-width: 6.5em; text-align: right; }
.p-main .results.compact { font-size: 1.25em; gap: 0.5em; }
.p-main .results.compact .result-track { height: 20px; }
/* Applied only when a question still overflows after going to two columns. */
.p-main.tight { padding-top: 1.4em; }
.p-main.tight .p-label { font-size: 2.1em; margin: 0.15em 0; }
.p-main.tight .p-text { font-size: 1.45em; margin-bottom: 0.35em; }
.p-main.tight .p-prompt { font-size: 1.6em; margin-bottom: 0.45em; }
.p-main.tight .p-status { margin-bottom: 0.6em; }
.p-main .results.many { grid-template-columns: 1fr 1fr; grid-auto-flow: column; column-gap: 3em; max-width: none; }

.p-controls {
  display: flex; align-items: center; gap: 0.6em; flex-wrap: wrap;
  padding: 0.7em 1.6em;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.btn {
  border: 1px solid var(--line); background: var(--bg); border-radius: 8px;
  padding: 0.5em 1em; cursor: pointer; font-weight: 400;
}
.btn:hover { border-color: var(--blue); color: var(--blue); }
.btn:disabled { opacity: 0.4; cursor: default; color: inherit; border-color: var(--line); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: var(--on-accent); font-weight: 500; min-width: 11em; }
.btn.primary:hover { background: #03638a; color: var(--on-accent); }
.btn:focus-visible, .p-join-chip:focus-visible, select:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.p-controls select {
  border: 1px solid var(--line); border-radius: 8px; padding: 0.45em 0.6em; background: var(--bg);
  max-width: 22em;
}
.p-spacer { flex: 1; }
.p-hint { color: var(--muted); font-size: 0.85em; }
.p-hint kbd {
  font-family: inherit; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 0.35em; background: var(--bg);
}

.p-join-overlay {
  position: fixed; inset: 0; z-index: 10;
  background: var(--bg);
  display: grid; place-content: center; justify-items: center; gap: 0.6em;
  text-align: center; cursor: pointer;
  border-top: 5px solid var(--red);
}
.p-join-overlay .qr { width: min(58vh, 40vw); height: min(58vh, 40vw); }
.join-url { font-size: 3em; font-weight: 500; margin: 0.2em 0 0; }
.join-hint { font-size: 1.4em; color: var(--muted); margin: 0; }
.join-close { font-size: 0.95em; color: var(--muted); margin: 1.2em 0 0; }

.p-panel {
  max-width: 34em; margin: 12vh auto; padding: 2em;
  border: 1px solid var(--line); border-top: 5px solid var(--red); border-radius: 12px;
}
.p-panel h1 { font-weight: 500; font-size: 1.6em; margin: 0 0 0.8em; }
.p-panel label { display: block; margin-bottom: 0.4em; color: var(--muted); }
.p-panel input {
  width: 100%; padding: 0.6em 0.8em; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 1em;
}
.p-panel ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.6em; }
.p-panel a {
  display: block; padding: 0.8em 1em; border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); text-decoration: none;
}
.p-panel a:hover { border-color: var(--blue); }
.p-panel a small { display: block; color: var(--muted); }
.p-panel h2 { font-size: 1em; font-weight: 500; color: var(--red); margin: 1.4em 0 0.6em; }
.p-panel li:first-child > h2 { margin-top: 0; }
.p-panel a .p-num { color: var(--muted); margin-right: 0.5em; font-variant-numeric: tabular-nums; }
.p-error { color: var(--red-dark); min-height: 1.4em; margin: 0.6em 0 0; }

.toast {
  position: fixed; left: 50%; bottom: 5.5em; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 0.5em 1.1em; border-radius: 8px;
  z-index: 20;
}

/* Web addresses must show exactly as typed (Jost would join "--" into a dash). */
.join-url, #chipUrl { font-variant-ligatures: none; font-feature-settings: "liga" 0, "dlig" 0; }
