/* ============================================================
   DAWNFALL - the Kara chat widget, on the design system

   public/scripts/chat-widget.js builds this markup on every page of
   the site for a signed-in visitor. Tokens only, as components.css.
   ============================================================ */

/* Its place on the window and the bubble's look are shared with the partner space's pill
   (components.css, kara-fab); what is the widget's own is here. */
#chat-widget {
  z-index: var(--z-chat);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--sp-3);
}

/* ── The button that opens the panel ───────────────────────── */

.chat-fab {
  width: var(--control-h-lg);
  display: grid;
  place-items: center;
  border-radius: var(--r-round);
}
.chat-fab svg   { width: var(--icon-lg); height: var(--icon-lg); }

/* ── The panel ─────────────────────────────────────────────── */

.chat-panel {
  width: var(--chat-w);
  max-width: calc(var(--viewport-w) - var(--sp-6));
  max-height: var(--chat-h);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--c-surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-menu);
}

.chat-head {
  padding: var(--sp-3) var(--sp-4);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--g-accent) border-box;
  color: var(--c-on-accent);
  font-size: var(--fs-small);
  font-weight: var(--fw-strong);
}
.chat-head-title { display: flex; align-items: center; gap: var(--sp-2); }
/* The online dot, ringed in the header's ink so it never melts into the gradient behind it. */
.chat-head-dot {
  width: var(--chat-dot);
  height: var(--chat-dot);
  background-color: var(--c-online);
  border-radius: var(--r-round);
  box-shadow: 0 0 0 var(--bw-hair) var(--c-on-accent);
}
.chat-close-btn {
  padding: var(--sp-1) var(--sp-2);
  background: none;
  border: none;
  border-radius: var(--r-pill);
  color: inherit;
  line-height: var(--lh-control);
  cursor: pointer;
  transition: background-color var(--dur-fast);
}
.chat-close-btn:hover { background-color: var(--c-wash); }

/* ── Messages ──────────────────────────────────────────────── */

/* The thread, its bubbles and the typing indicator (.chat-messages, .chat-msg, .chat-typing) are
   components.css's, section 9: the partner space's Kara panel draws its thread with the same rules. */

/* The one link the widget ever builds: the same-site path Kara answers with. */
.chat-link { color: var(--c-accent-ink); text-decoration: underline; font-weight: var(--fw-strong); }

/* While the admin switch keeps Kara off: her message, and the button to the support page. */
.chat-dev-notice { padding: var(--sp-3); display: grid; justify-items: start; gap: var(--sp-3); }

/* ── Input row ─────────────────────────────────────────────── */

.chat-input-row {
  padding: var(--sp-3);
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: var(--sp-2);
  border-top: var(--bw-hair) solid var(--c-line);
}
.chat-input {
  max-height: var(--chat-input-h);
  padding: var(--sp-2) var(--sp-3);
  flex: 1;
  overflow-y: auto;
  resize: none;
  background-color: var(--c-field);
  border: var(--bw-hair) solid var(--c-line-strong);
  border-radius: var(--r-md);
  font-size: var(--fs-small);
}
/* Focused, it wears the system's ring (components.css, section 1). */
.chat-send-btn {
  width: var(--control-h-sm);
  height: var(--control-h-sm);
  flex: none;
  display: grid;
  place-items: center;
  background: var(--g-accent) border-box;
  color: var(--c-on-accent);
  border: none;
  border-radius: var(--r-round);
  cursor: pointer;
}
.chat-send-btn:disabled { opacity: var(--a-faint); cursor: default; }
.chat-send-btn svg      { width: var(--icon); height: var(--icon); }

/* ── Phones ────────────────────────────────────────────────── */

@media (max-width: 25rem) {
  .chat-panel  { width: calc(var(--viewport-w) - var(--sp-6)); }
}
