/**
 * Professional Animations & Effects
 * King Size Game - Premium Experience
 * Version: 3.0.0
 */

/* ==========================================================================
   SUBTLE GLITCH EFFECTS
   ========================================================================== */

/* Refined glitch with minimal distortion */
@keyframes glitchSubtle {
  0%, 100% {
    transform: translate(0);
    filter: hue-rotate(0deg);
  }
  20% {
    transform: translate(-1px, 1px);
    filter: hue-rotate(90deg);
  }
  40% {
    transform: translate(-1px, -1px);
    filter: hue-rotate(180deg);
  }
  60% {
    transform: translate(1px, 1px);
    filter: hue-rotate(270deg);
  }
  80% {
    transform: translate(1px, -1px);
    filter: hue-rotate(360deg);
  }
}

.glitch-subtle {
  position: relative;
  animation: glitchSubtle 0.5s ease-in-out;
}

.glitch-subtle:hover {
  animation: glitchSubtle 0.2s ease-in-out infinite;
}

/* Professional glitch text effect */
.glitch-text {
  position: relative;
  display: inline-block;
}

.glitch-text::before,
.glitch-text::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
}

.glitch-text:hover::before {
  animation: glitchTextBefore 0.3s ease-in-out;
  opacity: 0.8;
}

.glitch-text:hover::after {
  animation: glitchTextAfter 0.3s ease-in-out;
  opacity: 0.8;
}

@keyframes glitchTextBefore {
  0%, 100% {
    clip-path: inset(0 0 0 0);
    transform: translate(0);
  }
  25% {
    clip-path: inset(10% 0 85% 0);
    transform: translate(-2px, -2px);
    text-shadow: 2px 2px 0 #00D4E6;
  }
  50% {
    clip-path: inset(80% 0 10% 0);
    transform: translate(2px, 2px);
    text-shadow: -2px -2px 0 #E91E63;
  }
  75% {
    clip-path: inset(40% 0 40% 0);
    transform: translate(-1px, 1px);
    text-shadow: 1px -1px 0 #7C4DFF;
  }
}

@keyframes glitchTextAfter {
  0%, 100% {
    clip-path: inset(0 0 0 0);
    transform: translate(0);
  }
  25% {
    clip-path: inset(85% 0 10% 0);
    transform: translate(2px, -1px);
    text-shadow: -2px 2px 0 #7C4DFF;
  }
  50% {
    clip-path: inset(10% 0 80% 0);
    transform: translate(-2px, 1px);
    text-shadow: 2px -2px 0 #00D4E6;
  }
  75% {
    clip-path: inset(50% 0 30% 0);
    transform: translate(1px, -2px);
    text-shadow: -1px 2px 0 #E91E63;
  }
}

/* ==========================================================================
   PREMIUM NEON EFFECTS
   ========================================================================== */

/* Soft neon glow */
.neon-soft {
  --neon-color: #00D4E6;
  color: var(--neon-color);
  text-shadow:
    0 0 5px rgba(0, 212, 230, 0.5),
    0 0 10px rgba(0, 212, 230, 0.3),
    0 0 15px rgba(0, 212, 230, 0.2);
  transition: all 0.3s ease;
}

.neon-soft:hover {
  text-shadow:
    0 0 10px rgba(0, 212, 230, 0.8),
    0 0 20px rgba(0, 212, 230, 0.6),
    0 0 30px rgba(0, 212, 230, 0.4),
    0 0 40px rgba(0, 212, 230, 0.2);
}

/* Animated neon border */
.neon-border {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.neon-border::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg,
    #00D4E6,
    #7C4DFF,
    #E91E63,
    #00D4E6
  );
  background-size: 400% 100%;
  border-radius: inherit;
  z-index: -1;
  opacity: 0.5;
  animation: neonBorderMove 4s linear infinite;
  filter: blur(4px);
}

@keyframes neonBorderMove {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* ==========================================================================
   HOLOGRAPHIC EFFECTS
   ========================================================================== */

.holographic {
  background: linear-gradient(
    135deg,
    #667eea 0%,
    #764ba2 20%,
    #f093fb 40%,
    #c471ed 60%,
    #667eea 80%,
    #764ba2 100%
  );
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: holographicShift 8s ease-in-out infinite;
}

@keyframes holographicShift {
  0%, 100% {
    background-position: 0% 50%;
    filter: hue-rotate(0deg);
  }
  25% {
    background-position: 50% 0%;
    filter: hue-rotate(45deg);
  }
  50% {
    background-position: 100% 50%;
    filter: hue-rotate(90deg);
  }
  75% {
    background-position: 50% 100%;
    filter: hue-rotate(45deg);
  }
}

/* ==========================================================================
   PARTICLE EFFECTS
   ========================================================================== */

.particle-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.particle {
  position: absolute;
  width: 2px;
  height: 2px;
  background: radial-gradient(circle, #00D4E6 0%, transparent 70%);
  border-radius: 50%;
  opacity: 0;
  animation: particleFloat 20s linear infinite;
}

@keyframes particleFloat {
  0% {
    opacity: 0;
    transform: translateY(100vh) scale(0) rotate(0deg);
  }
  10% {
    opacity: 1;
    transform: translateY(90vh) scale(1) rotate(36deg);
  }
  90% {
    opacity: 1;
    transform: translateY(10vh) scale(1) rotate(324deg);
  }
  100% {
    opacity: 0;
    transform: translateY(0) scale(0) rotate(360deg);
  }
}

/* Create multiple particles with different timings */
.particle:nth-child(1) { left: 10%; animation-delay: 0s; animation-duration: 18s; }
.particle:nth-child(2) { left: 20%; animation-delay: 2s; animation-duration: 20s; }
.particle:nth-child(3) { left: 30%; animation-delay: 4s; animation-duration: 22s; }
.particle:nth-child(4) { left: 40%; animation-delay: 6s; animation-duration: 19s; }
.particle:nth-child(5) { left: 50%; animation-delay: 8s; animation-duration: 21s; }
.particle:nth-child(6) { left: 60%; animation-delay: 10s; animation-duration: 17s; }
.particle:nth-child(7) { left: 70%; animation-delay: 12s; animation-duration: 23s; }
.particle:nth-child(8) { left: 80%; animation-delay: 14s; animation-duration: 20s; }
.particle:nth-child(9) { left: 90%; animation-delay: 16s; animation-duration: 18s; }
.particle:nth-child(10) { left: 95%; animation-delay: 18s; animation-duration: 24s; }

/* ==========================================================================
   SCANNING EFFECTS
   ========================================================================== */

.scan-line {
  position: relative;
  overflow: hidden;
}

.scan-line::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(0, 212, 230, 0.8),
    transparent
  );
  animation: scanMove 3s linear infinite;
}

@keyframes scanMove {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* Vertical scan effect */
.scan-vertical::after {
  content: '';
  position: absolute;
  top: -100%;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    180deg,
    transparent,
    rgba(0, 212, 230, 0.1),
    transparent
  );
  animation: scanVertical 4s linear infinite;
}

@keyframes scanVertical {
  0% { top: -100%; }
  100% { top: 100%; }
}

/* ==========================================================================
   PREMIUM HOVER EFFECTS
   ========================================================================== */

/* Smooth scale with shadow */
.hover-lift {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.hover-lift:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow:
    0 20px 40px rgba(0, 212, 230, 0.15),
    0 10px 20px rgba(124, 77, 255, 0.1);
}

/* 3D flip effect */
.hover-flip {
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.hover-flip:hover {
  transform: rotateY(10deg) rotateX(-10deg);
}

/* Magnetic effect */
.hover-magnetic {
  transition: transform 0.2s ease-out;
}

/* ==========================================================================
   LOADING ANIMATIONS
   ========================================================================== */

/* Premium spinner */
.spinner-premium {
  width: 50px;
  height: 50px;
  position: relative;
}

.spinner-premium::before,
.spinner-premium::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: #00D4E6;
  animation: spinnerRotate 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.spinner-premium::after {
  border-top-color: #7C4DFF;
  animation-delay: 0.5s;
}

@keyframes spinnerRotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Pulse loader */
.pulse-loader {
  display: inline-flex;
  gap: 8px;
}

.pulse-loader span {
  width: 12px;
  height: 12px;
  background: linear-gradient(135deg, #00D4E6, #7C4DFF);
  border-radius: 50%;
  animation: pulseLoad 1.4s ease-in-out infinite;
}

.pulse-loader span:nth-child(2) {
  animation-delay: 0.2s;
}

.pulse-loader span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes pulseLoad {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1.2);
    opacity: 1;
  }
}

/* ==========================================================================
   TRANSITION EFFECTS
   ========================================================================== */

/* Fade in from bottom */
.fade-in-up {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.fade-in-up.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger animation */
.stagger-item {
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.stagger-container.visible .stagger-item {
  opacity: 1;
  transform: translateY(0);
}

.stagger-container.visible .stagger-item:nth-child(1) { transition-delay: 0.1s; }
.stagger-container.visible .stagger-item:nth-child(2) { transition-delay: 0.2s; }
.stagger-container.visible .stagger-item:nth-child(3) { transition-delay: 0.3s; }
.stagger-container.visible .stagger-item:nth-child(4) { transition-delay: 0.4s; }
.stagger-container.visible .stagger-item:nth-child(5) { transition-delay: 0.5s; }

/* Reveal effect */
.reveal-text {
  position: relative;
  overflow: hidden;
}

.reveal-text::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  transform: translateX(-100%);
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-text.visible::after {
  transform: translateX(100%);
}

/* ==========================================================================
   BACKGROUND EFFECTS
   ========================================================================== */

/* Animated gradient background */
.bg-animated-gradient {
  background: linear-gradient(
    -45deg,
    #0A0A0F,
    #1A1A2E,
    #16213E,
    #0A0A0F
  );
  background-size: 400% 400%;
  animation: gradientShift 15s ease infinite;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* Matrix rain effect */
.matrix-rain {
  position: relative;
  overflow: hidden;
}

.matrix-rain::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 255, 65, 0.03) 2px,
    rgba(0, 255, 65, 0.03) 4px
  );
  animation: matrixRain 20s linear infinite;
  pointer-events: none;
}

@keyframes matrixRain {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(100%); }
}

/* ==========================================================================
   PERFORMANCE OPTIMIZATIONS
   ========================================================================== */

/* Hardware acceleration for smooth animations */
.gpu-accelerated {
  transform: translateZ(0);
  will-change: transform, opacity;
  backface-visibility: hidden;
  perspective: 1000px;
}

/* 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;
  }
}