document.addEventListener('DOMContentLoaded', function (){
const revealItems=Array.from(document.querySelectorAll('.reveal'));
const cursor=document.querySelector('.cursor-orb');
function reveal(){
const line=window.scrollY + window.innerHeight * 0.86;
revealItems.forEach(function (el){
if(!el.classList.contains('is-visible')&&el.getBoundingClientRect().top + window.scrollY < line){
el.classList.add('is-visible');
}});
}
reveal();
window.addEventListener('scroll', reveal, { passive: true });
window.addEventListener('resize', reveal);
document.querySelectorAll('a[href^="#"]').forEach(function (link){
link.addEventListener('click', function (event){
const id=link.getAttribute('href');
if(!id||id==='#') return;
const target=document.querySelector(id);
if(!target) return;
event.preventDefault();
window.scrollTo({ top: target.getBoundingClientRect().top + window.scrollY - 84, behavior: 'smooth' });
const menu=document.querySelector('#mainMenu');
if(menu&&menu.classList.contains('show')&&window.bootstrap){
bootstrap.Collapse.getOrCreateInstance(menu).hide();
}});
});
if(cursor){
document.addEventListener('mousemove', function (event){
cursor.style.left=event.clientX + 'px';
cursor.style.top=event.clientY + 'px';
}, { passive: true });
}
window.addEventListener('scroll', function (){
const scroll=window.scrollY;
document.querySelectorAll('[data-parallax]').forEach(function (el){
const img=el.querySelector('img');
if(!img||window.matchMedia('(max-width: 991.98px)').matches) return;
const y=(scroll - (el.getBoundingClientRect().top + window.scrollY)) * 0.025;
img.style.transform='translateY(' + 20 + 'px) scale(1.035)';
});
}, { passive: true });
});