/* ===========================================
   Y2K DESIGN SYSTEM — MOTION TOKENS
   BPM-synced keyframes (130-170 BPM range)
   Respects prefers-reduced-motion
   =========================================== */

:root {
  /* --- BPM Timing (default: 140 BPM) --- */
  --bpm: 140;
  --beat: calc(60s / var(--bpm));           /* ~428ms */
  --half-beat: calc(var(--beat) / 2);       /* ~214ms */
  --double-beat: calc(var(--beat) * 2);     /* ~857ms */
  --bar: calc(var(--beat) * 4);             /* ~1714ms */

  /* --- Easing --- */
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-sharp: cubic-bezier(0.4, 0, 0.6, 1);
  --ease-chaos: cubic-bezier(0.68, -0.55, 0.27, 1.55);

  /* --- Functional transitions --- */
  --transition-fast: 150ms var(--ease-smooth);
  --transition-base: 250ms var(--ease-smooth);
  --transition-slow: 400ms var(--ease-smooth);
}

/* --- Decorative Keyframes (chaos layer only) --- */

@keyframes pulse-glow {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.02); }
}

@keyframes drift-horizontal {
  0% { transform: translateX(-5%); }
  50% { transform: translateX(5%); }
  100% { transform: translateX(-5%); }
}

@keyframes drift-vertical {
  0% { transform: translateY(-3%); }
  50% { transform: translateY(3%); }
  100% { transform: translateY(-3%); }
}

@keyframes rotate-slow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes flicker {
  0%, 95%, 100% { opacity: 1; }
  96% { opacity: 0.4; }
  97% { opacity: 0.9; }
  98% { opacity: 0.3; }
}

@keyframes glitch-shift {
  0%, 90%, 100% { transform: translate(0); }
  92% { transform: translate(-2px, 1px); }
  94% { transform: translate(2px, -1px); }
  96% { transform: translate(-1px, 2px); }
}

@keyframes noise-scroll {
  0% { background-position: 0 0; }
  100% { background-position: 100% 100%; }
}

@keyframes beat-scale {
  0%, 100% { transform: scale(1); }
  10% { transform: scale(1.05); }
  20% { transform: scale(1); }
}

/* --- Utility Classes --- */

.animate-pulse-glow {
  animation: pulse-glow var(--bar) ease-in-out infinite;
}

.animate-drift-h {
  animation: drift-horizontal calc(var(--bar) * 4) ease-in-out infinite;
}

.animate-drift-v {
  animation: drift-vertical calc(var(--bar) * 3) ease-in-out infinite;
}

.animate-rotate {
  animation: rotate-slow calc(var(--bar) * 8) linear infinite;
}

.animate-flicker {
  animation: flicker calc(var(--bar) * 2) steps(1) infinite;
}

.animate-glitch {
  animation: glitch-shift calc(var(--bar) * 3) steps(1) infinite;
}

.animate-beat {
  animation: beat-scale var(--beat) var(--ease-bounce) infinite;
}

/* --- ACCESSIBILITY: Respect reduced motion --- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
