/* Parker presence orb.
   One living object shared by the signed-in app and the standalone pages.
   States: idle, listening, thinking, speaking, done, error.
   It stays mostly still and only reacts at moments that mean something:
   a slow settle when a reply starts arriving (speaking), a small warm
   brighten when it finishes (done), and a slower dim on a stop or error.
   Reduced motion shows a still orb in each state's resting look. */

.parker-orb {
  --orb-size: 64px;
  --orb-speed: 1;
  --orb-curve: cubic-bezier(0.22, 1, 0.36, 1);
  --orb-ember: #e85d24;
  --orb-deep: #9f3510;
  --orb-peach: #ffd3b8;
  --orb-cool: #b8c9dc;
  --orb-glow: rgba(232, 93, 36, 0.32);
  position: relative;
  display: inline-block;
  flex: none;
  width: var(--orb-size);
  height: var(--orb-size);
  font-size: var(--orb-size);
  isolation: isolate;
  pointer-events: none;
  vertical-align: middle;
}

.parker-orb > span {
  position: absolute;
  border-radius: 50%;
}

.orb-halo {
  inset: -34%;
  z-index: -1;
  background: radial-gradient(circle, var(--orb-glow) 0%, rgba(232, 93, 36, 0.12) 42%, rgba(232, 93, 36, 0) 68%);
  opacity: 0.55;
  animation: orb-halo calc(5.2s * var(--orb-speed)) var(--orb-curve) infinite;
}

.orb-body {
  inset: 0;
  overflow: hidden;
  background: radial-gradient(circle at 42% 38%, #fff3ea 0%, var(--orb-peach) 18%, #f7925c 42%, var(--orb-ember) 66%, #c8450f 86%, var(--orb-deep) 100%);
  box-shadow: inset 0 -0.06em 0.14em rgba(110, 30, 4, 0.22), inset 0 0 0.12em rgba(255, 210, 180, 0.55), 0 0 0.3em rgba(232, 93, 36, 0.28);
  animation: orb-breathe calc(5.2s * var(--orb-speed)) var(--orb-curve) infinite;
  transition: filter 1800ms var(--orb-curve);
}

/* Each swirl is a soft blob riding an orbit; rotating the orbit moves it. */
.orb-swirl {
  position: absolute;
  inset: 0;
  animation: orb-orbit calc(var(--swirl-period) * var(--orb-speed)) var(--orb-curve) infinite;
  animation-direction: var(--swirl-direction, normal);
}

.orb-swirl::before {
  content: "";
  position: absolute;
  width: var(--swirl-size);
  height: var(--swirl-size);
  left: var(--swirl-x);
  top: var(--swirl-y);
  border-radius: 50%;
  background: radial-gradient(circle, var(--swirl-color) 0%, transparent 70%);
  filter: blur(0.12em);
  mix-blend-mode: var(--swirl-blend, screen);
  opacity: 0.85;
}

.orb-swirl.a { --swirl-period: 9s; --swirl-size: 72%; --swirl-x: -8%; --swirl-y: -6%; --swirl-color: rgba(255, 236, 222, 0.95); }
.orb-swirl.b { --swirl-period: 13s; --swirl-size: 66%; --swirl-x: 38%; --swirl-y: 46%; --swirl-color: rgba(150, 40, 6, 0.6); --swirl-blend: multiply; --swirl-direction: reverse; }
.orb-swirl.c { --swirl-period: 17s; --swirl-size: 54%; --swirl-x: 50%; --swirl-y: 2%; --swirl-color: rgba(150, 178, 255, 0.7); }

.orb-sheen {
  inset: 10% 34% 58% 18%;
  background: radial-gradient(ellipse at 50% 50%, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 72%);
  opacity: 0.45;
  transform: rotate(-24deg);
}

.orb-ring {
  inset: 0;
  border: 1px solid rgba(232, 93, 36, 0.5);
  opacity: 0;
}

/* A warm inner light, raised briefly when Parker finishes. */
.orb-warmth {
  inset: 0;
  background: radial-gradient(circle at 44% 40%, rgba(255, 240, 222, 0.95) 0%, rgba(255, 186, 132, 0.45) 52%, rgba(255, 186, 132, 0) 76%);
  opacity: 0;
}

.parker-orb[data-state="listening"] { --orb-speed: 0.6; --orb-glow: rgba(232, 93, 36, 0.42); }
.parker-orb[data-state="listening"] .orb-halo { opacity: 0.8; }
.parker-orb[data-state="listening"] .orb-body { animation-name: orb-lean; }

.parker-orb[data-state="thinking"] { --orb-speed: 0.34; --orb-glow: rgba(232, 93, 36, 0.48); }
.parker-orb[data-state="thinking"] .orb-ring { animation: orb-ring 1.8s var(--orb-curve) infinite; }
.parker-orb[data-state="thinking"] .orb-ring.late { animation-delay: 0.9s; }

/* The reply starts arriving: the orb exhales once and settles into a calm breath. */
.parker-orb[data-state="speaking"] { --orb-speed: 1.3; --orb-glow: rgba(242, 122, 72, 0.42); }
.parker-orb[data-state="speaking"] .orb-halo { animation: orb-arrive-halo 1400ms var(--orb-curve) both, orb-halo calc(5.2s * var(--orb-speed)) var(--orb-curve) 1400ms infinite; }
.parker-orb[data-state="speaking"] .orb-body { animation: orb-arrive 1400ms var(--orb-curve) both, orb-breathe calc(5.2s * var(--orb-speed)) var(--orb-curve) 1400ms infinite; }

/* Finished: a small warm brighten, then rest. */
.parker-orb[data-state="done"] { --orb-speed: 1.6; --orb-glow: rgba(246, 140, 80, 0.5); }
.parker-orb[data-state="done"] .orb-halo { animation: orb-warm-halo 1200ms var(--orb-curve) both, orb-halo 8.3s var(--orb-curve) 1200ms infinite; }
.parker-orb[data-state="done"] .orb-warmth { animation: orb-warm 1200ms var(--orb-curve) both; }

/* Stopped or failed: a slow dim and stillness. Never a shake. */
.parker-orb[data-state="error"] { --orb-speed: 2.4; --orb-glow: rgba(111, 111, 107, 0.25); }
.parker-orb[data-state="error"] .orb-body { filter: grayscale(0.7); animation: orb-dim 1800ms var(--orb-curve) both; }
.parker-orb[data-state="error"] .orb-halo { animation: orb-dim-halo 1800ms var(--orb-curve) both; }

/* Mini orbs carry live state in tight spaces (sidebar rows, tool rows). */
.parker-orb.is-mini .orb-swirl,
.parker-orb.is-mini .orb-sheen,
.parker-orb.is-mini .orb-ring.late { display: none; }
.parker-orb.is-mini .orb-body { box-shadow: none; }
.parker-orb.is-mini .orb-halo { inset: -45%; }

@keyframes orb-halo {
  0%, 100% { opacity: 0.45; transform: scale(0.94); }
  50% { opacity: 0.8; transform: scale(1.06); }
}

@keyframes orb-breathe {
  0%, 100% { transform: scale(0.97); }
  50% { transform: scale(1.01); }
}

@keyframes orb-lean {
  0%, 100% { transform: scale(1.01) translateY(0); }
  50% { transform: scale(1.04) translateY(-2%); }
}

@keyframes orb-orbit {
  to { transform: rotate(360deg); }
}

@keyframes orb-ring {
  0% { opacity: 0.7; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.7); }
}

@keyframes orb-arrive {
  0% { transform: scale(1.07); }
  100% { transform: scale(0.97); }
}

@keyframes orb-arrive-halo {
  0% { opacity: 0.9; transform: scale(1.14); }
  100% { opacity: 0.45; transform: scale(0.94); }
}

@keyframes orb-warm {
  0% { opacity: 0; }
  35% { opacity: 0.55; }
  100% { opacity: 0.12; }
}

@keyframes orb-warm-halo {
  0% { opacity: 0.5; transform: scale(0.96); }
  35% { opacity: 1; transform: scale(1.12); }
  100% { opacity: 0.6; transform: scale(1); }
}

@keyframes orb-dim {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0.62; transform: scale(0.96); }
}

@keyframes orb-dim-halo {
  0% { opacity: 0.55; }
  100% { opacity: 0.12; }
}

@media (prefers-reduced-motion: reduce) {
  .parker-orb,
  .parker-orb * {
    animation: none !important;
  }
  .parker-orb[data-state="thinking"] .orb-halo,
  .parker-orb[data-state="speaking"] .orb-halo { opacity: 0.9; }
  .parker-orb[data-state="done"] .orb-warmth { opacity: 0.12; }
  .parker-orb[data-state="error"] .orb-body { opacity: 0.62; transition: none; }
  .parker-orb[data-state="error"] .orb-halo { opacity: 0.12; }
}
