import "~/styles/globals.css";

import { type Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import Script from "next/script";

import { env } from "~/env";

export const metadata: Metadata = {
  metadataBase: new URL("https://hadlock.tech"),
  title: {
    default: "Hadlock Technologies — Everything technical, handled",
    template: "%s · Hadlock Technologies",
  },
  description:
    "Hadlock Technologies is a full-stack technical partner: networks, servers, cloud, databases, web applications, and commerce systems — infrastructure to applications, one accountable name.",
  keywords: [
    "IT consulting",
    "UniFi",
    "network infrastructure",
    "cloud servers",
    "web development",
    "Shopify",
    "Long Island",
    "New York",
    "Hadlock Technologies",
  ],
  authors: [{ name: "Hadlock Technologies LLC" }],
  openGraph: {
    title: "Hadlock Technologies — Everything technical, handled",
    description:
      "Networks, servers, cloud, databases, web, and commerce — one accountable technical partner.",
    url: "https://hadlock.tech",
    siteName: "Hadlock Technologies",
    type: "website",
  },
};

const umamiEnabled =
  !!env.NEXT_PUBLIC_UMAMI_SRC && !!env.NEXT_PUBLIC_UMAMI_WEBSITE_ID;

const geist = Geist({
  subsets: ["latin"],
  variable: "--font-geist-sans",
});

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

export default function RootLayout({
  children,
}: Readonly<{ children: React.ReactNode }>) {
  return (
    <html lang="en" className={`${geist.variable} ${geistMono.variable}`}>
      <body className="font-sans">
        {children}
        {umamiEnabled && (
          <Script
            src={env.NEXT_PUBLIC_UMAMI_SRC}
            data-website-id={env.NEXT_PUBLIC_UMAMI_WEBSITE_ID}
            strategy="afterInteractive"
          />
        )}
      </body>
    </html>
  );
}
