// cookie-consent.js — extracted from base.html
(function() {
    var CookieConsent = {
        storageKey: 'af_cookie_consent',
        init: function() {
            var consent = localStorage.getItem(this.storageKey);
            if (!consent) {
                var banner = document.getElementById('cookie-banner');
                if (banner) banner.style.display = 'block';
            }
        },
        accept: function() {
            localStorage.setItem(this.storageKey, 'accepted');
            var banner = document.getElementById('cookie-banner');
            if (banner) banner.style.display = 'none';
        },
        dismiss: function() {
            localStorage.setItem(this.storageKey, 'declined');
            var banner = document.getElementById('cookie-banner');
            if (banner) banner.style.display = 'none';
        }
    };
    
    // Make global for CSP delegation
    window.CookieConsent = CookieConsent;
    
    // Initialize on DOM ready
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', function() { CookieConsent.init(); });
    } else {
        CookieConsent.init();
    }
})();
