/* Pure CSS Scroll-Triggered Animations */

/* Smooth scrolling for the entire page */
html {
  scroll-behavior: smooth;
}

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

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

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

/* Initial hidden state for all animated elements */
.project-card,
.project-info,
.experience-box,
.about-item,
.contact-item,
.contact-section,
.project-details,
.project-image-wrapper-full,
.project-image-wrapper-half,
.project-text-center,
.project-text-left,
.project-detail-card,
.side-projects-section,
.about-section {
  opacity: 0;
}

/* Apply scroll-triggered animations using view timeline */
.project-card {
  animation: fadeInScale 0.6s ease-out forwards;
  animation-timeline: view();
  animation-range: entry 0% cover 30%;
}

.project-info {
  animation: fadeInUp 0.6s ease-out forwards;
  animation-timeline: view();
  animation-range: entry 0% cover 30%;
}

.experience-box {
  animation: fadeInUp 0.8s ease-out forwards;
  animation-timeline: view();
  animation-range: entry 0% cover 30%;
}

.about-item {
  animation: fadeInUp 0.6s ease-out forwards;
  animation-timeline: view();
  animation-range: entry 0% cover 30%;
}

.about-item:nth-child(odd) {
  animation: fadeInLeft 0.6s ease-out forwards;
  animation-timeline: view();
  animation-range: entry 0% cover 30%;
}

.about-item:nth-child(even) {
  animation: fadeInRight 0.6s ease-out forwards;
  animation-timeline: view();
  animation-range: entry 0% cover 30%;
}

.contact-item,
.contact-section {
  animation: fadeInUp 0.6s ease-out forwards;
  animation-timeline: view();
  animation-range: entry 0% cover 30%;
}

.project-details,
.project-image-wrapper-full,
.project-image-wrapper-half,
.project-text-center,
.project-text-left,
.project-detail-card {
  animation: fadeInUp 0.6s ease-out forwards;
  animation-timeline: view();
  animation-range: entry 0% cover 30%;
}

.side-projects-section,
.about-section {
  animation: fadeInUp 0.6s ease-out forwards;
  animation-timeline: view();
  animation-range: entry 0% cover 30%;
}

/* Fallback for browsers that don't support animation-timeline */
@supports not (animation-timeline: view()) {
  /* Use intersection observer polyfill approach with CSS only */
  .project-card,
  .project-info,
  .experience-box,
  .about-item,
  .contact-item,
  .contact-section,
  .project-details,
  .project-image-wrapper-full,
  .project-image-wrapper-half,
  .project-text-center,
  .project-text-left,
  .project-detail-card,
  .side-projects-section,
  .about-section {
    opacity: 1;
    animation: fadeInUp 0.6s ease-out;
  }
  
  .project-card {
    animation: fadeInScale 0.6s ease-out;
  }
  
  .project-info {
    animation: fadeInUp 0.6s ease-out;
  }
  
  .about-item:nth-child(odd) {
    animation: fadeInLeft 0.6s ease-out;
  }
  
  .about-item:nth-child(even) {
    animation: fadeInRight 0.6s ease-out;
  }
  
  /* Staggered delays for fallback */
  .project-card:nth-child(1) { animation-delay: 0.1s; }
  .project-card:nth-child(2) { animation-delay: 0.2s; }
  .project-card:nth-child(3) { animation-delay: 0.3s; }
  .project-card:nth-child(4) { animation-delay: 0.4s; }
  .project-card:nth-child(5) { animation-delay: 0.5s; }
  .project-card:nth-child(6) { animation-delay: 0.6s; }
  
  .experience-box:nth-of-type(1) { animation-delay: 0.2s; }
  .experience-box:nth-of-type(2) { animation-delay: 0.4s; }
  
  .about-item:nth-child(1) { animation-delay: 0.1s; }
  .about-item:nth-child(2) { animation-delay: 0.2s; }
  .about-item:nth-child(3) { animation-delay: 0.3s; }
  .about-item:nth-child(4) { animation-delay: 0.4s; }
  .about-item:nth-child(5) { animation-delay: 0.5s; }
  .about-item:nth-child(6) { animation-delay: 0.6s; }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .project-card,
  .project-info,
  .experience-box,
  .about-item,
  .contact-item,
  .contact-section,
  .project-details,
  .project-image-wrapper-full,
  .project-image-wrapper-half,
  .project-text-center,
  .project-text-left,
  .project-detail-card,
  .side-projects-section,
  .about-section {
    opacity: 1 !important;
  }
  
  html {
    scroll-behavior: auto;
  }
}
