// Function to add focus class to menu items with children when focused
function addFocusClass(event) {
    const menuItem = event.target.closest('.menu-item-has-children');
    if (menuItem) {
        menuItem.classList.add('focus');
    }
}

// Function to remove focus class from all menu items with children
function removeFocusClass() {
    const menuItems = document.querySelectorAll('.menu-item-has-children');
    menuItems.forEach(item => {
        item.classList.remove('focus');
    });
}

// Add event listener for focusin event to add focus class
document.addEventListener('focusin', addFocusClass);

// Add event listener for focusout event to remove focus class
document.addEventListener('focusout', removeFocusClass);
