/* =========================================================================
   Partei-Umfrage – Design-System im SPD-Look
   Farben/Fonts zentral als Variablen, damit sie an einer Stelle anpassbar sind.
   Bewusst ohne externe Fonts/CDN, damit alles offline im lokalen WLAN läuft.
   Schrift: Open Sans – von der SPD als freie Webschrift empfohlen (spd.de),
   hier selbst gehostet (Variable Font), daher offline verfügbar. Die proprietäre
   Hausschrift "The Sans" darf NICHT als Webfont eingebunden werden (keine Lizenz).
   ========================================================================= */
@font-face {
  font-family: "Open Sans";
  src: url("/fonts/OpenSans-var.woff2") format("woff2");
  font-weight: 300 800;
  font-style: normal;
  font-display: swap;
}
:root {
  --spd-red:        #E3000F;   /* SPD-Rot (Primärfarbe) */
  --spd-red-dark:   #B3000C;
  --spd-magenta:    #E10078;   /* SPD-Sekundär (Akzent) */
  --ink:            #1A1A1A;
  --ink-soft:       #4A4A4A;
  --muted:          #767676;
  --line:           #E2E2E2;
  --bg:             #F4F4F5;
  --card:           #FFFFFF;
  --ok:             #2E7D32;
  --radius:         14px;
  --shadow:         0 1px 2px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.06);
  --font:           "Open Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --maxw:           760px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.01em; margin: 0 0 .4em; }
a { color: var(--spd-red); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }

/* ---- Kopfzeile / Marke ------------------------------------------------- */
.topbar {
  background: var(--spd-red);
  color: #fff;
  padding: 14px 18px;
  display: flex; align-items: center; gap: 14px;
}
.brand {
  font-weight: 800; font-size: 1.05rem; letter-spacing: .02em;
  display: inline-flex; align-items: center; gap: 10px;
}
.brand .logo {
  background: #fff; color: var(--spd-red); font-weight: 900;
  padding: 4px 8px; border-radius: 6px; font-size: .9rem; letter-spacing: .04em;
}
.topbar .spacer { flex: 1; }
.topbar .meta { font-size: .85rem; opacity: .92; }

/* ---- Layout ------------------------------------------------------------ */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 22px 18px 80px; }
.wide { max-width: 1100px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; margin: 0 0 18px;
}
.card h2 { font-size: 1.25rem; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }

/* ---- Formulare --------------------------------------------------------- */
label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
input[type=text], input[type=number], input[type=password], textarea, select {
  width: 100%; font: inherit; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 3px solid rgba(227,0,15,.25); border-color: var(--spd-red); }
textarea { min-height: 70px; resize: vertical; }
.field + .field { margin-top: 14px; }

/* ---- Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; cursor: pointer;
  padding: 12px 20px; border-radius: 10px; border: 1.5px solid transparent;
  background: var(--spd-red); color: #fff; transition: filter .12s, transform .02s;
}
.btn:hover { filter: brightness(.94); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost { background: transparent; color: var(--spd-red); border-color: var(--spd-red); }
.btn.danger { background: #fff; color: var(--spd-red-dark); border-color: var(--spd-red-dark); }
.btn.big { padding: 18px 26px; font-size: 1.15rem; width: 100%; }
.btn.sm { padding: 7px 12px; font-size: .85rem; }

/* ---- Code-Eingabe (Beitritt) ------------------------------------------ */
.codebox {
  font-size: 2rem; letter-spacing: .35em; text-align: center; text-transform: uppercase;
  font-weight: 800; padding: 16px; font-variant-numeric: tabular-nums;
}

/* ---- Badges / Status --------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  background: #f0f0f0; color: var(--ink-soft);
}
.badge.open   { background: #E9F7EC; color: var(--ok); }
.badge.closed { background: #FDE7E9; color: var(--spd-red-dark); }
.badge.secret { background: #EEE9F7; color: #5B3FA0; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; display: inline-block; }
.live { color: var(--ok); font-weight: 700; }
.live .dot { animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

/* ---- Auswahl-Optionen (Stimmabgabe) ----------------------------------- */
.choice {
  display: flex; align-items: center; gap: 14px; width: 100%;
  border: 2px solid var(--line); border-radius: 12px; padding: 16px 18px;
  background: #fff; cursor: pointer; text-align: left; font: inherit;
  transition: border-color .1s, background .1s;
}
.choice:hover { border-color: #bbb; }
.choice.selected { border-color: var(--spd-red); background: #FFF4F5; }
.choice .mark {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid #bbb; flex: none;
  display: grid; place-items: center;
}
.choice.selected .mark { border-color: var(--spd-red); background: var(--spd-red); }
.choice.selected .mark::after { content: ""; width: 11px; height: 11px; border-radius: 50%; background: #fff; }
.choice .label { font-weight: 700; }
.choice .sub { font-size: .85rem; color: var(--muted); font-weight: 400; }
.choice .num { margin-left: auto; font-weight: 800; color: var(--muted); }

/* ---- Ergebnis-Balken --------------------------------------------------- */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 1fr; gap: 4px; }
.bar-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.bar-name { font-weight: 700; }
.bar-name .sub { font-weight: 400; color: var(--muted); font-size: .85rem; }
.bar-val { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-track { background: #ECECEC; border-radius: 8px; height: 26px; overflow: hidden; }
.bar-fill {
  height: 100%; background: var(--spd-red); border-radius: 8px;
  transition: width .5s cubic-bezier(.2,.8,.2,1); min-width: 2px;
}
.bar-row:nth-child(2) .bar-fill { background: var(--spd-magenta); }
.bar-row.nein .bar-fill { background: var(--ink-soft); }
.bar-row.enthaltung .bar-fill { background: #B9B9B9; }

/* ---- Hinweise ---------------------------------------------------------- */
.note {
  border-left: 4px solid var(--spd-red); background: #FFF6F6;
  padding: 12px 16px; border-radius: 0 10px 10px 0; font-size: .9rem;
}
.note.legal { border-color: #C9A227; background: #FFFBEF; }
.hr { height: 1px; background: var(--line); border: 0; margin: 18px 0; }

/* ---- Tabellen (Teilnehmerliste) --------------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* ---- Toast ------------------------------------------------------------- */
#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 50; font-weight: 600;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--spd-red-dark); }

/* =========================================================================
   Beamer-/Präsentationsansicht – große Schrift, hoher Kontrast
   ========================================================================= */
body.present { background: #fff; }
.present-stage { max-width: 1400px; margin: 0 auto; padding: 3vh 4vw; min-height: 100vh; display: flex; flex-direction: column; }
.present-stage .ptop { display: flex; align-items: center; gap: 18px; margin-bottom: 2vh; }
.present-stage .plogo { background: var(--spd-red); color: #fff; font-weight: 900; padding: 8px 14px; border-radius: 10px; font-size: clamp(1rem, 2.2vw, 1.6rem); }
.present-stage h1 { font-size: clamp(1.8rem, 4.5vw, 3.6rem); }
.present-stage .pdesc { font-size: clamp(1rem, 2vw, 1.6rem); color: var(--ink-soft); }
.present-stage .pbars { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: clamp(12px, 2.5vh, 28px); }
.present-stage .pbar-name { font-size: clamp(1.2rem, 2.8vw, 2.4rem); font-weight: 800; }
.present-stage .pbar-name .sub { font-size: .55em; font-weight: 400; color: var(--muted); }
.present-stage .pbar-val { font-size: clamp(1.2rem, 2.8vw, 2.4rem); font-weight: 900; }
.present-stage .bar-track { height: clamp(34px, 6vh, 64px); }
.present-stage .pfoot { display: flex; justify-content: space-between; align-items: center; font-size: clamp(1rem, 2vw, 1.5rem); color: var(--muted); margin-top: 2vh; border-top: 2px solid var(--line); padding-top: 1.4vh; }
.present-stage .waiting { flex: 1; display: grid; place-items: center; text-align: center; color: var(--muted); }
.present-stage .waiting .big { font-size: clamp(2rem, 6vw, 5rem); font-weight: 900; color: var(--ink); letter-spacing: .1em; }

@media (max-width: 560px) {
  .wrap { padding: 16px 14px 80px; }
  .card { padding: 18px 16px; }
  .card h1 { font-size: 1.5rem; }
  h1, h2, h3 { overflow-wrap: break-word; }
  .codebox { font-size: 1.6rem; letter-spacing: .25em; }
  /* Kopfbereich des Wahlleiter-Dashboards stapeln statt quetschen */
  .headrow { flex-direction: column; align-items: stretch; }
  .headrow .btn { width: 100%; }
  .idrow { flex-direction: column; align-items: stretch; }
  .idrow .idcode { width: 100%; }
  .choice { padding: 14px; }
}
