/* Custom One — "Ask us anything" sales chat (sales-chat.js).
   Looks like the in-app help panel (UniqueQuizzSaas SupportChatView): a soft
   brand-gradient wash, a short headline, plain-text answers. The launcher is
   the app's mascot crew peeking out of a white bubble.
   Self-contained: brand tokens with hard fallbacks, so it renders the same on
   control (styles.css) and /v2/ (its own stylesheet). Sits under the cookie
   banner (z-index 2147483000) so consent always wins. */

.co-chat {
  --chat-ink: var(--c-ink, #0f0f10);
  --chat-surface: var(--surface, #ffffff);
  --chat-bg-2: var(--bg-2, #f2f2ee);
  --chat-line: var(--line, #e8e8e3);
  --chat-line-2: var(--line-2, #d8d8d2);
  --chat-t1: var(--t-1, #0f0f10);
  --chat-t2: var(--t-2, #4a4a4f);
  --chat-t3: var(--t-3, #8a8a90);
  --chat-blue: var(--c-blue, #5490ff);
  --chat-blue-tint: var(--p-blue, #e8efff);
  --chat-grad: linear-gradient(95deg, #ff5454 0%, #ffb800 30%, #5490ff 60%, #ee54ff 100%);

  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147482000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: var(--font, "Rethink Sans", "Inter", system-ui, -apple-system, sans-serif);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--chat-t1);
}

.co-chat *, .co-chat *::before, .co-chat *::after { box-sizing: border-box; }
.co-chat [hidden] { display: none !important; }

/* ── The crew (the app's mascot) ──────────────────────────────────────
   Drawn at the app's own size on a 392×233 stage, then scaled with --s.
   --nx / --ny (-1…1) come from the pointer, set by sales-chat.js. */
.co-crew {
  --s: 0.4;
  --nx: 0;
  --ny: 0;
  position: relative;
  width: calc(392px * var(--s));
  height: calc(233px * var(--s));
  flex: none;
  pointer-events: none;
}
.co-crew-stage {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 392px;
  height: 233px;
  transform: scale(var(--s));
  transform-origin: 0 100%;
}
.co-crew-char {
  position: absolute;
  bottom: 0;
  transform-origin: 50% 100%;
  animation: co-crew-breathe var(--breath, 5s) ease-in-out infinite;
  animation-delay: var(--phase, 0s);
}
.co-crew-body {
  position: absolute;
  inset: 0;
  background: var(--color);
  border-radius: var(--radius);
}
.co-crew-face {
  position: absolute;
  inset-inline: 0;
  top: var(--face-top);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--face-gap);
  transform: translate(calc(var(--nx) * var(--drift-x)), calc(var(--ny) * var(--drift-y)));
  transition: transform 120ms linear;
}
.co-crew-eyes { display: flex; gap: var(--eye-gap); }
.co-crew-eye {
  position: relative;
  width: var(--eye);
  height: var(--eye);
  border-radius: 50%;
  transition: transform 110ms ease;
}
.co-crew-pupil {
  position: absolute;
  inset: var(--pupil-inset, 0);
  border-radius: 50%;
  background: #1a1a1d;
  transform: translate(calc(var(--nx) * var(--pupil)), calc(var(--ny) * var(--pupil) * 0.7));
  transition: transform 120ms linear;
}
.co-crew-mouth {
  display: block;
  width: var(--mouth);
  height: var(--stroke);
  border-radius: 999px;
  background: #1a1a1d;
}
.co-crew-char.is-blinking .co-crew-eye { transform: scaleY(0.08); }

/* Coral — big, round, springy. Bare dot eyes and a smile. */
.co-crew-char--coral {
  --color: #ff5454;
  --radius: 50% 50% 8px 8px / 55% 55% 8px 8px;
  --face-top: 26px; --face-gap: 13px;
  --eye: 14px; --eye-gap: 34px; --pupil: 2px;
  --mouth: 9px; --stroke: 4px;
  --drift-x: 22px; --drift-y: 13px;
  --breath: 5.2s; --phase: -3.4s;
  left: 0; width: 190px; height: 145px; z-index: 4;
}
.co-crew-char--coral .co-crew-mouth,
.co-crew-char--blue .co-crew-mouth {
  height: calc(var(--mouth) * 0.42);
  border: var(--stroke) solid #1a1a1d;
  border-top: 0;
  border-radius: 0 0 999px 999px;
  background: transparent;
}
/* Blue — tall and eager. Small white eyes. */
.co-crew-char--blue {
  --color: #5490ff;
  --radius: 22px 22px 6px 6px;
  --face-top: 26px; --face-gap: 12px;
  --eye: 14px; --eye-gap: 26px; --pupil: 2px; --pupil-inset: 22%;
  --mouth: 13px; --stroke: 5.5px;
  --drift-x: 30px; --drift-y: 3px;
  --breath: 4.6s; --phase: -0.4s;
  left: 88px; width: 108px; height: 233px; z-index: 2;
}
/* Magenta — small, wide-eyed, no mouth. */
.co-crew-char--magenta {
  --color: #ee54ff;
  --radius: 38px 38px 6px 6px;
  --face-top: 28px; --face-gap: 0px;
  --eye: 21px; --eye-gap: 7px; --pupil: 3px; --pupil-inset: 26%;
  --drift-x: 16px; --drift-y: 9px;
  --breath: 6.4s; --phase: -2.1s;
  left: 200px; width: 76px; height: 219px; z-index: 1;
}
.co-crew-char--magenta .co-crew-mouth { display: none; }
.co-crew-char--blue .co-crew-eye,
.co-crew-char--magenta .co-crew-eye { background: #fff; }
/* Amber — deadpan. Tiny dot eyes over one long line. */
.co-crew-char--amber {
  --color: #ffb800;
  --radius: 59px 59px 8px 8px;
  --face-top: 22px; --face-gap: 11px;
  --eye: 5.5px; --eye-gap: 16px; --pupil: 1px;
  --mouth: 48px; --stroke: 2.5px;
  --drift-x: 24px; --drift-y: 8px;
  --breath: 7.8s; --phase: -5.3s;
  left: 274px; width: 118px; height: 163px; z-index: 3;
}
.co-crew-char--amber .co-crew-mouth { transform: rotate(calc(var(--nx) * 7deg)); }

@keyframes co-crew-breathe {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(1.025); }
}

/* ── Launcher: the crew peeking out of a white card, with the words ── */
.co-chat-launcher {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 12px;
  height: 64px;
  padding: 0 20px 0 10px;
  border: 1px solid var(--chat-line);
  border-radius: 22px;
  background:
    linear-gradient(180deg, #fff 0%, rgba(255, 255, 255, 0.6) 100%),
    linear-gradient(110deg, rgba(255, 84, 84, 0.22) 0%, rgba(255, 183, 0, 0.18) 35%, rgba(84, 144, 255, 0.24) 70%, rgba(238, 84, 255, 0.2) 100%);
  box-shadow: 0 10px 28px rgba(15, 15, 16, 0.14);
  color: var(--chat-t1);
  font: inherit;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 0.18s ease;
}
.co-chat-launcher-crew { display: flex; align-items: flex-end; }
.co-crew--launcher { --s: 0.2; transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
.co-chat-launcher-text {
  align-self: center;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.co-chat-launcher:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(15, 15, 16, 0.18); }
.co-chat-launcher:hover .co-crew--launcher { transform: translateY(-3px); }
.co-chat-launcher:focus-visible { outline: 3px solid var(--chat-blue); outline-offset: 3px; }
.co-chat--open .co-chat-launcher { padding: 0 10px; }
.co-chat--open .co-chat-launcher-text { display: none; }

/* ── Teaser: "Got a question? We're here." ─────────────────────────────
   Springs out of the launcher with an overshoot, then gives two small
   nudges; the wave waves. The crew in the launcher hops at the same time. */
.co-chat-teaser {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-right: 6px;
  padding: 6px 6px 6px 16px;
  background: var(--chat-surface);
  border: 1px solid var(--chat-line);
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 14px 34px rgba(15, 15, 16, 0.16), 0 0 0 4px rgba(84, 144, 255, 0.08);
  transform-origin: 90% 100%;
  animation:
    co-chat-teaser-in 0.6s cubic-bezier(0.18, 1.5, 0.4, 1) both,
    co-chat-teaser-nudge 0.5s ease-in-out 1.5s 2;
}
@keyframes co-chat-teaser-in {
  0% { transform: translateY(18px) scale(0.3); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: none; opacity: 1; }
}
@keyframes co-chat-teaser-nudge {
  0%, 100% { transform: none; }
  30% { transform: rotate(-2.5deg) scale(1.03); }
  65% { transform: rotate(2deg) scale(1.03); }
}
.co-chat-teaser-wave {
  display: inline-block;
  margin-right: 6px;
  transform-origin: 70% 80%;
  animation: co-chat-wave 1.2s ease-in-out 0.4s 2;
}
@keyframes co-chat-wave {
  0%, 60%, 100% { transform: rotate(0); }
  10%, 30% { transform: rotate(16deg); }
  20%, 40% { transform: rotate(-8deg); }
}
.co-chat-launcher.is-calling .co-crew--launcher { animation: co-crew-hop 0.65s ease-in-out 2; }
@keyframes co-crew-hop {
  0%, 100% { transform: translateY(0); }
  35% { transform: translateY(-7px); }
  60% { transform: translateY(1px); }
}
.co-chat-teaser-text {
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--chat-t1);
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}
.co-chat-teaser-close {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--chat-t3);
  cursor: pointer;
}
.co-chat-teaser-close svg { width: 14px; height: 14px; }
.co-chat-teaser-close:hover { background: var(--chat-bg-2); color: var(--chat-t1); }
.co-chat-teaser-text:focus-visible,
.co-chat-teaser-close:focus-visible { outline: 2px solid var(--chat-blue); outline-offset: 2px; border-radius: 8px; }

@keyframes co-chat-pop {
  from { transform: translateY(8px) scale(0.96); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ── Panel ─────────────────────────────────────────────────────────── */
.co-chat-panel {
  position: relative;
  width: 400px;
  height: min(640px, calc(100vh - 124px));
  display: flex;
  flex-direction: column;
  background-color: var(--chat-surface);
  /* Empty state only: the app's softened signature gradient washing the
     top and fading into white. Plain white once the chat has started. */
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.78) 62%, #fff 100%),
    linear-gradient(110deg, rgba(255, 84, 84, 0.22) 0%, rgba(255, 183, 0, 0.18) 35%, rgba(84, 144, 255, 0.24) 70%, rgba(238, 84, 255, 0.2) 100%);
  background-repeat: no-repeat;
  background-size: 100% 340px, 100% 340px;
  border: 1px solid var(--chat-line);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(15, 15, 16, 0.18);
  overflow: hidden;
  animation: co-chat-pop 0.24s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.co-chat-panel--started { background-image: none; }

.co-chat-header {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
  padding: 10px 10px 0;
  flex: none;
}
.co-chat-close {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--chat-t2);
  cursor: pointer;
}
.co-chat-close:hover { background: rgba(15, 15, 16, 0.06); }
.co-chat-panel:not(.co-chat-panel--started) .co-chat-new { display: none; }
.co-chat-close:focus-visible { outline: 2px solid var(--chat-blue); outline-offset: 1px; }

.co-chat-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 36px 24px;
  text-align: center;
}
.co-crew--hero { --s: 0.36; margin-bottom: 8px; }
.co-chat-title {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--chat-t1);
}
.co-chat-title-grad {
  background: var(--chat-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}
.co-chat-subtitle { font-size: 13.5px; color: var(--chat-t2); }

/* ── Thread ────────────────────────────────────────────────────────── */
.co-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 4px 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overscroll-behavior: contain;
}
.co-chat-panel:not(.co-chat-panel--started) .co-chat-messages { display: none; }

.co-chat-msg { display: flex; flex-direction: column; }
.co-chat-msg--user { align-self: flex-end; align-items: flex-end; max-width: 85%; }
.co-chat-msg--assistant { align-self: stretch; align-items: flex-start; }

.co-chat-bubble { overflow-wrap: anywhere; }
/* The visitor speaks in a tinted bubble; the answer is plain text. */
.co-chat-msg--user .co-chat-bubble {
  padding: 9px 14px;
  border-radius: 16px 16px 6px 16px;
  background: var(--chat-blue-tint);
}
.co-chat-bubble p { margin: 0; }
.co-chat-bubble p + p, .co-chat-bubble p + ul, .co-chat-bubble ul + p { margin-top: 8px; }
.co-chat-bubble ul { margin: 6px 0 0; padding-left: 18px; }
.co-chat-bubble li + li { margin-top: 3px; }
.co-chat-bubble a { color: #2f6be6; text-decoration: underline; text-underline-offset: 2px; }
.co-chat-bubble strong { font-weight: 650; }

.co-chat-typing { display: inline-flex; gap: 4px; padding: 8px 0; }
.co-chat-typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--chat-t3);
  animation: co-chat-dot 1.1s ease-in-out infinite;
}
.co-chat-typing i:nth-child(2) { animation-delay: 0.15s; }
.co-chat-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes co-chat-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.co-chat-actions { margin-top: 10px; }
.co-chat-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--chat-ink);
  color: #fff !important;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none !important;
  cursor: pointer;
  white-space: nowrap;
}
.co-chat-cta:hover { background: #26262a; }
.co-chat-cta:focus-visible { outline: 3px solid var(--chat-blue); outline-offset: 2px; }

.co-chat-email-form { display: flex; flex-wrap: wrap; gap: 8px; }
.co-chat-email {
  flex: 1 1 170px;
  min-width: 0;
  height: 38px;
  padding: 0 14px;
  border: 1.5px solid var(--chat-line-2);
  border-radius: 999px;
  background: var(--chat-surface);
  color: var(--chat-t1);
  font: inherit;
}
.co-chat-email:focus { outline: none; border-color: var(--chat-blue); }
.co-chat-note { margin: 0; color: #167a4a; font-weight: 600; }
.co-chat-error { margin: 4px 0 0; color: #c0392b; font-size: 13.5px; flex-basis: 100%; }

/* ── Composer ──────────────────────────────────────────────────────── */
.co-chat-composer { flex: none; padding: 8px 14px 10px; }
.co-chat-form {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 7px 7px 14px;
  background: var(--chat-surface);
  border: 1.5px solid var(--chat-line-2);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(15, 15, 17, 0.05);
  transition: border-color 0.15s ease;
}
.co-chat-form:focus-within { border-color: var(--chat-blue); }
.co-chat-input {
  flex: 1;
  min-height: 22px;
  max-height: 120px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--chat-t1);
  font: inherit;
  /* 16px keeps iOS Safari from zooming the page on focus. */
  font-size: 16px;
  line-height: 1.4;
  resize: none;
  outline: none;
  overflow-y: hidden;
}
.co-chat-send {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--chat-blue);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.co-chat-send svg { width: 16px; height: 16px; }
.co-chat-send:disabled { background: var(--chat-bg-2); color: var(--chat-t3); cursor: default; }
.co-chat-send:focus-visible { outline: 3px solid var(--chat-blue); outline-offset: 2px; }

.co-chat-disclaimer {
  margin-top: 7px;
  text-align: center;
  color: var(--chat-t3);
  font-size: 11.5px;
}

/* ── Phones: the panel takes the screen ────────────────────────────── */
@media (max-width: 520px) {
  .co-chat { right: 14px; bottom: 14px; }
  .co-chat--open .co-chat-launcher { display: none; }
  .co-chat-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }
  .co-chat-close { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .co-chat-panel, .co-chat-teaser, .co-crew-char, .co-chat-typing i, .co-chat-teaser-wave,
  .co-chat-launcher.is-calling .co-crew--launcher { animation: none; }
  .co-chat-launcher, .co-crew--launcher { transition: none; }
}

@media print {
  .co-chat { display: none; }
}
