import type { Metadata, Viewport } from "next";
import { Geist, Geist_Mono, Oxanium, Noto_Sans_JP } from "next/font/google";
import { JsonLd } from "./lib/structured-data";
import { GoogleAnalytics } from "./components/Analytics/GoogleAnalytics";
import { MotionProvider } from "./components/Motion/MotionProvider";
import "./globals.css";

// Oxanium is display-only: headlines and the wordmark. Restricted to the two
// weights actually declared, rather than shipping the full 200-800 axis.
const oxanium = Oxanium({
  variable: "--font-oxanium",
  subsets: ["latin", "latin-ext"],
  weight: ["600", "700"],
  display: "swap",
});

// Geist Sans carries all running text and UI. Chosen over Inter/IBM Plex
// because Geist_Mono is already loaded below, so this completes a superfamily
// without adding a third type designer to the page.
const geistSans = Geist({
  variable: "--font-geist-sans",
  subsets: ["latin"],
  display: "swap",
});

const notoSansJP = Noto_Sans_JP({
  variable: "--font-noto-jp",
  weight: ["400", "500", "600", "700"],
  display: "swap",
  // Japanese glyph set is large; load on demand rather than preloading.
  preload: false,
});

const geistMono = Geist_Mono({
  variable: "--font-geist-mono",
  subsets: ["latin"],
});

export const metadata: Metadata = {
  metadataBase: new URL("https://meliorate.pro"),
  title: {
    template: "%s | Meliorate",
    default:
      "Meliorate - AI Automation, Product Engineering & Growth Infrastructure",
  },
  description:
    "Meliorate is an execution-focused studio building AI automation, custom software, and growth infrastructure for ambitious teams and enterprises.",
  keywords: [
    "AI automation",
    "product engineering",
    "custom software development",
    "growth infrastructure",
    "CRM automation",
    "task management",
    "Agentic AI",
    "workflow automation",
    "marketing systems",
    "resume screening AI",
  ],
  authors: [{ name: "Meliorate", url: "https://meliorate.pro" }],
  creator: "Meliorate",
  publisher: "Meliorate",
  icons: {
    icon: "/img/logoicon.ico",
    apple: "/img/Favicon.png",
  },
  // No `images` here on purpose: src/app/opengraph-image.tsx generates it, and
  // declaring one at this level would override the generated route.
  openGraph: {
    type: "website",
    locale: "en_US",
    siteName: "Meliorate",
  },
  twitter: {
    card: "summary_large_image",
  },
  robots: {
    index: true,
    follow: true,
    googleBot: {
      index: true,
      follow: true,
      "max-video-preview": -1,
      "max-image-preview": "large",
      "max-snippet": -1,
    },
  },
};

export const viewport: Viewport = {
  themeColor: "#0f0f11",
  width: "device-width",
  initialScale: 1,
  maximumScale: 5,
};

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html
      lang="en"
      className={`${geistSans.variable} ${oxanium.variable} ${notoSansJP.variable} ${geistMono.variable}`}
    >
      <body>
        <JsonLd
          data={{
            "@context": "https://schema.org",
            "@type": "Organization",
            name: "Meliorate",
            url: "https://meliorate.pro",
            logo: "https://meliorate.pro/img/MeliorateH.svg",
            sameAs: [
              "https://www.instagram.com/meliorate.pro",
              "https://www.linkedin.com/company/73263460",
            ],
          }}
        />
        <JsonLd
          data={{
            "@context": "https://schema.org",
            "@type": "WebSite",
            name: "Meliorate",
            url: "https://meliorate.pro",
          }}
        />
        <GoogleAnalytics />
        <MotionProvider>{children}</MotionProvider>
      </body>
    </html>
  );
}
