import type { Metadata } from 'next';
import { Poppins, Oleo_Script_Swash_Caps } from 'next/font/google';
import localFont from 'next/font/local';
import '../css/iconfont.css';
import '../css/iconfont-v2.css';
import './globals.css';
import { Providers } from '@/lib/providers';
import { DeviceIdProvider } from '@/components/device-id-provider';
import ProgressBar from '@/context/progress';

const poppins = Poppins({
  variable: '--font-poppins',
  weight: ['400', '500', '600', '700'],
  display: 'swap',
  subsets: ['latin'],
});

const oleoScriptSwashCaps = Oleo_Script_Swash_Caps({
  variable: '--font-oleo-script-swash-caps',
  weight: ['400'],
  display: 'swap',
  subsets: ['latin'],
});

const NumDisplay = localFont({
  src: [
    {
      path: './DIN-Alternate-Bold.ttf',
      weight: '700',
      style: 'normal',
    },
  ],
  variable: '--font-display-num',
  display: 'swap',
});

export const metadata: Metadata = {
  metadataBase: new URL(process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'),
  title: 'CrushLevel',
  description: 'CrushLevel - Next Generation Social Platform',
};

export default async function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html lang="en">
      <body
        className={`${poppins.variable} ${oleoScriptSwashCaps.variable} ${NumDisplay.variable} antialiased`}
      >
        <DeviceIdProvider>
          <Providers>
            <ProgressBar>{children}</ProgressBar>
          </Providers>
        </DeviceIdProvider>
      </body>
    </html>
  );
}
