/* ═══════════════════════════════════════════════════════════════════════════
   QUANTUM TRADER — Animation Tokens & Keyframes
   Duration and easing CSS variables + reusable keyframe animations.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Duration + Easing variables (defined in design-tokens.css) ───
   --duration-instant: 0ms
   --duration-fast:    100ms
   --duration-normal:  200ms
   --duration-slow:    400ms
   --easing-linear:    linear
   --easing-in:        cubic-bezier(0.4, 0, 1, 1)
   --easing-out:       cubic-bezier(0, 0, 0.2, 1)
   --easing-in-out:    cubic-bezier(0.4, 0, 0.2, 1)
   ────────────────────────────────────────────────────────── */

/* ─── Utility classes for animation ──────────────────────── */
.animate-fast {
  transition-duration: var(--duration-fast);
}

.animate-normal {
  transition-duration: var(--duration-normal);
}

.animate-slow {
  transition-duration: var(--duration-slow);
}

.animate-ease-out {
  transition-timing-function: var(--easing-out);
}

.animate-ease-in-out {
  transition-timing-function: var(--easing-in-out);
}

/* ─── Keyframe: fadeIn ───────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.animate-fade-in {
  animation: fadeIn var(--duration-normal) var(--easing-out) forwards;
}

/* ─── Keyframe: fadeInUp ─────────────────────────────────── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in-up {
  animation: fadeInUp var(--duration-normal) var(--easing-out) forwards;
}

/* ─── Keyframe: slideInRight ──────────────────────────────── */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

.animate-slide-in-right {
  animation: slideInRight var(--duration-slow) var(--easing-out) forwards;
}

/* ─── Keyframe: pulse (for loading states) ───────────────── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

.animate-pulse {
  animation: pulse 2s var(--easing-in-out) infinite;
}

/* ─── Keyframe: spin (for loader icons) ──────────────────── */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* ─── Keyframe: shimmer (skeleton loading) ────────────────── */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.animate-shimmer {
  background: linear-gradient(
    90deg,
    var(--theme-surface) 25%,
    var(--theme-surface-hover) 50%,
    var(--theme-surface) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s var(--easing-in-out) infinite;
}

/* ─── Keyframe: dataUpdate (flash for changing values) ───── */
@keyframes dataUpdate {
  0%   { background-color: transparent; }
  50%  { background-color: var(--color-primary-700); }
  100% { background-color: transparent; }
}

.animate-data-update {
  animation: dataUpdate var(--duration-normal) var(--easing-out) 1;
}

/* ─── Keyframe: scaleIn (for modals/dialogs) ──────────────── */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.animate-scale-in {
  animation: scaleIn var(--duration-normal) var(--easing-out) forwards;
}

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