/* ===========================================================================
   qquiz – app.css
   Farb- und Schriftvariablen kommen aus dem Branding (CSS-Variablen werden
   pro Schule überschrieben, Premium-Feature). Schriften: assets/fonts/.
   =========================================================================== */

:root {
  --qz-primary:   #1f4e8c;
  --qz-secondary: #f5a623;
  --qz-font:      'QQuizSans', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --qz-ink:    #17233a;
  --qz-muted:  #66718a;
  --qz-bg:     #f2f5fa;
  --qz-card:   #ffffff;
  --qz-line:   #dde4ef;
  --qz-ok:     #2f9e6e;
  --qz-bad:    #d64550;

  /* Antwort-Farben (Kahoot-artig, aber eigenständig) */
  --qz-a0: #d64550;  /* ▲ */
  --qz-a1: #2b6cb0;  /* ◆ */
  --qz-a2: #d98f1f;  /* ● */
  --qz-a3: #2f9e6e;  /* ■ */
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--qz-font);
  color: var(--qz-ink);
  background: var(--qz-bg);
  line-height: 1.45;
}
a { color: var(--qz-primary); }
h1 { font-size: 1.6rem; margin: .4em 0 .6em; }
h2 { font-size: 1.15rem; margin: .3em 0 .5em; }
.muted { color: var(--qz-muted); }
.center { text-align: center; }
.err { color: var(--qz-bad); font-weight: 600; }

/* ---------- Rahmen (eingeloggte Seiten) ---------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--qz-primary); color: #fff; padding: .55rem 1rem;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; }
.brand-logo { height: 28px; width: auto; display: block; }
.topbar-right { display: flex; align-items: center; gap: .7rem; font-size: .85rem; }
.tb-role { background: rgba(255,255,255,.18); border-radius: 999px;
           padding: .12rem .6rem; font-size: .72rem; font-weight: 700;
           text-transform: uppercase; letter-spacing: .04em; }
.tb-user { font-weight: 600; max-width: 220px; overflow: hidden;
           text-overflow: ellipsis; white-space: nowrap; }
.tb-logout { color: #fff; opacity: .8; text-decoration: none;
             border: 1px solid rgba(255,255,255,.4); border-radius: 999px;
             padding: .22rem .75rem; font-size: .8rem; }
.tb-logout:hover { opacity: 1; background: rgba(255,255,255,.12); }
@media (max-width: 480px) { .tb-role { display: none; } .tb-user { max-width: 120px; } }
.wrap { max-width: 1080px; margin: 0 auto; padding: 1rem; }

.card {
  background: var(--qz-card); border: 1px solid var(--qz-line);
  border-radius: 12px; padding: 1rem; margin-bottom: 1rem;
}
.row { display: flex; gap: .6rem; align-items: center; }
.wrap-row { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }

label { display: block; margin: .5rem 0; font-weight: 600; }
input[type=text], input[type=password], input[type=number], select, textarea {
  font: inherit; width: 100%; padding: .5rem .6rem; margin-top: .25rem;
  border: 1px solid var(--qz-line); border-radius: 8px; background: #fff;
}
.row input[type=text], .row select { width: auto; flex: 1; }
input:focus-visible, select:focus-visible, textarea:focus-visible,
button:focus-visible { outline: 3px solid color-mix(in srgb, var(--qz-primary) 45%, white); outline-offset: 1px; }

/* ---------- Buttons ---------- */

.btn {
  font: inherit; font-weight: 700; cursor: pointer;
  padding: .5rem .9rem; border-radius: 9px;
  border: 1px solid var(--qz-line); background: #fff; color: var(--qz-ink);
}
.btn:hover { border-color: var(--qz-primary); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--qz-primary); border-color: var(--qz-primary); color: #fff; }
.btn.danger  { background: #fff; border-color: var(--qz-bad); color: var(--qz-bad); }
.btn.big { width: 100%; padding: .85rem; font-size: 1.1rem; margin-top: .8rem; }
.btn.sm  { padding: .2rem .5rem; font-size: .85rem; }

.plan-badge {
  font-size: .7rem; vertical-align: middle; padding: .2em .6em;
  border-radius: 99px; background: var(--qz-line); color: var(--qz-muted);
}
.plan-badge.premium { background: var(--qz-secondary); color: #4a3300; }

/* ---------- Dashboard / Editor ---------- */

.quiz-item, .q-item {
  display: flex; justify-content: space-between; align-items: center; gap: .8rem;
}
.quiz-title { font-weight: 700; }
.quiz-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.q-type {
  font-size: .72rem; background: var(--qz-line); border-radius: 99px;
  padding: .1em .6em; margin-right: .4em; white-space: nowrap;
}
.media-box { border: 1px dashed var(--qz-line); border-radius: 10px;
             padding: .6rem .8rem; margin: .8rem 0; }
.media-box legend { font-weight: 700; padding: 0 .4em; }
#audioRow.locked { opacity: .5; pointer-events: none; }

/* ---------- Host-Live-Ansicht ---------- */

.host-head { display: flex; justify-content: space-between;
             align-items: baseline; flex-wrap: wrap; gap: .5rem; }
.join-info { font-size: .95rem; }
.big-code {
  font-size: 1.6rem; font-weight: 800; letter-spacing: .12em;
  color: var(--qz-primary); background: #fff; border: 2px solid var(--qz-primary);
  border-radius: 8px; padding: .05em .35em;
}
.host-controls { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.host-status { margin-left: auto; color: var(--qz-muted); font-size: .9rem; }

.stage-prompt { font-size: 1.5rem; font-weight: 700; margin: .4rem 0 .8rem; }
.answered-count { font-size: 1.1rem; }
.timer { font-size: 2rem; font-weight: 800; color: var(--qz-secondary); }

.chip {
  display: inline-block; background: var(--qz-bg); border: 1px solid var(--qz-line);
  border-radius: 99px; padding: .15em .7em; margin: .15em; font-weight: 600;
}
.board-row {
  display: flex; justify-content: space-between; padding: .35rem .5rem;
  border-bottom: 1px solid var(--qz-line);
}
.board-row.big { font-size: 1.25rem; padding: .5rem .6rem; }
.board-row.podium { background: color-mix(in srgb, var(--qz-secondary) 18%, white); }

.bars { margin-top: .6rem; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 40px;
           gap: .5rem; align-items: center; margin: .3rem 0; }
.bar { background: var(--qz-bg); border-radius: 6px; height: 22px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--qz-primary); }
.bar-row.ok .bar-fill { background: var(--qz-ok); }
.bar-row.ok span:first-child { font-weight: 800; color: var(--qz-ok); }
.sol { font-size: 1.15rem; }
.cloud { line-height: 2.1; text-align: center; padding: .5rem 0; }
.cloud-word { margin: 0 .4em; font-weight: 700; color: var(--qz-primary); }
.cloud-word:nth-child(2n) { color: var(--qz-secondary); }

/* ---------- Teilnehmer (mobil zuerst) ---------- */

.play-body { background: var(--qz-primary); }
.play-top {
  display: flex; justify-content: space-between; align-items: center;
  color: #fff; padding: .55rem .9rem; font-weight: 700;
}
.play-score { background: rgba(255,255,255,.15); border-radius: 99px; padding: .15em .7em; }
.play-main {
  background: var(--qz-bg); border-radius: 16px 16px 0 0;
  min-height: calc(100vh - 52px); padding: 1rem; max-width: 640px;
  margin: 0 auto; width: 100%;
}
@media (min-width: 700px) {
  .play-main { border-radius: 16px; min-height: 0; margin-top: 1rem; padding: 1.4rem; }
}

.join-wrap { min-height: 100vh; display: flex; align-items: center;
             justify-content: center; padding: 1rem; }
.join-card { width: 100%; max-width: 380px; }
.join-logo { font-size: 1.4rem; font-weight: 800; color: var(--qz-primary);
             letter-spacing: .03em; }

.overlay {
  position: fixed; inset: 0; background: color-mix(in srgb, var(--qz-primary) 92%, black);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 2rem;
}
.overlay .btn { max-width: 320px; font-size: 1.3rem; }

.wait-screen { text-align: center; padding: 2.5rem 0; }
.wait-emoji { font-size: 3rem; }

.q-prompt { font-size: 1.25rem; font-weight: 700; margin: .6rem 0; }
.q-image { max-width: 100%; max-height: 220px; display: block;
           margin: .5rem auto; border-radius: 10px; }

.answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
@media (max-width: 420px) { .answer-grid { grid-template-columns: 1fr; } }
.answer-btn {
  font: inherit; font-weight: 700; color: #fff; border: none; cursor: pointer;
  border-radius: 12px; padding: 1rem .8rem; min-height: 74px; text-align: left;
  display: flex; align-items: center; gap: .6rem;
}
.answer-btn .shape { font-size: 1.2rem; opacity: .85; }
.answer-btn.shape-0 { background: var(--qz-a0); }
.answer-btn.shape-1 { background: var(--qz-a1); }
.answer-btn.shape-2 { background: var(--qz-a2); }
.answer-btn.shape-3 { background: var(--qz-a3); }
.answer-btn:active { transform: scale(.98); }
.answer-btn.picked { outline: 4px solid var(--qz-secondary); }

.answer-grid.imgs { gap: .8rem; }
.answer-grid.imgs .img-btn {
  background: #fff; color: var(--qz-ink); border: 2px solid var(--qz-line);
  flex-direction: column; gap: .3rem; padding: .5rem; min-height: 0;
}
/* Bilder so groß wie möglich: volle Spaltenbreite, Höhe am Viewport
   orientiert (die Teilnehmer-Ansicht wird bei Bildauswahl zusätzlich
   per .wide auf 1200 px verbreitert, s. play.js) */
.img-btn img {
  width: 100%; max-height: none; border-radius: 8px;
  height: clamp(150px, 36vh, 400px); object-fit: contain;
}

.big-input { font-size: 1.2rem; padding: .8rem; }

.slider-value { text-align: center; font-size: 2.4rem; font-weight: 800;
                color: var(--qz-primary); }
input[type=range] { width: 100%; accent-color: var(--qz-primary);
                    height: 2.2rem; }
.slider-scale { display: flex; justify-content: space-between; color: var(--qz-muted); }

.order-list { list-style: none; margin: .4rem 0; padding: 0; }
.order-list li {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  background: #fff; border: 1px solid var(--qz-line); border-radius: 10px;
  padding: .55rem .7rem; margin: .35rem 0; font-weight: 600;
}
.order-btns { display: flex; gap: .3rem; }

.timer-bar { background: var(--qz-line); border-radius: 99px;
             height: 10px; overflow: hidden; }
.timer-fill { height: 100%; background: var(--qz-secondary);
              transition: width .25s linear; }
.timer-num { text-align: right; font-weight: 800; color: var(--qz-muted);
             font-size: .9rem; margin-top: .15rem; }

.result { text-align: center; padding: 1.8rem 0 .8rem; }
.result h2 { font-size: 1.8rem; margin: .3em 0; }
.result.ok h2 { color: var(--qz-ok); }
.result.bad h2 { color: var(--qz-bad); }
.result .pts { font-size: 1.3rem; font-weight: 800; color: var(--qz-secondary); }
.sol-list { text-align: left; max-width: 380px; margin: .5rem auto; }
.own-rank { font-size: 1.15rem; margin-top: 1rem; }

/* ---------- Hotspot (Bildbereich treffen) ---------- */

.hotspot-wrap { position: relative; display: inline-block; max-width: 100%; }
.hotspot-wrap.center-block { display: block; margin: 0 auto; max-width: 480px; }
.hotspot-wrap img {
  display: block; max-width: 100%; max-height: 360px;
  border-radius: 10px; user-select: none; -webkit-user-drag: none;
}
.hotspot-wrap.editor { cursor: crosshair; touch-action: none; }
.hs-rect {
  position: absolute; pointer-events: none; border-radius: 4px;
  border: 3px solid var(--qz-ok);
  background: color-mix(in srgb, var(--qz-ok) 25%, transparent);
}
.hs-marker, .hs-dot {
  position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border-radius: 50%; border: 2px solid #fff; pointer-events: none;
  background: var(--qz-secondary); box-shadow: 0 0 0 2px rgba(0,0,0,.25);
}
.hs-dot.ok  { background: var(--qz-ok); }
.hs-dot.bad { background: var(--qz-bad); }

/* ---------- Foto-Einreichungen & Galerie ---------- */

.sub-grid, .gal-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .6rem; margin: .6rem 0;
}
.sub-tile, .gal-tile {
  background: #fff; border: 1px solid var(--qz-line); border-radius: 10px;
  padding: .4rem; font-size: .82rem; overflow-wrap: anywhere;
}
.sub-tile img, .gal-tile img {
  width: 100%; height: 100px; object-fit: cover;
  border-radius: 6px; display: block; margin-bottom: .25rem;
}
.gal-grid.big .gal-tile img { height: 150px; }
.sub-tile label { display: flex; gap: .35rem; align-items: center;
                  font-weight: 600; margin: .2rem 0 0; }
.gal-cap  { font-weight: 700; }
.gal-nick { color: var(--qz-muted); }

/* ---------- Sichtbarkeit / Freigaben (Dashboard) ---------- */

.vis-row { margin-top: .5rem; border-top: 1px dashed var(--qz-line); padding-top: .5rem; }
.vis-badge {
  font-size: .75rem; font-weight: 700; padding: .15em .6em;
  border-radius: 99px; background: var(--qz-bg); border: 1px solid var(--qz-line);
}
.vis-badge.school { background: color-mix(in srgb, var(--qz-primary) 14%, white); }
.vis-badge.public { background: color-mix(in srgb, var(--qz-ok) 16%, white); }
.vis-badge.pend   { background: color-mix(in srgb, var(--qz-secondary) 25%, white); }
.vis-badge.premium { background: color-mix(in srgb, var(--qz-secondary) 35%, white); color: #4a3300; }
.quiz-item.premium-locked { opacity: .65; }
.vis-select { width: auto; padding: .25rem .4rem; font-size: .85rem; }

/* ---------- Editor: Bildergalerie zur Auswahl ---------- */

.media-gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: .4rem; margin: .4rem 0 .8rem;
}
.mg-tile {
  padding: 0; border: 2px solid var(--qz-line); border-radius: 8px;
  background: #fff; cursor: pointer; overflow: hidden;
}
.mg-tile img { width: 100%; height: 64px; object-fit: cover; display: block; }
.mg-tile:hover { border-color: var(--qz-primary); }
.mg-tile.sel { border-color: var(--qz-secondary); outline: 2px solid var(--qz-secondary); }

/* ---------- Toast (Rückmeldung nach Speichern) ---------- */

.editor-nav { justify-content: space-between; margin-bottom: .4rem; }
.toast {
  position: sticky; top: .5rem; z-index: 40;
  display: flex; align-items: center; gap: .8rem;
  background: var(--qz-ink); color: #fff;
  border-radius: 10px; padding: .55rem .9rem; margin-bottom: .6rem;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}

/* ---------- QR-Codes ---------- */

.qr-box { text-align: center; margin: .6rem 0; }
.qr-box canvas, .qr-canvas {
  background: #fff; border-radius: 8px; max-width: 240px;
  width: 100%; height: auto; image-rendering: pixelated;
}

/* ---------- Galerie: größer auf großen Bildschirmen ---------- */

/* Teilnehmer-Ansicht bei Galerie-Folien verbreitern (sonst 640 px) */
.play-main.wide { max-width: 1200px; }
.qr-link { display: block; margin-top: .4rem; font-size: .8rem;
           overflow-wrap: anywhere; }

@media (min-width: 700px) {
  .gal-grid.big { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .gal-grid.big .gal-tile img { height: 170px; }
}
@media (min-width: 1100px) {
  .gal-grid.big { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .gal-grid.big .gal-tile img { height: 220px; }
  .gal-grid.big .gal-tile { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
