/* ============================================================================
   Floating action stack (WhatsApp + chat launcher) and the chat qualifier.

   Loaded site-wide from base.html, after styles.css and authority.css — the
   panel uses the authority tokens so the chat and the About page speak one
   visual language. Nothing here leaks outside the .fab* / .cq* prefixes.

   Placement note: the NagishLi accessibility widget is pinned bottom-LEFT
   (`nl_pos = "bl"`), so everything here lives bottom-RIGHT — in RTL too.
   ========================================================================== */

/* A class selector beats the UA's `[hidden]{display:none}`, so anything here
   that sets `display` has to opt back out explicitly — otherwise the element
   is on screen from page load and its open() handler never runs.
   styles.css:1040 does the same for the lead modal. */
.cq[hidden],.fab[hidden],.fabstack[hidden]{display:none}

/* ---------- Floating stack ---------- */

.fabstack{
  position:fixed;
  right:18px;
  bottom:18px;
  z-index:900;                 /* under the lead modal (which is 1000+) */
  display:flex;
  flex-direction:column-reverse;  /* first child sits lowest */
  align-items:flex-end;
  gap:12px;
}

.fab{
  display:inline-flex;
  align-items:center;
  gap:9px;
  height:54px;
  padding:0 18px 0 16px;
  border:0;
  border-radius:999px;
  font:inherit;
  font-size:15.5px;
  font-weight:600;
  color:#fff;
  text-decoration:none;
  cursor:pointer;
  box-shadow:var(--shadow-lg);
  transition:transform .16s ease, box-shadow .16s ease;
}
.fab:hover{transform:translateY(-2px)}
.fab:focus-visible{outline:3px solid var(--blue);outline-offset:3px}
.fab svg{width:24px;height:24px;fill:currentColor;flex:none}

.fab--wa{background:#25D366}
.fab--chat{background:var(--blue);position:relative}

/* The label is a nicety on desktop; on a phone the icon alone keeps the
   thumb-zone clear. */
@media(max-width:640px){
  .fabstack{right:12px;bottom:12px;gap:10px}
  .fab{height:50px;padding:0;width:50px;justify-content:center}
  .fab__label{display:none}
}

/* One-line teaser bubble that pops out of the launcher on first visit. */
.fabtease{
  max-width:250px;
  background:#fff;
  color:var(--auth-ink);
  border:1px solid var(--auth-line);
  border-radius:14px;
  box-shadow:var(--auth-shadow-card);
  padding:12px 14px;
  font-size:14.5px;
  line-height:1.55;
  cursor:pointer;
  text-align:start;
  animation:cq-pop .22s ease both;
}
.fabtease__x{
  float:inline-end;margin-inline-start:8px;
  border:0;background:none;font-size:17px;line-height:1;
  color:var(--auth-muted);cursor:pointer;padding:0;
}

/* ============================================================================
   PANEL SHELL

   Laid out like the Intercom Messenger brandpush.co runs: a gradient home
   screen with a greeting, rows that overlap its lower edge, a searchable help
   list, and a bottom tab bar. Behind it is our own qualifier, not a support
   inbox — see templates/partials/_chat_widget.html.
   ========================================================================== */

.cq{
  position:fixed;
  right:18px;
  bottom:18px;
  z-index:950;
  width:min(400px, calc(100vw - 24px));
  height:min(688px, calc(100vh - 36px));
  display:flex;
  flex-direction:column;
  background:var(--auth-surface);
  border-radius:var(--auth-r-2xl);
  box-shadow:0 5px 40px rgba(0,0,0,.16);
  overflow:hidden;
  font-size:var(--auth-base);
  animation:cq-pop .22s var(--auth-ease) both;
}
@media(max-width:640px){
  .cq{right:0;bottom:0;width:100vw;height:100dvh;border-radius:0}
}
@keyframes cq-pop{from{opacity:0;transform:translateY(12px) scale(.985)}to{opacity:1;transform:none}}

/* ---------- Home screen ---------- */

.cq__home{
  flex:1;min-height:0;overflow-y:auto;
  display:flex;flex-direction:column;
  background:var(--auth-band);
}
.cq__home[hidden],.cq__conv[hidden]{display:none}

/* The gradient plate. The greeting sits low in it and the rows below overlap
   its bottom edge — that overlap is what gives the messenger its depth. */
.cq__hero{
  position:relative;flex:none;
  padding:1.5rem 1.5rem 3.25rem;
  background:linear-gradient(135deg,#0050C9 0%,#2C6BE0 45%,#5B8DF0 100%);
  color:#fff;
}
.cq__herologo{
  display:block;height:26px;width:auto;margin-bottom:2.25rem;
  filter:brightness(0) invert(1);opacity:.95;
}
.cq__greet{
  margin:0;font-size:1.5rem;font-weight:700;line-height:1.3;
  color:rgba(255,255,255,.6);
}
.cq__greet--big{color:#fff;margin-top:.15rem}
.cq__x--onhero{position:absolute;top:.7rem;inset-inline-end:.7rem;color:rgba(255,255,255,.85)}
.cq__x--onhero:hover{background:rgba(255,255,255,.16);color:#fff}

.cq__homebody{
  flex:1;display:flex;flex-direction:column;gap:.75rem;
  padding:0 .875rem 1rem;margin-top:-2.25rem;
}

.cq__row{
  display:flex;align-items:center;gap:.75rem;width:100%;text-align:start;
  background:var(--auth-surface);border:0;border-radius:var(--auth-r-xl);
  box-shadow:var(--auth-shadow-card);
  padding:1rem 1.125rem;font:inherit;cursor:pointer;text-decoration:none;
  transition:box-shadow .16s ease,transform .16s ease;
}
.cq__row:hover{box-shadow:var(--auth-shadow-mid);transform:translateY(-1px)}
.cq__row span{flex:1;min-width:0}
.cq__row b{
  display:block;font-size:var(--auth-sm);font-weight:var(--auth-w-semibold);
  color:var(--auth-ink);line-height:1.4;
}
.cq__row i{
  display:block;margin-top:.2rem;font-style:normal;
  font-size:var(--auth-xs);color:var(--auth-muted);line-height:1.45;
}
.cq__rowarrow{width:18px;height:18px;flex:none;fill:var(--blue)}
.cq__rowext{width:15px;height:15px;flex:none;fill:var(--auth-muted)}
[dir="rtl"] .cq__rowarrow{transform:scaleX(-1)}

.cq__card{
  background:var(--auth-surface);border-radius:var(--auth-r-xl);
  box-shadow:var(--auth-shadow-card);overflow:hidden;
}

.cq__search{
  display:flex;align-items:center;gap:.6rem;
  padding:.85rem 1.125rem;border-bottom:1px solid var(--auth-line-soft);
}
.cq__search input{
  flex:1;min-width:0;border:0;outline:none;background:none;font:inherit;
  font-size:var(--auth-sm);font-weight:var(--auth-w-semibold);color:var(--auth-ink);
}
.cq__search input::placeholder{color:var(--auth-muted);font-weight:500}
.cq__search input::-webkit-search-cancel-button{-webkit-appearance:none}
.cq__search svg{width:17px;height:17px;fill:var(--auth-muted);flex:none}

.cq__help{list-style:none;margin:0;padding:0}
.cq__help li{border-bottom:1px solid var(--auth-line-soft)}
.cq__help li:last-child{border-bottom:0}
.cq__help li[hidden]{display:none}
.cq__help a{
  display:flex;align-items:center;justify-content:space-between;gap:.75rem;
  padding:.85rem 1.125rem;text-decoration:none;
  font-size:var(--auth-sm);color:var(--auth-ink);line-height:1.45;
}
/* A chevron drawn from two borders — no icon file for five list rows. */
.cq__help a::after{
  content:"";flex:none;width:7px;height:7px;
  border-top:2px solid var(--auth-muted);border-inline-end:2px solid var(--auth-muted);
  transform:rotate(45deg);
}
[dir="rtl"] .cq__help a::after{transform:rotate(-135deg)}
.cq__help a:hover{background:var(--auth-band)}
.cq__noresult{margin:0;padding:.85rem 1.125rem;font-size:var(--auth-sm);color:var(--auth-muted)}

/* ---------- Tab bar ---------- */

.cq__tabs{
  flex:none;display:grid;grid-template-columns:repeat(3,1fr);
  background:var(--auth-surface);border-top:1px solid var(--auth-line-soft);
  padding-bottom:env(safe-area-inset-bottom,0);
}
.cq__tab{
  display:flex;flex-direction:column;align-items:center;gap:.2rem;
  padding:.6rem .25rem .55rem;border:0;background:none;cursor:pointer;
  font:inherit;font-size:.6875rem;font-weight:var(--auth-w-semibold);
  color:var(--auth-muted);text-decoration:none;
}
.cq__tab svg{width:20px;height:20px;fill:currentColor}
.cq__tab:hover{color:var(--auth-ink)}
.cq__tab.is-active,.cq__tab.is-active:hover{color:var(--blue)}

/* ---------- Conversation view ---------- */

.cq__conv{flex:1;min-height:0;display:flex;flex-direction:column}

.cq__head{
  display:flex;align-items:center;gap:.6rem;
  padding:.85rem 1rem;
  border-bottom:1px solid var(--auth-line-soft);
  background:var(--auth-surface);
  flex:none;
}
.cq__back{
  border:0;background:none;cursor:pointer;padding:2px;flex:none;
  color:var(--auth-muted);display:grid;place-items:center;
}
.cq__back svg{width:20px;height:20px;fill:currentColor}
[dir="rtl"] .cq__back svg{transform:scaleX(-1)}
.cq__back:hover{color:var(--auth-ink)}
.cq__avatar{
  width:28px;height:28px;border-radius:var(--auth-r-pill);flex:none;
  background:var(--blue);color:#fff;
  display:grid;place-items:center;font-weight:700;font-size:13px;
}
.cq__who{flex:1;min-width:0;display:flex;align-items:center;gap:.45rem}
.cq__who b{font-size:var(--auth-base);font-weight:var(--auth-w-semibold);color:var(--auth-ink);line-height:1.2}
.cq__who span{font-size:var(--auth-xs);color:var(--auth-muted)}
/* A live dot beats the word "online" for the same reassurance. */
.cq__live{
  width:7px;height:7px;border-radius:50%;background:#22C55E;flex:none;
  box-shadow:0 0 0 3px rgba(34,197,94,.16);
}
.cq__x{
  border:0;background:none;color:var(--auth-muted);cursor:pointer;
  font-size:22px;line-height:1;padding:2px 6px;border-radius:var(--auth-r-md);
}
.cq__x:hover{background:var(--auth-chip);color:var(--auth-ink)}

.cq__bar{height:2px;background:var(--auth-line-soft);flex:none}
.cq__bar i{
  display:block;height:100%;width:0;background:var(--blue);
  transition:width .45s var(--auth-ease);
}

/* ---------- Transcript ---------- */

.cq__log{
  flex:1;overflow-y:auto;overscroll-behavior:contain;
  padding:1.25rem 1.25rem .5rem;
  background:var(--auth-surface);
  display:flex;flex-direction:column;gap:1rem;
}

/* The visitor's own line: grey pill, one corner squared off toward them. */
.cq__msg--user{
  align-self:flex-end;max-width:92%;
  padding:.7rem .9rem;
  border-radius:var(--auth-r-2xl) var(--auth-r-2xl) var(--auth-r-lg) var(--auth-r-2xl);
  background:var(--auth-chip);
  color:var(--auth-ink);
  font-size:var(--auth-sm);
  line-height:var(--auth-lead-normal);
}

/* The assistant answers as prose, not as a bubble. */
.cq__msg--bot{
  align-self:flex-start;max-width:100%;
  color:var(--auth-ink);
  font-size:var(--auth-base);
  line-height:var(--auth-lead-relaxed);
  white-space:pre-wrap;
}

/* A sourced answer. Prose, not a bubble — a finding reads as a finding.
   The reserved height keeps the card from growing as the text types in. */
.cq__msg--fact{
  align-self:flex-start;max-width:100%;
  padding:0;
  color:var(--auth-ink);
  font-size:var(--auth-base);
  line-height:var(--auth-lead-relaxed);
  white-space:pre-wrap;
  min-height:4.5rem;
}
/* The name being talked about, lifted out of the sentence. */
.cq__brand{color:#0587ED;font-weight:600}

/* "Checked N sources" — the line that makes an answer read as researched. */
.cq__checked{
  align-self:flex-start;
  margin:-.6rem 0 -.3rem;
  font-size:.6875rem;line-height:1.2;letter-spacing:.01em;
  color:var(--auth-muted);
}

/* ---------- Character-by-character typing ---------- */
/* Every character is its own span with a staggered fade; words are kept
   unbreakable so a line never reflows mid-animation. */
.cq__ch{display:inline;opacity:0;animation:cq-ch-in .08s ease forwards}
.cq__w{display:inline;white-space:nowrap}
@keyframes cq-ch-in{to{opacity:1}}

.cq__typing{align-self:flex-start;display:flex;gap:4px;padding:.35rem 0}
.cq__typing i{
  width:6px;height:6px;border-radius:50%;background:var(--auth-muted);
  animation:cq-blink 1.1s infinite ease-in-out;
}
.cq__typing i:nth-child(2){animation-delay:.16s}
.cq__typing i:nth-child(3){animation-delay:.32s}
@keyframes cq-blink{0%,80%,100%{opacity:.25}40%{opacity:1}}

/* ---------- Source chips ---------- */

.cq__sources{margin-top:.15rem}
.cq__sources-label{
  display:block;margin-bottom:.5rem;
  font-size:var(--auth-xs);font-weight:var(--auth-w-semibold);letter-spacing:var(--auth-track-caps);
  text-transform:uppercase;color:var(--auth-muted);
}
.cq__chips{display:flex;flex-wrap:wrap;gap:.4rem}
.cq__chip{
  display:inline-flex;align-items:center;gap:.35rem;
  padding:.35rem .65rem;
  border:1px solid var(--auth-line);
  border-radius:var(--auth-r-pill);
  background:var(--auth-surface);
  color:var(--auth-ink);
  font-size:var(--auth-xs);font-weight:var(--auth-w-semibold);line-height:1.2;white-space:nowrap;
  opacity:0;transform:translateY(4px);
  transition:opacity .28s var(--auth-ease),transform .28s var(--auth-ease);
}
.cq__chip.is-visible{opacity:1;transform:none}
.cq__chip img{width:16px;height:16px;object-fit:contain;flex:none}

/* ---------- Composer ---------- */

.cq__foot{
  flex:none;border-top:1px solid var(--auth-line-soft);
  background:var(--auth-surface);padding:.9rem 1rem 1rem;
}
.cq__choices{display:flex;flex-wrap:wrap;gap:.5rem}
.cq__choice{
  border:1px solid var(--auth-line);
  background:var(--auth-surface);
  color:var(--auth-ink);
  font:inherit;font-size:var(--auth-sm);font-weight:var(--auth-w-semibold);
  padding:.55rem .9rem;border-radius:var(--auth-r-pill);cursor:pointer;
  transition:border-color .14s ease,color .14s ease;
}
.cq__choice:hover{border-color:var(--blue);color:var(--blue)}
.cq__choice:disabled{opacity:.5;cursor:default}

.cq__inputrow{
  display:flex;gap:.5rem;align-items:center;
  border:1px solid var(--auth-line);border-radius:var(--auth-r-pill);
  padding:.25rem .25rem .25rem .9rem;
}
.cq__inputrow:focus-within{border-color:var(--blue)}
.cq__input{
  flex:1;min-width:0;border:0;background:none;outline:none;
  padding:.55rem 0;font:inherit;font-size:var(--auth-base);color:var(--auth-ink);
}
.cq__input::placeholder{color:var(--auth-muted)}
.cq__input[dir="ltr"]{text-align:left}
.cq__send{
  flex:none;width:36px;height:36px;border:0;border-radius:var(--auth-r-pill);
  background:var(--auth-ink);color:#fff;cursor:pointer;
  display:grid;place-items:center;
}
.cq__send svg{width:17px;height:17px;fill:currentColor}
.cq__send:disabled{opacity:.4;cursor:default}
/* The send arrow points the way the language runs. */
[dir="rtl"] .cq__send svg,[dir="rtl"] .cq-card__send svg{transform:scaleX(-1)}

.cq__err{margin:.6rem .15rem 0;font-size:var(--auth-sm);color:var(--red);line-height:1.5}
.cq__fine{margin:.6rem .15rem 0;font-size:var(--auth-xs);color:var(--auth-muted);line-height:1.5}

.cq__done{display:flex;flex-direction:column;gap:.55rem}
.cq__done a{
  display:flex;align-items:center;justify-content:center;gap:.5rem;
  height:44px;border-radius:var(--auth-r-lg);text-decoration:none;
  font-size:var(--auth-sm);font-weight:var(--auth-w-semibold);
}
.cq__done a svg{width:19px;height:19px;fill:currentColor}
.cq__done .cq__wa{background:#25D366;color:#fff}
.cq__done .cq__app{background:var(--auth-surface);color:var(--auth-ink);border:1px solid var(--auth-line)}

.cq__hp{position:absolute;left:-9999px;width:1px;height:1px;opacity:0}

@media(prefers-reduced-motion:reduce){
  .cq,.fabtease{animation:none}
  .fab{transition:none}
  .cq__typing i{animation:none;opacity:.6}
  .cq__ch{opacity:1;animation:none}
  .cq__chip{opacity:1;transform:none;transition:none}
}
