/* 
 * Animation Styles
 * Keyframes and animation utilities
 */

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

@keyframes fadeOut {
  from { 
    opacity: 1; 
  }
  to { 
    opacity: 0; 
  }
}

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

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

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

@keyframes slideRight {
  from { 
    opacity: 0;
    transform: translateX(-20px); 
  }
  to { 
    opacity: 1;
    transform: translateX(0); 
  }
}

@keyframes scaleIn {
  from { 
    opacity: 0;
    transform: scale(0.9); 
  }
  to { 
    opacity: 1;
    transform: scale(1); 
  }
}

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

@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    transform: translateY(0);
  }
  40%, 43% {
    transform: translateY(-10px);
  }
  70% {
    transform: translateY(-5px);
  }
  90% {
    transform: translateY(-2px);
  }
}

@keyframes shake {
  0%, 100% { 
    transform: translateX(0); 
  }
  10%, 30%, 50%, 70%, 90% { 
    transform: translateX(-4px); 
  }
  20%, 40%, 60%, 80% { 
    transform: translateX(4px); 
  }
}

@keyframes pulse {
  0%, 100% { 
    opacity: 1; 
  }
  50% { 
    opacity: 0.7; 
  }
}

@keyframes glow {
  0%, 100% { 
    box-shadow: 
      var(--glass-shadow),
      0 0 5px currentColor; 
  }
  50% { 
    box-shadow: 
      var(--glass-shadow),
      0 0 20px currentColor,
      0 0 30px currentColor; 
  }
}

@keyframes spin {
  from { 
    transform: rotate(0deg); 
  }
  to { 
    transform: rotate(360deg); 
  }
}

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

@keyframes wiggle {
  0%, 7% {
    transform: rotateZ(0);
  }
  15% {
    transform: rotateZ(-15deg);
  }
  20% {
    transform: rotateZ(10deg);
  }
  25% {
    transform: rotateZ(-10deg);
  }
  30% {
    transform: rotateZ(6deg);
  }
  35% {
    transform: rotateZ(-4deg);
  }
  40%, 100% {
    transform: rotateZ(0);
  }
}

@keyframes heartbeat {
  0% {
    transform: scale(1);
  }
  14% {
    transform: scale(1.1);
  }
  28% {
    transform: scale(1);
  }
  42% {
    transform: scale(1.1);
  }
  70% {
    transform: scale(1);
  }
}

@keyframes rubberBand {
  from {
    transform: scale3d(1, 1, 1);
  }
  30% {
    transform: scale3d(1.25, 0.75, 1);
  }
  40% {
    transform: scale3d(0.75, 1.25, 1);
  }
  50% {
    transform: scale3d(1.15, 0.85, 1);
  }
  65% {
    transform: scale3d(0.95, 1.05, 1);
  }
  75% {
    transform: scale3d(1.05, 0.95, 1);
  }
  to {
    transform: scale3d(1, 1, 1);
  }
}

@keyframes jello {
  from, 11.1%, to {
    transform: translate3d(0, 0, 0);
  }
  22.2% {
    transform: skewX(-12.5deg) skewY(-12.5deg);
  }
  33.3% {
    transform: skewX(6.25deg) skewY(6.25deg);
  }
  44.4% {
    transform: skewX(-3.125deg) skewY(-3.125deg);
  }
  55.5% {
    transform: skewX(1.5625deg) skewY(1.5625deg);
  }
  66.6% {
    transform: skewX(-0.78125deg) skewY(-0.78125deg);
  }
  77.7% {
    transform: skewX(0.390625deg) skewY(0.390625deg);
  }
  88.8% {
    transform: skewX(-0.1953125deg) skewY(-0.1953125deg);
  }
}

/* ===== Game Specific Animations ===== */

@keyframes turnIndicatorPulse {
  0%, 100% { 
    box-shadow: 
      var(--glass-shadow),
      0 0 10px currentColor; 
  }
  50% { 
    box-shadow: 
      var(--glass-shadow),
      0 0 25px currentColor,
      0 0 40px currentColor; 
  }
}

@keyframes statusToastSlide {
  0% { 
    opacity: 0; 
    transform: translateY(-20px) scale(0.9); 
  }
  10% { 
    opacity: 1; 
    transform: translateY(0) scale(1); 
  }
  90% { 
    opacity: 1; 
    transform: translateY(0) scale(1); 
  }
  100% { 
    opacity: 0; 
    transform: translateY(-20px) scale(0.9); 
  }
}

@keyframes chatMessageAppear {
  from { 
    opacity: 0; 
    transform: translateY(10px) scale(0.95); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0) scale(1); 
  }
}

@keyframes popupSlideIn {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(-30px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes loadingSpinner {
  0% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  100% {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@keyframes glowBorder {
  0%, 100% {
    border-color: var(--border);
    box-shadow: var(--glass-shadow);
  }
  50% {
    border-color: var(--primary-400);
    box-shadow: 
      var(--glass-shadow),
      0 0 20px rgba(14, 165, 233, 0.4);
  }
}

/* ===== Animation Classes ===== */
.animate-fade-in {
  animation: fadeIn var(--transition-normal) ease-out;
}

.animate-fade-out {
  animation: fadeOut var(--transition-normal) ease-out;
}

.animate-slide-up {
  animation: slideUp var(--transition-normal) ease-out;
}

.animate-slide-down {
  animation: slideDown var(--transition-normal) ease-out;
}

.animate-slide-left {
  animation: slideLeft var(--transition-normal) ease-out;
}

.animate-slide-right {
  animation: slideRight var(--transition-normal) ease-out;
}

.animate-scale-in {
  animation: scaleIn var(--transition-normal) ease-out;
}

.animate-scale-out {
  animation: scaleOut var(--transition-normal) ease-out;
}

.animate-bounce {
  animation: bounce 1s ease-in-out;
}

.animate-shake {
  animation: shake 0.5s ease-in-out;
}

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

.animate-glow {
  animation: glow 2s ease-in-out infinite;
}

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

.animate-float {
  animation: float 3s ease-in-out infinite;
}

.animate-wiggle {
  animation: wiggle 1s ease-in-out;
}

.animate-heartbeat {
  animation: heartbeat 1.5s ease-in-out infinite;
}

.animate-rubber-band {
  animation: rubberBand 1s ease-in-out;
}

.animate-jello {
  animation: jello 1s ease-in-out;
}

/* ===== Game Specific Animation Classes ===== */
.animate-card-flip {
  animation: cardFlip 0.6s ease-in-out;
}

.animate-card-hover {
  animation: cardHover var(--transition-normal) ease-out forwards;
}

.animate-turn-pulse {
  animation: turnIndicatorPulse 2.4s ease-in-out infinite;
}

.animate-toast-slide {
  animation: statusToastSlide 2.5s ease-out forwards;
}

.animate-chat-appear {
  animation: chatMessageAppear 0.3s ease-out;
}

.animate-popup-slide {
  animation: popupSlideIn 0.3s ease-out;
}

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

.animate-glow-border {
  animation: glowBorder 2s ease-in-out infinite;
}

/* ===== Hover Animations ===== */
.hover-lift {
  transition: transform var(--transition-normal);
}

.hover-lift:hover {
  transform: translateY(-4px);
}

.hover-grow {
  transition: transform var(--transition-normal);
}

.hover-grow:hover {
  transform: scale(1.05);
}

.hover-shrink {
  transition: transform var(--transition-normal);
}

.hover-shrink:hover {
  transform: scale(0.95);
}

.hover-rotate {
  transition: transform var(--transition-normal);
}

.hover-rotate:hover {
  transform: rotate(5deg);
}

.hover-glow {
  transition: all var(--transition-normal);
}

.hover-glow:hover {
  box-shadow: 
    var(--glass-shadow),
    0 0 20px rgba(255, 255, 255, 0.2);
}

.hover-brighten {
  transition: filter var(--transition-normal);
}

.hover-brighten:hover {
  filter: brightness(1.2);
}

/* ===== Animation Utilities ===== */
.animation-delay-100 {
  animation-delay: 0.1s;
}

.animation-delay-200 {
  animation-delay: 0.2s;
}

.animation-delay-300 {
  animation-delay: 0.3s;
}

.animation-delay-500 {
  animation-delay: 0.5s;
}

.animation-duration-fast {
  animation-duration: var(--transition-fast);
}

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

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

.animation-infinite {
  animation-iteration-count: infinite;
}

.animation-once {
  animation-iteration-count: 1;
}

.animation-paused {
  animation-play-state: paused;
}

.animation-running {
  animation-play-state: running;
}

/* ===== Reduced Motion Support ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .animate-pulse,
  .animate-glow,
  .animate-float,
  .animate-heartbeat,
  .animate-turn-pulse,
  .animate-glow-border {
    animation: none !important;
  }
}
