// ----------------image tilt code------------------

const image = document.querySelector(".tilt");

window.addEventListener("mousemove", event => {
  const centerX = window.innerWidth / 2;
  const centerY = window.innerHeight / 2;

  const offsetX = (event.clientX - centerX) / centerX;
  const offsetY = (centerY - event.clientY) / centerY;

  image.style.transform = `perspective(1000px) rotateY(${offsetX * 10}deg) rotateX(${offsetY * 10}deg) scale3d(1, 1, 1)`;
});
// ---------------------logo-slider-script-----------------------------

let currentSlide = 0;
const slides = document.querySelectorAll('.logo-slide');

function showNextSlide() {
    slides[currentSlide].classList.remove('active'); // Hide current logo
    currentSlide = (currentSlide + 1) % slides.length; // Move to next logo
    slides[currentSlide].classList.add('active'); // Show new logo
}

// Change slide every 3 seconds
setInterval(showNextSlide, 3000);
// ---------------------------------video popup js-------------------------------------------
// Select all video buttons
const videoButtons = document.querySelectorAll('.video-btn');
const popup = document.getElementById('video-popup');
const popupVideo = document.getElementById('popup-video');
const popupClose = document.getElementById('popup-close');

// Loop through each video button to add click event
videoButtons.forEach(button => {
    button.addEventListener('click', () => {
        // Get video URL from data attribute
        const videoUrl = button.getAttribute('data-video-url');
        
        // Set iframe src to the video URL and show popup
        popupVideo.src = videoUrl;
        popup.style.display = 'flex';
    });
});

// Close the popup when the close button is clicked
popupClose.addEventListener('click', () => {
    popup.style.display = 'none';
    popupVideo.src = ''; // Stop video playback
});

// Close popup when clicking outside the content
popup.addEventListener('click', (e) => {
    if (e.target === popup) {
        popup.style.display = 'none';
        popupVideo.src = '';
    }
});
