/* Animations */

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

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

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

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

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

/* Cursor Blink */
@keyframes blink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* Pulse */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 0 0 var(--color-primary-glow);
  }
  50% {
    opacity: 0.8;
    box-shadow: 0 0 0 10px transparent;
  }
}

/* Glow */
@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 20px var(--color-primary-glow);
  }
  50% {
    box-shadow: 0 0 40px var(--color-primary-glow), 0 0 60px var(--color-primary-glow);
  }
}

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

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

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

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

/* Underline expand */
@keyframes underlineExpand {
  from {
    transform: scaleX(0);
    transform-origin: left;
  }
  to {
    transform: scaleX(1);
    transform-origin: left;
  }
}

/* Count Up */
@keyframes countUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Utility Classes */
.animate-fadeInUp {
  animation: fadeInUp 0.6s ease forwards;
  will-change: transform, opacity;
}

.animate-fadeIn {
  animation: fadeIn 0.6s ease forwards;
  will-change: opacity;
}

.animate-scaleIn {
  animation: scaleIn 0.6s ease forwards;
  will-change: transform, opacity;
}

.animate-slideInLeft {
  animation: slideInLeft 0.6s ease forwards;
  will-change: transform, opacity;
}

.animate-slideInRight {
  animation: slideInRight 0.6s ease forwards;
  will-change: transform, opacity;
}

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

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
  will-change: box-shadow;
}

.animate-glow {
  animation: glow 2s ease-in-out infinite;
  will-change: box-shadow;
}

.animate-bounce {
  animation: bounce 2s ease-in-out infinite;
  will-change: transform;
}

/* Contain layout for animated elements to improve paint performance */
[data-aos] {
  contain: layout style;
}

/* GPU acceleration for animated elements */
.particles-canvas,
.cursor-blink,
.btn-glow,
.btn-glow-large {
  will-change: transform;
  transform: translateZ(0);
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  .animate-fadeInUp,
  .animate-fadeIn,
  .animate-scaleIn,
  .animate-slideInLeft,
  .animate-slideInRight {
    animation: none;
    opacity: 1;
    transform: none;
    will-change: auto;
  }
  
  .animate-float,
  .animate-pulse,
  .animate-glow,
  .animate-bounce {
    animation: none;
    will-change: auto;
  }
  
  [data-aos] {
    opacity: 1;
    transform: none;
    transition: none;
    will-change: auto;
    contain: none;
  }
}

/* Stagger delays */
[data-delay="0"] { animation-delay: 0ms; }
[data-delay="100"] { animation-delay: 100ms; }
[data-delay="200"] { animation-delay: 200ms; }
[data-delay="300"] { animation-delay: 300ms; }
[data-delay="400"] { animation-delay: 400ms; }
[data-delay="500"] { animation-delay: 500ms; }
[data-delay="600"] { animation-delay: 600ms; }
[data-delay="700"] { animation-delay: 700ms; }
[data-delay="800"] { animation-delay: 800ms; }

/* Initial states for scroll animations */
[data-aos] {
  opacity: 0;
  transition-property: opacity, transform;
  transition-duration: 0.6s;
  transition-timing-function: ease;
}

[data-aos="fade-up"] {
  transform: translateY(30px);
}

[data-aos="fade-down"] {
  transform: translateY(-30px);
}

[data-aos="fade-left"] {
  transform: translateX(30px);
}

[data-aos="fade-right"] {
  transform: translateX(-30px);
}

[data-aos].aos-animate {
  opacity: 1;
  transform: translate(0);
}

/* Code Typing Animation */
@keyframes typing {
  from { width: 0; }
  to { width: 100%; }
}

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

.code-line {
  overflow: hidden;
  white-space: nowrap;
  border-right: 2px solid var(--color-primary);
  animation: 
    typing 0.5s steps(30, end) forwards,
    blink-caret 0.75s step-end infinite;
  animation-fill-mode: both;
}

.code-line:last-child {
  border-right: none;
  animation: typing 0.5s steps(30, end) forwards;
}

.code-line.typing-complete {
  border-right: none;
  white-space: normal;
}