/* ============================================
   Lead chat widget (public/js/components/lead-chat.js)
   Loaded only by views/partials/site/lead-chat.ejs on pages that show the widget.
   Colours come from the theme tokens in tokens.css, so it follows dark and light themes.
   Every class is prefixed vplc- so nothing else on the page is affected.
   Look: option C "Waving hello" with drawing 2 "Headset" (owner choice 2026-11-19). Motion is
   limited (the closed button waves LEAD_CHAT_NUDGES times, then rests) and switched off for
   visitors who ask for reduced motion. No glows or pulsing.
   ============================================ */
.vplc { position: fixed; right: 20px; bottom: 20px; z-index: 9000; display: flex; flex-direction: column; align-items: flex-end; gap: 14px; font-family: inherit; pointer-events: none; }
.vplc > * { pointer-events: auto; }
.vplc-teaser[hidden], .vplc-box[hidden], .vplc-intro[hidden], .vplc-convo[hidden], .vplc-badge[hidden] { display: none; }
.vplc-launcher:focus-visible, .vplc button:focus-visible, .vplc-input:focus-visible { outline: 2px solid rgb(var(--accent-rgb)); outline-offset: 2px; }

/* ── The assistant's picture (round; falls back to the name's first letter) ── */
.vplc-face { display: grid; place-items: center; overflow: hidden; border-radius: 50%; flex: none; box-sizing: border-box;
  background: rgb(var(--accent-rgb) / .15); color: rgb(var(--accent-rgb)); font-weight: 700; line-height: 1; }
.vplc-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vplc-wave { position: absolute; line-height: 1; transform-origin: 70% 80%; pointer-events: none; }

/* ── Closed: the picture is the chat button ── */
.vplc-launcher { position: relative; width: 62px; height: 62px; padding: 0; border-radius: 50%; cursor: pointer;
  border: 3px solid rgb(var(--accent-rgb)); background: rgb(var(--accent-rgb));
  box-shadow: 0 8px 24px rgb(var(--shadow-rgb) / calc(.35 * var(--shadow-alpha, 1))); transition: transform .15s ease; }
.vplc-launcher:hover { transform: translateY(-2px); }
.vplc-face-launch { width: 100%; height: 100%; font-size: 24px; }
.vplc-wave-launch { left: -13px; bottom: -5px; font-size: 24px; }
.vplc-nudging .vplc-wave-launch { animation: vplc-wave 4s ease-in-out .3s; }
.vplc-badge { position: absolute; top: -6px; right: -6px; min-width: 21px; height: 21px; padding: 0 5px; box-sizing: border-box; border-radius: 11px;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; background: #fff; color: rgb(var(--accent-hover-rgb));
  border: 2px solid rgb(var(--surface-rgb)); animation: vplc-pop .3s cubic-bezier(.25, 1, .5, 1) both; }

.vplc-teaser { position: relative; max-width: 300px; }
.vplc-teaser-text { display: block; text-align: left; cursor: pointer; padding: 14px 32px 14px 16px; border-radius: 14px; font-size: 14px; line-height: 1.45;
  background: rgb(var(--surface-raised-rgb)); color: rgb(var(--text-primary-rgb)); border: 1px solid rgb(var(--sand-rule-rgb) / .12);
  box-shadow: 0 10px 30px rgb(var(--shadow-rgb) / calc(.3 * var(--shadow-alpha, 1))); animation: vplc-in .25s ease-out; }
.vplc-teaser-close { position: absolute; top: 4px; right: 6px; border: 0; background: none; cursor: pointer; font-size: 18px; line-height: 1; padding: 4px;
  color: rgb(var(--text-tertiary-rgb)); }

/* ── Open: name tag and close button float above the panel ── */
.vplc-box { position: relative; width: 360px; max-width: calc(100vw - 32px); padding-top: 22px; animation: vplc-in .2s ease-out; }
.vplc-pill { position: absolute; top: 0; left: -4px; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 999px;
  font-weight: 600; font-size: 14px; background: rgb(var(--surface-nested-rgb)); color: rgb(var(--text-primary-rgb));
  border: 1px solid rgb(var(--sand-rule-rgb) / .18); box-shadow: 0 6px 18px rgb(var(--shadow-rgb) / calc(.35 * var(--shadow-alpha, 1))); }
.vplc-pill-av { position: relative; display: block; width: 28px; height: 28px; }
.vplc-face-pill { width: 28px; height: 28px; font-size: 13px; }
.vplc-pill-dot { position: absolute; right: -1px; bottom: -1px; width: 9px; height: 9px; border-radius: 50%; background: rgb(var(--positive-rgb));
  border: 2px solid rgb(var(--surface-nested-rgb)); }
.vplc-x { position: absolute; top: 2px; right: -2px; z-index: 2; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 18px; line-height: 1;
  border: 1px solid rgb(var(--sand-rule-rgb) / .14); background: rgb(var(--surface-nested-rgb)); color: rgb(var(--text-secondary-rgb)); }
.vplc-x:hover { color: rgb(var(--text-primary-rgb)); }
.vplc-panel { width: 100%; max-height: min(600px, calc(100vh - 130px)); display: flex; flex-direction: column; overflow: hidden; border-radius: 18px;
  background: rgb(var(--surface-raised-rgb)); color: rgb(var(--text-primary-rgb)); border: 1px solid rgb(var(--sand-rule-rgb) / .14);
  box-shadow: 0 18px 50px rgb(var(--shadow-rgb) / calc(.45 * var(--shadow-alpha, 1))); }

/* ── Intro card ── */
.vplc-intro { display: flex; flex-direction: column; padding-bottom: 14px; overflow-y: auto; }
.vplc-hero { margin: 8px; padding: 28px 12px 18px; border-radius: 12px; display: grid; justify-items: center; gap: 10px; text-align: center;
  background: linear-gradient(165deg, rgb(var(--surface-nested-rgb)) 0%, rgb(var(--surface-raised-rgb)) 90%); border: 1px solid rgb(var(--sand-rule-rgb) / .06); }
.vplc-big { position: relative; width: 96px; height: 96px; }
.vplc-face-big { width: 96px; height: 96px; font-size: 38px; border: 2px solid rgb(var(--accent-rgb) / .45); }
.vplc-big-dot { position: absolute; right: 4px; bottom: 4px; width: 15px; height: 15px; box-sizing: border-box; border-radius: 50%;
  background: rgb(var(--positive-rgb)); border: 3px solid rgb(var(--surface-nested-rgb)); }
.vplc-wave-big { left: -18px; bottom: -6px; font-size: 32px; }
.vplc-open.vplc-intro-on .vplc-wave-big { animation: vplc-wave 4s ease-in-out .4s infinite; }
.vplc-hero-role { font-size: 12px; color: rgb(var(--text-secondary-rgb)); }
.vplc-say { max-width: 270px; min-height: 44px; box-sizing: border-box; display: grid; place-items: center; padding: 10px 13px; border-radius: 12px;
  font-size: 14px; line-height: 1.45; background: rgb(var(--surface-raised-rgb)); border: 1px solid rgb(var(--sand-rule-rgb) / .1); }
.vplc-cta { display: block; margin: 6px 14px 0; height: 44px; }

/* ── Conversation (the two lead steps) ── */
.vplc-convo { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.vplc-head { padding: 24px 16px 12px; border-bottom: 1px solid rgb(var(--sand-rule-rgb) / .1); }
.vplc-role { font-weight: 600; font-size: 14px; }
.vplc-status { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 12px; color: rgb(var(--text-secondary-rgb)); }
.vplc-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: rgb(var(--positive-rgb)); }
.vplc-log { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; min-height: 80px; }
.vplc-msg { max-width: 85%; padding: 10px 12px; border-radius: 12px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.vplc-bot { align-self: flex-start; background: rgb(var(--surface-nested-rgb, var(--surface-rgb))); border-top-left-radius: 4px; }
.vplc-me { align-self: flex-end; background: rgb(var(--accent-rgb)); color: #fff; border-top-right-radius: 4px; }
.vplc-foot { padding: 12px 16px 16px; border-top: 1px solid rgb(var(--sand-rule-rgb) / .1); }
.vplc-foot:empty { display: none; }
.vplc-form { display: flex; flex-direction: column; gap: 10px; }
.vplc-field { display: flex; flex-direction: column; gap: 4px; }
.vplc-label { font-size: 12px; color: rgb(var(--text-secondary-rgb)); }
.vplc-input { width: 100%; box-sizing: border-box; padding: 9px 11px; border-radius: 8px; font: inherit; font-size: 14px; resize: vertical;
  background: rgb(var(--surface-rgb)); color: rgb(var(--text-primary-rgb)); border: 1px solid rgb(var(--sand-rule-rgb) / .18); }
/* One focus ring only: the site's global input focus ring was drawn on top of ours. */
.vplc .vplc-input:focus, .vplc .vplc-input:focus-visible { outline: 2px solid rgb(var(--accent-rgb)); outline-offset: 0; box-shadow: none; border-color: transparent; }
.vplc-hp { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; opacity: 0; }
.vplc-note { margin: 0; font-size: 11.5px; line-height: 1.4; color: rgb(var(--text-tertiary-rgb)); }
.vplc-note a { color: inherit; text-decoration: underline; }
.vplc-btn { border: 0; border-radius: 8px; padding: 10px 14px; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  background: rgb(var(--accent-rgb)); color: #fff; }
.vplc-btn:hover { background: rgb(var(--accent-hover-rgb)); }
.vplc-btn:disabled { opacity: .6; cursor: progress; }
.vplc-error { margin-bottom: 8px; font-size: 13px; color: rgb(var(--negative-rgb)); }

/* ── Typing dots ── */
.vplc-typing { display: inline-flex; align-items: center; gap: 4px; }
.vplc-typing span { width: 7px; height: 7px; border-radius: 50%; background: rgb(var(--text-secondary-rgb)); animation: vplc-typing 1.2s ease-in-out infinite; }
.vplc-typing span:nth-child(2) { animation-delay: .15s; }
.vplc-typing span:nth-child(3) { animation-delay: .3s; }
.vplc-typing-msg { padding: 13px 14px; }
.vplc-teaser-text .vplc-typing { padding: 4px 0; }

@keyframes vplc-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes vplc-typing { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes vplc-wave { 0% { transform: rotate(0); } 6% { transform: rotate(18deg); } 12% { transform: rotate(-10deg); } 18% { transform: rotate(18deg); }
  24% { transform: rotate(-6deg); } 30% { transform: rotate(10deg); } 36%, 100% { transform: rotate(0); } }
@keyframes vplc-pop { from { transform: scale(0); } to { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .vplc-teaser-text, .vplc-box, .vplc-badge { animation: none; }
  .vplc .vplc-wave { animation: none !important; }
  .vplc-launcher { transition: none; }
  .vplc-typing span { animation: none; opacity: .7; }
}

/* Phones: panel spans the width with a 16px gutter. */
@media (max-width: 480px) {
  .vplc { right: 16px; bottom: 16px; left: 16px; align-items: flex-end; }
  .vplc-box { width: 100%; }
  .vplc-panel { max-height: calc(100vh - 120px); }
  .vplc-teaser { max-width: calc(100vw - 32px); }
}

/* Greeting card (owner flow 2026-11-19): stolen-logins number that counts up once, then the question. */
.vplc [hidden] { display: none !important; }
.vplc-teaser:has(.vplc-card:not([hidden])) { max-width: 320px; }
.vplc-card { width: 320px; max-width: 100%; box-sizing: border-box; padding: 20px 18px 16px; border-radius: 16px;
  background: rgb(var(--surface-raised-rgb)); color: rgb(var(--text-primary-rgb)); border: 1px solid rgb(var(--sand-rule-rgb) / .12);
  box-shadow: 0 16px 48px rgb(var(--shadow-rgb) / calc(.4 * var(--shadow-alpha, 1))); animation: vplc-in .3s ease-out; }
.vplc-stat-num { font-size: 44px; line-height: 1; font-weight: 700; letter-spacing: -.02em; color: rgb(var(--accent-rgb)); font-variant-numeric: tabular-nums; }
.vplc-stat-label { margin-top: 6px; font-size: 14px; line-height: 1.35; color: rgb(var(--text-secondary-rgb)); }
.vplc-card-row { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; padding-top: 14px; border-top: 1px solid rgb(var(--sand-rule-rgb) / .1); }
.vplc-avatar.vplc-avatar-sm { width: 32px; height: 32px; font-size: 14px; }
.vplc-card-who { min-width: 0; }
.vplc-card-name { font-size: 12px; font-weight: 600; color: rgb(var(--text-secondary-rgb)); }
.vplc-card-text { margin: 2px 0 0; font-size: 14px; line-height: 1.45; }
.vplc-card-actions { display: flex; gap: 8px; margin-top: 14px; }
.vplc-card-actions .vplc-btn { flex: 1 1 auto; white-space: nowrap; }
.vplc-card-actions .vplc-btn:first-child { flex-grow: 2; }
.vplc-btn-ghost { background: transparent; color: rgb(var(--text-secondary-rgb)); border: 1px solid rgb(var(--sand-rule-rgb) / .18); }
.vplc-btn-ghost:hover { background: rgb(var(--sand-rule-rgb) / .08); color: rgb(var(--text-primary-rgb)); }
.vplc-teaser-close.vplc-card-close { top: 8px; right: 8px; }
.vplc-report { display: inline-block; margin-top: 8px; padding: 7px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; text-decoration: none;
  background: rgb(var(--accent-rgb)); color: #fff; }
.vplc-report:hover { background: rgb(var(--accent-hover-rgb)); }
@media (prefers-reduced-motion: reduce) { .vplc-card { animation: none; } }
@media (max-width: 480px) { .vplc-card { width: calc(100vw - 32px); } .vplc-stat-num { font-size: 38px; } }
