(function () {
  "use strict";

  document.querySelectorAll(".search-container").forEach(function (search) {
    var column = search.closest("[class*='col-md-']");
    if (column) column.remove();
    else search.remove();
  });

  document.querySelectorAll("#slidemenu .col-md-11").forEach(function (navigation) {
    navigation.classList.remove("col-md-11");
    navigation.classList.add("col-md-12");
  });

  document.querySelectorAll(".page-footer .copyright").forEach(function (copyright) {
    copyright.textContent = "© 2026 KFZ-Meisterwerkstatt Deniz · Alle Rechte vorbehalten";
  });
})();

/* Was Wir Tun — bento grid: mouse spotlight + staggered scroll reveal */
(function () {
  "use strict";

  var cards = Array.prototype.slice.call(document.querySelectorAll(".wwt-card"));
  if (!cards.length) return;

  var fine = window.matchMedia && window.matchMedia("(hover: hover) and (pointer: fine)").matches;
  if (fine) {
    cards.forEach(function (card) {
      card.addEventListener("mousemove", function (e) {
        var r = card.getBoundingClientRect();
        card.style.setProperty("--mx", (e.clientX - r.left) + "px");
        card.style.setProperty("--my", (e.clientY - r.top) + "px");
      });
    });
  }

  /* reveal classes are added via JS only, so cards stay visible without JS */
  if ("IntersectionObserver" in window) {
    cards.forEach(function (card, i) {
      card.style.setProperty("--wwt-i", i % 4);
      card.classList.add("wwt-reveal");
    });

    var observer = new IntersectionObserver(function (entries) {
      entries.forEach(function (entry) {
        if (entry.isIntersecting) {
          entry.target.classList.add("wwt-in");
          observer.unobserve(entry.target);
        }
      });
    }, { threshold: 0.15, rootMargin: "0px 0px -40px 0px" });

    cards.forEach(function (card) { observer.observe(card); });
  }
})();
