/* ===================================
   Animation Definitions
   =================================== */

/* Respect user preference for reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===================================
   Fade Animations
   =================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.fade-in {
  animation: fadeIn 300ms ease-in;
}

.fade-out {
  animation: fadeOut 300ms ease-out;
}

/* ===================================
   Slide Animations
   =================================== */
@keyframes slideInLeft {
  from {
    transform: translateX(-120%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(120%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideInTop {
  from {
    transform: translateX(-50%) translateY(-200%);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

@keyframes slideInBottom {
  from {
    transform: translateX(-50%) translateY(200%);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

@keyframes slideOutLeft {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(-100%);
    opacity: 0;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

@keyframes slideOutTop {
  from {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
  to {
    transform: translateX(-50%) translateY(-200%);
    opacity: 0;
  }
}

@keyframes slideOutBottom {
  from {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
  to {
    transform: translateX(-50%) translateY(200%);
    opacity: 0;
  }
}

@keyframes slideOutCurrent {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.9);
  }
}

.slide-in-left {
  animation: slideInLeft 400ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

.slide-in-right {
  animation: slideInRight 400ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

.slide-in-top {
  animation: slideInTop 400ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

.slide-in-bottom {
  animation: slideInBottom 400ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* ===================================
   Scale Animations
   =================================== */
@keyframes scaleIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes scaleOut {
  from {
    transform: scale(1);
    opacity: 1;
  }
  to {
    transform: scale(0.8);
    opacity: 0;
  }
}

.scale-in {
  animation: scaleIn 300ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

.scale-out {
  animation: scaleOut 300ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* ===================================
   Pulse Animation (for attention)
   =================================== */
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.8;
  }
}

.pulse {
  animation: pulse 2s ease-in-out infinite;
}

/* ===================================
   Shake Animation (for errors)
   =================================== */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-4px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(4px);
  }
}

.shake {
  animation: shake 400ms ease-in-out;
}

/* ===================================
   Spin Animation (for loading)
   =================================== */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.spin {
  animation: spin 1s linear infinite;
}

/* ===================================
   Glow Animation (for neon effect)
   =================================== */
@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(0, 229, 255, 0.3),
                0 0 10px rgba(0, 229, 255, 0.2);
  }
  50% {
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.5),
                0 0 20px rgba(0, 229, 255, 0.3);
  }
}

.glow {
  animation: glow 2s ease-in-out infinite;
}

/* ===================================
   Bounce Animation (for success)
   =================================== */
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-20px);
  }
  60% {
    transform: translateY(-10px);
  }
}

.bounce {
  animation: bounce 1s ease-in-out;
}

/* ===================================
   Color Transition (for game circles)
   =================================== */
.color-transition {
  transition: background-color 300ms cubic-bezier(0.4, 0.0, 0.2, 1),
              border-color 300ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* ===================================
   Transform Transitions (GPU-accelerated)
   =================================== */
.transform-transition {
  transition: transform 250ms cubic-bezier(0.4, 0.0, 0.2, 1);
  will-change: transform;
}

/* Remove will-change after animation completes */
.transform-transition-end {
  will-change: auto;
}

/* ===================================
   Notification Slide Animations
   =================================== */
.notification-enter {
  animation: slideInBottom 400ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

.notification-exit {
  animation: fadeOut 300ms ease-out;
}

/* ===================================
   Modal Animations
   =================================== */
.modal-enter .modal-backdrop {
  animation: fadeIn 300ms ease-in;
}

.modal-enter .modal-content {
  animation: scaleIn 300ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

.modal-exit .modal-backdrop {
  animation: fadeOut 300ms ease-out;
}

.modal-exit .modal-content {
  animation: scaleOut 300ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* ===================================
   Game Card Unlock Animation
   =================================== */
@keyframes unlock {
  0% {
    transform: scale(1) rotate(0deg);
  }
  25% {
    transform: scale(1.1) rotate(-5deg);
  }
  75% {
    transform: scale(1.1) rotate(5deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

.unlock-animation {
  animation: unlock 600ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* ===================================
   Progress Bar Fill Animation
   =================================== */
.progress-fill-animate {
  transition: width 800ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* ===================================
   Distraction Overlay Animations
   =================================== */
.distraction-left {
  animation: slideInLeft 300ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

.distraction-right {
  animation: slideInRight 300ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

.distraction-top {
  animation: slideInTop 300ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

.distraction-bottom {
  animation: slideInBottom 300ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* ===================================
   Response Pulse Animation (for Focus Flow)
   =================================== */
@keyframes responsePulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(0, 229, 255, 0.7);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 20px 10px rgba(0, 229, 255, 0.4);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(0, 229, 255, 0);
  }
}

@keyframes responsePulseHit {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.7);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 0 25px 15px rgba(0, 255, 136, 0.5);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(0, 255, 136, 0);
  }
}

@keyframes responsePulseError {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 82, 82, 0.7);
  }
  50% {
    transform: scale(0.95);
    box-shadow: 0 0 20px 10px rgba(255, 82, 82, 0.4);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 82, 82, 0);
  }
}

.response-pulse {
  animation: responsePulse 300ms ease-out;
}

.response-pulse-hit {
  animation: responsePulseHit 400ms ease-out;
}

.response-pulse-error {
  animation: responsePulseError 300ms ease-out;
}

/* ===================================
   Utility Classes
   =================================== */
.no-animation {
  animation: none !important;
  transition: none !important;
}

.animate-once {
  animation-iteration-count: 1;
}

.animate-infinite {
  animation-iteration-count: infinite;
}

.delay-100 {
  animation-delay: 100ms;
}

.delay-200 {
  animation-delay: 200ms;
}

.delay-300 {
  animation-delay: 300ms;
}

.delay-500 {
  animation-delay: 500ms;
}
