"use client"; import { useState, useEffect } from "react"; import { Menu, X } from "lucide-react"; import Image from "next/image"; const navLinks = [ { href: "#about", label: "About" }, { href: "#services", label: "Services" }, { href: "#projects", label: "Projects" }, { href: "#gallery", label: "Gallery" }, { href: "#contact", label: "Contact" }, ]; export default function Navigation() { const [scrolled, setScrolled] = useState(false); const [mobileOpen, setMobileOpen] = useState(false); const [activeSection, setActiveSection] = useState(""); useEffect(() => { const handleScroll = () => setScrolled(window.scrollY > 50); window.addEventListener("scroll", handleScroll, { passive: true }); return () => window.removeEventListener("scroll", handleScroll); }, []); // Track active section useEffect(() => { const observer = new IntersectionObserver( (entries) => { entries.forEach((entry) => { if (entry.isIntersecting) { setActiveSection(`#${entry.target.id}`); } }); }, { threshold: 0.3, rootMargin: "-80px 0px -40% 0px" } ); const sections = document.querySelectorAll("section[id]"); sections.forEach((section) => observer.observe(section)); return () => observer.disconnect(); }, []); // Lock body scroll when mobile menu is open useEffect(() => { document.body.style.overflow = mobileOpen ? "hidden" : ""; return () => { document.body.style.overflow = ""; }; }, [mobileOpen]); return ( ); }