/* The BizGuru bubble: a floating orb that opens a talk-or-type panel for Cruz (and later Aura).
   One component, skinned by data-theme. Colours and fonts live on the theme block only. */

.bz { --b-size: 60px; --b-inset: 22px; --b-level: 0;
  position: fixed; right: var(--b-inset); bottom: calc(var(--b-inset) + env(safe-area-inset-bottom, 0px)); z-index: 9990;
  font-family: var(--b-body); color: var(--b-fg); display: grid; justify-items: end; gap: 10px; }
.bz * { box-sizing: border-box; }

/* BizGuru home: dark and neon */
.bz[data-theme="bizguru"] { --b-orb-a: #00FFEE; --b-orb-b: #CDFF00; --b-orb-c: #FF00FF; --b-ring: #CDFF00;
  --b-panel: #121214; --b-fg: #FAFAF8; --b-muted: #9b9b97; --b-line: rgba(255,255,255,0.10);
  --b-agent: #1d1d21; --b-user: #CDFF00; --b-user-fg: #0A0A0A; --b-btn: #CDFF00; --b-btn-fg: #0A0A0A; --b-end: #ff5a5a;
  --b-head: "Cabinet Grotesk", "Satoshi", system-ui, sans-serif; --b-body: "Satoshi", system-ui, sans-serif; --b-radius: 22px; --b-shadow: 0 24px 60px rgba(0,0,0,0.55); }
/* Cruz: navy and amber on paper */
.bz[data-theme="cruz"] { --b-orb-a: #0f1b2d; --b-orb-b: #ffc45c; --b-orb-c: #1f3357; --b-ring: #f4a61d;
  --b-panel: #ffffff; --b-fg: #0f1b2d; --b-muted: #5b6577; --b-line: #e4e1d9;
  --b-agent: #f1efe8; --b-user: #0f1b2d; --b-user-fg: #ffffff; --b-btn: #0f1b2d; --b-btn-fg: #ffffff; --b-end: #b3261e;
  --b-head: "Bricolage Grotesque", "Cabinet Grotesk", system-ui, sans-serif; --b-body: "Instrument Sans", "Satoshi", system-ui, sans-serif; --b-radius: 20px; --b-shadow: 0 24px 60px rgba(15,27,45,0.22); }
/* Aura: ivory, deep green, blush and gold */
.bz[data-theme="aura"] { --b-orb-a: #F3CFD6; --b-orb-b: #DDD3F2; --b-orb-c: #C9A45C; --b-ring: #C9A45C;
  --b-panel: #F7F3EC; --b-fg: #1F3D2B; --b-muted: rgba(31,61,43,0.62); --b-line: rgba(31,61,43,0.14);
  --b-agent: #ffffff; --b-user: #1F3D2B; --b-user-fg: #F7F3EC; --b-btn: #1F3D2B; --b-btn-fg: #F7F3EC; --b-end: #9c3b2f;
  --b-head: "Fraunces", Georgia, serif; --b-body: "Satoshi", system-ui, sans-serif; --b-radius: 24px; --b-shadow: 0 24px 60px rgba(31,61,43,0.18); }

/* ---- the orb: a rotating colour layer under a fixed highlight, a voice ring, and two ripples ---- */
.bz-orb { width: var(--b-size); height: var(--b-size); border-radius: 50%; position: relative; flex: none; transform: translateZ(0); will-change: transform;
  animation: bz-breathe 4.6s ease-in-out infinite; }
.bz-orb > i { position: absolute; border-radius: 50%; display: block; pointer-events: none; }
.bz-orb .c { inset: 0; background: conic-gradient(from 0deg, var(--b-orb-a), var(--b-orb-b), var(--b-orb-c), var(--b-orb-a)); animation: bz-spin 16s linear infinite; will-change: transform; }
.bz-orb .h { inset: 0; background: radial-gradient(circle at 32% 28%, rgba(255,255,255,0.78) 0, rgba(255,255,255,0.10) 34%, rgba(255,255,255,0) 52%), radial-gradient(circle at 70% 78%, rgba(0,0,0,0.18) 0, rgba(0,0,0,0) 45%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.28), 0 10px 26px color-mix(in srgb, var(--b-ring) 42%, transparent); }
.bz-orb .r { inset: -6px; border: 2px solid var(--b-ring); opacity: 0.35; transform: scale(calc(1 + var(--b-level) * 0.38)); transition: transform 80ms linear, opacity 200ms; }
.bz-orb .p { inset: -2px; border: 2px solid var(--b-ring); opacity: 0; }
.bz[data-voice="listening"] .bz-orb { animation: none; }
.bz[data-voice="listening"] .bz-orb .r { opacity: 0.9; }
.bz[data-voice="speaking"] .bz-orb { animation: none; transform: scale(calc(1 + var(--b-level) * 0.10)); transition: transform 70ms linear; }
.bz[data-voice="speaking"] .bz-orb .p.one { animation: bz-ripple 1.7s ease-out infinite; }
.bz[data-voice="speaking"] .bz-orb .p.two { animation: bz-ripple 1.7s ease-out 0.55s infinite; }
.bz[data-voice="connecting"] .bz-orb .r { opacity: 0.9; animation: bz-spin-ring 1.1s linear infinite; border-color: transparent; border-top-color: var(--b-ring); }
@keyframes bz-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes bz-spin { to { transform: rotate(360deg); } }
@keyframes bz-spin-ring { to { transform: rotate(360deg); } }
@keyframes bz-ripple { 0% { transform: scale(1); opacity: 0.6; } 100% { transform: scale(1.8); opacity: 0; } }

/* ---- launcher ---- */
.bz-launch { display: inline-flex; align-items: center; gap: 10px; border: 0; padding: 0; background: transparent; cursor: pointer; color: inherit; font: inherit; }
.bz-launch:focus-visible .bz-orb { outline: 3px solid var(--b-ring); outline-offset: 4px; }
.bz-pill { background: var(--b-panel); color: var(--b-fg); border: 1px solid var(--b-line); box-shadow: 0 8px 24px rgba(0,0,0,0.14); border-radius: 999px; padding: 9px 14px; font: 600 14px var(--b-body); white-space: nowrap; order: -1; text-align: left; line-height: 1.2; }
.bz-pill small { display: block; font-weight: 400; font-size: 11.5px; color: var(--b-muted); margin-top: 2px; }

/* ---- teaser, once per visit ---- */
.bz-teaser { position: relative; max-width: 250px; background: var(--b-panel); color: var(--b-fg); border: 1px solid var(--b-line); border-radius: 16px 16px 4px 16px; box-shadow: var(--b-shadow); padding: 12px 34px 12px 14px; font-size: 14px; line-height: 1.4;
  transform-origin: bottom right; animation: bz-pop 260ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.bz-teaser b { font-family: var(--b-head); font-weight: 700; }
.bz-teaser .x { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: transparent; color: var(--b-muted); cursor: pointer; font-size: 16px; line-height: 1; }
.bz-teaser .x:hover { background: var(--b-agent); }
@keyframes bz-pop { from { opacity: 0; transform: translateY(6px) scale(0.94); } to { opacity: 1; transform: none; } }

/* ---- panel ---- */
.bz-panel { width: min(360px, calc(100vw - 2 * var(--b-inset))); height: min(560px, calc(100dvh - 2 * var(--b-inset) - 24px)); background: var(--b-panel); color: var(--b-fg); border: 1px solid var(--b-line); border-radius: var(--b-radius); box-shadow: var(--b-shadow);
  display: grid; grid-template-rows: auto 1fr auto; grid-template-columns: minmax(0, 1fr); overflow: hidden; transform-origin: bottom right; animation: bz-pop 260ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.bz-panel > * { min-width: 0; }
.bz-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; border-bottom: 1px solid var(--b-line); }
.bz-head .bz-orb { --b-size: 30px; }
.bz-head .who { min-width: 0; flex: 1; line-height: 1.15; }
.bz-head .who b { font: 700 16px var(--b-head); display: block; }
.bz-head .who span { font-size: 12px; color: var(--b-muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bz-status { font: 500 11.5px var(--b-body); color: var(--b-muted); border: 1px solid var(--b-line); border-radius: 999px; padding: 4px 9px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.bz-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--b-muted); }
.bz[data-voice="listening"] .bz-status::before, .bz[data-voice="connecting"] .bz-status::before { background: var(--b-ring); animation: bz-blink 1.2s ease-in-out infinite; }
.bz[data-voice="text"] .bz-status::before { background: var(--b-ring); }
.bz[data-voice="speaking"] .bz-status::before { background: var(--b-ring); }
@keyframes bz-blink { 50% { opacity: 0.3; } }
.bz-close { width: 30px; height: 30px; border-radius: 50%; border: 0; background: transparent; color: var(--b-muted); font-size: 18px; cursor: pointer; }
.bz-close:hover { background: var(--b-agent); color: var(--b-fg); }
.bz-log { padding: 14px; overflow-y: auto; display: grid; gap: 8px; align-content: start; font-size: 14px; line-height: 1.45; overscroll-behavior: contain; }
.bz-msg { max-width: 86%; padding: 9px 12px; border-radius: 16px; overflow-wrap: anywhere; }
.bz-msg.a { background: var(--b-agent); border-bottom-left-radius: 5px; justify-self: start; }
.bz-msg.u { background: var(--b-user); color: var(--b-user-fg); border-bottom-right-radius: 5px; justify-self: end; }
.bz-msg.s { justify-self: center; background: transparent; color: var(--b-muted); font-size: 12px; padding: 2px 0; text-align: center; max-width: 100%; }
.bz-msg.live::after { content: ""; display: inline-block; width: 6px; height: 12px; margin-left: 4px; vertical-align: -2px; background: var(--b-ring); border-radius: 2px; animation: bz-blink 0.9s steps(2) infinite; }
.bz-foot { padding: 10px 12px 10px; border-top: 1px solid var(--b-line); display: grid; gap: 8px; }
.bz-row { display: flex; gap: 8px; align-items: center; }
.bz-call { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; border-radius: 999px; border: 1.5px solid transparent; background: var(--b-btn); color: var(--b-btn-fg); font: 600 15px var(--b-body); cursor: pointer; transition: background 160ms, color 160ms; }
.bz-call svg { width: 18px; height: 18px; flex: none; }
.bz-call:disabled { opacity: 0.6; cursor: wait; }
.bz:not([data-voice="off"]):not([data-voice="ended"]):not([data-voice="text"]) .bz-call { background: transparent; color: var(--b-end); border-color: currentColor; }
.bz-ico { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--b-line); background: transparent; color: var(--b-fg); display: inline-grid; place-items: center; cursor: pointer; flex: none; }
.bz-ico svg { width: 18px; height: 18px; }
.bz-ico[aria-pressed="true"] { background: var(--b-fg); color: var(--b-panel); }
.bz-input { display: flex; align-items: center; gap: 6px; border: 1px solid var(--b-line); border-radius: 999px; padding: 4px 4px 4px 14px; background: color-mix(in srgb, var(--b-agent) 60%, var(--b-panel)); }
.bz-input input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--b-fg); font: 14px var(--b-body); outline: none; }
.bz-input input::placeholder { color: var(--b-muted); }
.bz-input:focus-within { border-color: var(--b-ring); }
.bz-send { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--b-btn); color: var(--b-btn-fg); display: grid; place-items: center; cursor: pointer; flex: none; }
.bz-send svg { width: 14px; height: 14px; }
.bz-fine { font-size: 11px; color: var(--b-muted); text-align: center; line-height: 1.35; overflow-wrap: anywhere; }
.bz-fine a { color: inherit; }

/* ---- states ---- */
.bz[data-state="idle"] .bz-teaser, .bz[data-state="idle"] .bz-panel { display: none; }
.bz[data-state="teaser"] .bz-panel { display: none; }
.bz[data-state="open"] .bz-teaser, .bz[data-state="open"] .bz-launch { display: none; }
.bz-status .on, .bz-call .on, .bz-ico.mute { display: none; }
.bz:not([data-voice="off"]):not([data-voice="ended"]) .bz-status .on { display: inline; }
.bz:not([data-voice="off"]):not([data-voice="ended"]) .bz-status .off { display: none; }
.bz:not([data-voice="off"]):not([data-voice="ended"]):not([data-voice="text"]) .bz-call .on { display: inline; }
.bz:not([data-voice="off"]):not([data-voice="ended"]):not([data-voice="text"]) .bz-call .off { display: none; }
.bz[data-voice="listening"] .bz-ico.mute, .bz[data-voice="speaking"] .bz-ico.mute { display: inline-grid; }

/* ---- phone: orb only, sheet above the site's sticky bar ---- */
@media (max-width: 640px) {
  .bz { --b-size: 52px; --b-inset: 14px; }
  .bz-pill { display: none; }
  body.has-sticky .bz { bottom: calc(var(--b-inset) + 62px + env(safe-area-inset-bottom, 0px)); }
  .bz-panel { width: calc(100vw - 2 * var(--b-inset)); height: min(600px, calc(100dvh - 2 * var(--b-inset) - 24px)); }
  .bz-teaser { max-width: calc(100vw - 2 * var(--b-inset) - 64px); }
}
@media (prefers-reduced-motion: reduce) {
  .bz-orb, .bz-orb .c, .bz-orb .p, .bz-teaser, .bz-panel { animation: none !important; }
  .bz-orb .r { transition: none; }
}
