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

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

@keyframes heroGradient {
  0%, 100% {
    background: linear-gradient(120deg, rgba(56, 189, 248, 0.12) 0%, rgba(16, 185, 129, 0.1) 100%);
  }
  50% {
    background: linear-gradient(240deg, rgba(16, 185, 129, 0.14) 0%, rgba(56, 189, 248, 0.1) 100%);
  }
}

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

@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.4);
  }
  70% {
    transform: scale(1.05);
    box-shadow: 0 0 0 10px rgba(56, 189, 248, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(56, 189, 248, 0);
  }
}

@keyframes textReveal {
  from {
    clip-path: inset(0 100% 0 0);
    opacity: 0;
  }
  to {
    clip-path: inset(0 0 0 0);
    opacity: 1;
  }
}

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

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

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

/* NEW: Enhanced animations */
@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(1deg); }
}

@keyframes pulseGlow {
  0%, 100% { 
    box-shadow: 0 0 20px 0 rgba(16, 185, 129, 0.4);
  }
  50% { 
    box-shadow: 0 0 40px 10px rgba(16, 185, 129, 0.8);
  }
}

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

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

@keyframes magneticHover {
  0% {
    transform: scale(1) translateX(0) translateY(0);
  }
  100% {
    transform: scale(1.05) translateX(var(--tx, 0)) translateY(var(--ty, 0));
  }
}

/* Utility classes */
.animate-heroGradient {
  animation: heroGradient 8s ease-in-out infinite alternate;
}

.bg-gradient-animated {
  background-size: 200% 200%;
  animation: gradient 8s ease infinite;
}

.text-gradient {
  background: linear-gradient(90deg, #38bdf8, #10b981);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.animate-text-reveal {
  animation: textReveal 1s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

.animate-fadeIn {
  animation: fadeIn 1s ease-out both;
}

.animate-slideInRight {
  animation: slideInRight 0.8s ease-out both;
}

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

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

.animate-stagger {
  animation: staggerFadeIn 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

/* Stagger delays */
.animate-delay-1 { animation-delay: 0.1s; }
.animate-delay-2 { animation-delay: 0.2s; }
.animate-delay-3 { animation-delay: 0.3s; }
.animate-delay-4 { animation-delay: 0.4s; }
.animate-delay-5 { animation-delay: 0.5s; }

.hero-stagger {
  opacity: 0;
  animation: fadeInUp 0.8s ease-out forwards;
}

.hero-stagger:nth-child(1) { animation-delay: 0.1s; }
.hero-stagger:nth-child(2) { animation-delay: 0.3s; }
.hero-stagger:nth-child(3) { animation-delay: 0.5s; }
.hero-stagger:nth-child(4) { animation-delay: 0.7s; }

/* Section and component animations */
.section-reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.section-visible {
  opacity: 1;
  transform: translateY(0);
}

.animate-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.6s ease-out;
}

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

/* Staggered children for resources and projects */
.stagger-container > * {
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.6s ease-out;
}

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

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

/* Enhanced Card hover animations */
.card-hover {
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform-style: preserve-3d;
}

.card-hover:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 
    0 20px 40px rgba(0, 0, 0, 0.1),
    0 0 0 1px rgba(56, 189, 248, 0.1);
}

/* Magnetic button effect */
.magnetic-btn {
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
  overflow: hidden;
}

.magnetic-btn::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 0.6s, height 0.6s;
}

.magnetic-btn:active::before {
  width: 300px;
  height: 300px;
}

/* Particle system */
.particle {
  position: absolute;
  pointer-events: none;
  animation: particleFloat 8s linear infinite;
}

/* Project card enhancements */
.project-card {
  position: relative;
  overflow: hidden;
}

.project-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.1), transparent);
  transition: left 0.6s ease;
}

.project-card:hover::before {
  left: 100%;
}

.project-image {
  transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.project-card:hover .project-image {
  transform: scale(1.1);
}

/* Form animations */
#form-message.success {
  animation: fadeInUp 0.5s ease-out;
}

#form-message.error {
  animation: shake 0.5s ease-in-out;
}

.form-input {
  transition: all 0.3s ease;
}

.form-input:focus {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(56, 189, 248, 0.15);
}

/* Loading animation for images */
.blur-load {
  filter: blur(10px);
  transition: filter 0.5s ease;
}

.blur-load.loaded {
  filter: blur(0);
}

/* Mobile menu animation */
.mobile-menu.open {
  transform: translateX(0);
}

/* Progress bar */
#progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, #38bdf8, #10b981);
  z-index: 100;
  transition: width 0.3s ease;
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .animate-on-scroll,
  .section-reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* Performance optimizations */
@media (prefers-reduced-motion: no-preference) {
  .will-change {
    will-change: transform, opacity;
  }
}