/* ==========================================================================
   EDISON — Animation System & Keyframes (Part 9)
   ========================================================================== */

/* ---------------------------------------------------------------------------
   AN-21: Holographic Gradient Cycle (30s continuous)
   --------------------------------------------------------------------------- */
@keyframes holo-shift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.anim-holo-gradient {
  background-size: 200% 200%;
  animation: holo-shift 30s ease infinite;
}

/* ---------------------------------------------------------------------------
   AN-22: Orbital Rotation (60s continuous)
   --------------------------------------------------------------------------- */
@keyframes orbital-rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes orbital-rotate-reverse {
  from {
    transform: rotate(360deg);
  }
  to {
    transform: rotate(0deg);
  }
}

.anim-orbital-clockwise {
  animation: orbital-rotate 60s linear infinite;
  transform-origin: center;
}

.anim-orbital-counter {
  animation: orbital-rotate-reverse 45s linear infinite;
  transform-origin: center;
}

/* ---------------------------------------------------------------------------
   AN-23: Intelligence Orb Pulse (2400ms continuous)
   --------------------------------------------------------------------------- */
@keyframes orb-pulse {
  0% {
    opacity: 0.6;
    transform: scale(0.98);
  }
  50% {
    opacity: 1;
    transform: scale(1.02);
  }
  100% {
    opacity: 0.6;
    transform: scale(0.98);
  }
}

.anim-orb-pulse {
  animation: orb-pulse 2.4s ease-in-out infinite;
  transform-origin: center;
}

/* ---------------------------------------------------------------------------
   AN-24: Live Indicator Pulse (2000ms continuous)
   --------------------------------------------------------------------------- */
@keyframes pulse-live {
  0% {
    transform: scale(0.92);
    box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.4);
  }
  70% {
    transform: scale(1.08);
    box-shadow: 0 0 0 6px rgba(124, 58, 237, 0);
  }
  100% {
    transform: scale(0.92);
    box-shadow: 0 0 0 0 rgba(124, 58, 237, 0);
  }
}

/* ---------------------------------------------------------------------------
   AN-25: Flame Flicker (Streak active continuous)
   --------------------------------------------------------------------------- */
@keyframes flame-flicker {
  0%, 100% {
    transform: scale(1) rotate(0deg);
    filter: drop-shadow(0 0 4px rgba(245, 166, 35, 0.4));
  }
  25% {
    transform: scale(1.06) rotate(-2deg);
    filter: drop-shadow(0 0 8px rgba(232, 69, 69, 0.5));
  }
  75% {
    transform: scale(0.96) rotate(2deg);
    filter: drop-shadow(0 0 6px rgba(245, 166, 35, 0.6));
  }
}

.anim-flame {
  animation: flame-flicker 1.8s ease-in-out infinite;
  transform-origin: bottom center;
}

/* ---------------------------------------------------------------------------
   AN-01 & AN-02: Initial Loader & Hero Entrance
   --------------------------------------------------------------------------- */
#app-loader {
  position: fixed;
  inset: 0;
  background: var(--canvas-base);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  transition: opacity 240ms var(--ease-in), visibility 240ms;
}

body.app-loading .main-stage {
  opacity: 0;
}

body:not(.app-loading) .main-stage {
  animation: stage-fade-in 400ms var(--ease-out) both;
}

#app-loader.loaded {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-brand {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.4em;
  color: var(--text-primary);
  text-transform: uppercase;
  margin-top: var(--space-3);
  animation: fade-up 600ms var(--ease-out) 200ms both;
}

.loader-bar-wrap {
  width: var(--loader-bar-width);
  height: var(--loader-bar-height);
  background: var(--canvas-mist);
  border-radius: var(--radius-pill);
  overflow: hidden;
  position: relative;
}

.loader-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-violet));
  border-radius: var(--radius-pill);
  animation: loader-fill 1000ms var(--ease-out) both;
}

.loader-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--canvas-mist);
  border-top-color: var(--accent-violet);
  border-radius: 50%;
}

@keyframes loader-fill {
  from { width: 0%; }
  to { width: 100%; }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes stage-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.hero-animate-in {
  animation: fade-up 600ms var(--ease-out) both;
}

/* Stagger reveals */
.stagger-1 { animation-delay: 60ms; }
.stagger-2 { animation-delay: 120ms; }
.stagger-3 { animation-delay: 180ms; }
.stagger-4 { animation-delay: 240ms; }

/* ---------------------------------------------------------------------------
   AN-12 & AN-13: Toasts & Popovers
   --------------------------------------------------------------------------- */
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes popover-fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------------------------------------------------------------------------
   AN-17: XP Float-Up Animation
   --------------------------------------------------------------------------- */
@keyframes xp-float {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.8);
  }
  20% {
    opacity: 1;
    transform: translateY(-8px) scale(1.1);
  }
  80% {
    opacity: 0.9;
    transform: translateY(-24px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-36px) scale(0.9);
  }
}

.xp-float-toast {
  position: absolute;
  pointer-events: none;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--accent-violet);
  background: var(--canvas-pearl);
  border: 1px solid var(--accent-violet-bright);
  box-shadow: 0 0 12px var(--accent-violet-glow-strong);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  animation: xp-float 1600ms var(--ease-out) forwards;
  z-index: 9999;
}

/* ---------------------------------------------------------------------------
   9.2 Reduced Motion Fallbacks
   --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .anim-orbital-clockwise,
  .anim-orbital-counter,
  .anim-orb-pulse,
  .anim-flame,
  .anim-holo-gradient {
    animation: none !important;
  }

  #app-loader {
    transition: none !important;
  }

  #app-loader .loader-signature,
  #app-loader .loader-bar-wrap {
    display: none !important;
  }

  #app-loader .loader-brand {
    margin-top: 0;
    animation: none !important;
  }

  #app-loader .loader-spinner {
    display: block;
  }

  #app-loader.loaded {
    display: none !important;
  }

  body.app-loading .main-stage,
  body:not(.app-loading) .main-stage {
    opacity: 1;
    animation: none !important;
  }
}

/* Motion Settings Off */
[data-motion="off"] *,
[data-motion="off"] *::before,
[data-motion="off"] *::after {
  animation: none !important;
  transition: none !important;
}
