        // scroll start  //
        
       function stickyScroll() {
            const header = document.querySelector("header");
            if (window.scrollY > 30) {
                header.classList.add("sticky-header");
            } else {
                header.classList.remove("sticky-header");
            }
        }
        window.addEventListener("scroll", stickyScroll);
        document.addEventListener("DOMContentLoaded", stickyScroll);

        // scroll ends //

      let mainSwiper, thumbSwiper;

  document.addEventListener("click", function(e) {
    if (e.target.classList.contains("gallery-item")) {
      const activeTab = e.target.closest(".tab-pane"); // get current tab
      const galleryItems = activeTab.querySelectorAll(".gallery-item");
      const clickedIndex = Array.from(galleryItems).indexOf(e.target);

      const mainWrapper = document.querySelector(".mainSwiper .swiper-wrapper");
      const thumbWrapper = document.querySelector(".thumbSwiper .swiper-wrapper");

      mainWrapper.innerHTML = "";
      thumbWrapper.innerHTML = "";

      galleryItems.forEach(img => {
        mainWrapper.innerHTML += `
          <div class="swiper-slide d-flex justify-content-center align-items-center">
            <img src="${img.src}" class="img-fluid" style="max-height:80vh; object-fit:contain;">
          </div>`;
        thumbWrapper.innerHTML += `
          <div class="swiper-slide d-flex justify-content-center align-items-center">
            <img src="${img.src}" class="img-fluid" style="height:80px; object-fit:cover;">
          </div>`;
      });

      // Destroy previous Swipers if exist
      if (mainSwiper) mainSwiper.destroy();
      if (thumbSwiper) thumbSwiper.destroy();

      thumbSwiper = new Swiper(".thumbSwiper", {
        spaceBetween: 10,
        slidesPerView: 6,
        freeMode: true,
        watchSlidesProgress: true,
      });

      mainSwiper = new Swiper(".mainSwiper", {
        spaceBetween: 10,
        navigation: {
          nextEl: ".swiper-button-next",
          prevEl: ".swiper-button-prev",
        },
        thumbs: { swiper: thumbSwiper },
      });

      const modal = new bootstrap.Modal(document.getElementById("imageModal"));
      modal.show();
      setTimeout(() => mainSwiper.slideTo(clickedIndex, 0), 200);
    }
  });

  document.addEventListener('DOMContentLoaded', function () {
    const elements = document.querySelectorAll('.first-process, .second-process, .third-process, .fourth-process');
    const observer = new IntersectionObserver((entries) => {
        entries.forEach(entry => {
            if (entry.isIntersecting) {
                entry.target.classList.add('animate');
                observer.unobserve(entry.target);
            }
        });
    }, { threshold: 0.3 });

    elements.forEach(el => observer.observe(el));
});



        
