/* =========================================================
   SeitenMeier – Chat «Frag Benjamin»
   Bühne unten rechts: Schild links, stehende Figur rechts. Das Panel
   öffnet darüber. Nur Farben aus style.css (:root). Der Chat speichert
   nichts im Browser: das Gespräch lebt nur in der Seite.
   ========================================================= */

/* ---------- Bühne: Schild und Figur ---------- */
.frag__buehne {
  position: fixed;
  right: 14px;
  bottom: 0;
  z-index: 56;
  display: flex;
  align-items: flex-end;
  transition: opacity .12s, translate .12s, visibility 0s, bottom .4s var(--feder);
}
.frag--versteckt .frag__buehne {
  translate: 0 7rem;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: translate .4s var(--feder), opacity .25s, visibility 0s .4s;
}
/* Offen: die Bühne weicht dem Panel */
.frag--offen .frag__buehne {
  opacity: 0;
  translate: 0 12px;
  pointer-events: none;
  visibility: hidden;
  transition: opacity .12s, translate .12s, visibility 0s .12s;
}

/* Schild */
.frag__schild {
  position: relative;
  display: grid;
  gap: 4px;
  margin: 0 4px 34px 0;
  padding: 13px 16px 12px;
  background: var(--papier);
  color: var(--schwarz);
  border: 0;
  border-radius: 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  opacity: 0;
  transition: translate .3s var(--aus), scale .15s var(--aus);
}
.frag__schild::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--leucht);
}
.frag__schild::after {         /* Spitze, die auf die Figur zeigt */
  content: '';
  position: absolute;
  right: -6px;
  bottom: 12px;
  width: 12px;
  height: 12px;
  background: var(--papier);
  rotate: 45deg;
}
.frag__schild b {
  display: block;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: -.01em;
  line-height: 1.1;
  white-space: nowrap;
}
.frag__schild span {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--grau);
  white-space: nowrap;
}
.frag--da .frag__schild {
  opacity: 1;
  animation: frag-feder .7s var(--feder) both;
}
.frag__schild:active { scale: .97; }
@keyframes frag-feder {
  from { opacity: 0; transform: translateX(1.4rem) rotate(4deg); }
  to   { opacity: 1; transform: none; }
}

/* Figur */
.frag__figur {
  position: relative;
  display: block;
  width: 117px;
  height: 280px;
  flex: none;
  margin: 0 0 -4px;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
  transform-origin: 50% 100%;
}
.frag__figur img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 100%;
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, .55)) drop-shadow(0 6px 12px rgba(0, 0, 0, .55));
  pointer-events: none;
  transition: opacity 120ms;
}
.frag__figur .w { opacity: 0; }
.frag__figur.hallo .w { opacity: 1; }
.frag__figur.hallo .s { opacity: 0; }
.frag__figur.hallo .w { animation: frag-wink .7s ease-in-out 2; }

/* Namensschild über dem Kopf */
.frag__figur i {
  position: absolute;
  left: 50%;
  top: -26px;
  translate: -50% 4px;
  padding: 5px 10px;
  background: var(--papier);
  color: var(--schwarz);
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, translate .2s var(--aus);
}
.frag__figur:focus-visible i { opacity: 1; translate: -50% 0; }
.frag__figur:focus-visible { outline: 3px solid var(--leucht); outline-offset: 4px; }

@keyframes frag-wink {
  0%, 100% { transform: translateY(-6px) rotate(0); }
  25% { transform: translateY(-6px) rotate(-3deg); }
  75% { transform: translateY(-6px) rotate(3deg); }
}

/* Hover nur mit Maus */
@media (hover: hover) and (pointer: fine) {
  .frag__schild:hover { translate: 0 -2px; }
  .frag__figur:hover i { opacity: 1; translate: -50% 0; }
  .frag__figur:hover .s { opacity: 0; }
  .frag__figur:hover .w { opacity: 1; animation: frag-wink .7s ease-in-out infinite; }
}

/* Schliessen-Knopf unten rechts, solange das Panel offen ist */
.frag__schliessen {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 58;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  padding: 0;
  background: var(--schwarz);
  color: var(--weiss);
  border: 2px solid var(--weiss);
  border-radius: 0;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: background .2s, color .2s, opacity .12s, visibility 0s .12s;
}
.frag__schliessen::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--leucht);
}
.frag__schliessen:hover,
.frag__schliessen:focus-visible { background: var(--leucht); color: var(--schwarz); }
.frag--offen .frag__schliessen {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: background .2s, color .2s, opacity .12s, visibility 0s;
}

/* ---------- Panel ---------- */
.frag__panel {
  position: fixed;
  right: 20px;
  bottom: 92px;
  z-index: 57;
  width: 400px;
  max-width: calc(100vw - 40px);
  height: min(640px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: var(--papier);
  color: var(--schwarz);
  border: 2px solid var(--schwarz);
  border-radius: 3px;
  box-shadow: .5rem .5rem 0 var(--schwarz);
  animation: frag-auf .35s var(--aus) both;
}
.frag__panel[hidden] { display: none; }
@keyframes frag-auf {
  from { opacity: 0; transform: translateY(.8rem); }
  to   { opacity: 1; transform: none; }
}

.frag__kopf {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .8rem .9rem;
  background: var(--schwarz);
  color: var(--weiss);
}
.frag__kopfbild {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  background: var(--blau-hell);
  object-fit: cover;
}
.frag__kopftext { display: grid; min-width: 0; flex: 1; }
.frag__titel { font-weight: 900; font-size: 1.1rem; line-height: 1.15; }
.frag__unter { font-size: .78rem; color: rgba(244, 245, 242, .72); line-height: 1.3; }
.frag__zu {
  flex: none;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  background: none;
  border: 0;
  color: var(--weiss);
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
}
.frag__zu:hover { color: var(--leucht); }

.frag__verlauf {
  flex: 1 1 auto;
  min-height: 9rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .7rem;
  padding: 1rem;
  overscroll-behavior: contain;
}

.frag__blase {
  max-width: 85%;
  padding: .65rem .85rem;
  border-radius: 3px;
  font-size: .98rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.frag__ki { align-self: flex-start; background: var(--blau-hell); color: var(--schwarz); }
.frag__nutzer { align-self: flex-end; background: var(--leucht); color: var(--schwarz); }
.frag__fehler { align-self: flex-start; background: transparent; border: 2px dashed var(--schwarz); }
.frag__blase a { color: inherit; font-weight: 800; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.frag__blase a:focus-visible { outline: 3px solid currentColor; outline-offset: 2px; }

/* Pfad allein auf einer Zeile: als Knopf */
.frag__blase a.frag__knopf-link {
  display: inline-flex;
  align-items: center;
  margin: .2rem 0;
  padding: .45rem .8rem;
  border: 2px solid var(--schwarz);
  border-radius: 0;
  font-weight: 800;
  text-decoration: none;
  background: transparent;
  transition: background .2s;
}
.frag__blase a.frag__knopf-link:hover,
.frag__blase a.frag__knopf-link:focus-visible { background: var(--leucht); }

/* Warten: drei hüpfende Punkte, bei reduzierter Bewegung ein stilles «…» */
.frag__punkte { display: inline-flex; align-items: center; gap: .3rem; min-height: 1.2em; }
.frag__punkte i {
  width: .42rem;
  height: .42rem;
  border-radius: 50%;
  background: var(--schwarz);
  animation: frag-punkt 1s infinite ease-in-out;
}
.frag__punkte i:nth-child(2) { animation-delay: .15s; }
.frag__punkte i:nth-child(3) { animation-delay: .3s; }
@keyframes frag-punkt {
  0%, 60%, 100% { transform: translateY(0); opacity: .35; }
  30% { transform: translateY(-.3rem); opacity: 1; }
}

.frag__chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.frag__vorschlaege {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  padding: 0 1rem .9rem;
}
.frag__vorschlaege[hidden] { display: none; }
.frag__vorschlag {
  padding: .4rem .65rem;
  background: transparent;
  color: var(--schwarz);
  border: 2px solid var(--schwarz);
  border-radius: 3px;
  font-family: inherit;
  font-size: .88rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.frag__vorschlag:hover,
.frag__vorschlag:focus-visible { background: var(--leucht); }
.frag__vorschlag:disabled { opacity: .5; cursor: default; background: transparent; }

.frag__fuss {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  margin: 0;
  padding: .7rem 1rem;
  border-top: 2px solid var(--schwarz);
}
.frag__eingabe {
  flex: 1;
  min-width: 0;
  resize: none;
  overflow-y: hidden;
  padding: .55rem .65rem;
  background: #fff;
  color: var(--schwarz);
  border: 2px solid var(--schwarz);
  border-radius: 3px;
  font: inherit;
  font-size: 1rem;
  line-height: 1.4;
}
.frag__eingabe:focus-visible { outline: 3px solid var(--leucht); outline-offset: 1px; }
.frag__eingabe:disabled { opacity: .6; }
.frag__senden {
  flex: none;
  width: 2.8rem;
  height: 2.8rem;
  display: grid;
  place-items: center;
  padding: 0;
  background: var(--schwarz);
  color: var(--weiss);
  border: 0;
  border-radius: 3px;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.frag__senden svg { width: 1.2rem; height: 1.2rem; }
.frag__senden:hover, .frag__senden:focus-visible { background: var(--leucht); color: var(--schwarz); }
.frag__senden:disabled { opacity: .5; cursor: default; background: var(--schwarz); color: var(--weiss); }

.frag__hinweis {
  margin: 0;
  padding: 0 1rem .8rem;
  font-size: .7rem;
  line-height: 1.4;
  color: var(--grau);
}
.frag__hinweis a { color: inherit; font-weight: 700; }

/* Solange der Chat offen ist, verschwindet der Rufer (sonst läge er unter dem Schliessen-Knopf) */
.frag-offen .rufer { visibility: hidden; pointer-events: none; }

/* ---------- Handy ---------- */
@media (max-width: 760px) {
  .frag__buehne { right: 6px; }
  .frag--hoch .frag__buehne { bottom: var(--frag-boden, 0px); }   /* steht auf dem Rufer-Knopf */
  .frag__schild { padding: 9px 11px 8px; margin-bottom: 22px; }
  .frag__schild b { font-size: 15px; }
  .frag__schild span { font-size: 10px; }
  .frag__figur { width: 80px; height: 190px; }
  .frag__panel {
    left: 8px;
    right: 8px;
    bottom: 76px;
    width: auto;
    max-width: none;
    height: min(640px, calc(100vh - 92px));
    height: min(640px, calc(100svh - 92px));
  }
  .frag__schliessen { right: 10px; bottom: 10px; width: 52px; height: 52px; }
}

/* ---------- Reduzierte Bewegung ---------- */
@media (prefers-reduced-motion: reduce) {
  .frag__panel,
  .frag--da .frag__schild { animation: none; }
  .frag__buehne, .frag__schild, .frag__figur img, .frag__figur i,
  .frag__vorschlag, .frag__senden, .frag__schliessen { transition: none; }
  .frag__figur.hallo .w { animation: none; }
  .frag__figur.hallo .w { opacity: 1; }
  .frag__figur.hallo .s { opacity: 0; }
  .frag__schild:hover, .frag__schild:active { translate: none; scale: none; }
  .frag__punkte i { animation: none; display: none; }
  .frag__punkte::before { content: '…'; }
}
@media (prefers-reduced-motion: reduce) and (hover: hover) and (pointer: fine) {
  .frag__figur:hover .w { animation: none; }
}
