'use client'; import { useEffect, useState } from 'react'; export default function BackgroundGrid() { const [size, setSize] = useState({ w: 375, h: 812 }); useEffect(() => { const updateSize = () => { setSize({ w: window.innerWidth, h: window.innerHeight }); }; updateSize(); window.addEventListener('resize', updateSize); return () => window.removeEventListener('resize', updateSize); }, []); const { w, h } = size; // Calculate grid lines // Responsive padding: lg is px-14 (56px), mobile is px-4 (16px) const isDesktop = w >= 1024; const paddingX = isDesktop ? 56 : 16; const edgeOffset = paddingX + 0.5; // +0.5 for crisp SVG rendering const cols = 3; // Left, Center, Right const rows = Math.ceil(h / 450) + 1; const vLines = Array.from({ length: cols }).map((_, i) => { if (i === 0) return edgeOffset; if (i === cols - 1) return w - edgeOffset; return w / 2; }); const hLines = Array.from({ length: rows }).map((_, i) => (i + 1) * 442); // Generate paths let vPath = ''; let hPath = ''; let crossPath = ''; const crossSize = 6; // 12px total width/height for the cross vLines.forEach(x => { hLines.forEach((y, i) => { const startY = i === 0 ? 0 : hLines[i - 1] + 12; const endY = y - 12; vPath += `M${x} ${startY}V${endY} `; crossPath += `M${x} ${y - crossSize}V${y + crossSize} `; crossPath += `M${x - crossSize} ${y}H${x + crossSize} `; }); const lastY = hLines[hLines.length - 1] + 12; vPath += `M${x} ${lastY}V${h} `; }); hLines.forEach(y => { vLines.forEach((x, i) => { const startX = i === 0 ? 0 : vLines[i - 1] + 12; const endX = x - 12; hPath += `M${startX} ${y}H${endX} `; }); const lastX = vLines[vLines.length - 1] + 12; hPath += `M${lastX} ${y}H${w} `; }); return (