/* Animations & Keyframes */

/* Fade In Up */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade In Down */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade In Left */
@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Fade In Right */
@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Scale In */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Pulse */
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* Typing Cursor */
@keyframes blink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* Animate Classes */
.animate {
  opacity: 0;
}

.animate.fade-in-up {
  animation: fadeInUp 0.6s ease forwards;
}

.animate.fade-in-down {
  animation: fadeInDown 0.6s ease forwards;
}

.animate.fade-in-left {
  animation: fadeInLeft 0.6s ease forwards;
}

.animate.fade-in-right {
  animation: fadeInRight 0.6s ease forwards;
}

.animate.scale-in {
  animation: scaleIn 0.6s ease forwards;
}

/* Animation Delays */
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }
.delay-5 { animation-delay: 0.5s; }
.delay-6 { animation-delay: 0.6s; }

/* Scroll Animation Classes */
.scroll-animate {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.6s ease;
}

.scroll-animate.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger children */
.stagger-children > * {
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.5s ease;
}

.stagger-children.visible > *:nth-child(1) { transition-delay: 0.1s; }
.stagger-children.visible > *:nth-child(2) { transition-delay: 0.2s; }
.stagger-children.visible > *:nth-child(3) { transition-delay: 0.3s; }
.stagger-children.visible > *:nth-child(4) { transition-delay: 0.4s; }
.stagger-children.visible > *:nth-child(5) { transition-delay: 0.5s; }
.stagger-children.visible > *:nth-child(6) { transition-delay: 0.6s; }
.stagger-children.visible > *:nth-child(7) { transition-delay: 0.7s; }
.stagger-children.visible > *:nth-child(8) { transition-delay: 0.8s; }

.stagger-children.visible > * {
  opacity: 1;
  transform: translateY(0);
}

/* Hover Transitions */
.hover-lift {
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.hover-lift:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

/* Icon Bounce */
.icon-bounce {
  transition: transform var(--transition-fast);
}

.icon-bounce:hover {
  animation: pulse 0.5s ease;
}

/* Typing Effect */
.typing-cursor::after {
  content: '|';
  animation: blink 1s infinite;
  color: var(--accent-primary);
}

/* Skill Bar Animation */
.skill-fill {
  width: 0;
  transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.skill-bar.animated .skill-fill {
  /* Width is set via inline style or JS */
}

/* Portfolio Card Animations */
.portfolio-card {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.portfolio-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.portfolio-card.hidden {
  display: none;
}

/* Timeline Animation */
.timeline-item {
  opacity: 0;
  transform: translateX(-20px);
  transition: all 0.5s ease;
}

.timeline-item.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Page Load Animation */
.page-loaded .hero-content > * {
  animation: fadeInUp 0.6s ease forwards;
}

.page-loaded .hero-greeting { animation-delay: 0.1s; }
.page-loaded .hero-name { animation-delay: 0.2s; }
.page-loaded .hero-title { animation-delay: 0.3s; }
.page-loaded .hero-tagline { animation-delay: 0.4s; }
.page-loaded .hero-buttons { animation-delay: 0.5s; }

/* Preloader */
.preloader {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.preloader.hidden {
  opacity: 0;
  visibility: hidden;
}

.preloader-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 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;
  }

  html {
    scroll-behavior: auto;
  }
}
