import { LocaleProvider } from '@/lib/i18n/locale-context';
import { loadContent } from '@/lib/content/load';
import { Navbar } from '@/components/nav/Navbar';
import { CustomCursor } from '@/components/ui/CustomCursor';

/**
 * Public site shell. Reads the live content tree (dict defaults merged with
 * any admin overrides) on every request so edits made in the panel appear
 * immediately, then feeds it to the client-side LocaleProvider.
 */
export const dynamic = 'force-dynamic';

export default function SiteLayout({ children }: { children: React.ReactNode }) {
  const content = loadContent();

  return (
    <LocaleProvider content={content}>
      {/* Ambient backdrop */}
      <div
        aria-hidden
        className="pointer-events-none fixed inset-0 -z-10 bg-radial-aurora"
      />
      <div
        aria-hidden
        className="pointer-events-none fixed inset-0 -z-10 bg-grid-faint bg-grid opacity-40"
        style={{
          maskImage:
            'radial-gradient(ellipse at center, black 30%, transparent 75%)',
          WebkitMaskImage:
            'radial-gradient(ellipse at center, black 30%, transparent 75%)',
        }}
      />
      <CustomCursor />
      <Navbar />
      <main>{children}</main>
    </LocaleProvider>
  );
}
