/* ICT Scouts styling: dark ink header, lavender/mint accents, pill buttons. */

:root {
  --ink: #1b1a27;
  --ink-soft: #3b3b3b;
  --paper: #fdfdfb;
  --white: #ffffff;
  --lavender: #c8c8ff;
  --lavender-deep: #9747f9;
  --mint: #c7ebcb;
  --green: #63da84;
  --grey: #919191;
  --grey-line: #dfdfdf;
  --grey-soft: #f2f2f0;
  --amber: #ffbd5d;
  --red: #e9484b;

  --radius: 18px;
  --radius-lg: 28px;
  --radius-pill: 999px;
  --shadow: 0 2px 10px rgba(27, 26, 39, 0.06);
  --shadow-lift: 0 12px 32px rgba(27, 26, 39, 0.12);

  --font: 'TT Commons Pro', 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    'Helvetica Neue', Arial, sans-serif;
  --header-h: 76px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--paper);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 0.5em;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.01em;
}

h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
h2 { font-size: clamp(1.35rem, 2.6vw, 1.8rem); }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1em; }
a { color: var(--lavender-deep); }

/* ------------------------------------------------------------------ header */

.site-header {
  background: var(--ink);
  color: var(--white);
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  flex-wrap: wrap;
}

.site-header .brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
}

.site-header .brand img { height: 44px; width: auto; display: block; }

.site-header .brand-claim {
  font-size: 0.85rem;
  color: var(--lavender);
  border-left: 1px solid rgba(255, 255, 255, 0.25);
  padding-left: 14px;
  line-height: 1.2;
}

.site-header nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.site-header nav a,
.site-header nav button {
  color: var(--white);
  text-decoration: none;
  font: inherit;
  font-weight: 600;
  background: none;
  border: 0;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.site-header nav a:hover,
.site-header nav button:hover { background: rgba(255, 255, 255, 0.12); }
.site-header nav a.active { background: var(--lavender); color: var(--ink); }

/* ------------------------------------------------------------------ layout */

.wrap {
  width: min(1120px, 100% - 40px);
  margin: 0 auto;
  padding: 36px 0 80px;
}

.wrap.narrow { width: min(660px, 100% - 32px); }
.wrap.wide { width: min(1500px, 100% - 40px); }

.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1 1 auto; }

.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.page-head {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.back-link { margin-bottom: 12px; gap: 8px; }
.page-head h1 { margin-bottom: 0; }
.page-head .sub { color: var(--grey); margin: 0; }

/* ------------------------------------------------------------------- cards */

.card {
  background: var(--white);
  border: 1px solid var(--grey-line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card.tight { padding: 16px 18px; }
.card.flat { box-shadow: none; }
.card.ink { background: var(--ink); color: var(--white); border-color: var(--ink); }
.card.lavender { background: var(--lavender); border-color: var(--lavender); }
.card.mint { background: var(--mint); border-color: var(--mint); }

a.card { text-decoration: none; color: inherit; display: block; transition: transform 0.12s ease, box-shadow 0.12s ease; }
a.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }

/* ----------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 700;
  padding: 12px 24px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--white);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.1s ease, background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn.primary { background: var(--lavender); border-color: var(--lavender); color: var(--ink); }
.btn.primary:hover { background: var(--lavender-deep); border-color: var(--lavender-deep); color: var(--white); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--grey-soft); }
.btn.danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn.danger:hover { background: var(--red); color: var(--white); }
.btn.small { min-height: var(--pill-h); padding: 0 16px; font-size: 0.85rem; border-width: 1.5px; }

/* Zwei Modus-Knöpfe als Segment: gleiche Breite, gleiche Höhe. */
.segmented { display: flex; gap: 8px; width: 100%; }
.segmented .btn { flex: 1 1 0; min-width: 0; padding-left: 8px; padding-right: 8px; }
.btn.big { padding: 16px 34px; font-size: 1.1rem; }
.btn.block { width: 100%; }

/* ------------------------------------------------------------------ inputs */

label.field { display: block; font-weight: 600; margin-bottom: 6px; }
.hint { color: var(--grey); font-size: 0.9rem; margin: 4px 0 0; }

input[type='text'],
input[type='password'],
input[type='number'],
input[type='search'],
select,
textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--white);
  border: 1.5px solid var(--grey-line);
  border-radius: 14px;
  padding: 12px 16px;
}

textarea { min-height: 110px; resize: vertical; }

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.btn:focus-visible,
.option:focus-visible {
  outline: 3px solid var(--lavender-deep);
  outline-offset: 2px;
}

.code-input {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-align: center;
  text-transform: uppercase;
}

/* ------------------------------------------------------------------- badges */

/* --pill-h hält Badges und kleine Buttons nebeneinander auf gleicher Höhe. */
:root { --pill-h: 34px; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--pill-h);
  padding: 0 14px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--grey-soft);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.badge.live { background: var(--green); color: var(--ink); }
.badge.closed { background: var(--grey-line); }
.badge.lavender { background: var(--lavender); color: var(--ink); }
.badge.mint { background: var(--mint); color: var(--ink); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* --------------------------------------------------------------- join code */

/* Skaliert am Container, nicht am Viewport – sonst läuft der Code in der
   schmalen Admin-Spalte über den Kartenrand. Nicht auf .qr-box legen: die
   ist inline-flex und würde ohne inhaltsabhängige Breite kollabieren. */
.card {
  container-type: inline-size;
}

.joincode {
  font-size: clamp(1.5rem, 18cqw, 3.4rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.05;
  text-align: center;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.qr-box {
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px;
  display: inline-flex;
  border: 1px solid var(--grey-line);
}
.qr-box svg { display: block; width: 100%; height: auto; }

/* ------------------------------------------------------------- question UI */

.question-title { font-size: clamp(1.3rem, 3.2vw, 2rem); font-weight: 700; margin-bottom: 6px; }
.question-help { color: var(--grey); margin-bottom: 20px; }

.options { display: grid; gap: 12px; }
.options.two { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  border: 2px solid var(--grey-line);
  border-radius: var(--radius);
  background: var(--white);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.1s ease;
}

.option:hover { border-color: var(--ink); transform: translateY(-1px); }
.option.selected { border-color: var(--lavender-deep); background: var(--lavender); }
.option.correct { border-color: var(--green); background: var(--mint); }
.option.wrong { border-color: var(--red); background: #fdecec; }
.option .emoji { font-size: 1.4rem; }
.option .mark { margin-left: auto; font-weight: 700; }

/* Grid, not flex-wrap: a wrapped button keeps its column width instead of
   stretching across the whole row. */
.scale-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(48px, 1fr));
  gap: 10px;
}

.scale-btn {
  min-width: 0;
  min-height: clamp(58px, 14vw, 92px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.2rem, 4vw, 1.9rem);
  font-weight: 700;
  border: 2px solid var(--grey-line);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.12s ease, background 0.12s ease;
}

.scale-btn:hover { transform: translateY(-2px); border-color: var(--ink); }
.scale-btn.selected { border-color: var(--lavender-deep); background: var(--lavender); }
.scale-btn.star.selected,
.scale-btn.star.filled { background: var(--mint); border-color: var(--green); }

.scale-labels { display: flex; justify-content: space-between; color: var(--grey); font-size: 0.9rem; margin-top: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--lavender);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  font-weight: 600;
  font-size: 0.9rem;
}
.chip button { border: 0; background: none; cursor: pointer; font: inherit; line-height: 1; padding: 0; }
.chip.soft { background: var(--grey-soft); }

.progress-track { height: 8px; background: var(--grey-soft); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--lavender-deep); transition: width 0.3s ease; }

/* ---------------------------------------------------------------- results */

.result-block + .result-block { margin-top: 28px; }
.result-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.result-head h3 { margin: 0; }
.result-head .count { color: var(--grey); font-size: 0.9rem; }

.bar-list { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 22%) 1fr auto; gap: 12px; align-items: center; }
.bar-row .bar-label { font-weight: 600; overflow-wrap: anywhere; }
.bar-track { background: var(--grey-soft); border-radius: 99px; height: 30px; overflow: hidden; }
.bar-fill {
  height: 100%;
  background: var(--lavender);
  border-radius: 99px;
  transition: width 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.bar-fill.correct { background: var(--green); }
.bar-fill.muted { background: var(--grey-line); }
.bar-row .bar-value { font-weight: 700; min-width: 3.5em; text-align: right; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.stat { background: var(--grey-soft); border-radius: var(--radius); padding: 16px 18px; }
.stat .value { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat .label { color: var(--grey); font-size: 0.85rem; margin-top: 6px; }

.wordcloud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  justify-content: center;
  padding: 12px 0;
}
.wordcloud span {
  font-weight: 700;
  line-height: 1.1;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  animation: pop 0.35s ease;
}

/* Auf hellem Grund abgedunkelt, auf der Bühne aufgehellt – sonst fällt ein
   Wort in die Hintergrundfarbe und verschwindet. */
.wordcloud .wc-0 { color: #9747f9; }
.wordcloud .wc-1 { color: #1b1a27; }
.wordcloud .wc-2 { color: #1f9d4d; }
.wordcloud .wc-3 { color: #2966cc; }
.wordcloud .wc-4 { color: #d0363a; }
.wordcloud .wc-5 { color: #a86a12; }
.wordcloud .wc-6 { color: #147d92; }

body.stage .wordcloud .wc-0 { color: #c8c8ff; }
body.stage .wordcloud .wc-1 { color: #ffffff; }
body.stage .wordcloud .wc-2 { color: #63da84; }
body.stage .wordcloud .wc-3 { color: #8fbcff; }
body.stage .wordcloud .wc-4 { color: #ff9092; }
body.stage .wordcloud .wc-5 { color: #ffbd5d; }
body.stage .wordcloud .wc-6 { color: #6fe0f5; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.answer-list { display: grid; gap: 10px; max-height: 60vh; overflow: auto; }
.answer-card {
  background: var(--grey-soft);
  border-radius: var(--radius);
  padding: 14px 18px;
  animation: slidein 0.3s ease;
}
.answer-card .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
@keyframes slidein { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }

.leaderboard { display: grid; gap: 8px; }
.leaderboard .lb-row { display: grid; grid-template-columns: 2.2em 1fr auto; gap: 12px; align-items: center; padding: 10px 16px; background: var(--grey-soft); border-radius: var(--radius-pill); font-weight: 600; }
.leaderboard .lb-row:first-child { background: var(--mint); }
.leaderboard .rank { font-weight: 700; color: var(--grey); }

table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--grey-line); vertical-align: top; }
table.data th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--grey); }
table.data tr:hover td { background: var(--grey-soft); }

/* ---------------------------------------------------------------- messages */

.notice { border-radius: var(--radius); padding: 14px 18px; font-weight: 600; }
.notice.error { background: #fdecec; color: #8e1f21; }
.notice.ok { background: var(--mint); }
.notice.info { background: var(--grey-soft); }

.empty { text-align: center; color: var(--grey); padding: 48px 20px; }

.toast-host { position: fixed; inset: auto 0 24px 0; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; z-index: 50; }
.toast { background: var(--ink); color: var(--white); padding: 12px 22px; border-radius: var(--radius-pill); box-shadow: var(--shadow-lift); animation: slidein 0.2s ease; }
.toast.error { background: var(--red); }

.hidden { display: none !important; }
.center { text-align: center; }
.muted { color: var(--grey); }
.mono { font-variant-numeric: tabular-nums; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* -------------------------------------------------------- presentation mode */

body.stage { background: var(--ink); color: var(--white); }
body.stage .wrap { padding-top: 24px; }
body.stage .card { background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.14); color: var(--white); }
body.stage .bar-track { background: rgba(255, 255, 255, 0.12); }
body.stage .stat { background: rgba(255, 255, 255, 0.08); }
body.stage .answer-card { background: rgba(255, 255, 255, 0.08); }
body.stage .leaderboard .lb-row { background: rgba(255, 255, 255, 0.08); }
body.stage .leaderboard .lb-row:first-child { background: var(--lavender); color: var(--ink); }
body.stage .muted, body.stage .result-head .count, body.stage .stat .label { color: rgba(255, 255, 255, 0.6); }
body.stage .chip.soft { background: rgba(255, 255, 255, 0.14); color: var(--white); }
body.stage .site-header { border-bottom: 1px solid rgba(255, 255, 255, 0.12); }
body.stage table.data th, body.stage table.data td { border-color: rgba(255, 255, 255, 0.14); }

/* ------------------------------------------------------- Beamer-Ansicht */

body.beamer { overflow: hidden; }

.beamer-shell {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: clamp(12px, 2vh, 28px);
  padding: clamp(14px, 2.4vh, 30px) clamp(20px, 3vw, 56px);
}

.beamer-top { display: flex; align-items: center; gap: 18px; }
.beamer-logo { height: clamp(28px, 3.4vh, 46px); width: auto; }
.beamer-survey { font-size: clamp(0.9rem, 1.4vw, 1.3rem); color: rgba(255, 255, 255, 0.55); font-weight: 600; }

/* Bedienelemente treten zurück, bis die Maus in die Nähe kommt. */
.beamer-tools { display: flex; gap: 8px; align-items: center; opacity: 0.25; transition: opacity 0.2s ease; }
.beamer-tools:hover, .beamer-tools:focus-within { opacity: 1; }
.beamer-tools .btn.ghost { color: var(--white); border-color: rgba(255, 255, 255, 0.35); }
.beamer-tools .btn.ghost:hover { background: rgba(255, 255, 255, 0.15); }

.beamer-main {
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.beamer-scroll { overflow-y: auto; height: 100%; display: grid; gap: clamp(24px, 5vh, 56px); padding-right: 8px; }
.beamer-closed { text-align: center; color: var(--lavender); font-weight: 700; margin: 18px 0 0; }

.stage-block { display: flex; flex-direction: column; gap: clamp(10px, 2vh, 26px); min-height: 0; }
.stage-question {
  font-size: clamp(1.6rem, 3.6vw, 4rem);
  line-height: 1.1;
  margin: 0;
  text-wrap: balance;
}
.stage-help { color: rgba(255, 255, 255, 0.55); font-size: clamp(0.95rem, 1.5vw, 1.5rem); margin: 0; }
.stage-body { min-height: 0; overflow: auto; }
.stage-locked { font-size: clamp(1.1rem, 2vw, 2rem); padding: clamp(18px, 4vh, 48px); }

/* Ergebnisse gross genug für die letzte Reihe im Raum. */
.beamer .bar-list { gap: clamp(8px, 1.6vh, 18px); }
.beamer .bar-track { height: clamp(30px, 6.4vh, 76px); }
.beamer .bar-label { font-size: clamp(1rem, 1.9vw, 2.1rem); }
.beamer .bar-row .bar-value { font-size: clamp(1rem, 1.9vw, 2.1rem); min-width: 5em; }
.beamer .bar-row .bar-value .muted { font-size: 0.7em; }
.beamer .answer-list { max-height: none; gap: clamp(8px, 1.4vh, 16px); }
.beamer .answer-card { font-size: clamp(1rem, 1.6vw, 1.8rem); padding: clamp(12px, 2vh, 22px) clamp(16px, 2vw, 28px); }
.beamer .badge.lavender { font-size: clamp(0.9rem, 1.4vw, 1.4rem); min-height: auto; padding: 6px 18px; }
.beamer .wordcloud { gap: clamp(10px, 2vh, 26px) clamp(18px, 3vw, 44px); }
.beamer .leaderboard .lb-row { font-size: clamp(1rem, 1.8vw, 1.9rem); padding: clamp(8px, 1.4vh, 16px) clamp(16px, 2vw, 28px); }

/* Lobby: QR-Code beherrscht das Bild, bis die erste Antwort da ist. */
body.is-lobby .beamer-foot { display: none; }
.lobby { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(8px, 1.6vh, 20px); height: 100%; }
.lobby-kicker { font-size: clamp(1.1rem, 2.4vw, 2.4rem); font-weight: 700; color: var(--lavender); margin: 0; }
.lobby-qr { width: min(46vh, 42vw); padding: clamp(10px, 1.6vh, 20px); }
.lobby-code { display: flex; flex-direction: column; align-items: center; }
.lobby-code-label {
  color: rgba(255, 255, 255, 0.5);
  font-size: clamp(0.8rem, 1.2vw, 1.2rem);
  text-transform: uppercase;
  letter-spacing: 0.18em;
}
.joincode.hero { font-size: clamp(2.4rem, 8vw, 7rem); letter-spacing: 0.1em; }
.lobby-url { color: rgba(255, 255, 255, 0.55); font-size: clamp(0.85rem, 1.5vw, 1.5rem); margin: 0; }
.lobby-count { color: var(--green); font-weight: 700; font-size: clamp(1rem, 1.8vw, 1.8rem); margin: 0; }

/* Fusszeile: Beitreten bleibt möglich, ohne die Frage zu stören. */
.beamer-foot {
  display: flex;
  align-items: center;
  gap: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: clamp(8px, 1.4vh, 16px);
  color: rgba(255, 255, 255, 0.6);
  font-size: clamp(0.8rem, 1.2vw, 1.15rem);
}
.beamer-foot:empty { display: none; }
.foot-join { display: flex; align-items: center; gap: 14px; }
.foot-qr { background: var(--white); border-radius: 10px; padding: 4px; width: clamp(46px, 7vh, 74px); display: flex; }
.foot-qr svg { width: 100%; height: auto; display: block; }
.foot-label { font-size: 0.85em; }
.foot-code { font-size: clamp(1.1rem, 2vw, 2rem); font-weight: 700; letter-spacing: 0.06em; color: var(--white); line-height: 1.1; }
.foot-progress, .foot-count { white-space: nowrap; }

@media (max-width: 640px) {
  .site-header { padding: 10px 16px; gap: 12px; }
  .site-header .brand img { height: 34px; }
  .site-header .brand-claim { display: none; }
  .wrap { padding: 24px 0 60px; }
  .card { padding: 18px; }
  .bar-row { grid-template-columns: minmax(70px, 30%) 1fr auto; }
}

@media print {
  .site-header, .no-print, .back-link { display: none !important; }
  body { background: var(--white); }
  .card { box-shadow: none; break-inside: avoid; }
}
