<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    {{-- Inline script to detect theme preference and apply it immediately to prevent flash --}}
    <script>
        (function() {
            const savedTheme = sessionStorage.getItem('theme') || 'system';

            if (savedTheme === 'system') {
                const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
                if (prefersDark) {
                    document.documentElement.classList.add('dark');
                }
            } else if (savedTheme === 'dark') {
                document.documentElement.classList.add('dark');
            }
        })();
    </script>

    {{-- Inline style to set the HTML background color based on our theme in app.css --}}
    <style>
        html {
            background-color: oklch(1 0 0);
        }

        html.dark {
            background-color: oklch(0.145 0 0);
        }
    </style>

    {!! SEOMeta::generate() !!}
    {!! OpenGraph::generate() !!}
    {!! Twitter::generate() !!}
    {!! JsonLd::generate() !!}

    <link rel="preconnect" href="https://fonts.bunny.net">
    <link href="https://fonts.bunny.net/css?family=bungee:400|instrument-sans:300,400,700" rel="stylesheet" />

    @routes
    @viteReactRefresh
    @vite(['resources/js/app.tsx', "resources/js/pages/{$page['component']}.tsx"])

    <link rel="canonical" href="{{ request()->url() }}">

    <link alt="MEMEFA.ST LOGO" rel="icon" href="{{ asset('logo/memefast-logo-144.png') }}" type="image/png">
    <link alt="MEMEFA.ST LOGO" rel="apple-touch-icon" sizes="180x180" href="{{ asset('logo/memefast-logo-180.png') }}">
    <link rel="manifest" href="{{ asset('site.webmanifest') }}">
</head>

<body class="font-sans antialiased">
    @inertia
</body>

</html>
