const revealItems=document.querySelectorAll('.reveal');const revealObserver=new IntersectionObserver((entries)=>{entries.forEach(entry=>{if(entry.isIntersecting){entry.target.classList.add('visible');revealObserver.unobserve(entry.target)}})},{threshold:.14});revealItems.forEach(item=>revealObserver.observe(item));
const faqButtons=document.querySelectorAll('.faq-item');faqButtons.forEach((button)=>{button.addEventListener('click',()=>{const answer=button.nextElementSibling;const icon=button.querySelector('b');const isOpen=answer.classList.contains('open');document.querySelectorAll('.faq-answer').forEach(item=>item.classList.remove('open'));document.querySelectorAll('.faq-item b').forEach(item=>item.textContent='+');if(!isOpen){answer.classList.add('open');icon.textContent='−'}})});
const form=document.getElementById('leadForm');const message=document.getElementById('formMessage');if(form){form.addEventListener('submit',async(e)=>{e.preventDefault();const button=form.querySelector('button[type="submit"]');const defaultText=button.textContent;button.textContent='Отправка...';button.disabled=true;message.textContent='';try{const response=await fetch('send.php',{method:'POST',body:new FormData(form)});const result=await response.json();message.textContent=result.message||'Спасибо! Мы скоро свяжемся с вами.';if(result.success)form.reset()}catch(error){message.textContent='Не удалось отправить форму. Попробуйте позвонить нам.'}finally{button.textContent=defaultText;button.disabled=false}})}
