/* ═══════════════════════════════════════════════════════════════
   SWIPECLEAN — ORBIT ASSISTANT
   Premium floating glass companion · vanilla implementation
   ═══════════════════════════════════════════════════════════════ */

.orbit-assistant {
  position: fixed;
  right: 34px;
  bottom: 34px;
  width: 78px;
  height: 78px;
  z-index: 8500;
  pointer-events: none;            /* only the core is interactive */
  --glow: 0.45;
  --ex: 0px;                       /* pupil offset X (set by JS) */
  --ey: 0px;                       /* pupil offset Y */
  --ring-speed: 14s;
  --core: #4648D4;
  --core2: #6B38D4;
}

/* gentle float for the whole companion */
.orbit-assistant {
  animation: orbit-float 5.5s ease-in-out infinite;
}
@keyframes orbit-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* ── Orbit ring (real element, state-driven) ───────────────────── */
.orbit-ring-el {
  position: absolute;
  top: 50%; left: 50%;
  width: 104px; height: 104px;
  margin: -52px 0 0 -52px;
  border-radius: 50%;
  border: 1.5px solid rgba(139,92,246,0.35);
  animation: orbit-ring-spin var(--ring-speed) linear infinite;
  transition: border-color .4s, width .4s, height .4s, margin .4s;
}
.orbit-ring-el::after {           /* the orbiting spark on the ring */
  content: '';
  position: absolute;
  top: -3px; left: 50%;
  width: 6px; height: 6px;
  margin-left: -3px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent), 0 0 16px rgba(139,92,246,0.5);
}
@keyframes orbit-ring-spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* second faint ring for depth */
.orbit-ring-el.ring-2 {
  width: 90px; height: 90px; margin: -45px 0 0 -45px;
  border-color: rgba(70,72,212,0.25);
  animation-direction: reverse;
  animation-duration: calc(var(--ring-speed) * 1.4);
}
.orbit-ring-el.ring-2::after { background: var(--primary); box-shadow: 0 0 8px var(--primary); }

/* ── Glass core ────────────────────────────────────────────────── */
.orbit-core {
  position: absolute;
  top: 50%; left: 50%;
  width: 72px; height: 72px;
  margin: -36px 0 0 -36px;
  border-radius: 50%;
  pointer-events: auto;
  cursor: pointer;
  background:
    radial-gradient(circle at 34% 30%, rgba(255,255,255,0.85) 0%, rgba(255,255,255,0.25) 18%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(167,139,250,0.55) 0%, rgba(70,72,212,0.6) 55%, rgba(107,56,212,0.7) 100%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.55);
  box-shadow:
    inset 0 2px 8px rgba(255,255,255,0.5),
    inset 0 -6px 14px rgba(70,72,212,0.5),
    0 8px 24px rgba(70,72,212,calc(var(--glow) * 0.9)),
    0 0 30px rgba(139,92,246,var(--glow));
  transition: box-shadow .45s var(--ease-out), transform .35s var(--ease-out);
  animation: orbit-breathe 4.5s ease-in-out infinite;
}
@keyframes orbit-breathe {
  0%, 100% { --glow: 0.4; }
  50%      { --glow: 0.62; }
}
/* (glow var animation fallback for browsers without @property) */
@keyframes orbit-breathe-shadow {
  0%, 100% { box-shadow: inset 0 2px 8px rgba(255,255,255,0.5), inset 0 -6px 14px rgba(70,72,212,0.5), 0 8px 24px rgba(70,72,212,0.35), 0 0 26px rgba(139,92,246,0.4); }
  50%      { box-shadow: inset 0 2px 8px rgba(255,255,255,0.5), inset 0 -6px 14px rgba(70,72,212,0.5), 0 10px 30px rgba(70,72,212,0.5),  0 0 40px rgba(139,92,246,0.62); }
}
.orbit-core { animation: orbit-breathe-shadow 4.5s ease-in-out infinite; }

.orbit-core:active { transform: scale(0.93); }

/* ── Eyes ──────────────────────────────────────────────────────── */
.orbit-eyes {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 10px;
  z-index: 2;
}
.orbit-eye {
  width: 11px; height: 15px;
  background: rgba(255,255,255,0.96);
  border-radius: 50%;
  position: relative;
  box-shadow: 0 0 6px rgba(255,255,255,0.6);
  animation: orbit-blink 5.5s infinite;
}
.orbit-eye .pupil {
  position: absolute;
  top: 50%; left: 50%;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #1a1535;
  transform: translate(calc(-50% + var(--ex)), calc(-50% + var(--ey)));
  transition: transform .12s linear;
}
@keyframes orbit-blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95%           { transform: scaleY(0.08); }
}

/* ── Speech bubble ─────────────────────────────────────────────── */
.orbit-bubble {
  position: absolute;
  bottom: 90px;
  right: 0;
  max-width: 220px;
  padding: 10px 14px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 10px 30px rgba(70,72,212,0.18);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text);
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px) scale(0.92);
  transform-origin: bottom right;
  transition: opacity .3s var(--ease-out), transform .3s var(--ease-out);
}
.orbit-bubble.show { opacity: 1; transform: translateY(0) scale(1); }

/* ── Spark particles (emitted via JS) ──────────────────────────── */
.orbit-spark {
  position: absolute;
  top: 50%; left: 50%;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  pointer-events: none;
  z-index: 3;
}

/* ── Mood states ───────────────────────────────────────────────── */
.orbit-assistant[data-mood="curious"] { --ring-speed: 9s; }
.orbit-assistant[data-mood="curious"] .orbit-core { transform: scale(1.05); }
.orbit-assistant[data-mood="curious"] .orbit-ring-el { border-color: rgba(139,92,246,0.6); }

.orbit-assistant[data-mood="hover"]   { --ring-speed: 7s; }
.orbit-assistant[data-mood="hover"] .orbit-core { transform: scale(1.08); }

.orbit-assistant[data-mood="thinking"] .orbit-ring-el { border-color: rgba(167,139,250,0.7); }

.orbit-assistant[data-mood="excited"] .orbit-core { animation: orbit-breathe-shadow 4.5s ease-in-out infinite, orbit-bounce 0.6s var(--ease-out); }
@keyframes orbit-bounce {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.18) translateY(-4px); }
  100% { transform: scale(1); }
}

.orbit-assistant[data-mood="celebrating"] { --ring-speed: 5s; }
.orbit-assistant[data-mood="celebrating"] .orbit-core {
  background:
    radial-gradient(circle at 34% 30%, rgba(255,255,255,0.9) 0%, transparent 42%),
    radial-gradient(circle at 50% 50%, rgba(134,239,172,0.55) 0%, rgba(34,197,94,0.55) 55%, rgba(70,72,212,0.6) 100%);
}

/* Future-AI transformation */
.orbit-assistant[data-mood="future_ai"] { --ring-speed: 6s; }
.orbit-assistant[data-mood="future_ai"] .orbit-ring-el {
  width: 120px; height: 120px; margin: -60px 0 0 -60px;
  border-color: rgba(139,92,246,0.75);
  box-shadow: 0 0 20px rgba(139,92,246,0.4);
}
.orbit-assistant[data-mood="future_ai"] .orbit-ring-el.ring-2 {
  width: 102px; height: 102px; margin: -51px 0 0 -51px;
}
.orbit-assistant[data-mood="future_ai"] .orbit-core {
  background:
    radial-gradient(circle at 34% 30%, rgba(255,255,255,0.85) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(196,181,253,0.6) 0%, rgba(139,92,246,0.7) 55%, rgba(107,56,212,0.85) 100%);
  box-shadow:
    inset 0 2px 8px rgba(255,255,255,0.5),
    inset 0 -6px 14px rgba(107,56,212,0.6),
    0 8px 28px rgba(139,92,246,0.55),
    0 0 50px rgba(139,92,246,0.7);
}

/* ── Toggle button (hide/show Orbit) ───────────────────────────── */
.orbit-toggle {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 8499;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  color: var(--text-secondary);
  display: none;                 /* shown only when Orbit hidden */
  align-items: center; justify-content: center;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
}
.orbit-dismiss {
  position: absolute;
  top: -4px; right: -4px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(17,24,39,0.85);
  color: #fff;
  font-size: 0.7rem;
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity .25s, transform .25s;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.2);
}
.orbit-assistant:hover .orbit-dismiss { opacity: 1; transform: scale(1); }

/* ── Mobile ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .orbit-assistant {
    right: 16px; bottom: 16px;
    width: 60px; height: 60px;
  }
  .orbit-core  { width: 56px; height: 56px; margin: -28px 0 0 -28px; }
  .orbit-ring-el { width: 80px; height: 80px; margin: -40px 0 0 -40px; }
  .orbit-ring-el.ring-2 { width: 70px; height: 70px; margin: -35px 0 0 -35px; }
  .orbit-bubble { bottom: 72px; max-width: 180px; font-size: 0.78rem; }
}

/* ── Reduced motion ────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .orbit-assistant,
  .orbit-core,
  .orbit-ring-el,
  .orbit-eye { animation: none !important; }
  .orbit-eye .pupil { transition: none; }
}
