
(function(){
const header=document.getElementById('siteHeader');const preloader=document.getElementById('sitePreloader');const menuToggle=document.querySelector('.menu-toggle');const langToggle=document.querySelector('.language-toggle');const langMenu=document.querySelector('.language-menu');const back=document.getElementById('backToTop');
window.addEventListener('load',()=>{setTimeout(()=>preloader&&preloader.classList.add('loaded'),800)});
function onScroll(){if(window.scrollY>40){header&&header.classList.add('scrolled')}else{header&&header.classList.remove('scrolled')}if(window.scrollY>400){back&&back.classList.add('show')}else{back&&back.classList.remove('show')}}onScroll();window.addEventListener('scroll',onScroll,{passive:true});
menuToggle&&menuToggle.addEventListener('click',()=>header.classList.toggle('menu-open'));
back&&back.addEventListener('click',()=>window.scrollTo({top:0,behavior:'smooth'}));
langToggle&&langToggle.addEventListener('click',(e)=>{e.stopPropagation();langMenu.classList.toggle('open')});document.addEventListener('click',()=>langMenu&&langMenu.classList.remove('open'));
document.querySelectorAll('[data-lang]').forEach(btn=>btn.addEventListener('click',()=>{const lang=btn.getAttribute('data-lang');const combo=document.querySelector('.goog-te-combo');if(combo){combo.value=lang;combo.dispatchEvent(new Event('change'));}}));
})();
