/* Společný základ. Obrazovka lektora se promítá, takže všude velké písmo
   a vysoký kontrast – musí to být čitelné z posledních řad. */

:root {
  --bg: #f5f5f4;
  --surface: #ffffff;
  --ink: #1c1917;
  --ink-soft: #6b6560;
  --line: #e0dedb;
  --accent: #2563eb;
  --danger: #dc2626;
  --radius: 14px;

  --opt-0: #2563eb;
  --opt-1: #db2777;
  --opt-2: #16a34a;
  --opt-3: #ea580c;
  --opt-4: #7c3aed;
  --opt-5: #0891b2;

  --yes: #16a34a;
  --no: #dc2626;
  --scale-0: #dc2626;
  --scale-1: #ea580c;
  --scale-2: #ca8a04;
  --scale-3: #65a30d;
  --scale-4: #16a34a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  padding: 0.7em 1.3em;
  font-weight: 600;
}
button:disabled { opacity: 0.4; cursor: default; }
button.ghost { background: transparent; color: var(--ink-soft); font-weight: 500; }
button.ghost:hover:not(:disabled) { color: var(--ink); }

input[type="text"], textarea {
  font: inherit;
  width: 100%;
  padding: 0.7em 0.9em;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}
input[type="text"]:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.setup-warning {
  max-width: 34rem;
  margin: 4rem auto;
  padding: 2rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px solid var(--danger);
}
.setup-warning code {
  background: var(--bg);
  padding: 0.15em 0.4em;
  border-radius: 5px;
}

/* ---------- Obrazovka lektora ---------- */

.host {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.host .center {
  margin: auto;
  text-align: center;
  padding: 2rem;
}
.host .center h1 { font-size: 2.5rem; margin-bottom: 0.5rem; }
.host .center p { color: var(--ink-soft); font-size: 1.1rem; }

.topbar {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0.9rem 1.6rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.topbar .label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-soft);
}
.topbar .code {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  line-height: 1.1;
}
.topbar .url { font-size: 1.25rem; font-weight: 600; line-height: 1.1; }
.topbar .spacer { flex: 1; }
.topbar .count { font-size: 2rem; font-weight: 800; line-height: 1.1; }

.board {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1.6rem 2.5rem;
  display: flex;
  flex-direction: column;
}
.board .question, .board .average, .board .status { flex: none; }

.results { display: flex; flex-direction: column; gap: 0.5rem; }
.board .question {
  font-size: clamp(1.8rem, 3.4vw, 3rem);
  line-height: 1.15;
  margin: 0 0 1.5rem;
}
.board .waiting {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: var(--ink-soft);
}
.board .waiting strong { font-size: 2rem; color: var(--ink); }

/* Výsledky – vodorovné sloupce */
.bar-row {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.bar-head {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  font-size: clamp(1.1rem, 1.8vw, 1.6rem);
  margin-bottom: 0.4rem;
}
.bar-head .letter {
  font-weight: 800;
  width: 1.4em;
  flex: none;
  color: var(--c);
}
.bar-head .text { font-weight: 600; flex: 1; }
.bar-head .num { font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.bar-track {
  flex: 0 1 2.4rem;
  min-height: 1rem;
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--c);
  border-radius: 8px;
  transition: width 0.4s ease;
}
.voters {
  flex: none;
  margin-top: 0.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.voters span {
  font-size: 0.95rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.12em 0.7em;
  color: var(--ink-soft);
}

/* Spodní lišta pro psaní otázky – schválně nízká, ať na plátně nekřičí */
.composer {
  flex: none;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 0.8rem 1.6rem;
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  font-size: 0.95rem;
}
.composer .fields { flex: 1; display: flex; flex-direction: column; gap: 0.5rem; }
.composer .options { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.composer .opt { display: flex; align-items: center; gap: 0.35rem; flex: 1 1 12rem; }
.composer .opt .letter { font-weight: 800; color: var(--ink-soft); }
.composer .actions { display: flex; flex-direction: column; gap: 0.4rem; }
.composer input[type="text"] { padding: 0.45em 0.7em; border-width: 1px; }

/* ---------- Obrazovka účastníka ---------- */

.join {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.2rem;
}
.join [data-screen] {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  max-width: 32rem;
  width: 100%;
  margin: 0 auto;
}
.join [data-screen][hidden] { display: none; }
.join h1 { font-size: 1.7rem; margin: 0; }
.join p.hint { color: var(--ink-soft); margin: 0; }
.join .code-input {
  text-transform: uppercase;
  letter-spacing: 0.35em;
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
}
.join .error { color: var(--danger); font-weight: 600; margin: 0; }

.whoami {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
  padding-bottom: 0.8rem;
}
.whoami strong { color: var(--ink); }
.whoami .spacer { flex: 1; }

.vote-question {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 0.5rem;
}
.choices { display: flex; flex-direction: column; gap: 0.7rem; }
.choice {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  width: 100%;
  text-align: left;
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--line);
  padding: 1.1rem 1.2rem;
  font-size: 1.2rem;
  font-weight: 600;
}
.choice .letter {
  font-size: 1.5rem;
  font-weight: 800;
  width: 1.3em;
  flex: none;
  color: var(--c);
}
.choice[aria-pressed="true"] {
  border-color: var(--c);
  background: color-mix(in srgb, var(--c) 12%, var(--surface));
}
.choice:disabled { opacity: 0.55; }

.status {
  text-align: center;
  color: var(--ink-soft);
  font-size: 1.05rem;
  margin: 0.4rem 0 0;
}

/* Wrapper obrazovky lektora nesmí rozbít sloupcový layout body */
#screen-stage { display: contents; }
#screen-stage[hidden] { display: none; }

/* Hlasovací obrazovka drží obsah nahoře, ať se otázka nehoupe uprostřed displeje */
#screen-vote { justify-content: flex-start; padding-top: 0.5rem; }

/* ---------- QR kódy ---------- */

.qr-mini svg { display: block; width: 64px; height: 64px; }
.qr-big svg { display: block; width: min(38vh, 300px); height: min(38vh, 300px); }

.board .waiting .qr-big { margin-bottom: 1.2rem; }
.board .waiting p { margin: 0.3rem 0 0; font-size: 1.1rem; }
.board .waiting p b { color: var(--ink); letter-spacing: 0.15em; }
.voters.names { justify-content: center; margin-top: 1.4rem; max-width: 60rem; }
.voters.names span { font-size: 1.05rem; }

/* ---------- průměr u škály ---------- */

.average {
  margin: -0.6rem 0 1.2rem;
  font-size: 1.3rem;
  color: var(--ink-soft);
}
.average strong {
  font-size: 2.6rem;
  color: var(--ink);
  vertical-align: -0.15em;
  margin-left: 0.3rem;
}

/* ---------- pruh s koncepty a historií ---------- */

.strip {
  flex: none;
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding: 0.5rem 1.6rem;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: none;
  max-width: 16rem;
  padding: 0.3em 0.7em;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink-soft);
  font-size: 0.85rem;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--ink); }
.chip .mark { font-size: 0.7em; }
.chip .chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.is-draft { border-style: dashed; border-color: var(--accent); color: var(--accent); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .del { padding: 0 0.2em; font-weight: 700; }
.chip .del:hover { color: var(--danger); }

/* ---------- přepínač typu otázky ---------- */

.types { display: flex; gap: 0.35rem; }
.types .type {
  background: var(--bg);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  padding: 0.25em 0.8em;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}
.types .type.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }

.composer .options[hidden] { display: none; }

/* ---------- škála na mobilu ---------- */

.scale-row { display: flex; gap: 0.5rem; }
.scale-row .choice {
  flex: 1;
  justify-content: center;
  padding: 1.2rem 0;
}
.scale-row .choice .big { font-size: 1.8rem; font-weight: 800; color: var(--c); }

/* Jména hlasujících se dají schovat, když je jich na plátno moc */
.board.hide-names .voters { display: none; }

.strip { align-items: center; }
.strip .chips { display: flex; gap: 0.4rem; overflow-x: auto; flex: 1; }
.strip .small {
  flex: none;
  font-size: 0.8rem;
  padding: 0.3em 0.7em;
  white-space: nowrap;
}

/* Bez jmen si sloupce rozdělí výšku plátna a nikdy se nemusí scrollovat.
   Se jmény má obsah přirozenou výšku – to už je vědomé rozhodnutí lektora. */
.board.hide-names .results { flex: 1; min-height: 0; }
.board.hide-names .bar-row { flex: 1 1 0; min-height: 0; overflow: hidden; }
.board:not(.hide-names) .bar-row { flex: none; padding-bottom: 0.7rem; }
