document.addEventListener("DOMContentLoaded",()=>{
 const page=location.pathname.split("/").pop()||"index.html";
 const links=[["index.html","Home"],["about.html","About Us"],["programs.html","Programs"],["volunteer.html","Get Involved"],["events.html","Events"],["impact.html","Impact"],["resources.html","Resources"]];
 const header=document.querySelector("[data-header]");
 if(header)header.innerHTML=`<header class="site-header"><div class="container nav-shell"><div class="nav"><a class="brand" href="index.html"><span class="brand-mark"></span><span>HopeBridge<small>FOUNDATION</small></span></a><nav class="main-nav" data-nav>${links.map(([h,l],i)=>`<a class="${page===h?"active":""}" href="${h}"><span>0${i+1}</span>${l}</a>`).join("")}</nav><div class="nav-action"><small>Turn care into action</small><a class="button button-green" href="donate.html">Donate <i data-lucide="arrow-up-right"></i></a></div><button class="menu" data-menu aria-label="Open navigation"><i data-lucide="menu"></i></button></div></div></header>`;
 const footer=document.querySelector("[data-footer]");
 if(footer)footer.innerHTML=`<footer><div class="container footer-grid"><div><a class="brand" href="index.html"><span class="brand-mark"></span><span>HopeBridge<small style="color:#9db1bc">FOUNDATION</small></span></a><p>Building stronger communities and creating lasting change through compassion and action.</p></div><div><h3>Quick Links</h3><a href="about.html">About Us</a><a href="programs.html">Programs</a><a href="impact.html">Impact</a></div><div><h3>Programs</h3><a href="programs.html">Education</a><a href="programs.html">Health</a><a href="programs.html">Clean Water</a></div><div><h3>Get Involved</h3><a href="donate.html">Donate</a><a href="volunteer.html">Volunteer</a><a href="events.html">Events</a></div><div><h3>Contact Us</h3><p>+1 (123) 456-7890<br>info@hopebridge.org<br>122 Hope Street, New York</p></div></div><div class="container footer-bottom">&copy; <span data-year></span> HopeBridge Foundation. All rights reserved.</div></footer>`;
 window.lucide?.createIcons();
 const play=document.querySelector(".watch span");if(play)play.textContent="\u25b6";
 document.querySelector("[data-menu]")?.addEventListener("click",()=>document.querySelector("[data-nav]").classList.toggle("open"));
 document.querySelectorAll("[data-filter]").forEach(btn=>btn.addEventListener("click",()=>{document.querySelectorAll("[data-filter]").forEach(x=>x.classList.toggle("active",x===btn));document.querySelectorAll("[data-type]").forEach(x=>x.classList.toggle("item-hidden",btn.dataset.filter!=="all"&&x.dataset.type!==btn.dataset.filter))}));
 document.querySelectorAll("[data-amount]").forEach(btn=>btn.addEventListener("click",()=>{document.querySelectorAll("[data-amount]").forEach(x=>x.classList.toggle("active",x===btn));document.querySelectorAll("[data-impact-amount]").forEach(x=>x.textContent=btn.dataset.amount)}));
 document.querySelectorAll("[data-demo-form]").forEach(form=>form.addEventListener("submit",e=>{e.preventDefault();show(form.dataset.message||"Thank you for supporting HopeBridge.");form.reset()}));
 document.querySelectorAll("[data-action]").forEach(btn=>btn.addEventListener("click",e=>{if(btn.tagName==="BUTTON")e.preventDefault();show(btn.dataset.action)}));
 document.querySelectorAll("img").forEach(img=>{if(!img.alt)img.alt="HopeBridge community program";img.loading="lazy";img.addEventListener("error",()=>img.src="assets/hopebridge-hero.png",{once:true})});
 document.querySelectorAll("[data-year]").forEach(x=>x.textContent=new Date().getFullYear());
 function show(msg){const t=document.querySelector("[data-toast]");if(!t)return;t.textContent=msg;t.classList.add("show");setTimeout(()=>t.classList.remove("show"),2200)}
});
