/* Umfragen (ROADMAP 8F): /polls, /polls/{id}, Cockpit-Reiter "Polls" (Editor mit Vorschau).
   Baut auf site.css auf. Farbe einer Umfrage = feste Palette aus den Design-Tokens (hell/dunkel automatisch). */

.poll-c-orange { --poll: var(--accent); --poll-soft: var(--accent-soft); }
.poll-c-blue   { --poll: var(--info);   --poll-soft: var(--info-soft); }
.poll-c-green  { --poll: var(--ok);     --poll-soft: var(--ok-soft); }
.poll-c-yellow { --poll: var(--warn);   --poll-soft: var(--warn-soft); }
.poll-c-red    { --poll: var(--bad);    --poll-soft: var(--bad-soft); }
.poll-c-gray   { --poll: var(--muted);  --poll-soft: color-mix(in srgb, var(--muted) 14%, transparent); }

/* --- Liste ---------------------------------------------------------------------------------- */
.poll-list { list-style: none; margin: 0 0 32px; padding: 0; display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.poll-card {
  display: grid; gap: 8px; align-content: start; padding: 18px 18px 16px; border-radius: var(--radius-l);
  background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--poll);
  color: inherit; text-decoration: none; min-width: 0;
  transition: transform .25s var(--ease), border-color .25s, box-shadow .25s;
}
a.poll-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--border-strong); border-top-color: var(--poll); }
a.poll-card:focus-visible { outline: 2px solid var(--poll); outline-offset: 2px; }
.poll-card h3 { margin: 0; font: 650 18px/1.3 var(--font-body); overflow-wrap: anywhere; }
.poll-card p { margin: 0; color: var(--muted); font-size: 14px; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.poll-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 13px; color: var(--muted); }
.poll-meta .icon { width: 15px; height: 15px; vertical-align: -2px; }
.poll-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--poll); flex: none; display: inline-block; }

/* --- Eine Umfrage --------------------------------------------------------------------------- */
.poll-head { border-top: 5px solid var(--poll); background: linear-gradient(180deg, var(--poll-soft), transparent 80%), var(--surface); }
.poll-head h1, .poll-head h2 { margin: 6px 0 8px; overflow-wrap: anywhere; }
.poll-desc { white-space: pre-line; color: var(--text-2); margin: 0 0 12px; overflow-wrap: anywhere; }
.poll-countdown {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: var(--poll-soft); color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums;
}
.poll-countdown .icon { color: var(--poll); width: 16px; height: 16px; }

.poll-q { padding: 18px 0; border-top: 1px solid var(--border); scroll-margin-top: calc(var(--header-h) + 20px); }
.poll-q:first-of-type { border-top: 0; padding-top: 4px; }
.poll-q > legend, .poll-q-title { font-weight: 650; font-size: 16px; margin-bottom: 4px; padding: 0; overflow-wrap: anywhere; }
fieldset.poll-q { border: 0; margin: 0; min-width: 0; }
.poll-req { color: var(--bad); margin-left: 4px; }
.poll-q .hint { margin-bottom: 10px; }
.poll-q.is-missing { border-left: 3px solid var(--bad); padding-left: 12px; }
.poll-q .poll-err { color: var(--bad); font-size: 14px; font-weight: 600; margin: 8px 0 0; }
.poll-options { display: grid; gap: 8px; }
.poll-option {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--bg-2); cursor: pointer; overflow-wrap: anywhere;
}
.poll-option:hover { border-color: var(--poll); }
.poll-option:has(input:checked) { border-color: var(--poll); background: var(--poll-soft); }
.poll-option input { width: 18px; height: 18px; margin: 0; accent-color: var(--poll); flex: none; }
.poll-rating { display: flex; flex-wrap: wrap; gap: 8px; }
.poll-rating label {
  position: relative; display: grid; place-items: center; min-width: 48px; height: 44px; padding: 0 10px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--bg-2); cursor: pointer; font-weight: 700;
}
.poll-rating input { position: absolute; opacity: 0; pointer-events: none; }
.poll-rating label:has(input:checked) { background: var(--poll); border-color: var(--poll); color: var(--bg); }
.poll-rating label:has(input:focus-visible) { outline: 2px solid var(--poll); outline-offset: 2px; }
.poll-rating-legend { display: flex; justify-content: space-between; max-width: 300px; font-size: 12px; color: var(--muted); margin-top: 4px; }

/* --- Ergebnisse (eigene Balken, keine Bibliothek) ------------------------------------------- */
.poll-results { display: grid; gap: 22px; }
.poll-r-q h3 { margin: 0 0 10px; font: 650 16px/1.35 var(--font-body); overflow-wrap: anywhere; }
.poll-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.poll-bar-row { display: grid; gap: 4px; }
.poll-bar-label { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.poll-bar-label span:first-child { overflow-wrap: anywhere; min-width: 0; }
.poll-bar-label b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.poll-bar-label .is-mine::after { content: ' ✓'; color: var(--poll); }
.poll-bar { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.poll-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--poll); width: 0;
  transition: width .6s var(--ease); }
.poll-bar.is-top > span { background: linear-gradient(90deg, var(--poll), color-mix(in srgb, var(--poll) 70%, var(--text))); }
.poll-avg { font: 400 28px/1 var(--font-display); color: var(--poll); margin-right: 8px; }
.poll-texts { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; max-height: 360px; overflow: auto; }
.poll-texts li { padding: 10px 12px; border-radius: var(--radius); background: var(--bg-2); border: 1px solid var(--border);
  white-space: pre-line; overflow-wrap: anywhere; font-size: 14px; }
@media (prefers-reduced-motion: reduce) { .poll-bar > span { transition: none; } }

/* --- Startseite ----------------------------------------------------------------------------- */
.home-poll .poll-card { max-width: 720px; }

/* --- Cockpit: Editor mit Vorschau ------------------------------------------------------------ */
.pa-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.pa-preview { position: sticky; top: calc(var(--header-h) + 16px); }
.pa-preview .poll-head { margin-bottom: 0; }
.pa-colors { display: flex; flex-wrap: wrap; gap: 8px; }
.pa-colors label { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--border-strong); cursor: pointer; font-size: 14px; }
.pa-colors label:has(input:checked) { border-color: var(--poll); background: var(--poll-soft); }
.pa-colors input { position: absolute; opacity: 0; pointer-events: none; }
.pa-colors label:has(input:focus-visible) { outline: 2px solid var(--poll); outline-offset: 2px; }
.pa-q { padding: 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-2); margin-bottom: 12px; }
.pa-q-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.pa-q-head .pa-q-num { font-weight: 700; margin-right: auto; }
.pa-opt { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.pa-opt input { flex: 1; min-width: 0; }
.pa-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pa-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); border-left: 4px solid var(--poll); background: var(--surface); }
.pa-list li a { font-weight: 650; overflow-wrap: anywhere; min-width: 0; flex: 1 1 200px; }
.pa-resp { width: 100%; }
.pa-resp td { vertical-align: top; overflow-wrap: anywhere; }
@media (max-width: 980px) {
  .pa-layout { grid-template-columns: 1fr; }
  .pa-preview { position: static; }
}
