import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";

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

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

export const metadata: Metadata = {
  title: {
    default: "molzi3d — 3D-Druck Guides & Wissen",
    template: "%s | molzi3d",
  },
  description:
    "Praxisnahe 3D-Druck Guides fuer fortgeschrittene Hobbyisten. Kalibrierung, Materialien, Slicer-Tipps und Fehlerbehebung.",
  keywords: [
    "3D-Druck",
    "3D-Drucker",
    "Filament",
    "PLA",
    "PETG",
    "Cura",
    "OrcaSlicer",
    "Kalibrierung",
  ],
};

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html
      lang="de"
      className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`}
      suppressHydrationWarning
    >
      <head>
        {/* Theme-Script: Verhindert Flash of Unstyled Content */}
        <script
          dangerouslySetInnerHTML={{
            __html: `
              (function() {
                var t = localStorage.getItem('m3d-theme');
                if (t === 'dark' || (!t && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
                  document.documentElement.classList.add('dark');
                }
              })();
            `,
          }}
        />
      </head>
      <body className="min-h-full flex flex-col">{children}</body>
    </html>
  );
}
