document.addEventListener("DOMContentLoaded", () => { const cards = document.querySelectorAll(".card"); // Log card positions for debugging window.addEventListener("scroll", () => { cards.forEach((card, index) => { const cardPosition = card.getBoundingClientRect(); console.log(`Card ${index + 1}: top=${cardPosition.top}, visible=${cardPosition.top < window.innerHeight}`); }); }); // Function to toggle visibility based on scroll const revealCards = () => { const windowHeight = window.innerHeight; cards.forEach((card) => { const cardTop = card.getBoundingClientRect().top; if (cardTop < windowHeight - 100) { card.classList.add("visible"); } else { card.classList.remove("visible"); } }); }; // Trigger reveal on scroll and initial page load window.addEventListener("scroll", revealCards); revealCards(); });