/**
 * Robinx Animation System
 * Comprehensive animations following design system specifications
 * Duration: 150-250ms for smooth, responsive feel
 * Never exceeding 300ms for accessibility
 */

/* ============================================================================
 * KEYFRAME ANIMATIONS
 * ========================================================================== */

/* Fade animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* Slide animations */
@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Scale animations */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

/* Pulse animation for live indicators */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Spin animation for loaders */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Bounce animation */
@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

/* Shimmer animation for loading states */
@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* Shake animation for errors */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

/* ============================================================================
 * UTILITY ANIMATION CLASSES
 * ========================================================================== */

/* Fade animations - 200ms standard duration */
.animate-fade-in {
  animation: fadeIn 200ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.animate-fade-out {
  animation: fadeOut 200ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* Slide animations - 250ms for better visibility */
.animate-slide-in-left {
  animation: slideInLeft 250ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.animate-slide-in-right {
  animation: slideInRight 250ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.animate-slide-in-up {
  animation: slideInUp 250ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.animate-slide-in-down {
  animation: slideInDown 250ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* Scale animations - 200ms for responsive feel */
.animate-scale-in {
  animation: scaleIn 200ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.animate-scale-out {
  animation: scaleOut 200ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* Standard pulse for live indicators */
.animate-pulse-live {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Standard spin for loaders */
.animate-spin-loader {
  animation: spin 1s linear infinite;
}

/* Bounce animation */
.animate-bounce-in {
  animation: bounce 600ms cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

/* Shimmer loading animation */
.animate-shimmer {
  animation: shimmer 2s infinite;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.2) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  background-size: 1000px 100%;
}

/* Shake error animation */
.animate-shake {
  animation: shake 400ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* ============================================================================
 * TRANSITION UTILITIES
 * ========================================================================== */

/* Smooth transitions for interactive elements */
.transition-smooth {
  transition: all 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.transition-smooth-fast {
  transition: all 100ms cubic-bezier(0.4, 0, 0.6, 1);
}

.transition-smooth-slow {
  transition: all 250ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Specific property transitions */
.transition-colors-smooth {
  transition: background-color 150ms cubic-bezier(0.2, 0.8, 0.2, 1),
              color 150ms cubic-bezier(0.2, 0.8, 0.2, 1),
              border-color 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.transition-transform-smooth {
  transition: transform 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.transition-opacity-smooth {
  transition: opacity 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.transition-shadow-smooth {
  transition: box-shadow 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ============================================================================
 * HOVER ANIMATIONS
 * ========================================================================== */

/* Lift effect for cards/buttons */
.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.hover-lift {
  transition: all 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Grow effect for interactive elements */
.hover-grow:hover {
  transform: scale(1.02);
}

.hover-grow {
  transition: transform 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Glow effect for highlighted elements */
.hover-glow:hover {
  filter: brightness(1.1);
}

.hover-glow {
  transition: filter 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ============================================================================
 * PERFORMANCE OPTIMIZATION
 * ========================================================================== */

/* Enable GPU acceleration for animations */
.will-animate {
  will-change: transform, opacity;
}

.will-animate-scroll {
  will-change: scroll-position;
}

/* Disable animations for 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;
    scroll-behavior: auto !important;
  }
}

/* ============================================================================
 * RESPONSIVE ANIMATION ADJUSTMENTS
 * ========================================================================== */

/* Slower animations on mobile for better performance */
@media (max-width: 768px) {
  .animate-slide-in-left,
  .animate-slide-in-right,
  .animate-slide-in-up,
  .animate-slide-in-down {
    animation-duration: 200ms;
  }

  .transition-smooth-slow {
    transition-duration: 200ms;
  }
}

/* ============================================================================
 * LOADING STATES
 * ========================================================================== */

/* Skeleton loading animation */
@keyframes skeleton-loading {
  0% {
    background-color: rgba(200, 200, 200, 0.1);
  }
  50% {
    background-color: rgba(200, 200, 200, 0.3);
  }
  100% {
    background-color: rgba(200, 200, 200, 0.1);
  }
}

.skeleton {
  animation: skeleton-loading 1.5s infinite;
  border-radius: 4px;
}

/* ============================================================================
 * FOCUS AND INTERACTION STATES
 * ========================================================================== */

/* Enhanced focus states for keyboard navigation */
.focus-ring {
  outline: none;
  ring-width: 2px;
  ring-color: rgba(124, 58, 237, 0.5);
}

/* Smooth focus transitions */
.focus-transition {
  transition: box-shadow 150ms cubic-bezier(0.2, 0.8, 0.2, 1),
              outline 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Active state animation */
.active-state:active {
  transform: scale(0.98);
}

.active-state {
  transition: transform 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
