/* ───────────────────────────────────────────────────────────────
   KinderLink — the website assistant (assets/js/assistant.js)

   Its own sheet, loaded after styles.css, whose tokens it uses and
   whose rules it follows: ink for buttons and text, the logo's wash
   and cream for grounds, hairlines for edges, three weights. The one
   orange thing is the logo's sun, which is the assistant's mark.

   The launcher sits in the corner OPPOSITE the WhatsApp button
   (inline-start), at the same height, and lifts with it above the
   sticky mobile CTA. Logical properties throughout, so the Arabic
   page (dir="rtl") mirrors with no rules of its own.

   Everything here is hidden until the API says the assistant is on:
   the root carries `hidden` in the markup and the script removes it.
   ─────────────────────────────────────────────────────────────── */

.kl-ask[hidden],
.kl-ask [hidden] { display: none !important; }

/* ─── Launcher ────────────────────────────────────────────── */
.kl-ask-open {
  position: fixed; bottom: 18px; inset-inline-start: 18px; z-index: 92;
  display: inline-flex; align-items: center; gap: 9px;
  height: 54px; padding-inline: 14px 20px;
  font: inherit; font-weight: 700; font-size: 15px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--hairline-200); border-radius: 999px;
  box-shadow: 0 4px 14px rgba(27, 15, 46, 0.18);
  cursor: pointer; transition: border-color 0.15s ease;
}
.kl-ask-open:hover { border-color: var(--ink); }
.kl-ask-open img { width: 26px; height: 26px; flex: none; }
.kl-ask.is-open .kl-ask-open { display: none; }
@media (max-width: 719.98px) {
  /* On a phone the hero's "skip the day" link sits in this same corner
     (styles.css moves it to inline-start, 22px up), so during the day the
     launcher rides just above it… */
  .kl-ask-open { bottom: 58px; }
  /* …and once the story is over it sits above the sticky mobile CTA, level
     with the WhatsApp button. */
  html:not(.js) .kl-ask-open,
  html.js body.past-day .kl-ask-open { bottom: 80px; }
}

/* ─── Panel ───────────────────────────────────────────────── */
.kl-ask-panel {
  position: fixed; z-index: 130; inset-inline-start: 18px; bottom: 18px;
  width: min(392px, calc(100vw - 36px));
  height: min(600px, calc(100vh - 36px)); height: min(600px, calc(100dvh - 36px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--ivory); color: var(--ink);
  border: 1px solid var(--hairline-200); border-radius: 20px;
  box-shadow: var(--shadow-lg);
}
@media (max-width: 719.98px) {
  .kl-ask-panel {
    inset-inline: 10px; bottom: 10px; width: auto;
    height: min(640px, calc(100vh - 20px)); height: min(640px, calc(100dvh - 20px));
  }
}

.kl-ask-head {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 12px 10px; padding-inline-start: 16px;
  background: var(--wash); border-bottom: 1px solid var(--hairline);
}
.kl-ask-head img { width: 28px; height: 28px; flex: none; }
/* Her name, and under it what she is. */
.kl-ask-who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.kl-ask-who h2 { font-size: 16px; line-height: 1.3; letter-spacing: 0; }
.kl-ask-who p { font-size: 12.5px; line-height: 1.35; color: var(--ink-soft); }
.kl-ask-icon {
  flex: none; width: 38px; height: 38px; display: grid; place-items: center;
  font: inherit; font-size: 24px; line-height: 1; color: var(--ink);
  background: transparent; border: 0; border-radius: 10px; cursor: pointer;
}
.kl-ask-icon:hover { background: rgba(45, 27, 105, 0.08); }
.kl-ask-icon svg { width: 19px; height: 19px; }

.kl-ask-log {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 10px; padding: 16px;
}
.kl-ask-intro { font-size: 14.5px; color: var(--ink-soft); }

.kl-ask-starters { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.kl-ask-starters button {
  font: inherit; font-size: 14px; font-weight: 600; line-height: 1.45; text-align: start; color: var(--ink);
  background: var(--paper); border: 1px solid var(--hairline-200); border-radius: 12px;
  padding: 9px 13px; cursor: pointer; transition: border-color 0.15s ease;
}
.kl-ask-starters button:hover { border-color: var(--ink); }

/* A message. `white-space: pre-wrap` because the text is shown as written,
   line breaks included; it is never inserted as HTML. */
.kl-ask-msg {
  max-width: 88%; padding: 10px 14px; border-radius: 16px;
  font-size: 14.5px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere;
}
.kl-ask-msg.from-user {
  align-self: flex-end; background: var(--ink); color: var(--ivory);
  border-end-end-radius: 6px;
}
.kl-ask-msg.from-assistant {
  align-self: flex-start; background: var(--paper); border: 1px solid var(--hairline);
  border-end-start-radius: 6px;
}
.kl-ask-msg.from-notice {
  align-self: stretch; max-width: none; background: var(--wash-flat); color: var(--ink-soft);
  font-size: 13.5px;
}
.kl-ask-msg a { color: inherit; font-weight: 600; text-underline-offset: 3px; }
.kl-ask-wait { align-self: flex-start; font-size: 13.5px; color: var(--ink-muted); }

.kl-ask-form {
  flex: none; display: flex; align-items: flex-end; gap: 8px;
  padding: 12px 12px 8px; border-top: 1px solid var(--hairline);
}
/* 16px: below that, iOS Safari zooms the page when the field takes focus. */
.kl-ask-form textarea {
  flex: 1; min-width: 0; resize: none; max-height: 116px;
  font: inherit; font-size: 16px; line-height: 1.5; color: var(--ink);
  background: var(--paper); border: 1px solid var(--hairline-200); border-radius: 12px;
  padding: 9px 12px;
}
.kl-ask-form textarea::placeholder { color: var(--ink-muted); }
.kl-ask-form textarea:focus { outline: 2px solid var(--ink); outline-offset: 1px; }
.kl-ask-form button {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center;
  color: var(--ivory); background: var(--ink); border: 0; border-radius: 12px; cursor: pointer;
  transition: background 0.15s ease;
}
.kl-ask-form button:hover { background: var(--ink-hover); }
.kl-ask-form button:disabled,
.kl-ask-form textarea:disabled { opacity: 0.45; cursor: default; }
.kl-ask-form button svg { width: 20px; height: 20px; }
/* The arrow points the way the text runs. */
html[dir="rtl"] .kl-ask-form button svg { transform: scaleX(-1); }

.kl-ask-fine { flex: none; padding: 0 14px 12px; font-size: 12px; line-height: 1.5; color: var(--ink-muted); }
.kl-ask-fine a { color: var(--ink); }

/* For the field's label: read by a screen reader, not drawn. */
.kl-ask-sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .kl-ask-open, .kl-ask-starters button, .kl-ask-form button { transition: none; }
}
