/* Telefon-Rahmen der Buerger-Seiten (Ticket 25). Bis 899 px: kein Rahmen, der Inhalt fuellt die Seite (100dvh, Tastatur und Safe-Area wie bisher,
   siehe chat.css). Ab 900 px: ein gezeichnetes Smartphone mit Innenflaeche 390 x 800 px (Statusleiste 48 px, Home-Indikator 24 px, der Rest ist der Chat) und
   optional dem Telegram-Panel daneben. Alle Zierteile tragen data-deko und aria-hidden="true" (templates/telefon.html.twig).
   Die Hoehe des Chats ist die Hoehe seines Containers (.telefon-inhalt), nicht die des Fensters. Farben nur aus den Tokens (ui.css). */
:root {
  --telefon-breite: 390px;
  --telefon-hoehe: 800px;
  --telefon-rand: 12px;
  --telefon-status: 48px;
  --telefon-home: 24px;
  --gehaeuse: #1a1d22;
  --gehaeuse-kante: #3a3f47;
}
@media (prefers-color-scheme: dark) {
  :root { --gehaeuse: #0b0c0e; --gehaeuse-kante: #444a53; }
}

/* ---- Handy und kleine Fenster (bis 899 px): kein Rahmen ------------------------------------------------------------------------------------ */
.buehne, .buehne-inhalt, .telefon { display: block; }
.telefon-schirm { position: relative; display: flex; flex-direction: column; height: 100vh; height: 100dvh; background: var(--background); }
.telefon-inhalt { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
[data-deko], .telegram-panel { display: none; }
.telefon-seite { padding: 1.25rem 1rem; overflow-y: auto; flex: 1 1 auto; }
.telefon-seite h1 { font-size: 1.5rem; }
.telefon-fuss { flex: none; display: flex; flex-wrap: wrap; justify-content: space-between; gap: .1rem .75rem; margin: 0; padding: .3rem .75rem; padding-bottom: calc(.3rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); font-size: .72rem; line-height: 1.35; color: var(--muted-foreground); background: var(--background); }
.telefon-fuss a { color: inherit; text-decoration: underline; }

/* ---- Mittlere Fenster (760 bis 899 px): wie bisher eine zentrierte Karte, kein Telefon -------------------------------------------------------- */
@media (min-width: 760px) and (max-width: 899px) {
  body.buehne-seite { background: var(--canvas); padding: 1rem 0; box-sizing: border-box; }
  .telefon-schirm { height: calc(100vh - 2rem); height: calc(100dvh - 2rem); max-width: var(--chat-breite); margin: 0 auto; border: 1px solid var(--border); border-radius: var(--radius-xl); overflow: hidden; box-shadow: var(--shadow-lg); }
}

/* ---- Computer (ab 900 px): Telefon-Rahmen -------------------------------------------------------------------------------------------------- */
@media (min-width: 900px) {
  /* im gezeichneten Telefon gilt wie am echten Handy die Grundgroesse 16 px */
  html:has(body.buehne-seite) { font-size: 16px; }
  body.buehne-seite { background: radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--foreground) 6%, var(--canvas)), var(--canvas)); margin: 0; }
  .buehne { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; box-sizing: border-box; }
  /* Bei kleiner Fensterhoehe schrumpft die ganze Buehne (Telefon und Panel) proportional; der Chat bleibt in seiner Innenflaeche 390 px breit und bedienbar. */
  .buehne-inhalt { display: flex; align-items: center; justify-content: center; gap: 64px; }
  .telefon { display: block; position: relative; flex: none; box-sizing: content-box; width: var(--telefon-breite); padding: var(--telefon-rand); border-radius: 64px;
    background: linear-gradient(150deg, #2a2e35 0%, var(--gehaeuse) 40%, #000 100%);
    box-shadow: 0 0 0 2px var(--gehaeuse-kante), 0 0 0 4px rgba(0, 0, 0, .35), 0 40px 80px -10px rgba(0, 0, 0, .45), 0 18px 30px -8px rgba(0, 0, 0, .3); }
  .telefon-schirm { width: var(--telefon-breite); height: var(--telefon-hoehe); border-radius: 52px; overflow: hidden; background: var(--background); isolation: isolate; contain: layout paint; }
  [data-deko] { display: block; }
  .telefon-taste { position: absolute; width: 4px; border-radius: 2px; background: var(--gehaeuse-kante); }
  .telefon-taste-leise { left: -6px; top: 120px; height: 28px; }
  .telefon-taste-laut-1 { left: -6px; top: 176px; height: 56px; }
  .telefon-taste-laut-2 { left: -6px; top: 244px; height: 56px; }
  .telefon-taste-ein { right: -6px; top: 200px; height: 90px; }
  .telefon-island { position: absolute; z-index: 5; top: 12px; left: 50%; width: 116px; height: 34px; margin-left: -58px; border-radius: 20px; background: #000; }
  .telefon-status { display: flex; flex: none; align-items: center; justify-content: space-between; height: var(--telefon-status); padding: 6px 30px 0 34px; box-sizing: border-box; background: var(--card); color: var(--foreground); font: 600 16px/1 system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: .01em; }
  .telefon-symbole { display: inline-flex; align-items: center; gap: 6px; }
  .telefon-symbole svg { fill: currentColor; display: block; }
  .telefon-home { display: flex; flex: none; align-items: center; justify-content: center; height: var(--telefon-home); background: var(--background); }
  .telefon-home span { width: 134px; height: 5px; border-radius: 3px; background: var(--foreground); opacity: .8; }
  .telefon-fuss { padding-bottom: .3rem; }
  .telefon-seite { padding: 1.5rem 1.25rem; }

  /* Telegram-Panel: die Huelle reserviert die Breite schon vor dem Nachladen, damit das Telefon nicht springt */
  .telegram-panel { display: block; flex: none; width: 400px; min-height: 1px; }
}

/* Im gezeichneten Telefon (Viewport ab 900 px) gelten die Regeln der schmalen Bildschirme aus chat.css, die dort an die Fensterbreite gebunden sind:
   Chips in einer wischbaren Reihe (spart Hoehe fuer das Gespraech) und etwas engere Abstaende */
@media (min-width: 900px) {
  .telefon .chat .chat-eingabe .chat-chips { flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: .15rem; scrollbar-width: none; }
  .telefon .chat .chat-eingabe .chat-chips > *, .telefon .chat .chat-eingabe .chat-chips .chip { flex: none; }
  .telefon .chat .chat-eingabe .chat-chips .chip { scroll-snap-align: start; white-space: nowrap; }
  .telefon .chat-verlauf { padding: .6rem .5rem; }
  .telefon .chat-name { font-size: 1rem; }
}

/* Skalierung bei geringer Fensterhoehe: Telefon (824 px mit Gehaeuse) und Panel schrumpfen zusammen (CSS zoom, proportional) */
@media (min-width: 900px) and (max-height: 879px) { .buehne-inhalt { zoom: .9; } }
@media (min-width: 900px) and (max-height: 779px) { .buehne-inhalt { zoom: .8; } }
@media (min-width: 900px) and (max-height: 699px) { .buehne-inhalt { zoom: .72; } }
@media (min-width: 900px) and (max-height: 619px) { .buehne-inhalt { zoom: .64; } }
@media (min-width: 900px) and (max-height: 559px) { .buehne-inhalt { zoom: .56; } }
/* schmale Computerfenster (900 bis 1199 px): das Panel rueckt unter das Telefon-Seitenverhaeltnis nicht, sondern wird schmaler */
@media (min-width: 900px) and (max-width: 1139px) { .buehne-inhalt { gap: 36px; } .telegram-panel { width: 320px; } }

/* ---- Telegram-Panel (Inhalt aus templates/telegram_panel.html.twig) ---------------------------------------------------------------------- */
.tg-panel { padding: 1.5rem 1.75rem 1.25rem; border: 1px solid var(--border); border-radius: calc(var(--radius) + 8px); background: var(--card); color: var(--card-foreground); box-shadow: var(--shadow-lg); }
.tg-panel h2 { margin: 0; font-size: 1.5rem; line-height: 1.2; }
.tg-panel h3 { margin: 1.25rem 0 .4rem; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-foreground); }
.tg-panel p { margin: 0 0 .5rem; }
/* QR-Code: schwarz auf weiss, ausreichende Ruhezone (mindestens 4 Module) auch im dunklen Modus */
.tg-qr { display: flex; justify-content: center; margin: 1rem 0 .6rem; }
.tg-qr img.qr { display: block; width: 240px; height: 240px; max-width: 100%; padding: 20px; box-sizing: content-box; background: #fff; border-radius: var(--radius-lg); border: 1px solid var(--border); image-rendering: crisp-edges; }
.tg-bot { text-align: center; font-weight: 600; font-size: 1.05rem; word-break: break-all; }
.tg-bot a { color: var(--foreground); }
.tg-panel [role="button"] { display: flex; width: 100%; margin: 0 0 .5rem; }
.tg-schritte { margin: 0 0 .6rem; padding-left: 1.3rem; list-style: decimal; font-size: .9375rem; }
.tg-schritte li { display: list-item; margin: 0 0 .15rem; padding: 0; }
.tg-live { margin: .9rem 0 0; padding-top: .9rem; border-top: 1px solid var(--border); }
.tg-live form { margin: 0 0 .4rem; }
.tg-live button { margin: 0; width: 100%; }

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