"use client";

import { usePathname } from "next/navigation";
import { PublicHeader } from "./public-header";

/**
 * Public chrome. Marketing pages lay out their own full-width sections, so they
 * get a bare <main>; app-ish pages (signup, portal, store) keep the centred
 * reading column they were written against.
 */
const FULL_WIDTH = ["/", "/privacy", "/demo"];

export function PublicChrome({ children }: { children: React.ReactNode }) {
  const pathname = usePathname() || "/";

  // The admin (including the public read-only demo at /admin?demo=1) renders its
  // own full-screen shell — no public marketing header on top.
  if (pathname.startsWith("/admin")) return <>{children}</>;

  const fullWidth = FULL_WIDTH.includes(pathname);
  return (
    <>
      <PublicHeader />
      <main className={fullWidth ? "" : "mx-auto max-w-5xl px-6 py-8"}>{children}</main>
    </>
  );
}
