/* KI-Assistent Qex-R4 (Testbetrieb). Auf allen Seiten ausser `chat: false`, siehe partials/chat.njk.
   Aufbau: Kopf, Verlauf (bekommt den ganzen freien Platz), Eingabezeile, eine Zeile Hinweis.
   Ebene 240/250: ueber der Kopfleiste der Website (200), unter dem Handy-Menue (500). */
/* Der Knopf erscheint erst ab 50 % Scrolltiefe oder nach 20 Sekunden (chat.js) und
   verschwindet, solange der Fussbereich im Bild ist. Entscheidung User 01.10.2026: Besucher
   sollen sich erst mit der Seite befassen, nicht sofort am Bot haengen. */
.chat-knopf{position:fixed;right:20px;bottom:20px;z-index:240;display:inline-flex;align-items:center;gap:.6rem;min-height:48px;padding:.45rem 1.2rem .45rem .45rem;border:0;border-radius:999px;background:var(--clay);color:#000;font:700 1rem/1 var(--font);cursor:pointer;box-shadow:0 6px 20px rgba(15,23,42,.18);opacity:0;transform:translateY(16px);pointer-events:none;transition:background .2s,opacity .35s ease,transform .35s ease}
.chat-knopf.is-sichtbar{opacity:1;transform:none;pointer-events:auto}
.chat-knopf[hidden]{display:none}
.chat-knopf:hover{background:#d97706}
.chat-knopf:focus-visible{outline:3px solid var(--ink);outline-offset:3px}
.chat-knopf[aria-expanded="true"]{display:none}
.chat-avatar{display:block;flex:none;width:44px;height:44px;border-radius:50%;object-fit:cover;object-position:center 26%;background:var(--paper)}
.chat-avatar--klein{width:36px;height:36px}

.chat-fenster{position:fixed;right:20px;bottom:20px;z-index:250;width:min(420px,calc(100vw - 32px));height:min(640px,calc(100vh - 40px));display:flex;flex-direction:column;overflow:hidden;background:var(--card);border:1px solid var(--line-2);border-radius:var(--r);box-shadow:0 12px 40px rgba(15,23,42,.22);color:var(--ink)}
.chat-fenster[hidden]{display:none}

/* Kopf: Bild, Name, KI-Kennzeichnung in einer Zeile darunter, Schliessen */
.chat-kopf{display:flex;align-items:center;gap:.75rem;padding:.75rem .75rem .75rem 1rem;border-bottom:1px solid var(--line)}
.chat-kopf__text{flex:1;min-width:0}
.chat-kopf h2{margin:0;font-size:1.05rem;line-height:1.3}
.chat-test{display:inline-block;margin-left:.3rem;padding:.05rem .45rem;border-radius:999px;background:var(--clay-soft);font-size:.72rem;font-weight:700;vertical-align:middle}
.chat-ki{display:flex;align-items:center;gap:.35rem;margin:.1rem 0 0;max-width:none;font-size:.82rem;line-height:1.3;color:#000}
.chat-ki img{flex:none;width:16px;height:16px}
.chat-zu{display:inline-flex;align-items:center;justify-content:center;width:44px;height:44px;border:0;border-radius:var(--r-sm);background:transparent;color:var(--ink);cursor:pointer;transition:background .2s}
.chat-zu:hover{background:var(--paper)}
.chat-zu:focus-visible{outline:2px solid var(--clay);outline-offset:-2px}
.chat-zu svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}

/* Verlauf */
.chat-verlauf{flex:1;min-height:0;overflow-y:auto;padding:1rem;display:flex;flex-direction:column;gap:.7rem;background:var(--paper)}
.chat-nachricht{margin:0;max-width:88%;padding:.7rem .9rem;border-radius:var(--r-sm);font-size:.95rem;line-height:1.5}
.chat-nachricht--bot{align-self:flex-start;background:var(--card);border:1px solid var(--line)}
.chat-nachricht--du{align-self:flex-end;background:var(--clay-soft);white-space:pre-wrap}
/* Wartesatz hervorgehoben in Bordeaux mit pulsierendem Punkt, damit klar ist: hier
   passiert gerade etwas (Wunsch User 01.10.2026). Kontrast #7f1d2d auf Weiss rund 10:1. */
.chat-nachricht--warten{color:#7f1d2d;font-weight:700;width:88%}
.chat-nachricht--warten::before{content:"";display:inline-block;width:.55em;height:.55em;margin-right:.5em;border-radius:50%;background:#7f1d2d;vertical-align:.1em;animation:chat-puls 1.2s ease-in-out infinite}
@keyframes chat-puls{0%,100%{opacity:1}50%{opacity:.25}}
@media (prefers-reduced-motion:reduce){.chat-nachricht--warten::before{animation:none}}
/* Feste Hoehe fuer den laengsten Fakt (4 Zeilen am Handy), damit die Nachricht beim
   Wechsel nicht waechst und schrumpft und der Verlauf nicht springt */
.chat-fakt{display:block;margin-top:.6rem;padding-top:.6rem;border-top:1px solid var(--line);color:#000;font-weight:400;min-height:calc(4 * 1.5em + .6rem)}
.chat-quellen{display:block;margin-top:.5rem;font-size:.85rem}
.chat-quellen a{color:var(--link)}
.chat-bewertung{display:flex;align-items:center;gap:.35rem;margin-top:.5rem;font-size:.82rem;color:#000}
.chat-daumen{display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;border:1px solid var(--line-2);border-radius:999px;background:#fff;color:var(--ink);cursor:pointer;transition:background .2s}
.chat-daumen:hover{background:var(--clay-soft)}
.chat-daumen:focus-visible{outline:2px solid var(--clay);outline-offset:1px}
.chat-daumen svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.chat-daumen--runter svg{transform:rotate(180deg)}

/* Eingabe: ein Rahmen mit Feld und Senden-Knopf */
.chat-eingabe{padding:.75rem 1rem .35rem;border-top:1px solid var(--line)}
.chat-einwilligung{display:flex;align-items:flex-start;gap:.5rem;margin:0 0 .6rem;max-width:none;font-size:.8rem;line-height:1.45;color:#000}
.chat-einwilligung[hidden]{display:none}
.chat-einwilligung input{flex:none;width:18px;height:18px;margin:.1rem 0 0;accent-color:var(--clay);cursor:pointer}
.chat-einwilligung label{cursor:pointer}
.chat-einwilligung a{color:var(--link)}
.chat-einwilligung--fehlt{padding:.45rem .55rem;border-radius:var(--r-sm);background:var(--clay-soft);outline:2px solid var(--clay)}
.chat-zeile{display:flex;align-items:flex-end;gap:.4rem;padding:.3rem .3rem .3rem .9rem;border:1px solid var(--line-2);border-radius:var(--r-sm);background:#fff;transition:border-color .2s}
.chat-zeile:focus-within{border-color:var(--clay);box-shadow:0 0 0 3px var(--clay-softer)}
.chat-zeile textarea{flex:1;min-width:0;min-height:5.3rem;max-height:10rem;padding:.55rem 0;border:0;outline:0;resize:none;background:transparent;font:inherit;font-size:1rem;line-height:1.45;color:var(--ink)}
.chat-senden{display:inline-flex;flex:none;align-items:center;justify-content:center;width:44px;height:44px;border:0;border-radius:50%;background:var(--clay);color:#000;cursor:pointer;transition:background .2s}
.chat-senden:hover{background:#d97706}
.chat-senden:focus-visible{outline:2px solid var(--ink);outline-offset:2px}
.chat-senden:disabled{opacity:.55;cursor:wait}
.chat-senden svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round}
.chat-zeichen{margin:.3rem .5rem 0;max-width:none;text-align:right;font-size:.75rem;color:#000}
.chat-zeichen[hidden]{display:none}
.chat-hinweis{margin:0;max-width:none;padding:.2rem 1rem .75rem;font-size:.75rem;line-height:1.4;color:#000}

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

/* Handy und kleines Tablet: Leiste ueber die volle Breite, die unten klebt (wie bei Buen
   Sonido), statt eines schwebenden Knopfs ueber dem Text */
@media (max-width:720px){
  .chat-knopf{left:0;right:0;bottom:0;width:100%;justify-content:center;min-height:56px;padding:.5rem 1rem calc(.5rem + env(safe-area-inset-bottom));border-radius:0;box-shadow:0 -6px 20px rgba(15,23,42,.18);transform:translateY(100%)}
  .chat-knopf.is-sichtbar{transform:none}
}
@media (max-width:480px){
  .chat-fenster{right:12px;left:12px;bottom:12px;width:auto;height:calc(100dvh - 24px)}
}
@media (prefers-reduced-motion:reduce){
  .chat-knopf,.chat-zu,.chat-daumen,.chat-senden,.chat-zeile{transition:none}
}
