/* ==========================================================================
   FANM GROWTH — COMPACT SOVEREIGN ROAMING COMPANION ("STROBI")
   Procedural 3D-Sphere Eye-Tracking Assistant
   ========================================================================== */

:root {
  --fanm-roam-size: 58px;
  --fanm-cyan: #00b4d8;
  --fanm-emerald: #00c988;
  --fanm-gold: #d4a843;
  --fanm-dark: #0a1628;
  --fanm-surface: #111d32;
  --fanm-alert: #f43f5e;
}

/* Full-viewport overlay host (zero blocking) */
.fanm-avatar-host {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9970;
  overflow: hidden;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-font-smoothing: antialiased;
  perspective: 800px;
}

/* Floating & Roaming Avatar Character Body */
.fanm-roaming-character {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--fanm-roam-size);
  height: var(--fanm-roam-size);
  pointer-events: auto;
  cursor: grab;
  will-change: transform;
  transform: translate3d(calc(100vw - 90px), calc(100vh - 180px), 0);
  transition: filter 0.25s ease;
  filter: drop-shadow(0 8px 22px rgba(0, 180, 216, 0.4));
  transform-style: flat; /* Keep speech bubble flat and stable */
}

.fanm-roaming-character.is-dragging {
  cursor: grabbing;
  filter: drop-shadow(0 14px 30px rgba(0, 180, 216, 0.7)) scale(1.08);
}

.fanm-roaming-character:hover {
  filter: drop-shadow(0 12px 28px rgba(0, 180, 216, 0.6));
}

/* 3D Sphere Stage (Encapsulates 3D perspective and rotation) */
.fanm-avatar-3d-stage {
  width: 100%;
  height: 100%;
  position: relative;
  perspective: 500px;
  transform-style: preserve-3d;
}

/* Rotating 3D Sphere Ball (Tracks mouse orientation without moving outer body or card) */
.fanm-avatar-3d-sphere {
  width: 100%;
  height: 100%;
  position: relative;
  border-radius: 50%;
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform 0.08s cubic-bezier(0.2, 0.8, 0.4, 1);
  box-shadow: 
    0 10px 24px -2px rgba(0, 180, 216, 0.45),
    0 4px 12px rgba(0, 0, 0, 0.6);
}

/* Glassy specular highlight reflection that glides with mouse gaze */
.fanm-sphere-specular-glare {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle at 34% 26%, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.45) 18%, rgba(72, 202, 228, 0.18) 36%, transparent 62%);
  mix-blend-mode: screen;
  z-index: 4;
  will-change: transform;
  transition: transform 0.08s cubic-bezier(0.2, 0.8, 0.4, 1);
}

/* 3D Fresnel Rim Light and Spherical Cavity Shadow */
.fanm-sphere-rim-light {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 
    inset -6px -7px 15px rgba(1, 25, 55, 0.85),
    inset 3px 3px 8px rgba(255, 255, 255, 0.45),
    inset 0 0 4px rgba(72, 202, 228, 0.5);
  border: none;
  z-index: 5;
}

/* Contact shadow beneath the 3D ball */
.fanm-sphere-ground-shadow {
  position: absolute;
  bottom: -6px;
  left: 10%;
  width: 80%;
  height: 8px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.65) 0%, rgba(0, 180, 216, 0.15) 45%, transparent 75%);
  border-radius: 50%;
  filter: blur(2px);
  pointer-events: none;
  z-index: 0;
}

/* Official @bible-strong/avatar-react styles */
.bs-avatar {
  box-sizing: border-box;
  aspect-ratio: 1;
  -webkit-user-select: none;
  user-select: none;
  outline: none;
  place-items: center;
  max-width: 100%;
  display: inline-grid;
}

.bs-avatar:focus-visible {
  outline-offset: 3px;
  outline: 3px solid;
}

.bs-avatar__svg {
  pointer-events: none;
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

/* Rendered @bible-strong/avatar-react container */
.fanm-avatar-viewport {
  width: 100%;
  height: 100%;
  position: relative;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.fanm-avatar-viewport .bs-avatar {
  width: 100% !important;
  height: 100% !important;
  display: inline-grid;
}

.fanm-avatar-viewport svg,
.fanm-avatar-viewport .bs-avatar__svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

/* SVG 3D Volumetric Gradient application */
.fanm-avatar-viewport svg path[fill="#c9cbcf"],
.fanm-avatar-viewport svg path[fill="#00b4d8"],
.fanm-avatar-viewport svg path.fanm-head-path {
  fill: url(#fanmSphere3D) !important;
}

.fanm-avatar-viewport svg g[clip-path] path {
  fill: url(#fanmEye3D) !important;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.85));
}

/* Eye Tracking Dynamic Container */
.fanm-avatar-viewport svg g[clip-path] {
  transition: transform 0.08s cubic-bezier(0.2, 0.8, 0.4, 1);
  will-change: transform;
}



/* Autonomous Floating Chat Bubble (Compact, One-Liner, Viewport-Safe) */
.fanm-avatar-card {
  pointer-events: auto;
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  left: auto;
  width: max-content;
  max-width: 195px;
  background: rgba(10, 22, 40, 0.96);
  border: 1px solid rgba(0, 180, 216, 0.4);
  border-radius: 12px;
  box-shadow: 
    0 8px 24px rgba(0, 0, 0, 0.7),
    0 0 14px rgba(0, 180, 216, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 7px 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  transform: scale(0.92);
  transform-origin: bottom right;
  z-index: 10;
}

.fanm-avatar-card.active {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

/* When dragged to the left half of the screen */
.fanm-avatar-card.align-left {
  right: auto;
  left: 0;
  transform-origin: bottom left;
}

/* Auto Flip Down when avatar is near top edge */
.fanm-avatar-card.flip-down {
  bottom: auto;
  top: calc(100% + 8px);
  transform-origin: top right;
}

.fanm-avatar-card.flip-down.align-left {
  transform-origin: top left;
}

.fanm-avatar-card.flip-down::after {
  bottom: auto;
  top: -5px;
  border-right: none;
  border-bottom: none;
  border-left: 1px solid rgba(0, 180, 216, 0.4);
  border-top: 1px solid rgba(0, 180, 216, 0.4);
}

/* Card Arrow Tip pointing down to Cloudee */
.fanm-avatar-card::after {
  content: "";
  position: absolute;
  bottom: -5px;
  right: 18px;
  left: auto;
  width: 10px;
  height: 10px;
  background: rgba(10, 22, 40, 0.96);
  border-right: 1px solid rgba(0, 180, 216, 0.4);
  border-bottom: 1px solid rgba(0, 180, 216, 0.4);
  transform: rotate(45deg);
}

.fanm-avatar-card.align-left::after {
  right: auto;
  left: 18px;
}

/* Bubble Header */
.fanm-avatar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  padding-bottom: 3px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: 6px;
}

.fanm-avatar-identity {
  display: flex;
  align-items: center;
  gap: 5px;
}

.fanm-avatar-name {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
  line-height: 1;
}

.fanm-avatar-tagline {
  font-size: 8.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fanm-cyan);
  background: rgba(0, 180, 216, 0.12);
  padding: 1px 4px;
  border-radius: 4px;
  line-height: 1.1;
}

.fanm-avatar-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  transition: color 0.15s;
}

.fanm-avatar-close-btn:hover {
  color: #fff;
}

/* Speech Text Body: crisp, small, one-liner */
.fanm-avatar-body {
  font-size: 11px;
  line-height: 1.35;
  color: #e2e8f0;
  word-break: break-word;
  white-space: normal;
}

.fanm-avatar-body strong {
  color: #fff;
  font-weight: 600;
}

.fanm-avatar-body em {
  color: var(--fanm-cyan);
  font-style: normal;
}

/* Direct Contact Chips in Bubble (WhatsApp / Direct Email) */
.fanm-avatar-contact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}

.fanm-avatar-contact-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 9.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 9999px;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
  border: 1px solid transparent;
}

.fanm-avatar-wa-btn {
  background: rgba(37, 211, 102, 0.16);
  border-color: rgba(37, 211, 102, 0.4);
  color: #25d366;
}

.fanm-avatar-wa-btn:hover {
  background: rgba(37, 211, 102, 0.3);
  color: #4ade80;
  transform: translateY(-1px);
}

.fanm-avatar-mail-btn {
  background: rgba(0, 180, 216, 0.16);
  border-color: rgba(0, 180, 216, 0.4);
  color: #38bdf8;
}

.fanm-avatar-mail-btn:hover {
  background: rgba(0, 180, 216, 0.28);
  color: #7dd3fc;
  transform: translateY(-1px);
}

/* Floating Zzz Particles during Sleep */
.fanm-sleep-zzz {
  position: absolute;
  top: -10px;
  right: -6px;
  font-size: 14px;
  font-weight: 800;
  color: #38bdf8;
  pointer-events: none;
  animation: fanm-zzz-float 2.2s ease-in-out infinite;
  text-shadow: 0 0 8px rgba(56, 189, 248, 0.8);
}

@keyframes fanm-zzz-float {
  0% { transform: translateY(0) scale(0.8); opacity: 0; }
  50% { opacity: 1; }
  100% { transform: translateY(-14px) translateX(6px) scale(1.2); opacity: 0; }
}

@keyframes fanm-halo-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
  :root {
    --fanm-roam-size: 46px;
  }
  .fanm-avatar-card {
    max-width: 175px;
    padding: 6px 8px;
    border-radius: 10px;
  }
  .fanm-avatar-body {
    font-size: 10.5px;
    line-height: 1.3;
  }
}

/* Accessibility: Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .fanm-roam-halo {
    animation: none !important;
  }
}
