/* ============================================================
   Klassen-Umfrage – gemeinsames Stylesheet
   Optik: "Pinnwand / Klassenbuch" – warmes Papier, Tinte, Textmarker-Akzent
   ============================================================ */

/* Schrift lokal eingebunden – funktioniert komplett offline, ohne Internet. */
@font-face {
  font-family: "Fredoka";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/fredoka-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Fredoka";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/fredoka-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Fredoka";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/fredoka-latin-700-normal.woff2") format("woff2");
}

:root {
  --paper: #faf7ef;
  --paper-raised: #ffffff;
  --ink: #22303c;
  --ink-soft: #5b6b78;
  --line: #e4ddc9;
  --accent: #ff6b4a;       /* Textmarker-Orange: Aktionen, aktive Zustände */
  --accent-ink: #ffffff;
  --accent-soft: #ffe7df;
  --live: #ffd23f;         /* Live-Indikator */
  --good: #2e8b57;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 2px 10px rgba(34, 48, 60, 0.08), 0 1px 2px rgba(34, 48, 60, 0.06);
  --font-display: "Fredoka", "Segoe UI Rounded", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(circle at 1px 1px, rgba(34,48,60,0.05) 1px, transparent 0);
  background-size: 22px 22px;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 18px 64px;
}

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

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 4px;
}

h1 { font-size: 1.65rem; letter-spacing: 0.2px; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }

.subtitle {
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin: 0 0 20px;
}

.card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px 20px;
  margin-bottom: 16px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 100px;
  margin-bottom: 10px;
}

/* ---- Formularelemente ---- */

label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

input[type="text"], textarea {
  width: 100%;
  font-size: 1rem;
  font-family: var(--font-body);
  padding: 11px 13px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  transition: border-color 0.15s ease;
}

input[type="text"]:focus, textarea:focus {
  outline: 3px solid var(--accent-soft);
  border-color: var(--accent);
}

textarea { resize: vertical; min-height: 140px; line-height: 1.5; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 0.98rem;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: 100px;
  border: none;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
  transition: transform 0.08s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn:hover { box-shadow: 0 4px 14px rgba(255,107,74,0.35); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

.btn-secondary {
  background: var(--paper-raised);
  color: var(--ink);
  border: 1.5px solid var(--line);
}
.btn-secondary:hover { box-shadow: var(--shadow); }

.btn-danger {
  background: #fff;
  color: #c0392b;
  border: 1.5px solid #f1c2bb;
}

.btn-block { width: 100%; }

/* ---- Fortschrittsanzeige (Abstimmungsseite) ---- */

.progress-wrap {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--paper);
  padding: 14px 0 10px;
  margin-bottom: 6px;
}

.progress-track {
  height: 8px;
  border-radius: 100px;
  background: var(--line);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 100px;
  transition: width 0.25s ease;
}
.progress-label {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 6px;
  font-weight: 600;
}

/* ---- Autocomplete / Typeahead ---- */

.autocomplete {
  position: relative;
}

.autocomplete-results {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 4px);
  background: var(--paper-raised);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  max-height: 240px;
  overflow-y: auto;
  z-index: 20;
  display: none;
}
.autocomplete-results.open { display: block; }

.autocomplete-item {
  padding: 10px 13px;
  cursor: pointer;
  font-size: 0.97rem;
  border-bottom: 1px solid var(--line);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--accent-soft);
}
.autocomplete-item mark {
  background: none;
  color: var(--accent);
  font-weight: 700;
}
.autocomplete-empty {
  padding: 10px 13px;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.selected-chip {
  display: none;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.88rem;
  color: var(--good);
  font-weight: 600;
}
.selected-chip.show { display: flex; }

/* ---- Live-Ergebnisseite ---- */

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--live);
  padding: 5px 12px;
  border-radius: 100px;
}
.live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #c0392b;
  animation: pulse 1.6s infinite;
}
@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(192,57,43,0.55); }
  70% { box-shadow: 0 0 0 7px rgba(192,57,43,0); }
  100% { box-shadow: 0 0 0 0 rgba(192,57,43,0); }
}

.rank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.rank-row:last-child { border-bottom: none; }
.rank-medal {
  font-family: var(--font-display);
  font-weight: 700;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper);
  border: 1.5px solid var(--line);
  font-size: 0.85rem;
  flex-shrink: 0;
}
.rank-row:nth-child(1) .rank-medal { background: #fff4d6; border-color: #f0d27a; }
.rank-row:nth-child(2) .rank-medal { background: #f1f1f1; border-color: #cfcfcf; }
.rank-row:nth-child(3) .rank-medal { background: #fbe6dd; border-color: #e8b9a3; }
.rank-name { font-weight: 600; flex: 1; }
.rank-score { color: var(--ink-soft); font-size: 0.9rem; font-weight: 600; }

.question-block {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.question-block:last-child { border-bottom: none; margin-bottom: 0; }
.question-weight {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 100px;
  margin-left: 6px;
  font-weight: 600;
  vertical-align: middle;
}

.empty-state {
  text-align: center;
  color: var(--ink-soft);
  padding: 30px 10px;
}

.meta-line {
  color: var(--ink-soft);
  font-size: 0.82rem;
  margin-top: 18px;
  text-align: center;
}

.alert {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 14px;
}
.alert-error { background: #fdecea; color: #b3261e; border: 1px solid #f4c6c0; }
.alert-success { background: #e8f5e9; color: #1e6b30; border: 1px solid #bfe3c3; }

.admin-section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.hint {
  font-size: 0.84rem;
  color: var(--ink-soft);
  margin: 0 0 12px;
}

footer.tool-footer {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.78rem;
  margin-top: 30px;
}

@media (max-width: 420px) {
  h1 { font-size: 1.4rem; }
  .page { padding: 18px 14px 56px; }
}

/* ---- Drei Auswahlfelder pro Frage ---- */
.pick-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.pick-num {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink-soft);
  width: 18px;
  flex-shrink: 0;
  text-align: right;
}
.pick-slot .autocomplete { flex: 1; }

/* ---- Beamer-Lesbarkeit der Ergebnisseite ---- */
body.results .page { max-width: 820px; }
body.results h1 { font-size: 2.1rem; }
body.results .rank-name { font-size: 1.25rem; }
body.results .rank-score { font-size: 1.05rem; }
body.results .rank-medal { width: 34px; height: 34px; font-size: 1rem; }
body.results h3 { font-size: 1.2rem; }
body.results #overallCard .rank-name { font-size: 1.4rem; }

/* ---- Live-Modus: Namensleiste & Links ---- */
.namebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--ink-soft);
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 8px 14px;
  margin-bottom: 14px;
}
.linkbtn {
  background: none; border: none; padding: 0;
  color: var(--accent); font-weight: 600; cursor: pointer;
  font-size: 0.9rem; text-decoration: underline;
}
.qmeta {
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--accent);
}
.qtext { margin: 4px 0 0; }

/* ---- Steuerleiste auf der Ergebnis-/Steuerseite ---- */
.controlbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 18px;
}
.control-status { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; margin-bottom: 10px; }
.control-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.control-buttons .btn { padding: 10px 16px; }

/* aktive Frage hervorheben */
.card.active-q { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.answers-line { font-size: 0.85rem; color: var(--ink-soft); margin: 2px 0 8px; }

/* Beamer: Steuerleiste & aktive Frage größer */
body.results .control-status { font-size: 1.4rem; }
body.results .qmeta { font-size: 0.95rem; }
