import "./globals.css";
import type { Metadata } from "next";
import { Inter, Fraunces, JetBrains_Mono } from "next/font/google";
import { GraphQLProvider } from "./providers";
import { ErrorBoundary } from "@edu/ui-components";
import { ObservabilityProvider } from "@/components/observability-provider";

/**
 * 字体加载（next/font/google self-host）
 *
 * 通过 CSS 变量暴露字体族，业务代码用 var(--font-family-sans/serif/mono)
 * 禁止字体名字面量（project_rules §3.10）
 *
 * 03-long-term-architecture.md §3.5 字体加载策略：
 * - font-display: swap（FOUT，优先文本可见性）
 * - 首屏字体 preload，次屏 lazy
 */
const inter = Inter({
  subsets: ["latin"],
  variable: "--font-inter",
  display: "swap",
});

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

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

export const metadata: Metadata = {
  title: "Edu Teacher Portal",
  description: "K12 智慧教务平台 - 教师端",
};

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html
      lang="zh-CN"
      className={`${inter.variable} ${fraunces.variable} ${mono.variable}`}
    >
      <body>
        <ObservabilityProvider>
          <ErrorBoundary>
            <GraphQLProvider>{children}</GraphQLProvider>
          </ErrorBoundary>
        </ObservabilityProvider>
      </body>
    </html>
  );
}
