/* =============================================================
   Pipeflow — Chat-Widget
   Rechts unten, wie der Rest der Seite: nur Schrift und Bewegung,
   kein Icon-Set. Der Ausloeser ist ein beschrifteter Pill-Button,
   das Panel ein Dokument in derselben Sprache wie .zdoc/.sked.
   ============================================================= */

.pfchat { position: fixed; right: clamp(16px, 3vw, 28px); bottom: clamp(16px, 3vw, 28px); z-index: 300; }

.pfchat__toggle {
  display: inline-flex; align-items: center; gap: 10px;
  height: 50px; padding-inline: 22px;
  border-radius: 100px; border: 1px solid transparent;
  background: var(--ink); color: var(--paper);
  font-family: var(--sans); font-size: 14.5px; font-weight: 500; letter-spacing: -0.01em;
  box-shadow: 0 6px 18px -8px rgba(11,11,12,.55);
  cursor: pointer;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.pfchat__toggle:hover { transform: translateY(-2px); box-shadow: 0 10px 24px -8px rgba(11,11,12,.6); }
.pfchat__toggle i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--paper);
  animation: blip 1.8s var(--ease-soft) infinite;
  flex: none;
}
.pfchat.is-open .pfchat__toggle { display: none; }

.pfchat__panel {
  position: absolute; right: 0; bottom: calc(100% + 14px);
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 120px));
  /* dvh zuletzt: auf dem Telefon schiebt die ein- und ausfahrende
     Adressleiste das Eingabefeld sonst aus dem Bild. */
  height: min(560px, calc(100dvh - 120px));
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
  opacity: 0; transform: translateY(10px) scale(.98);
  pointer-events: none;
  transition: opacity .25s var(--ease), transform .3s var(--ease);
  transform-origin: bottom right;
}
.pfchat.is-open .pfchat__panel { opacity: 1; transform: none; pointer-events: auto; }
.pfchat__panel[hidden] { display: none !important; }
.pfchat__retry, .pfchat__contact { display: inline-block; margin-top: 10px; font: inherit; color: var(--ink); }
.pfchat__retry { background: white; border: 1px solid var(--rule); padding: 9px 12px; border-radius: 5px; cursor: pointer; margin-right: 12px; }
.pfchat__contact { text-decoration: underline; text-underline-offset: 3px; }
.pfchat__log { overscroll-behavior: contain; }

.pfchat__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px;
  background: var(--ink); color: var(--paper);
  flex: none;
}
.pfchat__bar-t {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 8px;
}
.pfchat__bar-t i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--paper);
  animation: blip 1.8s var(--ease-soft) infinite;
}
.pfchat__close {
  appearance: none; border: 0; background: none; color: var(--paper);
  font-family: var(--mono); font-size: 13px; letter-spacing: .05em;
  cursor: pointer; opacity: .8;
  /* Volle Daumenflaeche, ohne die Leiste hoeher zu machen. */
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding-inline: 10px; margin-block: -14px; margin-right: -10px;
  transition: opacity .2s var(--ease);
}
.pfchat__close:hover { opacity: 1; }

.pfchat__log {
  flex: 1; overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 16px;
  background: var(--paper);
}
.pfchat__msg { max-width: 88%; }
.pfchat__msg--user { align-self: flex-end; text-align: right; }
.pfchat__msg--bot  { align-self: flex-start; }
.pfchat__who {
  display: block;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 5px;
}
.pfchat__bubble {
  font-size: 14px; line-height: 1.5; color: var(--ink);
  white-space: pre-wrap; word-break: break-word;
}
.pfchat__msg--user .pfchat__bubble {
  display: inline-block; text-align: left;
  background: var(--wash); border-radius: 12px 12px 2px 12px;
  padding: 9px 13px;
}
.pfchat__msg--bot .pfchat__bubble::after {
  content: ''; display: inline-block; width: 2px; height: 1em; margin-left: 2px; vertical-align: -2px;
  background: var(--ink); opacity: 0;
}
.pfchat__msg--bot.is-typing .pfchat__bubble::after { opacity: 1; animation: caret .9s steps(1) infinite; }

.pfchat__hint {
  font-size: 13px; color: var(--ink-3); line-height: 1.5;
  padding-top: 2px;
}
.pfchat__hint a { color: var(--ink); border-bottom: 1px solid var(--rule); }

.pfchat__err { font-size: 13px; color: var(--ink); background: var(--wash); border-radius: 8px; padding: 8px 11px; }

.pfchat__form {
  flex: none; display: flex; align-items: flex-end; gap: 8px;
  padding: 12px; border-top: 1px solid var(--rule-soft);
  background: var(--paper);
}
.pfchat__input {
  flex: 1; resize: none; border: 1px solid var(--rule); border-radius: 10px;
  padding: 10px 12px; font: inherit; font-size: 14px; color: var(--ink);
  max-height: 110px; line-height: 1.4;
  transition: border-color .2s var(--ease);
}
.pfchat__input:focus { outline: none; border-color: var(--ink); }
.pfchat__send {
  flex: none; height: 40px; padding-inline: 16px;
  border-radius: 100px; border: 1px solid transparent;
  background: var(--ink); color: var(--paper);
  font-size: 13.5px; font-weight: 500; cursor: pointer;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.pfchat__send:hover { transform: translateY(-1px); }
.pfchat__send:disabled { opacity: .35; cursor: default; transform: none; }

/* Auf Touch muss das Eingabefeld mindestens 16px haben — darunter
   zoomt iOS beim Antippen in die Seite hinein und kommt nicht zurueck. */
@media (pointer: coarse) {
  .pfchat__input { font-size: 16px; }
  .pfchat__send { height: 44px; }
}

@media (max-width: 520px) {
  .pfchat { right: 12px; bottom: 12px; }
  .pfchat__panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 96px);
    height: calc(100dvh - 96px);
  }
  .pfchat__toggle { height: 46px; padding-inline: 18px; font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .pfchat__toggle, .pfchat__panel, .pfchat__send { transition: none; }
  .pfchat__toggle i, .pfchat__bar-t i { animation: none; }
  .pfchat__msg--bot.is-typing .pfchat__bubble::after { animation: none; opacity: .6; }
}
