/* XSSNow - Advanced Animations & Effects */

/* Keyframes */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes glow {
  from {
    box-shadow: 0 0 10px rgba(0, 255, 65, 0.3);
  }
  to {
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.6), 0 0 30px rgba(0, 255, 65, 0.4);
  }
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

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

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

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

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

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

@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
    transform: translate3d(0, 0, 0);
  }
  40%, 43% {
    animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
    transform: translate3d(0, -10px, 0);
  }
  70% {
    animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
    transform: translate3d(0, -5px, 0);
  }
  90% {
    transform: translate3d(0, -2px, 0);
  }
}

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

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

@keyframes matrix-fall {
  0% {
    transform: translateY(-100vh);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh);
    opacity: 0;
  }
}

@keyframes glitch {
  0%, 100% {
    transform: translate(0);
  }
  10% {
    transform: translate(-2px, 2px);
  }
  20% {
    transform: translate(-3px, 0px);
  }
  30% {
    transform: translate(3px, 2px);
  }
  40% {
    transform: translate(-1px, -1px);
  }
  50% {
    transform: translate(2px, 2px);
  }
  60% {
    transform: translate(-2px, 1px);
  }
  70% {
    transform: translate(3px, 1px);
  }
  80% {
    transform: translate(-1px, -1px);
  }
  90% {
    transform: translate(1px, 2px);
  }
}

@keyframes textShadowGlitch {
  0% {
    text-shadow: 0.05em 0 0 #00ffff, -0.03em -0.04em 0 #ff00ff, 0.025em 0.04em 0 #ffff00;
  }
  15% {
    text-shadow: 0.05em 0 0 #00ffff, -0.03em -0.04em 0 #ff00ff, 0.025em 0.04em 0 #ffff00;
  }
  16% {
    text-shadow: -0.05em -0.025em 0 #00ffff, 0.025em 0.035em 0 #ff00ff, -0.05em -0.05em 0 #ffff00;
  }
  49% {
    text-shadow: -0.05em -0.025em 0 #00ffff, 0.025em 0.035em 0 #ff00ff, -0.05em -0.05em 0 #ffff00;
  }
  50% {
    text-shadow: 0.05em 0.035em 0 #00ffff, 0.03em 0 0 #ff00ff, 0 -0.04em 0 #ffff00;
  }
  99% {
    text-shadow: 0.05em 0.035em 0 #00ffff, 0.03em 0 0 #ff00ff, 0 -0.04em 0 #ffff00;
  }
  100% {
    text-shadow: -0.05em 0 0 #00ffff, -0.025em -0.04em 0 #ff00ff, -0.04em -0.025em 0 #ffff00;
  }
}

@keyframes typing {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes scanline {
  0%, 100% {
    transform: translateX(-100%);
  }
  50% {
    transform: translateX(100vw);
  }
}

@keyframes neonBorderGlow {
  0%, 100% {
    border-color: rgba(0, 255, 65, 0.5);
    box-shadow:
      0 0 5px rgba(0, 255, 65, 0.5),
      inset 0 0 5px rgba(0, 255, 65, 0.2);
  }
  50% {
    border-color: rgba(0, 255, 65, 1);
    box-shadow:
      0 0 20px rgba(0, 255, 65, 0.8),
      0 0 30px rgba(0, 255, 65, 0.6),
      inset 0 0 10px rgba(0, 255, 65, 0.4);
  }
}

@keyframes dataFlow {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* Animation Classes */
.animate-fade-in {
  animation: fadeIn 0.8s ease-out;
}

.animate-fade-in-up {
  animation: fadeInUp 0.8s ease-out;
}

.animate-slide-in-left {
  animation: slideInLeft 0.8s ease-out;
}

.animate-slide-in-right {
  animation: slideInRight 0.8s ease-out;
}

.animate-slide-in-up {
  animation: slideInUp 0.8s ease-out;
}

.animate-bounce {
  animation: bounce 2s infinite;
}

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

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

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

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

.animate-glitch {
  animation: glitch 0.3s infinite;
}

.animate-text-glitch {
  animation: textShadowGlitch 2s infinite linear alternate-reverse;
}

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

/* Hover Effects */
.hover-scale {
  transition: transform 0.3s ease;
}

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

.hover-glow {
  transition: all 0.3s ease;
}

.hover-glow:hover {
  box-shadow: var(--glow-green);
  transform: translateY(-2px);
}

.hover-neon {
  transition: all 0.3s ease;
}

.hover-neon:hover {
  text-shadow:
    0 0 5px currentColor,
    0 0 10px currentColor,
    0 0 15px currentColor;
}

/* Loading Animations */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(0, 255, 65, 0.3);
  border-top: 3px solid var(--neon-green);
  border-radius: 50%;
  animation: rotate 1s linear infinite;
}

.loading-dots::after {
  content: '';
  animation: dots 1.5s infinite;
}

@keyframes dots {
  0%, 20% { content: ''; }
  40% { content: '.'; }
  60% { content: '..'; }
  80%, 100% { content: '...'; }
}

/* Typing Effect */
.typing-effect {
  overflow: hidden;
  border-right: 2px solid var(--neon-green);
  white-space: nowrap;
  margin: 0 auto;
  letter-spacing: 0.15em;
  animation: typing 3.5s steps(40, end), blink 1s step-end infinite;
}

/* Matrix Rain Effect */
.matrix-char {
  position: absolute;
  color: var(--matrix-green);
  font-family: var(--font-mono);
  font-size: 14px;
  animation: matrix-fall 3s linear infinite;
  opacity: 0;
}

.matrix-char:nth-child(odd) {
  animation-delay: 0.5s;
}

.matrix-char:nth-child(even) {
  animation-delay: 1s;
}

/* Scanline Effect */
.scanline::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(0, 255, 65, 0.3),
    transparent
  );
  animation: scanline 2s ease-in-out infinite;
  pointer-events: none;
}

/* Data Flow Effect */
.data-flow::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--neon-cyan),
    transparent
  );
  animation: dataFlow 2s ease-in-out infinite;
  transform: translateY(-50%);
}

/* Glitch Text Effect */
.glitch-text {
  position: relative;
  color: var(--text-primary);
  font-weight: 700;
}

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

.glitch-text::before {
  animation: glitch 0.3s infinite;
  color: var(--neon-cyan);
  z-index: -1;
}

.glitch-text::after {
  animation: glitch 0.3s infinite reverse;
  color: var(--neon-pink);
  z-index: -2;
}

/* Neon Button Effect */
.neon-btn {
  position: relative;
  background: transparent;
  border: 2px solid var(--neon-green);
  color: var(--neon-green);
  padding: 1rem 2rem;
  text-decoration: none;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 2px;
  overflow: hidden;
  transition: all 0.3s ease;
}

.neon-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(0, 255, 65, 0.4),
    transparent
  );
  transition: left 0.5s ease;
}

.neon-btn:hover::before {
  left: 100%;
}

.neon-btn:hover {
  color: var(--text-inverse);
  background: var(--neon-green);
  box-shadow:
    0 0 10px var(--neon-green),
    0 0 20px var(--neon-green),
    0 0 30px var(--neon-green);
}

/* Circuit Board Pattern */
.circuit-bg {
  background-image:
    radial-gradient(circle at 25px 25px, rgba(0, 255, 65, 0.2) 2px, transparent 2px),
    radial-gradient(circle at 75px 75px, rgba(0, 245, 255, 0.2) 2px, transparent 2px);
  background-size: 100px 100px;
  background-position: 0 0, 50px 50px;
  animation: float 6s ease-in-out infinite;
}

/* Hologram Effect */
.hologram {
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(0, 255, 65, 0.1) 50%,
    transparent 70%
  );
  animation: scanline 3s ease-in-out infinite;
}

/* Particle Effect */
.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--neon-green);
  border-radius: 50%;
  pointer-events: none;
  animation: particleFloat 4s linear infinite;
}

@keyframes particleFloat {
  0% {
    transform: translateY(100vh) translateX(0px) rotateZ(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(-10vh) translateX(100px) rotateZ(360deg);
    opacity: 0;
  }
}

/* Code Syntax Highlighting Animation */
.syntax-highlight {
  position: relative;
  overflow: hidden;
}

.syntax-highlight::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(0, 255, 65, 0.2),
    transparent
  );
  animation: dataFlow 3s ease-in-out infinite;
}

/* Terminal Cursor */
.terminal-cursor {
  display: inline-block;
  background-color: var(--neon-green);
  animation: blink 1s infinite;
}

/* Success/Error Animations */
.success-flash {
  animation: successFlash 0.6s ease-out;
}

@keyframes successFlash {
  0% { background-color: transparent; }
  50% { background-color: rgba(0, 255, 65, 0.3); }
  100% { background-color: transparent; }
}

.error-shake {
  animation: shake 0.6s ease-out;
}

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

/* Scroll-triggered Animations */
.fade-in-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.8s ease-out;
}

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

.slide-in-left-on-scroll {
  opacity: 0;
  transform: translateX(-50px);
  transition: all 0.8s ease-out;
}

.slide-in-left-on-scroll.visible {
  opacity: 1;
  transform: translateX(0);
}

.slide-in-right-on-scroll {
  opacity: 0;
  transform: translateX(50px);
  transition: all 0.8s ease-out;
}

.slide-in-right-on-scroll.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Progress Bar Animation */
.progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(0, 255, 65, 0.2);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar::before {
  content: '';
  display: block;
  width: 100%;
  height: 100%;
  background: var(--gradient-primary);
  transform: translateX(-100%);
  animation: progressLoad 2s ease-out forwards;
}

@keyframes progressLoad {
  to {
    transform: translateX(0);
  }
}

/* Staggered Animation Delays */
.stagger-delay-1 { animation-delay: 0.1s; }
.stagger-delay-2 { animation-delay: 0.2s; }
.stagger-delay-3 { animation-delay: 0.3s; }
.stagger-delay-4 { animation-delay: 0.4s; }
.stagger-delay-5 { animation-delay: 0.5s; }

/* Reduce motion for accessibility */
@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;
  }
}