/* Blacktop chat widget — design from chatbot-handoff, wired to /api/chat.
   Uses global site.css tokens (--bg, --ink, --red, --font-*). All rules scoped
   under .bt-chat so nothing leaks into the page. Fonts come from the site (CSP
   font-src 'self') — no external font links. */
.bt-chat { position: fixed; right: clamp(18px,3vw,32px); bottom: clamp(18px,3vw,32px); z-index: 9000; font-family: var(--font-body, "Hanken Grotesk", system-ui, sans-serif); }
.bt-chat *, .bt-chat *::before, .bt-chat *::after { box-sizing: border-box; }

/* ---------- launcher ---------- */
.bt-chat .bt-launcher {
  position: relative; width: 64px; height: 64px; border: 0; padding: 0; cursor: pointer;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #10161c, #07090c 78%);
  box-shadow: 0 14px 34px rgba(0,0,0,.55), 0 4px 12px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.08);
  display: grid; place-items: center;
  transition: transform .3s cubic-bezier(.22,1,.36,1), box-shadow .3s;
  -webkit-tap-highlight-color: transparent;
}
.bt-chat .bt-launcher::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 1px solid rgba(255,255,255,.12); pointer-events: none; }
.bt-chat .bt-launcher:hover { transform: translateY(-3px); box-shadow: 0 20px 44px rgba(0,0,0,.6), 0 6px 16px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.1); }
.bt-chat .bt-launcher:active { transform: translateY(-1px); }
.bt-chat .bt-launcher .glyph { position: absolute; inset: 0; display: grid; place-items: center; transition: opacity .25s, transform .3s cubic-bezier(.22,1,.36,1); }
.bt-chat .bt-launcher .g-swoosh { opacity: 1; transform: scale(1); }
.bt-chat .bt-launcher .g-close { opacity: 0; transform: scale(.6) rotate(-30deg); }
.bt-chat .bt-launcher .g-swoosh svg { width: 34px; height: 34px; display: block; }
.bt-chat .bt-launcher .g-close svg { width: 22px; height: 22px; display: block; }
.bt-chat .bt-launcher .dot {
  position: absolute; top: 5px; right: 5px; width: 13px; height: 13px; border-radius: 50%;
  background: var(--red, #cf353f); border: 2.5px solid #0a0d11;
  box-shadow: 0 0 0 0 rgba(207,53,63,.55); animation: btPulse 2.6s infinite;
}
@keyframes btPulse { 0% { box-shadow: 0 0 0 0 rgba(207,53,63,.5); } 70% { box-shadow: 0 0 0 9px rgba(207,53,63,0); } 100% { box-shadow: 0 0 0 0 rgba(207,53,63,0); } }

/* ---------- panel ---------- */
.bt-chat .bt-panel {
  position: absolute; right: 0; bottom: 80px; width: 380px; max-width: calc(100vw - 32px);
  height: min(600px, calc(100vh - 120px));
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--line, rgba(255,255,255,.10)); border-radius: 20px;
  background: linear-gradient(180deg, rgba(18,20,25,.985), rgba(11,13,17,.985));
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 30px 70px rgba(0,0,0,.62), 0 12px 30px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.05);
  transform-origin: bottom right; opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(14px) scale(.96);
  transition: opacity .3s ease, transform .34s cubic-bezier(.22,1,.36,1), visibility 0s linear .34s;
  color: var(--ink, #f4f6f8);
}

/* ---------- header ---------- */
.bt-chat .bt-head { position: relative; display: flex; align-items: center; gap: 13px; padding: 18px 16px 18px 18px; background: linear-gradient(180deg, rgba(20,23,28,.9), rgba(14,17,21,.6)); border-bottom: 1px solid var(--line-2, rgba(255,255,255,.06)); }
.bt-chat .bt-head .avatar { position: relative; width: 42px; height: 42px; flex: 0 0 auto; border-radius: 50%; background: radial-gradient(circle at 34% 28%, #10161c, #07090c 78%); display: grid; place-items: center; border: 1px solid rgba(255,255,255,.1); }
.bt-chat .bt-head .avatar svg { width: 24px; height: 24px; display: block; }
.bt-chat .bt-head .avatar .a-dot { position: absolute; bottom: 0; right: 0; width: 11px; height: 11px; border-radius: 50%; background: var(--red, #cf353f); border: 2px solid #14171c; }
.bt-chat .bt-head .ht { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.bt-chat .bt-head .ht .name { font-family: var(--font-display, "Clash Display", system-ui, sans-serif); font-weight: 600; font-size: 16px; letter-spacing: -0.01em; color: #fff; }
.bt-chat .bt-head .ht .status { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted, rgba(244,246,248,.62)); white-space: nowrap; }
.bt-chat .bt-head .ht .status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #36c26a; box-shadow: 0 0 8px rgba(54,194,106,.7); }
.bt-chat .bt-head .close { margin-left: auto; flex: 0 0 auto; position: relative; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; padding: 0; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.14); display: grid; place-items: center; transition: background .25s, border-color .25s; }
.bt-chat .bt-head .close:hover { background: rgba(255,255,255,.11); border-color: rgba(255,255,255,.3); }
.bt-chat .bt-head .close svg { width: 14px; height: 14px; display: block; color: rgba(255,255,255,.85); }

/* ---------- messages ---------- */
.bt-chat .bt-body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 20px 18px 8px; display: flex; flex-direction: column; gap: 14px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
.bt-chat .bt-body::-webkit-scrollbar { width: 7px; }
.bt-chat .bt-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 4px; }
.bt-chat .bt-body::-webkit-scrollbar-track { background: transparent; }
.bt-chat .bt-day { align-self: center; font-size: 11px; letter-spacing: .06em; color: var(--muted-2, rgba(244,246,248,.42)); text-transform: uppercase; margin: 2px 0 4px; }
.bt-chat .msg { display: flex; flex-direction: column; max-width: 84%; gap: 5px; animation: btMsgIn .38s cubic-bezier(.22,1,.36,1) both; }
@keyframes btMsgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.bt-chat .msg .bubble { font-size: 14.5px; line-height: 1.5; padding: 11px 14px; border-radius: 16px; text-wrap: pretty; white-space: pre-wrap; word-wrap: break-word; }
.bt-chat .msg .time { font-size: 10.5px; color: var(--muted-2, rgba(244,246,248,.42)); padding: 0 4px; }
.bt-chat .msg.bot { align-self: flex-start; }
.bt-chat .msg.bot .bubble { background: linear-gradient(180deg, rgba(255,255,255,.075), rgba(255,255,255,.035)); border: 1px solid rgba(255,255,255,.09); color: rgba(244,246,248,.92); border-bottom-left-radius: 5px; }
.bt-chat .msg.user { align-self: flex-end; align-items: flex-end; }
.bt-chat .msg.user .bubble { background: linear-gradient(180deg, var(--red-bright, #e0444b), var(--red, #cf353f)); color: #fff; border-bottom-right-radius: 5px; box-shadow: 0 6px 16px rgba(207,53,63,.3); }

/* typing indicator */
.bt-chat .typing { align-self: flex-start; display: flex; gap: 5px; padding: 13px 15px; border-radius: 16px; border-bottom-left-radius: 5px; background: linear-gradient(180deg, rgba(255,255,255,.075), rgba(255,255,255,.035)); border: 1px solid rgba(255,255,255,.09); animation: btMsgIn .3s both; }
.bt-chat .typing span { width: 7px; height: 7px; border-radius: 50%; background: rgba(244,246,248,.55); animation: btType 1.3s infinite; }
.bt-chat .typing span:nth-child(2) { animation-delay: .18s; }
.bt-chat .typing span:nth-child(3) { animation-delay: .36s; }
@keyframes btType { 0%,60%,100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

/* ---------- quick replies ---------- */
.bt-chat .bt-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 18px 4px; }
.bt-chat .bt-chip { font: 500 12.5px/1 var(--font-body, "Hanken Grotesk", system-ui, sans-serif); color: rgba(255,255,255,.85); cursor: pointer; border: 1px solid rgba(255,255,255,.16); border-radius: 999px; padding: 9px 14px; background: rgba(255,255,255,.04); white-space: nowrap; transition: background .2s, border-color .2s, color .2s, transform .15s; }
.bt-chat .bt-chip:hover { background: rgba(207,53,63,.12); border-color: rgba(207,53,63,.5); color: #fff; }
.bt-chat .bt-chip:active { transform: scale(.96); }

/* ---------- composer ---------- */
.bt-chat .bt-foot { padding: 12px 14px calc(12px + env(safe-area-inset-bottom,0px)); border-top: 1px solid var(--line-2, rgba(255,255,255,.06)); background: linear-gradient(180deg, rgba(14,17,21,.4), rgba(9,11,14,.7)); }
.bt-chat .bt-input { display: flex; align-items: flex-end; gap: 9px; background: rgba(4,5,7,.85); border: 1px solid rgba(255,255,255,.16); border-radius: 14px; padding: 6px 6px 6px 15px; box-shadow: inset 0 2px 6px rgba(0,0,0,.45); transition: border-color .25s; }
.bt-chat .bt-input:focus-within { border-color: rgba(207,53,63,.6); }
.bt-chat .bt-input textarea { flex: 1; border: 0; outline: 0; resize: none; background: transparent; color: #fff; font: 400 16px/1.45 var(--font-body, "Hanken Grotesk", system-ui, sans-serif); padding: 9px 0; max-height: 96px; min-height: 20px; }
/* Kill the site-wide :focus-visible ring (white outline + red box-shadow) on the
   chat box — the wrapper border turning red on focus is the only indicator we want. */
.bt-chat .bt-input textarea:focus, .bt-chat .bt-input textarea:focus-visible { outline: none; box-shadow: none; }
.bt-chat .bt-input textarea::placeholder { color: var(--muted-2, rgba(244,246,248,.42)); }
.bt-chat .bt-send { flex: 0 0 auto; width: 40px; height: 40px; border: 0; border-radius: 11px; cursor: pointer; background: linear-gradient(180deg, var(--red-bright, #e0444b), var(--red, #cf353f)); display: grid; place-items: center; box-shadow: 0 6px 16px rgba(207,53,63,.36); transition: transform .2s, box-shadow .2s, opacity .2s; }
.bt-chat .bt-send svg { width: 18px; height: 18px; display: block; color: #fff; }
.bt-chat .bt-send:hover { transform: translateY(-1px); box-shadow: 0 9px 20px rgba(207,53,63,.46); }
.bt-chat .bt-send:disabled { opacity: .4; cursor: default; transform: none; box-shadow: none; }
.bt-chat .bt-foot .legal { margin: 9px 4px 0; text-align: center; font-size: 10.5px; color: var(--muted-2, rgba(244,246,248,.42)); }
.bt-chat .bt-foot .legal strong { color: var(--muted, rgba(244,246,248,.62)); font-weight: 600; }

/* ---------- open state ---------- */
.bt-chat.open .bt-panel { opacity: 1; visibility: visible; pointer-events: auto; transform: none; transition: opacity .34s ease, transform .4s cubic-bezier(.22,1,.36,1); }
.bt-chat.open .bt-launcher .g-swoosh { opacity: 0; transform: scale(.6) rotate(30deg); }
.bt-chat.open .bt-launcher .g-close { opacity: 1; transform: none; }
.bt-chat.open .bt-launcher .dot { opacity: 0; animation: none; }

/* ---------- mobile: full-screen sheet ---------- */
@media (max-width: 520px) {
  .bt-chat { right: 16px; bottom: 16px; }
  .bt-chat .bt-panel { position: fixed; right: 0; left: 0; bottom: 0; top: 0; width: 100vw; max-width: none; height: 100vh; border-radius: 0; border: 0; transform-origin: center bottom; transform: translateY(100%); }
  .bt-chat.open .bt-panel { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .bt-chat *, .bt-chat *::before, .bt-chat *::after { animation-duration: .001ms !important; transition-duration: .08s !important; }
  .bt-chat .bt-launcher .dot { animation: none; }
}
