document.addEventListener('DOMContentLoaded', () => {
    AOS.init({
        duration: 1000,     
        once: true,         
        mirror: false,      
        anchorPlacement: 'top-bottom', 
    });

    const countdownElement = document.getElementById('countdown');
    const joinButton = document.getElementById('joinTelegramBtn');
    const redirectUrl = 'https://telegram.me/+TnjMnHJUeDszMzE1'; 
    let timeLeft = 30;

    const timerInterval = setInterval(() => {
        timeLeft--;
        countdownElement.textContent = timeLeft;

        if (timeLeft <= 0) {
            clearInterval(timerInterval);
            countdownElement.textContent = '0';
            joinButton.textContent = 'Redirecting you now...';
            joinButton.style.backgroundColor = 'gray';
            joinButton.style.cursor = 'not-allowed';
            joinButton.disabled = true; 
            setTimeout(() => {
                window.location.href = redirectUrl; 
            }, 500); 
        }
    }, 1000); 
   
    joinButton.href = redirectUrl;

   
    joinButton.addEventListener('mousedown', () => {
        joinButton.style.transform = 'translateY(-2px) scale(0.98)';
        joinButton.style.boxShadow = '0 5px 20px rgba(255, 215, 0, 0.4)';
    });

    joinButton.addEventListener('mouseup', () => {
        joinButton.style.transform = ''; 
        joinButton.style.boxShadow = ''; 
    });
});