document.addEventListener('DOMContentLoaded', function() {
    // Select elements
    const subMenuTrigger1 = document.querySelector('.sub-menu-1');
    const subMenu1 = document.querySelector('.sub-1');

    const subMenuTrigger2 = document.querySelector('.sub-menu-2');
    const subMenu2 = document.querySelector('.sub-2');

    // Function to show a specific submenu
    function showSubMenu(subMenu) {
        subMenu.style.height = 'auto';
        subMenu.style.visibility = 'visible';
        subMenu.style.opacity = '1';
    }

    // Function to hide a specific submenu
    function hideSubMenu(subMenu) {
        subMenu.style.height = '0';
        subMenu.style.visibility = 'hidden';
        subMenu.style.opacity = '0';
    }

    // Add event listeners for hover on sub-menu-1 and sub-menu-2
    subMenuTrigger1.addEventListener('mouseover', function() {
        showSubMenu(subMenu1);
    });
    subMenuTrigger1.addEventListener('mouseout', function() {
        hideSubMenu(subMenu1);
    });

    subMenuTrigger2.addEventListener('mouseover', function() {
        showSubMenu(subMenu2);
    });
    subMenuTrigger2.addEventListener('mouseout', function() {
        hideSubMenu(subMenu2);
    });

    // Ensure each submenu hides when the mouse leaves it
    subMenu1.addEventListener('mouseover', function() {
        showSubMenu(subMenu1);
    });
    subMenu1.addEventListener('mouseout', function() {
        hideSubMenu(subMenu1);
    });

    subMenu2.addEventListener('mouseover', function() {
        showSubMenu(subMenu2);
    });
    subMenu2.addEventListener('mouseout', function() {
        hideSubMenu(subMenu2);
    });
});

// document.addEventListener('DOMContentLoaded', function() {
//     const menu = document.querySelector('.menu');
//     const menuBtn = document.querySelector('.menu-btn');

//     // Log the actual screen width for debugging
//     console.log('Current screen width:', window.innerWidth);

//     // Function to set top value based on screen width
//     function setTopValue() {
//         if (window.matchMedia("(max-width: 575px)").matches) {
//             menu.style.top = '-236px';
//             console.log('Screen <= 575px: top set to -236px');
//         } else {
//             menu.style.top = '-152px';
//             console.log('Screen > 575px: top set to -152px');
//         }
//     }

//     // Show the menu on hover
//     menuBtn.addEventListener('mouseover', function() {
//         menu.style.top = '0';
//     });

//     menuBtn.addEventListener('mouseout', function() {
//         setTopValue();  // Set correct top value based on screen width
//     });

//     // Keep the menu open when hovering over it
//     menu.addEventListener('mouseover', function() {
//         menu.style.top = '0';
//     });

//     menu.addEventListener('mouseout', function() {
//         setTopValue();  // Set correct top value based on screen width
//     });

//     // Set the initial top value based on screen width
//     setTopValue();

//     // Update top value on window resize
//     window.addEventListener('resize', setTopValue);
// });



document.addEventListener('DOMContentLoaded', function() {
    const menu = document.querySelector('.menu');
    const menuBtn = document.querySelector('.menu-btn');

    menuBtn.addEventListener('mouseover', function() {
        menu.style.top = '0';
    });

    menuBtn.addEventListener('mouseout', function() {
        menu.style.top = '-152px';
    });

    // Optionally: Keep the menu open when hovering over it
    menu.addEventListener('mouseover', function() {
        menu.style.top = '0';
    });

    menu.addEventListener('mouseout', function() {
        menu.style.top = '-152px';
    });
});



// -------------------------------popup script----------------------------------
function openPopup() {
    document.getElementById("popup").style.display = "flex";
}

function closePopup() {
    document.getElementById("popup").style.display = "none";
}
// -----------------------------------------------------------------
// Saare anchor tags ko select karna jo paragraphs dikhayenge
const links = document.querySelectorAll('.show-paragraph');

links.forEach(link => {
    link.addEventListener('click', function(event) {
        event.preventDefault(); // Default link behavior ko rokna
        
        // Selected paragraph number ko lena
        const paragraphNumber = this.getAttribute('data-paragraph');
        
        // Sabhi paragraphs ko hide karna
        const paragraphs = document.querySelectorAll('.paragraph');
        paragraphs.forEach(paragraph => {
            paragraph.style.display = 'none';
        });
        
        // Selected paragraph ko show karna
        document.getElementById('paragraph' + paragraphNumber).style.display = 'block';
    });
});
// ------------------------------------active link js----------------
// Select all anchor tags with the 'show-paragraph' class
document.querySelectorAll('.about-links li a').forEach(function(link) {
    link.addEventListener('click', function(event) {
        // Remove 'active' class from all links
        document.querySelectorAll('.about-links li a').forEach(function(el) {
            el.classList.remove('active');
        });

        // Add 'active' class to the clicked link
        this.classList.add('active');
    });
});
// ------------------------------------------Prevent default anchor behavio--------------------------
document.querySelector('.awards-link').addEventListener('click', function(event) {
    // Prevent default anchor behavior
    event.preventDefault();
    });
    document.addEventListener('DOMContentLoaded', function() {
        // Select sub-menu elements
        const subMenuTrigger1 = document.querySelector('.sub-menu-1 a');
        const subMenuTrigger2 = document.querySelector('.sub-menu-2 a');
    
        // Prevent default click action on sub-menu triggers
        subMenuTrigger1.addEventListener('click', function(event) {
            event.preventDefault();
        });
    
        subMenuTrigger2.addEventListener('click', function(event) {
            event.preventDefault();
        });
    });
// --------------------------------------------------------------------------
