jQuery(document).ready(function ($) {
    $('#search-icon').on('click keydown', function (event) {
        // Check if the event is a click or an "Enter" or "Space" key press
        if (event.type === 'click' || event.key === 'Enter' || event.key === ' ') {
            $('#search-form-container').toggleClass('visible');
            
            // Check if the search form is now visible
            if ($('#search-form-container').hasClass('visible')) {
                // Find the first input field within the search form and focus it
                $('#search-form-container').find('input[type="search"]').focus();
            }

            // Prevent default action for "Space" to avoid scrolling the page
            event.preventDefault();
        }
    });
});



// icons
jQuery(document).ready(function ($) {
    $('#share-icon').on('click', function () {
        $('#icons-container').toggle();
    });

    // Add a window resize event listener to reset the visibility on view change
    $(window).on('resize', function () {
        var windowWidth = $(window).width();
        if (windowWidth > 768) { // Assuming 768px is the breakpoint for mobile to desktop
            $('#icons-container').show(); // Show search form container on desktop view
        } else {
            $('#icons-container').hide(); // Hide search form container on mobile view
        }
    });

    // Trigger resize event to set initial state
    $(window).trigger('resize');
});


