/* ==========================================================================
   AI BRIDGE PARTNERS — chat.css

   Der Assistent übernimmt die Sprache der Seite: dunkler Grund, Haarlinien,
   ein Blau als Signal, Inter Tight für Text und JetBrains Mono für Labels.
   Bewusst leise gehalten — die Bühne gehört dem Hero, nicht dem Widget.
   ========================================================================== */

:root {
  /* Eigener gedämpfter Ton statt --fg-mute: dieser erreicht 5,6:1 auf dem
     dunklen Grund und damit den WCAG-AA-Wert für Kleintext. */
  --chat-mute: #8593ab;
  --chat-surface: #0a0f1b;
  --chat-bubble: #131b2b;
}

/* ---------- Auslöser ---------- */
.chat-launch {
  position: fixed;
  right: max(1.25rem, env(safe-area-inset-right));
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  z-index: 90;

  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 48px;
  padding: 0 1.1rem 0 0.9rem;

  background: var(--ink-700);
  border: 1px solid var(--hair-strong);
  border-radius: 99px;
  color: var(--fg);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  box-shadow: 0 12px 32px rgba(2, 4, 10, 0.55);

  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.35s var(--ease), border-color 0.3s var(--ease),
    opacity 0.3s var(--ease);
}
.chat-launch:hover {
  transform: translateY(-2px);
  border-color: var(--blue-500);
}
.chat-launch[aria-expanded='true'] {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

/* Derselbe Ring-und-Punkt wie im Favicon und im Preloader. */
.chat-launch__mark {
  position: relative;
  width: 22px;
  height: 22px;
  flex: none;
  border: 1.5px solid var(--blue-400);
  border-radius: 50%;
}
.chat-launch__mark::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 6px;
  height: 6px;
  background: var(--blue-400);
  border-radius: 50%;
  animation: pulse 2.8s var(--ease-io) infinite;
}

/* ---------- Panel ---------- */
.chat {
  position: fixed;
  right: max(1.25rem, env(safe-area-inset-right));
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  z-index: 95;

  display: flex;
  flex-direction: column;
  width: min(24rem, calc(100vw - 2.5rem));
  height: min(34rem, calc(100dvh - 3rem));

  background: var(--chat-surface);
  border: 1px solid var(--hair-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(2, 4, 10, 0.7);
  overflow: hidden;
}

@media (max-width: 560px) {
  .chat {
    inset: 0;
    width: 100%;
    height: 100dvh;
    border: 0;
    border-radius: 0;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ---------- Kopfzeile ---------- */
.chat__head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 0.75rem 0.9rem 1.15rem;
  border-bottom: 1px solid var(--hair);
  flex: none;
}
.chat__title {
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.chat__sub {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--chat-mute);
  margin-top: 0.2rem;
}
.chat__close {
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--chat-mute);
  touch-action: manipulation;
  transition: color 0.25s var(--ease), background 0.25s var(--ease);
}
.chat__close:hover {
  color: var(--fg);
  background: rgba(148, 176, 226, 0.08);
}
.chat__close svg {
  width: 15px;
  height: 15px;
}

/* ---------- Verlauf ---------- */
.chat__log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.chat__note {
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--chat-mute);
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--hair);
}
.chat__note a {
  color: var(--blue-300);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.msg {
  max-width: 88%;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg--bot {
  align-self: flex-start;
  background: var(--chat-bubble);
  border: 1px solid var(--hair);
  border-bottom-left-radius: 4px;
}
.msg--me {
  align-self: flex-end;
  background: rgba(76, 141, 255, 0.14);
  border: 1px solid var(--blue-600);
  color: var(--blue-100);
  border-bottom-right-radius: 4px;
}
.msg--error {
  align-self: stretch;
  max-width: 100%;
  background: rgba(255, 120, 120, 0.08);
  border: 1px solid rgba(255, 140, 140, 0.3);
  color: #ffc9c9;
  font-size: 0.85rem;
}

/* Tippanzeige */
.msg--typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 0.85rem 0.9rem;
}
.msg--typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chat-mute);
  animation: chat-blink 1.3s ease-in-out infinite;
}
.msg--typing i:nth-child(2) { animation-delay: 0.18s; }
.msg--typing i:nth-child(3) { animation-delay: 0.36s; }

@keyframes chat-blink {
  0%, 60%, 100% { opacity: 0.28; }
  30%           { opacity: 1; }
}

/* ---------- Vorschläge ---------- */
.chat__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 1.15rem 0.9rem;
  flex: none;
}
.chat__chip {
  min-height: 34px;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--hair);
  border-radius: 99px;
  font-size: 0.8rem;
  color: var(--fg-dim);
  touch-action: manipulation;
  transition: border-color 0.25s var(--ease), color 0.25s var(--ease);
}
.chat__chip:hover {
  border-color: var(--blue-500);
  color: var(--fg);
}

/* ---------- Eingabe ---------- */
.chat__form {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  padding: 0.85rem 1.15rem 1.05rem;
  border-top: 1px solid var(--hair);
  flex: none;
}
.chat__input {
  flex: 1;
  min-height: 44px;
  max-height: 7.5rem;
  padding: 0.7rem 0.85rem;
  background: var(--ink-800);
  border: 1px solid var(--hair);
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.45;
  resize: none;
  transition: border-color 0.25s var(--ease);
}
.chat__input::placeholder { color: var(--fg-mute); }
.chat__input:focus { border-color: var(--blue-500); }

.chat__send {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  background: var(--blue-400);
  color: var(--ink-900);
  border-radius: 10px;
  touch-action: manipulation;
  transition: background 0.25s var(--ease), opacity 0.25s var(--ease);
}
.chat__send:hover { background: var(--blue-300); }
.chat__send[disabled] { opacity: 0.4; cursor: not-allowed; }
.chat__send svg { width: 17px; height: 17px; }

.chat__foot {
  padding: 0 1.15rem 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--chat-mute);
  flex: none;
}

/* ---------- Bewegung zurücknehmen ---------- */
@media (prefers-reduced-motion: reduce) {
  .chat-launch__mark::after,
  .msg--typing i {
    animation: none;
  }
  .msg--typing i { opacity: 0.6; }
}
