"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { useEffect, useRef } from "react"; import { isActivePath, mobileNavItems } from "@/lib/navigation"; import { cn } from "@/lib/utils"; /** * Mobile bottom tab bar. Shown only < md (the side NavRail is hidden there). * Mirrors the FULL desktop sidebar nav (all primary items, same as NavRail) so * every page is reachable on mobile. On narrow screens the bar scrolls * horizontally (snap) — the active item snaps into view on navigation. Safe-area * aware for notched devices. */ export function MobileNav() { const path = usePathname() ?? "/"; const stripRef = useRef(null); // Keep the active item visible: snap it into view whenever the route changes. useEffect(() => { const strip = stripRef.current; if (!strip) return; const item = mobileNavItems.find((n) => isActivePath(path, n.matchPrefix)); const el = item ? strip.querySelector(`a[href="${item.href}"]`) : null; if (el) { el.scrollIntoView({ block: "nearest", inline: "nearest" }); } }, [path]); return ( ); }