(function ($) {
    "use strict";

    // Navbar Toggler
    $('.navbar-toggler').click(function () {
        $('.nav-links').toggleClass('mobile-active d-none');
    });

    // Close menu when clicking outside
    $(document).click(function (event) {
        var $target = $(event.target);
        if (!$target.closest('.navbar').length && $('.nav-links').hasClass('mobile-active')) {
            $('.nav-links').removeClass('mobile-active').addClass('d-none');
            // Ensure d-lg-flex remains by checking screen size logic if needed, 
            // but bootstrap d-none d-lg-flex handles desktop visibility fine.
            // On mobile, removing mobile-active puts it back to d-none (via the toggle logic above if we are consistent).
            // Actually, simply toggling styles is safer.
        }
    });

    // Handle Resize
    $(window).resize(function() {
        if ($(window).width() >= 992) {
            $('.nav-links').removeClass('mobile-active d-none'); // Ensure visible on desktop
        } else {
            if (!$('.nav-links').hasClass('mobile-active')) {
                $('.nav-links').addClass('d-none');
            }
        }
    });

    // Sticky Navbar shadow on scroll
    $(window).scroll(function () {
        if ($(this).scrollTop() > 50) {
            $('.glass-panel').css('box-shadow', '0 10px 30px rgba(0,0,0,0.1)');
        } else {
            $('.glass-panel').css('box-shadow', 'var(--shadow-sm)');
        }
    });

    // Hero Floating Animation Randomizer (Optional Polish)
    $('.floating-card').each(function(index) {
        $(this).css('animation-delay', (index * 0.5) + 's');
    });

})(jQuery);
