jQuery(document).ready(function($) {
    // Debug logging
    if (window.console && console.log) {
        console.log('MMPro Committees: Initializing accordion functionality');
    }

    $('.mmpro-committees__toggle').on('click', function(e) {
        e.preventDefault();
        e.stopPropagation();
        
        const $button = $(this);
        const $item = $button.closest('.mmpro-committees__item');
        const $content = $item.find('.mmpro-committees__content');
        const isExpanded = $button.attr('aria-expanded') === 'true';
        
        // Debug logging
        if (window.console && console.log) {
            console.log('MMPro Committees: Toggle clicked', {
                button: $button[0],
                isExpanded: isExpanded,
                contentFound: $content.length > 0
            });
        }

        // Toggle this item
        $button.attr('aria-expanded', !isExpanded);
        
        if (isExpanded) {
            $content.removeClass('is-expanded').attr('hidden', '');
        } else {
            $content.addClass('is-expanded').removeAttr('hidden');
        }
    });

    // Debug: Log total number of committees and toggles
    if (window.console && console.log) {
        console.log('MMPro Committees: Found toggles:', $('.mmpro-committees__toggle').length);
        console.log('MMPro Committees: Found content sections:', $('.mmpro-committees__content').length);
    }
}); 