const menuToggle=document.querySelector('.menu-toggle');
const nav=document.querySelector('.main-nav');
menuToggle?.addEventListener('click',()=>{const open=nav.classList.toggle('open');menuToggle.setAttribute('aria-expanded',open)});
document.querySelectorAll('.main-nav a').forEach(a=>a.addEventListener('click',()=>{nav.classList.remove('open');menuToggle?.setAttribute('aria-expanded','false')}));

document.querySelectorAll('.gallery-grid img,.work-placeholder img,.hero-image img,.studio-image img').forEach(img=>img.addEventListener('click',()=>{const box=document.getElementById('lightbox');const target=document.getElementById('lightbox-img');target.src=img.src;target.alt=img.alt;box.classList.add('open');box.setAttribute('aria-hidden','false')}));
const close=()=>{const box=document.getElementById('lightbox');box.classList.remove('open');box.setAttribute('aria-hidden','true')};
document.querySelector('.lightbox-close')?.addEventListener('click',close);document.getElementById('lightbox')?.addEventListener('click',e=>{if(e.target.id==='lightbox')close()});document.addEventListener('keydown',e=>{if(e.key==='Escape')close()});

const accept=document.getElementById('accept');const submit=document.getElementById('submit-btn');accept?.addEventListener('change',()=>submit.disabled=!accept.checked);
document.getElementById('booking-form')?.addEventListener('submit',e=>{e.preventDefault();if(!accept.checked)return;const f=new FormData(e.currentTarget);const subject=`Studio booking enquiry — ${f.get('date')} — ${f.get('type')}`;const body=[`Name: ${f.get('name')}`,`Email: ${f.get('email')}`,`Phone: ${f.get('phone')}`,`Production: ${f.get('type')}`,`Preferred date: ${f.get('date')}`,`Hours: ${f.get('time')}`,`Equipment: ${f.get('equipment')}`,`Message: ${f.get('message')}`,``, `I confirm that I have read and agreed to the Studio Rules and Disclaimer.`].join('\n');window.location.href=`mailto:info@89forestdrive.co.za?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`});
document.getElementById('year').textContent=new Date().getFullYear();
