/**
 * Präsentationsansicht (#/stage/:code): große Schrift für 2–3 m Lesbarkeit,
 * hoher Kontrast (WCAG 2.1 AA), viel Weißraum, kein Blinken.
 * App-Chrome blendet body.stage-mode aus.
 */

body.stage-mode {
  grid-template-rows: 1fr;
  background: #ffffff;
  color: #111111;
}

body.stage-mode .skip-link,
body.stage-mode #legal-hash-link,
body.stage-mode #app-footer,
body.stage-mode #consent-dialog {
  display: none !important;
}

body.stage-mode .app {
  height: 100dvh;
  height: 100vh;
  min-height: 0;
}

.view-stage {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 0;
  height: 100dvh;
  height: 100vh;
  overflow: hidden;
  background: #ffffff;
  color: #111111;
  /* ~40 % Weißraum über große Außenabstände */
  --stage-pad-y: 8vh;
  --stage-pad-x: 8vw;
}

.view-stage[hidden] {
  display: none !important;
}

.stage-reaction-layer {
  z-index: 6;
}

.stage-conn {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  margin: 0;
  padding: 10px 18px;
  border-radius: 999px;
  background: #111111;
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
}

.stage-conn[hidden] {
  display: none !important;
}

.stage-logo-wrap {
  display: flex;
  justify-content: center;
  padding: 16px var(--stage-pad-x) 0;
}

.stage-logo-wrap[hidden] {
  display: none !important;
}

.stage-logo-wrap img {
  max-height: 48px;
  max-width: 220px;
  object-fit: contain;
}

.stage-frame {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4vh;
  padding: var(--stage-pad-y) var(--stage-pad-x);
  min-height: 0;
  overflow: hidden;
}

.stage-frame.is-fading {
  animation: stageFade 480ms ease;
}

@keyframes stageFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage-frame.is-fading {
    animation: none;
  }
}

.stage-kicker {
  margin: 0;
  font-size: clamp(18px, 1.6vw, 22px);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #333333;
}

.stage-question {
  margin: 0;
  max-width: 18em;
  text-align: center;
  font-size: clamp(48px, 6.2vw, 96px);
  font-weight: 800;
  line-height: 1.12;
  color: #111111;
}

.stage-subtitle {
  margin: 0.65em 0 0;
  max-width: 22em;
  text-align: center;
  font-size: clamp(22px, 2.2vw, 34px);
  font-weight: 600;
  line-height: 1.35;
  color: #444444;
}

.stage-prompt {
  margin: 0.65em 0 0;
  max-width: 22em;
  text-align: center;
  font-size: clamp(32px, 3.4vw, 48px);
  font-weight: 700;
  line-height: 1.25;
  color: #111111;
}

.stage-subtitle + .stage-prompt {
  margin-top: 0.45em;
}

/* Schätzfrage: kleinere Frage, engerer Kopf (Frage → subtitle/prompt → Ergebnis/Teaser). */
.stage-frame--estimation {
  gap: 0.75vh;
  justify-content: flex-start;
  padding-top: max(2vh, 12px);
}

.stage-frame--estimation .stage-interaction-hint {
  margin: 0 0 0.25rem;
}

.stage-frame--estimation .stage-question {
  font-size: clamp(34px, 4.2vw, 58px);
  line-height: 1.08;
}

.stage-frame--estimation .stage-subtitle {
  margin-top: 0.12em;
  font-size: clamp(18px, 1.9vw, 28px);
  line-height: 1.2;
}

.stage-frame--estimation .stage-prompt {
  margin-top: 0.1em;
  font-size: clamp(22px, 2.3vw, 34px);
  line-height: 1.15;
}

.stage-frame--estimation .stage-subtitle + .stage-prompt {
  margin-top: 0.08em;
}

.stage-frame--estimation .stage-results {
  gap: 0.35vh;
  margin-top: 0;
  /* Restliche Viewport-Höhe für das Histogramm nutzen */
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.stage-frame--estimation .stage-results.stage-estimation {
  width: min(1100px, 100%);
}

.stage-frame--estimation .stage-teaser {
  margin: 0;
}

/* Multiple Choice: kompakter Kopf, Optionenliste oder Ergebnisbalken darunter (Timer/QR wie Schätzfrage). */
.stage-frame--choice {
  gap: 0.75vh;
  justify-content: flex-start;
  padding-top: max(2vh, 12px);
}

.stage-frame--choice .stage-interaction-hint {
  margin: 0 0 0.25rem;
}

.stage-frame--choice .stage-question {
  font-size: clamp(34px, 4.2vw, 58px);
  line-height: 1.08;
}

.stage-frame--choice .stage-choice-options-wrap {
  width: min(920px, 100%);
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage-frame--choice .stage-choice-options {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.6vh, 18px);
}

.stage-frame--choice .stage-choice-option {
  margin: 0;
  padding: clamp(14px, 1.8vh, 22px) clamp(18px, 2.4vw, 28px);
  border-radius: 14px;
  background: #f4f4f4;
  border: 2px solid #e0e0e0;
  font-size: clamp(24px, 2.6vw, 38px);
  font-weight: 700;
  line-height: 1.25;
  color: #111111;
  text-align: left;
}

.stage-frame--choice .stage-choice-option[data-color="0"] { border-left: 8px solid var(--c1, #b42318); }
.stage-frame--choice .stage-choice-option[data-color="1"] { border-left: 8px solid var(--c2, #175cd3); }
.stage-frame--choice .stage-choice-option[data-color="2"] { border-left: 8px solid var(--c3, #027a48); }
.stage-frame--choice .stage-choice-option[data-color="3"] { border-left: 8px solid var(--c4, #93370d); }
.stage-frame--choice .stage-choice-option[data-color="4"] { border-left: 8px solid var(--c5, #6941c6); }
.stage-frame--choice .stage-choice-option[data-color="5"] { border-left: 8px solid var(--c6, #155eef); }

.stage-frame--choice .stage-results.stage-choice-results {
  flex: 1 1 auto;
  min-height: 0;
  justify-content: center;
}

.stage-frame--choice .stage-teaser {
  margin: 0;
}

/* Stimmenzähler unter der Frage — live während der Abstimmung */
.stage-frame--choice .stage-vote-count {
  margin: 0.35em 0 0;
  font-size: clamp(22px, 2.4vw, 36px);
  font-weight: 700;
  text-align: center;
  color: #444444;
  font-variant-numeric: tabular-nums;
}

/* QR unten rechts: Optionen nicht überdecken */
.stage-frame--choice:has(.stage-slide-qr-overlay) .stage-choice-options-wrap,
.stage-frame--choice:has(.stage-slide-qr-overlay) .stage-results.stage-choice-results {
  padding-right: min(14rem, 30vw);
  box-sizing: border-box;
}

.stage-wait {
  font-size: clamp(40px, 5vw, 72px);
  font-weight: 800;
  text-align: center;
}

.stage-results {
  width: min(1100px, 100%);
  display: flex;
  flex-direction: column;
  gap: 2.4vh;
}

.stage-results .poll-row {
  display: grid;
  grid-template-columns: minmax(8rem, 1fr) minmax(12rem, 2.2fr) auto;
  gap: 1.2rem 1.6rem;
  align-items: center;
}

.stage-results .poll-label {
  font-size: clamp(28px, 2.8vw, 40px);
  font-weight: 700;
  color: #111111;
}

.stage-results .poll-track {
  height: 2.4rem;
  background: #e8e8e8;
  border-radius: 999px;
  overflow: hidden;
}

.stage-results .poll-fill {
  height: 100%;
  width: var(--bar-width, 0%);
  border-radius: inherit;
  transition: width 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: width;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-inline: 12px;
}

/* Unterschiedliche Balkenfarben — Theme-Tokens wie Presenter/Join */
.stage-results .poll-fill[data-color="0"] { background: var(--c1, #b42318); color: var(--c1-ink, #fff); }
.stage-results .poll-fill[data-color="1"] { background: var(--c2, #175cd3); color: var(--c2-ink, #fff); }
.stage-results .poll-fill[data-color="2"] { background: var(--c3, #027a48); color: var(--c3-ink, #fff); }
.stage-results .poll-fill[data-color="3"] { background: var(--c4, #93370d); color: var(--c4-ink, #fff); }
.stage-results .poll-fill[data-color="4"] { background: var(--c5, #6941c6); color: var(--c5-ink, #fff); }
.stage-results .poll-fill[data-color="5"] { background: var(--c6, #155eef); color: var(--c6-ink, #fff); }

.stage-results .poll-fill--custom {
  background: var(--bar-bg);
  color: var(--bar-ink);
}

.stage-choice-option.choice-color--custom {
  border-left-width: 6px;
  border-left-style: solid;
  border-left-color: var(--choice-accent, var(--bar-bg));
}

/* Reguläre Folien: Chrome-Reserve (Timer oben, QR unten) — dynamisch via JS */
.stage-frame--regular {
  gap: 0.75vh;
  justify-content: flex-start;
  padding-top: max(2vh, var(--stage-chrome-top, 12px));
  padding-bottom: max(1vh, var(--stage-chrome-bottom, 12px));
  box-sizing: border-box;
}

.stage-frame--regular:has(.stage-slide-qr-overlay) .stage-results,
.stage-frame--regular:has(.stage-slide-qr-overlay) .stage-cloud,
.stage-frame--regular:has(.stage-slide-qr-overlay) .stage-choice-options-wrap {
  max-width: calc(100% - min(13rem, 28vw));
}

.stage-clock[data-reduced-motion="true"][data-urgency="critical"] strong {
  animation: none;
}

.stage-results .poll-count {
  font-size: clamp(18px, 2vw, 28px);
  font-weight: 800;
  color: inherit;
}

.stage-results .poll-pct {
  min-width: 5.5ch;
  font-size: clamp(36px, 4.2vw, 64px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #111111;
  text-align: right;
}

.stage-teaser {
  font-size: clamp(32px, 3.5vw, 52px);
  font-weight: 700;
  text-align: center;
  color: #111111;
}

.stage-avg {
  margin: 0;
  font-size: clamp(72px, 11vw, 160px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: center;
  color: #111111;
}

.stage-avg-scale {
  display: block;
  margin-top: 0.2em;
  font-size: 0.28em;
  font-weight: 700;
  color: #333333;
}

/* Wortwolke: Frage oben, große Papierfläche, QR in der Fußzone */
.stage-frame--wordcloud {
  gap: 0.85vh;
  justify-content: flex-start;
  padding-top: max(2vh, 12px);
}

.stage-frame--wordcloud .stage-question {
  font-size: clamp(32px, 3.8vw, 56px);
  line-height: 1.12;
  max-width: 22em;
}

.stage-frame--wordcloud .stage-subtitle {
  margin-top: 0.25em;
}

.stage-frame--wordcloud .stage-wordcloud-count {
  margin: 0.35em 0 0;
  font-size: clamp(22px, 2.4vw, 36px);
  font-weight: 700;
  text-align: center;
  color: #444444;
  font-variant-numeric: tabular-nums;
}

/* Kein zweiter Beitragszähler in der Canvas-Hülle (Stage hat #stage-wordcloud-count). */
.stage-frame--wordcloud .wordcloud-contribution-count,
.stage-frame--wordcloud .wordcloud-live {
  display: none !important;
}

.stage-frame--wordcloud .stage-cloud {
  /* 0%-Basis: Rest der Leinwand füllen, unabhängig von der Canvas-Pixelhöhe. */
  flex: 1 1 0%;
  min-height: 0;
  width: min(98%, 1600px);
}

.stage-frame--wordcloud .wordcloud-paper {
  min-height: 0;
  height: 100%;
}

/* QR unten rechts: Papierfläche seitlich und unten freihalten */
.stage-frame--wordcloud:has(.stage-slide-qr-overlay) .stage-cloud {
  padding-right: min(14rem, 30vw);
  box-sizing: border-box;
}

/* QR-Fußzone als Innenabstand der Leinwand — ohne QR wächst die Wolke mit. */
.stage-frame--wordcloud:has(.stage-slide-qr-overlay) {
  padding-bottom: min(10.5rem, 26vh);
}

.stage-cloud {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  flex: 1;
}

.stage-cloud canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.stage-qa {
  width: min(1000px, 100%);
  max-height: 100%;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
}

.stage-qa-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1.2rem;
  align-items: start;
  padding-bottom: 1.2rem;
  border-bottom: 2px solid #e4e4e4;
}

.stage-qa-rank {
  font-size: clamp(28px, 3vw, 40px);
  font-weight: 800;
  color: #007cc1;
}

.stage-qa-text {
  margin: 0;
  font-size: clamp(28px, 2.6vw, 40px);
  font-weight: 700;
  line-height: 1.25;
  color: #111111;
}

.stage-qa-votes {
  font-size: clamp(32px, 3.4vw, 48px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #111111;
}

.stage-quiz-options {
  width: min(960px, 100%);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.stage-quiz-opt {
  padding: 0.6em 0.8em;
  font-size: clamp(28px, 2.6vw, 40px);
  font-weight: 700;
  border-radius: 12px;
  background: #f4f4f4;
  color: #111111;
}

.stage-quiz-opt.is-correct {
  background: #1b7a3a;
  color: #ffffff;
}

.stage-board {
  width: min(720px, 100%);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.stage-board-row {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  font-size: clamp(26px, 2.4vw, 36px);
  font-weight: 700;
}

.stage-open-list {
  width: min(900px, 100%);
  max-height: 100%;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stage-open-card {
  font-size: clamp(26px, 2.4vw, 36px);
  font-weight: 700;
}

.stage-images {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.5rem;
  width: min(1100px, 100%);
}

.stage-images img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: 12px;
}

.stage-images p {
  margin: 0.4rem 0 0;
  font-size: clamp(22px, 2vw, 32px);
  font-weight: 700;
  text-align: center;
}

.stage-footer-copy {
  margin: 0;
  padding: 12px var(--stage-pad-x) 16px;
  text-align: center;
  font-size: 16px;
  color: #333333;
}

.stage-footer-copy[hidden] {
  display: none !important;
}

.stage-fs {
  padding: 12px 18px;
  border: 2px solid #111111;
  border-radius: 999px;
  background: #ffffff;
  color: #111111;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

/* Auto-ausblendbare Vollbildsteuerung (stageDisplayControls.js) */
.stage-display-controls {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 5;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.stage-display-controls.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.view-stage[data-stage-mode="share"] .stage-display-controls {
  display: none !important;
}

.stage-fs:focus-visible {
  outline: 3px solid #007cc1;
  outline-offset: 3px;
}

.stage-pause {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  background: rgba(17, 17, 17, 0.92);
  color: #ffffff;
}

.stage-pause[hidden] {
  display: none !important;
}

.stage-pause p {
  margin: 0;
  font-size: clamp(40px, 6vw, 80px);
  font-weight: 800;
  text-align: center;
}

.stage-clock {
  position: absolute;
  top: 16px;
  right: 20px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  font-variant-numeric: tabular-nums;
}

.stage-clock[hidden] {
  display: none !important;
}

.stage-clock-ring {
  width: 56px;
  height: 56px;
}

.stage-clock strong {
  font-size: 28px;
  font-weight: 800;
}

.stage-clock[data-urgency="ok"] strong {
  color: #1b7a3a;
}

.stage-clock[data-urgency="warn"] strong {
  color: #8a6a00;
}

.stage-clock[data-urgency="critical"] strong {
  color: #b00020;
}

@media (max-width: 900px) {
  .stage-question {
    font-size: 48px;
  }

  .stage-prompt {
    font-size: 32px;
  }

  .view-stage {
    --stage-pad-y: 5vh;
    --stage-pad-x: 5vw;
  }
}

/* Screen-Sharing-Modus (?share=1): größere Typo, ruhigere Animationen */
.view-stage[data-stage-mode="share"] {
  --stage-pad-y: 8vh;
  --stage-pad-x: 10vw;
}

#stage-event-countdown .event-countdown-title {
  font-size: clamp(2rem, 6.5vw, 4.25rem);
}

.view-stage[data-stage-mode="share"] .event-countdown-title {
  font-size: clamp(2rem, 5vw, 3.75rem);
}

.view-stage[data-stage-mode="share"] .event-countdown-num {
  font-size: clamp(4rem, 14vw, 9rem);
}

.view-stage[data-stage-mode="share"] .event-countdown-datetime {
  font-size: clamp(1.35rem, 3.5vw, 2.5rem);
}

.view-stage[data-stage-mode="share"] .event-countdown-qr-card {
  max-width: min(24rem, 92vw);
  padding: 1.25rem 1.5rem;
}

.view-stage[data-stage-mode="share"] .event-countdown-qr-canvas {
  width: min(240px, 44vw);
  height: auto;
  aspect-ratio: 1 / 1;
}

.view-stage[data-stage-mode="share"] .event-countdown-bg {
  animation: none;
}

/* QR auf der Stage leicht vergrößert (Folien-Badge + Countdown, nicht Presenter-Vorschau) */
.view-stage .stage-slide-qr-overlay .stage-slide-qr-card {
  max-width: min(13.5rem, 30vw);
  padding: 0.75rem 1rem;
}

.view-stage .stage-slide-qr-overlay .event-countdown-qr-canvas {
  width: min(168px, 26vw);
}

.view-stage:not([data-stage-mode="share"]) .event-countdown-host .event-countdown-qr-canvas {
  width: min(228px, 40vw);
}

/* Stage-Tastatursteuerung: dezente Toasts und Hilfe (keine Toolbar) */
.stage-kbd-toast,
.stage-kbd-hint {
  position: absolute;
  right: max(16px, var(--stage-pad-x));
  bottom: max(16px, var(--stage-pad-y));
  z-index: 8;
  max-width: min(420px, 90vw);
  padding: 10px 16px;
  border-radius: 8px;
  background: rgba(17, 17, 17, 0.92);
  color: #ffffff;
  font-size: clamp(14px, 1.6vw, 18px);
  font-weight: 600;
  line-height: 1.35;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
}

.stage-kbd-toast[hidden],
.stage-kbd-hint[hidden] {
  display: none !important;
}

.stage-kbd-hint {
  opacity: 0.88;
  font-weight: 500;
}

@media (prefers-reduced-motion: no-preference) {
  .stage-kbd-toast:not([hidden]),
  .stage-kbd-hint:not([hidden]) {
    animation: stage-kbd-fade-in 0.2s ease-out;
  }
}

@keyframes stage-kbd-fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stage-kbd-help-dialog {
  max-width: 36rem;
  width: min(36rem, 92vw);
}

.stage-kbd-help-dialog h2 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
}

.stage-kbd-help-section h3 {
  margin: 1rem 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 700;
}

.stage-kbd-help-list {
  margin: 0;
  display: grid;
  gap: 0.35rem;
}

.stage-kbd-help-list div {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.5rem;
  align-items: baseline;
}

.stage-kbd-help-list dt {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
}

.stage-kbd-help-list dd {
  margin: 0;
}

.stage-kbd-help-note {
  margin: 1rem 0 0;
  font-size: 0.9rem;
  color: var(--muted, #555);
}

.stage-kbd-help-muted {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted, #555);
}

.stage-kbd-help-actions {
  margin-top: 1.25rem;
  display: flex;
  justify-content: flex-end;
}
