(function () {
document.addEventListener('click', function (e) {
const a = e.target.closest('a[href*="#"]');
if (!a) return;
const url = new URL(a.href, window.location.origin);
const id = url.hash; // e.g. "#Package-Section"
// Only intercept if:
// 1) we're on the homepage,
// 2) the link points to the home URL on the same origin,
// 3) the target exists on this page.
const isHome = location.pathname === '/' || location.pathname === '/index.php';
const sameHost = url.origin === location.origin;
const isHomeLink = (url.pathname === '/' || url.pathname === '/index.php');
if (isHome && sameHost && isHomeLink && id && document.querySelector(id)) {
e.preventDefault();
document.querySelector(id).scrollIntoView({ behavior: 'smooth' });
history.pushState(null, '', id);
}
});
})();