// source --> https://alecatan.com.br/wp-content/themes/ale-catan/assets/js/custom.js?ver=202408191837 
jQuery(function ($) {


    $('#AboutDrop').on('shown.bs.collapse', function () {
        document.body.classList.add('no-scroll');
    });

    $('#AboutDrop').on('hidden.bs.collapse', function () {
        document.body.classList.remove('no-scroll');
    });    

}); // jQuery End




document.addEventListener('DOMContentLoaded', function() {
    var aboutMask = document.querySelector('.about_mask');
    var aboutDrop = document.querySelector('#AboutDrop');

    if (aboutMask && aboutDrop) {
        // Função para fechar o modal ao clicar em .about_mask
        aboutMask.addEventListener('click', function() {
            
            aboutDrop.classList.remove('show');
           
        });

        // Função para fechar o modal ao pressionar a tecla "Esc"
        document.addEventListener('keydown', function(event) {
            if (event.key === 'Escape') {
               
                aboutDrop.classList.remove('show');
               
            }
        });
    }
});

        function voltarPagina() {
            window.history.back();
        }


    


        // Função para fechar apenas as #FilterList e #FilterGrid ao rolar a página, se existirem
        
        function closeSpecificCollapsesOnScroll() {
            var collapseElements = ['FilterList', 'FilterGrid'];
            collapseElements.forEach(function (id) {
                var collapseElement = document.getElementById(id);
                if (collapseElement) {
                    var bsCollapse = new bootstrap.Collapse(collapseElement, {
                        toggle: false
                    });
                    if (collapseElement.classList.contains('show')) {
                        bsCollapse.hide();
                    }
                }
            });
        }

        window.addEventListener('scroll', closeSpecificCollapsesOnScroll);

       
        
        
        
        document.addEventListener('DOMContentLoaded', (event) => {
            const themeSwitcher = document.getElementById('bs-theme-switcher');
        
            // Verifique se o themeSwitcher existe
            if (themeSwitcher) {
                const savedTheme = localStorage.getItem('theme') || 'light';
        
                if (savedTheme === 'dark') {
                    document.body.classList.add('dark-mode');
                    themeSwitcher.checked = true;
                }
        
                themeSwitcher.addEventListener('change', function() {
                    document.body.classList.toggle('dark-mode');
                    const theme = document.body.classList.contains('dark-mode') ? 'dark' : 'light';
                    localStorage.setItem('theme', theme);
                });
            }
        });
        
    
        document.addEventListener('DOMContentLoaded', function() {
            var lastScrollTop = 0;
        
            window.addEventListener('scroll', function() {
                var currentScroll = window.pageYOffset || document.documentElement.scrollTop;
        
                if (currentScroll > lastScrollTop && currentScroll > 10) {
                    // Rolou para baixo mais de 50px
                    document.body.classList.add('scrolldown');
                } else if (currentScroll < lastScrollTop) {
                    // Rolou para cima
                    document.body.classList.remove('scrolldown');
                }
        
                lastScrollTop = currentScroll <= 0 ? 0 : currentScroll; // Para manter o valor de lastScrollTop
            });
        });

 

document.addEventListener('DOMContentLoaded', () => {
    if (window.innerWidth > 768) { 
        OverlayScrollbars(document.body, {});      
		
		//OverlayScrollbars(document.querySelector('.bio_content'), {});	
    }
	
});