/* Chess Puzzles - Custom Animations & Design System */

/* ============================================
   CSS CUSTOM PROPERTIES (Design Tokens)
   ============================================ */
:root {
  /* Primary Colors */
  --chess-amber-50: #fffbeb;
  --chess-amber-100: #fef3c7;
  --chess-amber-200: #fde68a;
  --chess-amber-300: #fcd34d;
  --chess-amber-400: #fbbf24;
  --chess-amber-500: #f59e0b;
  --chess-amber-600: #d97706;
  --chess-amber-700: #b45309;

  /* Slate Colors */
  --chess-slate-50: #f8fafc;
  --chess-slate-100: #f1f5f9;
  --chess-slate-200: #e2e8f0;
  --chess-slate-300: #cbd5e1;
  --chess-slate-400: #94a3b8;
  --chess-slate-500: #64748b;
  --chess-slate-600: #475569;
  --chess-slate-700: #334155;
  --chess-slate-800: #1e293b;
  --chess-slate-900: #0f172a;

  /* Success/Error Colors */
  --chess-green-100: #dcfce7;
  --chess-green-500: #22c55e;
  --chess-green-600: #16a34a;
  --chess-red-100: #fee2e2;
  --chess-red-500: #ef4444;
  --chess-red-600: #dc2626;

  /* Animation Durations */
  --duration-instant: 100ms;
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 350ms;
  --duration-slower: 500ms;

  /* Animation Easings */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.68, -0.55, 0.265, 1.55);

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-glow: 0 0 20px rgba(245, 158, 11, 0.3);
  --shadow-glow-green: 0 0 20px rgba(34, 197, 94, 0.3);

  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;

  /* Spacing Scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
}

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

/* Fade In */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Fade In Up */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade In Down */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* Scale In with Bounce */
@keyframes scaleInBounce {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

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

/* Slide In Right */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Pop In */
@keyframes popIn {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(10px);
  }
  70% {
    transform: scale(1.02) translateY(-2px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Shimmer (Loading) */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Pulse Glow */
@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(245, 158, 11, 0.4);
  }
  50% {
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.6), 0 0 40px rgba(245, 158, 11, 0.3);
  }
}

/* Success Pulse */
@keyframes successPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  }
  70% {
    transform: scale(1.02);
    box-shadow: 0 0 0 15px rgba(34, 197, 94, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

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

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

/* Rotate */
@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Bounce Subtle */
@keyframes bounceSubtle {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

/* Confetti Burst */
@keyframes confettiBurst {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--tx), var(--ty)) rotate(var(--rot)) scale(0.5);
  }
}

/* Card Hover Lift */
@keyframes cardLift {
  from {
    transform: translateY(0);
    box-shadow: var(--shadow-md);
  }
  to {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
  }
}

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

/* Animation Durations */
.animate-instant { animation-duration: var(--duration-instant); }
.animate-fast { animation-duration: var(--duration-fast); }
.animate-normal { animation-duration: var(--duration-normal); }
.animate-slow { animation-duration: var(--duration-slow); }
.animate-slower { animation-duration: var(--duration-slower); }

/* Animation Easings */
.ease-out-expo { animation-timing-function: var(--ease-out-expo); }
.ease-out-back { animation-timing-function: var(--ease-out-back); }
.ease-spring { animation-timing-function: var(--ease-spring); }

/* Animation Fill Mode */
.animate-fill-forwards { animation-fill-mode: forwards; }
.animate-fill-both { animation-fill-mode: both; }

/* Fade Animations */
.animate-fade-in {
  animation: fadeIn var(--duration-normal) var(--ease-out-expo) forwards;
}

.animate-fade-in-up {
  animation: fadeInUp var(--duration-normal) var(--ease-out-expo) forwards;
}

.animate-fade-in-down {
  animation: fadeInDown var(--duration-normal) var(--ease-out-expo) forwards;
}

/* Scale Animations */
.animate-scale-in {
  animation: scaleIn var(--duration-normal) var(--ease-out-expo) forwards;
}

.animate-scale-in-bounce {
  animation: scaleInBounce var(--duration-slow) var(--ease-out-back) forwards;
}

/* Slide Animations */
.animate-slide-in-left {
  animation: slideInLeft var(--duration-normal) var(--ease-out-expo) forwards;
}

.animate-slide-in-right {
  animation: slideInRight var(--duration-normal) var(--ease-out-expo) forwards;
}

/* Special Animations */
.animate-pop-in {
  animation: popIn var(--duration-slow) var(--ease-out-back) forwards;
}

.animate-shimmer {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.4) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

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

.animate-success {
  animation: successPulse 0.6s var(--ease-out-expo);
}

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

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

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

.animate-bounce-subtle {
  animation: bounceSubtle 2s ease-in-out infinite;
}

/* Stagger Animation Delays */
.stagger-1 { animation-delay: 50ms; }
.stagger-2 { animation-delay: 100ms; }
.stagger-3 { animation-delay: 150ms; }
.stagger-4 { animation-delay: 200ms; }
.stagger-5 { animation-delay: 250ms; }
.stagger-6 { animation-delay: 300ms; }
.stagger-7 { animation-delay: 350ms; }
.stagger-8 { animation-delay: 400ms; }

/* ============================================
   COMPONENT ANIMATIONS
   ============================================ */

/* Card Hover Effects */
.card-hover {
  transition: all var(--duration-fast) var(--ease-out-expo);
}

.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
}

/* Button Animations */
.btn-animate {
  transition: all var(--duration-fast) var(--ease-out-expo);
  position: relative;
  overflow: hidden;
}

.btn-animate::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width var(--duration-normal) var(--ease-out-expo),
              height var(--duration-normal) var(--ease-out-expo);
}

.btn-animate:hover::before {
  width: 300px;
  height: 300px;
}

.btn-animate:active {
  transform: scale(0.98);
}

/* Link Underline Animation */
.link-animate {
  position: relative;
  text-decoration: none;
}

.link-animate::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: currentColor;
  transition: width var(--duration-fast) var(--ease-out-expo);
}

.link-animate:hover::after {
  width: 100%;
}

/* Input Focus Animation */
.input-animate {
  transition: all var(--duration-fast) var(--ease-out-expo);
  border: 2px solid transparent;
}

.input-animate:focus {
  border-color: var(--chess-amber-500);
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.1);
  transform: translateY(-1px);
}

/* Badge/Pill Animations */
.badge-animate {
  transition: all var(--duration-fast) var(--ease-out-expo);
}

.badge-animate:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}

/* Icon Animations */
.icon-spin:hover {
  animation: rotate 0.5s var(--ease-out-expo);
}

.icon-bounce:hover {
  animation: bounceSubtle 0.5s var(--ease-out-expo);
}

/* ============================================
   PAGE TRANSITIONS (Turbo)
   ============================================ */

/* Turbo Loading Bar */
.turbo-progress-bar {
  height: 3px;
  background: linear-gradient(90deg, var(--chess-amber-500), var(--chess-amber-400), var(--chess-amber-500));
  background-size: 200% 100%;
  animation: shimmer 1s linear infinite;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

/* Page Transition Classes */
.page-transition-enter {
  opacity: 0;
  transform: translateY(10px);
}

.page-transition-enter-active {
  opacity: 1;
  transform: translateY(0);
  transition: all var(--duration-normal) var(--ease-out-expo);
}

.page-transition-exit {
  opacity: 1;
  transform: translateY(0);
}

.page-transition-exit-active {
  opacity: 0;
  transform: translateY(-10px);
  transition: all var(--duration-fast) var(--ease-in-out);
}

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

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--chess-slate-100) 0%,
    var(--chess-slate-200) 50%,
    var(--chess-slate-100) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 1em;
  margin-bottom: 0.5em;
}

.skeleton-text:last-child {
  width: 80%;
}

/* Loading Spinner */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--chess-slate-200);
  border-top-color: var(--chess-amber-500);
  border-radius: 50%;
  animation: rotate 0.8s linear infinite;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

/* ============================================
   SPECIAL EFFECTS
   ============================================ */

/* Glass Morphism */
.glass {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.glass-dark {
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Gradient Borders */
.gradient-border {
  position: relative;
  background: white;
  border-radius: var(--radius-lg);
}

.gradient-border::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--chess-amber-400), var(--chess-amber-600));
  z-index: -1;
}

/* Glow Effects */
.glow-amber {
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
}

.glow-green {
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
}

.glow-red {
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
}

/* ============================================
   RESPONSIVE ANIMATIONS (Reduced Motion)
   ============================================ */

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

  .animate-shimmer,
  .animate-pulse-glow,
  .animate-float,
  .animate-bounce-subtle,
  .skeleton {
    animation: none !important;
  }

  .spinner {
    animation: none;
    border-top-color: var(--chess-slate-400);
  }
}

/* ============================================
   UTILITY CLASSES - QUICK ACCESS
   ============================================ */

/* Opacity Utilities for Animations */
.opacity-0 { opacity: 0; }
.opacity-100 { opacity: 1; }

/* Transform Utilities */
.translate-y-4 { transform: translateY(1rem); }
.translate-y-0 { transform: translateY(0); }
.scale-95 { transform: scale(0.95); }
.scale-100 { transform: scale(1); }
.scale-105 { transform: scale(1.05); }

/* Transition Utilities */
.transition-all {
  transition-property: all;
  transition-timing-function: var(--ease-out-expo);
  transition-duration: var(--duration-fast);
}

.transition-transform {
  transition-property: transform;
  transition-timing-function: var(--ease-out-expo);
  transition-duration: var(--duration-fast);
}

.transition-opacity {
  transition-property: opacity;
  transition-timing-function: var(--ease-out-expo);
  transition-duration: var(--duration-fast);
}

.transition-shadow {
  transition-property: box-shadow;
  transition-timing-function: var(--ease-out-expo);
  transition-duration: var(--duration-fast);
}
