/* ========================= Smooth Scroll for Anchor Links ========================= */ document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener("click", function(e) { e.preventDefault(); const target = document.querySelector(this.getAttribute("href")); if (target) target.scrollIntoView({ behavior: "smooth" }); }); }); /* ========================= Sticky Add-to-Cart (Mobile, Product Page Only) ========================= */ window.addEventListener("scroll", function() { const cartBtn = document.querySelector(".product-show .s-button-primary"); if (cartBtn) { if (window.scrollY > 300) cartBtn.classList.add("sticky-cart-btn"); else cartBtn.classList.remove("sticky-cart-btn"); } }); /* ========================= WhatsApp Button Pulse ========================= */ const whatsappBtn = document.querySelector(".sicon-whatsapp2"); if (whatsappBtn) whatsappBtn.classList.add("pulse-whatsapp"); /* ========================= Fade-in Animation on Scroll ========================= */ const fadeElements = document.querySelectorAll(".s-product-card-vertical, .banner-entry"); const fadeInOnScroll = () => { fadeElements.forEach(el => { const rect = el.getBoundingClientRect(); if (rect.top < window.innerHeight - 50) el.classList.add("fade-in-active"); }); }; window.addEventListener("scroll", fadeInOnScroll); window.addEventListener("load", fadeInOnScroll); /* ========================= WhatsApp Button Customization ========================= */ window.addEventListener("load", () => { const whatsappLink = document.querySelector('a[href="https://wa.me/966580323960"]'); if (whatsappLink) { if (whatsappLink.nextElementSibling) whatsappLink.nextElementSibling.style.display = "none"; whatsappLink.style.backgroundColor = "#EBE7D5"; } }); /* ========================= إعلان افتتاح قريبًا - FIXED Luxury ========================= */ window.addEventListener("load", () => { if (document.getElementById("shibah-announcement")) return; if (!localStorage.getItem('announcementClosed')) { const bar = document.createElement("div"); bar.id = "shibah-announcement"; const closeBtn = document.createElement("button"); closeBtn.className = "close-btn"; closeBtn.innerText = "✖"; closeBtn.onclick = () => { bar.remove(); localStorage.setItem('announcementClosed', 'true'); }; const text = document.createElement("div"); text.className = "text"; text.innerHTML = "✨ سنفتتح قريبًا ✨ تابعونا لمزيد من التفاصيل ✨ تابعنا على واتساب"; bar.appendChild(closeBtn); bar.appendChild(text); document.body.prepend(bar); } });