import type { Metadata, Viewport } from "next";
import { Inter, Inter_Tight, Instrument_Serif, JetBrains_Mono } from "next/font/google";
import { Footer } from "@/components/Footer";
import { Header } from "@/components/Header";
import { ScrollReveal } from "@/components/ScrollReveal";
import { ThemeScript } from "@/components/ThemeScript";
import { DOWNLOAD_FRAME_NAME } from "@/lib/downloads";
import { site } from "@/lib/site";
import "bootstrap/dist/css/bootstrap.min.css";
import "@/styles/style.css";
import "@/styles/header-footer.css";
import "@/styles/home.css";
import "@/styles/support.css";
import "@/styles/blog.css";
import "@/styles/legal.css";
import "./globals.css";

const inter = Inter({
  subsets: ["latin"],
  display: "swap",
  variable: "--font-inter",
});

const interTight = Inter_Tight({
  subsets: ["latin"],
  display: "swap",
  variable: "--font-inter-tight",
});

const instrumentSerif = Instrument_Serif({
  subsets: ["latin"],
  weight: "400",
  style: ["normal", "italic"],
  display: "swap",
  variable: "--font-instrument-serif",
});

const jetBrainsMono = JetBrains_Mono({
  subsets: ["latin"],
  display: "swap",
  variable: "--font-jetbrains-mono",
});

const fontVariables = [
  inter.variable,
  interTight.variable,
  instrumentSerif.variable,
  jetBrainsMono.variable,
].join(" ");

export const metadata: Metadata = {
  metadataBase: new URL(site.url),
  title: {
    default: `${site.name} | ${site.tagline}`,
    template: `%s | ${site.name}`,
  },
  description: site.description,
  applicationName: site.name,
  openGraph: {
    type: "website",
    locale: "en_US",
    url: site.url,
    siteName: site.name,
    title: `${site.name} | ${site.tagline}`,
    description: site.description,
  },
  twitter: {
    card: "summary",
    title: `${site.name} | ${site.tagline}`,
    description: site.description,
  },
};

export const viewport: Viewport = {
  themeColor: "#f3f1ea",
};

export default function RootLayout({ children }: LayoutProps<"/">) {
  return (
    <html
      lang="en"
      className={fontVariables}
      data-bs-theme="light"
      data-scroll-behavior="smooth"
      suppressHydrationWarning
    >
      <head>
        <ThemeScript />
      </head>
      <body>
        <iframe
          id={DOWNLOAD_FRAME_NAME}
          name={DOWNLOAD_FRAME_NAME}
          title="background-download"
          style={{ display: "none" }}
          aria-hidden="true"
        />
        <ScrollReveal />
        <Header />
        <main className="site-main flex-grow-1">{children}</main>
        <Footer />
      </body>
    </html>
  );
}
