// ===== NAVBAR =====
const nb = document.getElementById('navbar');
if (nb) window.addEventListener('scroll', () => nb.classList.toggle('scrolled', window.scrollY > 50));

// ===== MOBILE NAV =====
const nt = document.getElementById('navToggle'), nl = document.getElementById('navLinks');
if (nt && nl) { nt.addEventListener('click', () => nl.classList.toggle('active')); nl.querySelectorAll('a').forEach(a => a.addEventListener('click', () => nl.classList.remove('active'))); }

// ===== SCROLL REVEAL (magazine entrance) =====
const obs = new IntersectionObserver(en => { en.forEach((e, i) => { if (e.isIntersecting) { setTimeout(() => e.target.classList.add('on'), i * 60); obs.unobserve(e.target); } }); }, { threshold: 0.06, rootMargin: '0px 0px -30px 0px' });
document.querySelectorAll('.rv,.rvl,.rvr').forEach(el => obs.observe(el));

// ===== PHOTO STRIP — auto-scroll animation =====
const strip = document.querySelector('.photo-strip');
if (strip) {
    let scrollDir = 1, scrollSpeed = .5, isPaused = false;
    strip.addEventListener('mouseenter', () => isPaused = true);
    strip.addEventListener('mouseleave', () => isPaused = false);
    (function autoScroll() {
        if (!isPaused) {
            strip.scrollLeft += scrollDir * scrollSpeed;
            if (strip.scrollLeft >= strip.scrollWidth - strip.clientWidth) { scrollDir = -1; }
            if (strip.scrollLeft <= 0) { scrollDir = 1; }
        }
        requestAnimationFrame(autoScroll);
    })();
}

// ===== CONTACT FORM =====
const cf = document.getElementById('contactForm');
if (cf) cf.addEventListener('submit', e => { e.preventDefault(); alert('Thank you for your feedback! Your letter has been received.'); cf.reset(); });

// ===== SMOOTH SCROLL =====
document.querySelectorAll('a[href^="#"]').forEach(a => { a.addEventListener('click', e => { e.preventDefault(); const t = document.querySelector(a.getAttribute('href')); if (t) t.scrollIntoView({ behavior: 'smooth', block: 'start' }); }); });
