import type { Metadata } from "next";
import { headers } from "next/headers";
import "./globals.css";

export async function generateMetadata(): Promise<Metadata> {
  const requestHeaders = await headers();
  const host = requestHeaders.get("host") ?? "localhost:3000";
  const forwardedProtocol = requestHeaders.get("x-forwarded-proto");
  const protocol = forwardedProtocol ?? (host.startsWith("localhost") ? "http" : "https");
  const image = `${protocol}://${host}/og.png`;

  return {
    title: "Studio, warmed by Allies · Kiduna Design System",
    description: "A warm celestial-enamel design system for the Kiduna Studio Field, Realms, taxonomy, motion, and Allies.",
    icons: { icon: "/favicon.svg", shortcut: "/favicon.svg" },
    openGraph: {
      title: "Studio, warmed by Allies",
      description: "Kiduna’s Studio Field, Realms, taxonomy, motion, and Allies in one celestial-enamel system.",
      images: [{ url: image, width: 1536, height: 1024, alt: "Studio, warmed by Allies" }],
    },
    twitter: { card: "summary_large_image", title: "Studio, warmed by Allies", images: [image] },
  };
}

export default function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) {
  return <html lang="en"><body>{children}</body></html>;
}
