/*
 * Pop-up der Live-Ziehung (public/ziehung-fenster.js) — gemeinsam für die
 * Web-Karte und die Team-App (docs/GEWINNSPIEL-LIVE.md, „Live-Ziehung 3").
 *
 * Alle Regeln tragen das Präfix zf-, damit nichts mit card.css oder
 * styles.css zusammenstößt. Die Farben sind die des Passes (Nacht und
 * Gold) und stehen als Variablen an .zf-deckel selbst: Das Fenster sieht
 * auf der hellen Kundenkarte und in beiden Themen der App gleich aus, und
 * keine Seite muss dafür etwas definieren. Handy zuerst (Hochformat), ab
 * 640 px Bühne und Liste nebeneinander.
 */

.zf-deckel {
  --ziehung-nacht: #11100e;
  --ziehung-gold: #d4af37;
  --zf-gold-hell: #e4c56c;
  --zf-creme: #faf5f1;
  --zf-gedaempft: #b3ab9d;
  --zf-rand: #2c281f;
  --zf-zeile: #1a1812;
  --zf-mein-grund: #2a2210;
  --zf-rot: #ff8a7a;
  --zf-schatten: rgba(0, 0, 0, 0.55);
  --zf-serif: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;

  position: fixed;
  inset: 0;
  z-index: 8500;               /* unter der PIN-Maske der App, über allem sonst */
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: var(--ziehung-nacht);
  color: var(--zf-creme);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
  animation: zf-auf 0.25s ease-out;
}

/* Das hidden-Attribut muss gegen die display-Regeln unten gewinnen. */
.zf-deckel [hidden] { display: none !important; }

/* Die Seite dahinter scrollt nicht mit. */
html.zf-offen,
html.zf-offen body { overflow: hidden; }

@keyframes zf-auf {
  from { opacity: 0; }
  to { opacity: 1; }
}

.zf-fenster {
  box-sizing: border-box;
  min-height: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ----------------------------------------------------------- Kopfzeile */

.zf-kopf {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.zf-titel {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-family: var(--zf-serif);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ziehung-gold);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zf-vorschau {
  flex: 0 0 auto;
  padding: 3px 9px;
  border: 1px solid var(--ziehung-gold);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ziehung-gold);
}

.zf-x {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--ziehung-gold);
  border-radius: 50%;
  background: transparent;
  color: var(--ziehung-gold);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.zf-x:focus-visible {
  outline: 2px solid var(--zf-gold-hell);
  outline-offset: 2px;
}

/* „Für Ton antippen" neben dem Ton-Knopf (`.ziehung-ton`, den die Aufrufer
   card.js und gewinnspiel.js in die Kopfzeile setzen; seine Regeln stehen
   in card.css und styles.css). Nur sichtbar, solange der Ton gewünscht,
   aber noch nicht freigegeben ist — iOS braucht dafür eine Geste, und ein
   Tipp irgendwo ins Fenster weckt ihn. Den Puls des Knopfs allein übersah
   der Betreiber (2026-09-25); das Wort blinkt sanft mit. Lange Sprachen
   brechen in eine zweite Zeile um, der Studioname links weicht. */
.zf-kopf .zf-ton-hinweis {
  flex: 0 0 auto;
  max-width: 9.5em;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  text-align: right;
  color: var(--ziehung-gold);
  cursor: pointer;
  animation: zf-ton-hinweis 1.6s ease-in-out infinite;
}
@keyframes zf-ton-hinweis {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ------------------------------------------------------- Inhalt (Handy) */

.zf-inhalt {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.zf-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.zf-rechts { min-width: 0; }

/* Losnummer der Kundin — steht die ganze Zeit, auch während der Show. */
.zf-los {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
}
.zf-los-wort {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--zf-gedaempft);
}
.zf-los-nr {
  font-family: var(--zf-serif);
  font-size: 40px;
  font-weight: 700;
  line-height: 1.05;
  color: var(--ziehung-gold);
  font-variant-numeric: tabular-nums;
}

/* Bühne und Countdown liegen übereinander. Die Zahl sitzt NEBEN dem
   Container des Moduls, nicht darin — das Modul räumt seinen Container
   beim Start leer. */
.zf-rahmen {
  position: relative;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}

.zf-buehne {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid var(--zf-rand);
  background: var(--ziehung-nacht);
}
.zf-buehne canvas { display: block; width: 100%; height: 100%; }

.zf-zahl {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  font-family: var(--zf-serif);
  font-size: 128px;
  font-weight: 700;
  line-height: 1;
  color: var(--ziehung-gold);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 4px 24px var(--zf-schatten);
}
/* Wartewort („Die Ziehung läuft"), bis das Paket da ist. */
.zf-zahl.zf-wartet {
  padding: 0 16px;
  font-size: 26px;
  text-align: center;
  animation: zf-atmen 1.8s ease-in-out infinite;
}

/* Zwei gleiche Animationen: Der Wechsel des Namens startet sie für jede
   neue Zahl neu. */
.zf-zahl.zf-tick-a { animation: zf-tick-a 0.9s ease-out both; }
.zf-zahl.zf-tick-b { animation: zf-tick-b 0.9s ease-out both; }
@keyframes zf-tick-a {
  0% { transform: scale(1.35); opacity: 0; }
  25% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.92); opacity: 0.85; }
}
@keyframes zf-tick-b {
  0% { transform: scale(1.35); opacity: 0; }
  25% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.92); opacity: 0.85; }
}
@keyframes zf-atmen {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.zf-status {
  margin: 0;
  min-height: 1.4em;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--zf-creme);
}
.zf-status.zf-gewonnen {
  font-family: var(--zf-serif);
  font-size: 24px;
  font-weight: 700;
  color: var(--ziehung-gold);
}
.zf-status.zf-fehler { color: var(--zf-rot); }

/* ------------------------------------------------------------- Liste */

.zf-liste {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.zf-zeile {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 10px 14px;
  border: 1px solid var(--zf-rand);
  border-radius: 14px;
  background: var(--zf-zeile);
  animation: zf-rein 0.45s ease-out;
}
@keyframes zf-rein {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.zf-nr {
  font-size: 18px;
  font-weight: 700;
  color: var(--zf-creme);
  font-variant-numeric: tabular-nums;
}
.zf-name {
  font-size: 16px;
  color: var(--zf-creme);
  overflow-wrap: anywhere;
}
.zf-preis {
  margin-left: auto;
  font-size: 14px;
  color: var(--zf-gedaempft);
  overflow-wrap: anywhere;
}

/* Die eigene Nummer golden. */
.zf-zeile.zf-mein {
  border-color: var(--ziehung-gold);
  background: var(--zf-mein-grund);
}
.zf-zeile.zf-mein .zf-nr { color: var(--ziehung-gold); }

/* Der Hauptgewinn — die letzte Kugel, ganz oben, etwas größer. */
.zf-zeile.zf-haupt {
  padding: 14px 16px;
  border: 2px solid var(--ziehung-gold);
}
.zf-zeile.zf-haupt .zf-nr {
  font-family: var(--zf-serif);
  font-size: 26px;
  color: var(--ziehung-gold);
}
.zf-zeile.zf-haupt .zf-name { font-size: 18px; }
.zf-zeile.zf-haupt .zf-preis {
  font-size: 15px;
  font-weight: 700;
  color: var(--zf-gold-hell);
}

.zf-fuss {
  margin: 0;
  text-align: center;
  font-size: 13px;
  color: var(--zf-gedaempft);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------- Breit: nebeneinander */

@media (min-width: 640px) {
  .zf-inhalt {
    flex-direction: row;
    align-items: flex-start;
    gap: 24px;
  }
  .zf-links {
    flex: 0 0 360px;
    position: sticky;
    top: 0;
  }
  .zf-rechts {
    flex: 1 1 auto;
    padding-top: 4px;
  }
  .zf-titel { font-size: 22px; }
}

/* --------------------------------- Bühne „Glaskugel" (2026-10-06) */
/* Die Haut setzt ziehung-fenster.js an .zf-deckel, wenn die Bühne aus
   public/ziehung-kugel.js spielt — nur mit fertig geladenen Bildern, also
   kommen die Bilder unten aus dem Browser-Cache. Nacht mit violettem
   Schimmer, goldener Rand um die Bühne. Bis das Canvas startet, steht die
   Maschine als Standbild da (Lage = KUGEL_GEO in ziehung-kugel.js: Bild
   112 % der Bühne, x0/y0 in Prozent der Restfläche umgerechnet); das Canvas
   deckt es danach Pixel für Pixel zu. */
.zf-deckel.zf-glaskugel {
  --ziehung-nacht: #0c0a17;
  --zf-rand: #2b2740;
  --zf-zeile: #17142a;
  --zf-mein-grund: #2a2210;
  --zf-glas-oben: #201a3f;
  --zf-glas-licht: rgba(241, 213, 122, 0.5);
  --zf-glas-schein: rgba(90, 70, 220, 0.3);
  --zf-glas-gold: rgba(241, 213, 122, 0.2);
  --zf-glas-tief: rgba(0, 0, 0, 0.6);
  background: radial-gradient(120% 60% at 50% 0%, var(--zf-glas-oben) 0%, var(--ziehung-nacht) 62%);
}
.zf-deckel.zf-glaskugel .zf-buehne {
  border-radius: 24px;
  border: 1px solid var(--zf-glas-licht);
  box-shadow: 0 0 0 1px var(--zf-glas-tief), 0 18px 50px var(--zf-glas-schein), 0 0 34px var(--zf-glas-gold);
  background:
    url("/ziehung/maschine-kugel.webp") 42.07% 46.93% / 112% no-repeat,
    var(--ziehung-nacht) url("/ziehung/buehne-nacht.webp") center / cover no-repeat;
}
.zf-deckel.zf-glaskugel .zf-zahl {
  text-shadow: 0 0 34px rgba(0, 0, 0, 0.9), 0 6px 26px rgba(0, 0, 0, 0.85);
}
.zf-deckel.zf-glaskugel .zf-zeile { align-items: center; }

/* Vor jeder Zeile der Gewinnerliste die Kugel in ihrer Farbe. */
.zf-kugel {
  flex: none;
  width: 26px;
  height: 26px;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
  animation: zf-kugel-rein 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
.zf-zeile.zf-haupt .zf-kugel { width: 34px; height: 34px; }
@keyframes zf-kugel-rein {
  from { transform: scale(0.2) rotate(-90deg); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ------------------------------------------------ Weniger Bewegung */

@media (prefers-reduced-motion: reduce) {
  .zf-deckel,
  .zf-zeile,
  .zf-kugel,
  .zf-zahl.zf-tick-a,
  .zf-zahl.zf-tick-b,
  .zf-zahl.zf-wartet,
  .zf-kopf .zf-ton-hinweis { animation: none; }
}
