(function () {
  "use strict";

  /* Reveal-on-scroll for cards/sections */
  var revealEls = document.querySelectorAll(".reveal");
  if ("IntersectionObserver" in window && revealEls.length) {
    var io = new IntersectionObserver(
      function (entries) {
        entries.forEach(function (entry) {
          if (entry.isIntersecting) {
            entry.target.classList.add("is-visible");
            io.unobserve(entry.target);
          }
        });
      },
      { threshold: 0.12, rootMargin: "0px 0px -40px 0px" }
    );
    revealEls.forEach(function (el) { io.observe(el); });
  } else {
    revealEls.forEach(function (el) { el.classList.add("is-visible"); });
  }

  /* Collapse mobile nav after a link is tapped */
  var navCollapse = document.getElementById("primaryNav");
  if (navCollapse) {
    navCollapse.querySelectorAll("a.nav-link-custom").forEach(function (link) {
      link.addEventListener("click", function () {
        if (navCollapse.classList.contains("show") && window.bootstrap) {
          var bsCollapse = window.bootstrap.Collapse.getOrCreateInstance(navCollapse);
          bsCollapse.hide();
        }
      });
    });
  }

  /* Simple client-side validation feedback for the request-visit form */
  var leadForm = document.getElementById("leadForm");
var leadForm = document.getElementById("leadForm");

if (leadForm) {
    leadForm.addEventListener("submit", function (event) {
        if (!leadForm.checkValidity()) {
            event.preventDefault();
            event.stopPropagation();
            leadForm.classList.add("was-validated");
        }
    });
}

  /* Footer year */
  var yearEl = document.getElementById("year");
  if (yearEl) { yearEl.textContent = new Date().getFullYear(); }
})();
