/* ================================
   JAIFORE — BOSSY BOT LAUNCHER AND CHAT PANEL
   styles/bossy-bot.css

   Markup is injected by scripts/bossy-bot.js. Launcher states are plain class
   names (is-open, is-thinking, bossy-x-*) so a Rive state machine can drive
   them later. Animations use transform and opacity only.
   ================================ */

:root {
  --bossy-size: 80px;
  --bossy-edge: 1.75rem;
  --bossy-bottom: calc(1.75rem + env(safe-area-inset-bottom));
  --bossy-ink: #000;             /* the mascot art has a pure black background */
}
:root.bossy-calm { --bossy-size: 60px; }
body.has-tabbar { --bossy-bottom: calc(64px + 12px + env(safe-area-inset-bottom)); }
@media (max-width: 480px) {
  :root { --bossy-size: 64px; --bossy-edge: 1.1rem; }
  :root.bossy-calm { --bossy-size: 52px; }
}

/* Back-to-top moves above the launcher, centred on it. */
body:has(#bossyLauncher) .back-to-top-btn {
  right: calc(var(--bossy-edge) + (var(--bossy-size) - 46px) / 2);
  bottom: calc(var(--bossy-bottom) + var(--bossy-size) + 14px);
}
@media (max-width: 600px) {
  body:has(#bossyLauncher) .back-to-top-btn {
    right: calc(var(--bossy-edge) + (var(--bossy-size) - 42px) / 2);
  }
}

/* ── LAUNCHER ──────────────────────────────────────── */
.bossy-launcher {
  position: fixed;
  right: var(--bossy-edge);
  bottom: var(--bossy-bottom);
  z-index: 160;
  width: var(--bossy-size);
  height: var(--bossy-size);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.2s ease;
}
.bossy-launcher:hover,
.bossy-launcher:focus-visible { transform: scale(1.08); }
.bossy-launcher:focus-visible { outline: 3px solid var(--purple-soft); outline-offset: 4px; }

.bossy-glow {
  position: absolute; inset: -22%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(193, 60, 240, 0.55) 0%, rgba(61, 220, 46, 0.25) 45%, transparent 70%);
  opacity: 0.35;
  pointer-events: none;
  animation: bossy-glow 3.6s ease-in-out infinite;
}
.bossy-launcher:hover .bossy-glow,
.bossy-launcher:focus-visible .bossy-glow { opacity: 0.8; animation: none; }

.bossy-shadow {
  position: absolute; left: 14%; right: 14%; bottom: -9%;
  height: 12%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.32);
  filter: blur(3px);
  pointer-events: none;
  animation: bossy-shadow 2.8s ease-in-out infinite;
}

.bossy-bob { position: absolute; inset: 0; animation: bossy-bob 2.8s ease-in-out infinite; }
.bossy-body { position: absolute; inset: 0; transform-origin: 50% 85%; }
.bossy-body img { display: block; width: 100%; height: 100%; border-radius: 50%; pointer-events: none; }

.bossy-close {
  position: absolute; inset: 0;
  display: none; align-items: center; justify-content: center;
  color: #fff; pointer-events: none;
}
.bossy-close svg { width: 38%; height: 38%; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.7)); }

/* Calm pages (checkout, design studio): bob only. */
:root.bossy-calm .bossy-glow { animation: none; opacity: 0.25; }

/* Open: still, mascot faded behind a close icon. */
.bossy-launcher.is-open .bossy-bob,
.bossy-launcher.is-open .bossy-shadow,
.bossy-launcher.is-open .bossy-glow { animation: none; }
.bossy-launcher.is-open .bossy-body img { opacity: 0.3; }
.bossy-launcher.is-open .bossy-close { display: flex; }
.bossy-launcher.is-open::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%; background: var(--bossy-ink);
}

/* One-off extras, toggled from JS. Never two at once. */
.bossy-x-tilt .bossy-body   { animation: bossy-tilt 1.1s ease-in-out 1; }
.bossy-x-hop .bossy-body    { animation: bossy-hop 0.8s cubic-bezier(.3, .7, .4, 1) 1; }
.bossy-x-wiggle .bossy-body { animation: bossy-wiggle 0.9s ease-in-out 1; }
.bossy-boing .bossy-body    { animation: bossy-boing 0.45s ease-out 1; }

/* Tab hidden: freeze everything. */
.bossy-paused .bossy-glow, .bossy-paused .bossy-shadow, .bossy-paused .bossy-bob,
.bossy-paused .bossy-body, .bossy-paused .bossy-avatar { animation-play-state: paused; }

@keyframes bossy-bob    { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes bossy-shadow { 0%, 100% { transform: scaleX(1); opacity: 0.9; } 50% { transform: scaleX(0.82); opacity: 0.55; } }
@keyframes bossy-glow   { 0%, 100% { opacity: 0.25; transform: scale(0.94); } 50% { opacity: 0.6; transform: scale(1.04); } }
@keyframes bossy-tilt   { 0%, 100% { transform: rotate(0); } 35% { transform: rotate(-6deg); } 70% { transform: rotate(6deg); } }
@keyframes bossy-hop    { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-14px); } 65% { transform: translateY(0) scale(1.04, 0.94); } }
@keyframes bossy-wiggle { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-8deg); } 40% { transform: rotate(8deg); } 60% { transform: rotate(-5deg); } 80% { transform: rotate(5deg); } }
@keyframes bossy-boing  { 0% { transform: scale(1); } 30% { transform: scale(1.18, 0.82); } 60% { transform: scale(0.9, 1.12); } 100% { transform: scale(1); } }
@keyframes bossy-wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-9deg); } 75% { transform: rotate(9deg); } }

/* ── TEASER ────────────────────────────────────────── */
.bossy-teaser {
  position: fixed;
  right: calc(var(--bossy-edge) + var(--bossy-size) + 10px);
  bottom: calc(var(--bossy-bottom) + var(--bossy-size) / 2 - 22px);
  z-index: 160;
  max-width: min(240px, calc(100vw - var(--bossy-size) - var(--bossy-edge) - 28px));
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  font: 500 var(--text-sm) / 1.35 var(--font-body);
  text-align: left;
  box-shadow: 0 6px 22px rgba(20, 16, 26, 0.18);
  cursor: pointer;
  opacity: 0;
  transform: translateX(8px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.bossy-teaser.is-shown { opacity: 1; transform: translateX(0); pointer-events: auto; }

/* ── PANEL ─────────────────────────────────────────── */
.bossy-panel {
  position: fixed;
  right: var(--bossy-edge);
  bottom: calc(var(--bossy-bottom) + var(--bossy-size) + 12px);
  z-index: 160;
  display: flex; flex-direction: column;
  width: 360px;
  height: min(560px, calc(100dvh - var(--bossy-bottom) - var(--bossy-size) - 28px));
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 14px 44px rgba(20, 16, 26, 0.28);
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  visibility: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
}
.bossy-panel.is-open { opacity: 1; transform: none; visibility: visible; transition-delay: 0s; }
@media (max-width: 480px) {
  .bossy-panel { left: 8px; right: 8px; width: auto; }
}

.bossy-head {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.65rem 0.9rem;
  background: var(--bossy-ink);
  color: #fff;
}
.bossy-avatar {
  flex: none; width: 46px; height: 46px;
  border-radius: 50%; object-fit: cover; object-position: 50% 8%;
  background: var(--bossy-ink);
  box-shadow: 0 0 0 2px var(--magenta);
}
.bossy-head.is-thinking .bossy-avatar { animation: bossy-wobble 0.8s ease-in-out infinite; }
.bossy-title { margin: 0; font: 700 1.05rem / 1.2 var(--font-display); }
.bossy-sub { margin: 0; font: 400 var(--text-xs) / 1.3 var(--font-body); color: var(--footer-muted); }

.bossy-thread {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.6rem;
  padding: 0.9rem;
  background: var(--bg-soft);
  overscroll-behavior: contain;
}
.bossy-msg {
  max-width: 85%;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-lg);
  font: 400 var(--text-sm) / 1.45 var(--font-body);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.bossy-msg--bot  { align-self: flex-start; background: var(--surface); border: 1px solid var(--border-soft); border-bottom-left-radius: 4px; }
.bossy-msg--user { align-self: flex-end; background: var(--purple-fill); color: var(--on-purple); border-bottom-right-radius: 4px; }

.bossy-greet {
  align-self: stretch; display: flex; align-items: center; gap: 0.8rem;
  padding: 0.6rem 0.9rem 0.6rem 0.6rem;
  border-radius: var(--radius-lg);
  background: var(--bossy-ink); color: #fff;
  font: 400 var(--text-sm) / 1.45 var(--font-body);
}
.bossy-greet img { flex: none; display: block; width: 54px; height: 100px; object-fit: contain; }

.bossy-retry {
  align-self: flex-start; padding: 0; border: 0; background: none;
  color: var(--purple); font: 600 var(--text-sm) var(--font-body); cursor: pointer; text-decoration: underline;
}
.bossy-typing { align-self: flex-start; display: flex; gap: 4px; padding: 0.7rem 0.8rem; background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-lg); }
.bossy-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted2); animation: bossy-dot 1s ease-in-out infinite; }
.bossy-typing span:nth-child(2) { animation-delay: 0.15s; }
.bossy-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bossy-dot { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }

.bossy-cards { align-self: stretch; display: flex; flex-direction: column; gap: 0.4rem; }
.bossy-card {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.4rem; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); color: inherit; text-decoration: none;
}
.bossy-card:hover, .bossy-card:focus-visible { border-color: var(--purple); }
.bossy-card img { flex: none; width: 48px; height: 48px; border-radius: var(--radius-sm); object-fit: cover; background: var(--bg-soft); }
.bossy-card-name { font: 600 var(--text-sm) / 1.3 var(--font-body); }
.bossy-card-price { font: 400 var(--text-xs) var(--font-body); color: var(--muted); }

.bossy-form { display: flex; gap: 0.5rem; padding: 0.6rem; border-top: 1px solid var(--border-soft); background: var(--surface); }
.bossy-input {
  flex: 1; min-width: 0; padding: 0.55rem 0.8rem;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg); color: var(--ink);
  font: 400 16px var(--font-body);             /* 16px stops iOS zooming the page on focus */
}
.bossy-input:focus-visible { outline: 2px solid var(--purple); outline-offset: 1px; }
.bossy-send {
  padding: 0 1rem; border: 0; border-radius: 999px;
  background: var(--purple-fill); color: var(--on-purple);
  font: 600 var(--text-sm) var(--font-body); cursor: pointer;
}
.bossy-send:disabled { opacity: 0.5; cursor: default; }
.bossy-send:focus-visible { outline: 2px solid var(--purple-soft); outline-offset: 2px; }

/* ── REDUCED MOTION: a static mascot only ──────────── */
@media (prefers-reduced-motion: reduce) {
  .bossy-glow, .bossy-shadow, .bossy-bob, .bossy-body, .bossy-head .bossy-avatar, .bossy-typing span { animation: none !important; }
  .bossy-launcher, .bossy-teaser, .bossy-panel { transition: none; }
  .bossy-launcher:hover, .bossy-launcher:focus-visible { transform: none; }
}
