/* ============================================================
   TORUS ANIMATION SYSTEM
   All motion respects prefers-reduced-motion.
   Requires design-tokens.css to be loaded first.
   ============================================================ */

/* ── KEYFRAMES ───────────────────────────────────────────── */

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

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

@keyframes t-scale-in {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1);    }
}

@keyframes t-bounce-in {
  0%   { transform: scale(0.5);  opacity: 0; }
  60%  { transform: scale(1.12);             }
  80%  { transform: scale(0.95);             }
  100% { transform: scale(1);    opacity: 1; }
}

@keyframes t-shimmer {
  from { background-position: -600px 0; }
  to   { background-position:  600px 0; }
}

@keyframes t-pulse-gold {
  0%,  100% { box-shadow: 0 0 0 0   rgba(110, 78, 242, 0.00); }
  50%        { box-shadow: 0 0 0 6px rgba(110, 78, 242, 0.22); }
}

@keyframes t-spin {
  to { transform: rotate(360deg); }
}

/* ── FLOATING WORLD MOTION (illustrations, badges, particles) ── */

@keyframes t-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-14px); }
}

@keyframes t-float-sm {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

@keyframes t-glow-soft {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

@keyframes t-spin-slow {
  to { transform: rotate(360deg); }
}

@keyframes t-shimmer-badge {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* ── EXPLICIT ANIMATION CLASSES ──────────────────────────── */

.t-anim-fade-up  { animation: t-fade-up  400ms var(--ease-spring) both; }
.t-anim-fade-in  { animation: t-fade-in  300ms ease              both; }
.t-anim-scale-in { animation: t-scale-in 350ms var(--ease-spring) both; }
.t-anim-bounce   { animation: t-bounce-in 600ms var(--ease-spring) both; }

/* Stagger delays — apply .t-stagger to the parent */
.t-stagger > *:nth-child(1) { animation-delay:   0ms; }
.t-stagger > *:nth-child(2) { animation-delay:  60ms; }
.t-stagger > *:nth-child(3) { animation-delay: 120ms; }
.t-stagger > *:nth-child(4) { animation-delay: 180ms; }
.t-stagger > *:nth-child(5) { animation-delay: 240ms; }
.t-stagger > *:nth-child(6) { animation-delay: 300ms; }
.t-stagger > *:nth-child(7) { animation-delay: 360ms; }
.t-stagger > *:nth-child(8) { animation-delay: 420ms; }

/* ── SCROLL REVEAL (JS controlled via IntersectionObserver) ─ */

.t-reveal {
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity   400ms var(--ease-spring),
    transform 400ms var(--ease-spring);
}

.t-reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── HOVER LIFT ──────────────────────────────────────────── */

.t-hover-lift {
  transition: transform var(--transition-slow) var(--ease-spring), box-shadow var(--transition);
}
.t-hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

/* ── FLOATING ILLUSTRATIONS / BADGES ─────────────────────── */
/* Slow, elegant, never distracting — apply to hero art, badges, chess icons */

.t-float {
  animation: t-float 6s ease-in-out infinite;
}

.t-float-sm {
  animation: t-float-sm 5s ease-in-out infinite;
}

.t-float-delay-1 { animation-delay: 1.2s; }
.t-float-delay-2 { animation-delay: 2.4s; }

.t-glow-soft {
  animation: t-glow-soft 4s ease-in-out infinite;
}

.t-spin-slow {
  animation: t-spin-slow 18s linear infinite;
}

/* ── SKELETON LOADING ────────────────────────────────────── */

.t-skeleton {
  background: linear-gradient(90deg,
    var(--surface-raised) 25%,
    var(--surface-border) 50%,
    var(--surface-raised) 75%
  );
  background-size: 1200px 100%;
  animation: t-shimmer 1.5s infinite linear;
  border-radius: var(--radius-sm);
  color: transparent !important;
  pointer-events: none;
  user-select: none;
}

.t-skeleton-dark {
  background: linear-gradient(90deg,
    rgba(255,255,255,0.05) 25%,
    rgba(255,255,255,0.10) 50%,
    rgba(255,255,255,0.05) 75%
  );
  background-size: 1200px 100%;
  animation: t-shimmer 1.5s infinite linear;
}

/* ── PROGRESS BAR — animated width ──────────────────────── */

[data-progress-fill] {
  width: 0% !important;
  transition: width 0.8s var(--ease-spring);
}

/* ── COUNTER — numeric display reset ─────────────────────── */

[data-counter] {
  font-variant-numeric: tabular-nums;
}

/* ── GOLD PULSE (streaks, notifications) ─────────────────── */

.t-pulse-gold {
  animation: t-pulse-gold 2s ease-in-out infinite;
}

/* ── SPINNER ─────────────────────────────────────────────── */

.t-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(110, 78, 242, 0.3);
  border-top-color: var(--origin);
  border-radius: 50%;
  animation: t-spin 0.65s linear infinite;
  vertical-align: middle;
}

/* ── REDUCED MOTION ──────────────────────────────────────── */

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

  .t-reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .t-skeleton,
  .t-skeleton-dark {
    animation: none;
    background: #f0f0f0;
  }

  [data-progress-fill] {
    transition: none;
  }
}
