/* ==========================================================================
   Chat-Assistent (assets/chat.js) – clockstack.app
   Nutzt die Variablen aus style.css (Farben, hell/dunkel), Schrift Schibsted Grotesk.
   ========================================================================== */

.kc { font-family: "Schibsted Grotesk", system-ui, -apple-system, sans-serif; }
.kc-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.kc .kc-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Knopf unten rechts, im Nachtblau des App-Symbols */
.kc-launcher {
  position: fixed; z-index: 90;
  right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  display: inline-flex; align-items: center; gap: 0.5em;
  padding: 11px 18px 11px 14px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.14);
  background: var(--wall-1); color: #f2f4fa;
  font: inherit; font-size: 15px; font-weight: 700; line-height: 1.2;
  cursor: pointer; box-shadow: 0 10px 30px rgba(10, 14, 40, 0.28);
  transition: background 0.18s, transform 0.18s;
}
.kc-launcher:hover { background: var(--wall-2); }
.kc-launcher:active { transform: translateY(1px); }
.kc-launcher:focus-visible { outline: 3px solid var(--link); outline-offset: 3px; }
.kc-launcher svg { color: var(--green); }
.kc-open .kc-launcher { display: none; }

/* Fenster */
.kc-panel {
  position: fixed; z-index: 200; right: 16px; bottom: 16px;
  width: min(400px, calc(100vw - 32px)); height: min(640px, calc(100dvh - 32px));
  display: flex; flex-direction: column; overflow: hidden; margin: 0; padding: 0; /* style.css gibt section Innenabstand */
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 24px 60px rgba(10, 14, 40, 0.3);
}
.kc-panel[hidden] { display: none; }

.kc-head { display: flex; align-items: center; gap: 4px; padding: 14px 10px 14px 18px; background: var(--wall-1); color: #f2f4fa; }
.kc-head-text { flex: 1; min-width: 0; }
.kc-title { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }
.kc-sub { margin: 2px 0 0; font-size: 12.5px; color: #c3c9e6; }
.kc-icon { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border: 0; border-radius: 999px; background: transparent; color: #f2f4fa; cursor: pointer; }
.kc-icon:hover { background: rgba(255, 255, 255, 0.12); }
.kc-icon:focus-visible { outline: 2px solid #f2f4fa; outline-offset: 1px; }

/* Verlauf */
.kc-log { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: var(--paper); }
.kc-msg { display: flex; flex-direction: column; gap: 6px; max-width: 88%; }
.kc-user { align-self: flex-end; align-items: flex-end; }
.kc-bot { align-self: flex-start; align-items: flex-start; }
.kc-bubble { padding: 10px 14px; border-radius: 16px; font-size: 15px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.kc-user .kc-bubble { background: var(--wall-1); color: #f2f4fa; border-bottom-right-radius: 6px; }
.kc-bot .kc-bubble { background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 6px; }

.kc-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; }
.kc-links-label { color: var(--muted); }
.kc-link { padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--link); text-decoration: none; line-height: 1.4; }
.kc-link:hover { border-color: var(--link); }
.kc-link:focus-visible { outline: 2px solid var(--link); outline-offset: 1px; }

.kc-handoff { font: inherit; font-size: 13.5px; font-weight: 700; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--ink); background: var(--panel); color: var(--ink); cursor: pointer; }
.kc-handoff:hover { background: var(--ink); color: var(--panel); }
.kc-handoff:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

.kc-typing .kc-bubble { display: inline-flex; align-items: center; gap: 5px; padding: 14px 16px; }
.kc-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: kc-blink 1.2s infinite ease-in-out; }
.kc-dot:nth-child(3) { animation-delay: 0.15s; }
.kc-dot:nth-child(4) { animation-delay: 0.3s; }
@keyframes kc-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* Hinweis, Eingabe (keine vorgegebenen Fragen) */
.kc-left { margin: 0; font-size: 12px; color: var(--muted); padding: 8px 16px 0; background: var(--panel); }
.kc-left:empty { display: none; }

.kc-form { display: flex; align-items: flex-end; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: var(--panel); }
/* Eingabe: zwei Zeilen hoch, wächst beim Schreiben (chat.js, bis 176 px), Zähler unten rechts */
.kc-input-wrap { position: relative; flex: 1; min-width: 0; display: flex; }
.kc-form textarea {
  flex: 1; min-width: 0; resize: none; overflow-y: hidden; scrollbar-width: thin;
  min-height: calc(2 * 1.45em + 28px); max-height: 176px;
  font: inherit; font-size: 15px; line-height: 1.45; padding: 11px 12px 15px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink);
}
.kc-form textarea::placeholder { color: var(--muted); opacity: 1; }
.kc-form textarea:focus { outline: 2px solid var(--link); outline-offset: 0; border-color: var(--link); background: var(--panel); }
.kc-count { position: absolute; right: 8px; bottom: 3px; padding: 1px 4px; border-radius: 6px; background: var(--paper); font-size: 11px; line-height: 1; color: var(--muted); pointer-events: none; }
.kc-input-wrap:focus-within .kc-count { background: var(--panel); }
.kc-count:empty { display: none; }
.kc-count-max { color: var(--red); font-weight: 700; }
.kc-send { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border: 0; border-radius: 999px; background: var(--wall-1); color: #f2f4fa; cursor: pointer; transition: background 0.18s; }
.kc-send:hover { background: var(--wall-2); }
.kc-send:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.kc-send:disabled { opacity: 0.45; cursor: wait; }

.kc-note { margin: 0; font-size: 11.5px; line-height: 1.45; color: var(--muted); padding: 0 14px 12px; background: var(--panel); }
.kc-note a { color: inherit; text-underline-offset: 2px; }

/* Weiterleitung an Konrad Sigl */
.kc-hand { align-self: stretch; display: grid; gap: 10px; padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.kc-hand label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 4px; }
.kc-hand input, .kc-hand textarea {
  width: 100%; font: inherit; font-size: 15px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink);
}
.kc-hand textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
.kc-hand input:focus, .kc-hand textarea:focus { outline: 2px solid var(--link); outline-offset: 0; border-color: var(--link); background: var(--panel); }
.kc-hand-note { margin: 0; font-size: 12px; line-height: 1.45; color: var(--muted); }
.kc-hand-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.kc-btn { font: inherit; font-size: 14px; font-weight: 700; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; }
.kc-btn:hover { border-color: var(--ink); }
.kc-btn-primary { background: var(--wall-1); border-color: var(--wall-1); color: #f2f4fa; }
.kc-btn-primary:hover { background: var(--wall-2); border-color: var(--wall-2); }
.kc-btn:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.kc-btn:disabled { opacity: 0.5; cursor: wait; }
.kc-hand-status { margin: 0; font-size: 13px; min-height: 1.2em; }
.kc-hand-status:empty { display: none; }
.kc-hand-status.err { color: var(--red); }

/* Dunkel: Kopf und eigene Fragen etwas heller als der Seitenhintergrund */
:root[data-theme="dark"] .kc-head, :root[data-theme="dark"] .kc-user .kc-bubble,
:root[data-theme="dark"] .kc-send, :root[data-theme="dark"] .kc-btn-primary, :root[data-theme="dark"] .kc-launcher { background: var(--wall-2); border-color: transparent; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .kc-head, :root:not([data-theme="light"]) .kc-user .kc-bubble,
  :root:not([data-theme="light"]) .kc-send, :root:not([data-theme="light"]) .kc-btn-primary,
  :root:not([data-theme="light"]) .kc-launcher { background: var(--wall-2); border-color: transparent; }
}

/* Handy: Fenster über die ganze Fläche */
@media (max-width: 560px) {
  .kc-panel { right: 0; bottom: 0; width: 100%; height: 100%; height: 100dvh; border: 0; border-radius: 0; }
  .kc-head { padding-top: max(14px, env(safe-area-inset-top)); }
  .kc-note { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .kc-form textarea, .kc-hand input, .kc-hand textarea { font-size: 16px; } /* verhindert Zoom auf iOS */
}

@media (prefers-reduced-motion: reduce) {
  .kc-dot { animation: none; opacity: 0.6; }
  .kc-launcher, .kc-send { transition: none; }
}

@media print { .kc { display: none !important; } }
@media (forced-colors: active) { .kc-launcher, .kc-send, .kc-bubble, .kc-panel { border: 1px solid CanvasText; } }
