@php
    $scriptNonce = $cspNonce ?? request()->attributes->get('csp_script_nonce');
@endphp

<!doctype html>
<html lang="de">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>@yield('title', 'Fotospiel - Event-Fotos einfach und sicher mit QR-Codes')</title>
    <meta name="description" content="Sammle Gastfotos für Events mit QR-Codes und unserer PWA-Plattform. Für Hochzeiten, Firmenevents und mehr. Kostenloser Einstieg.">
    <link rel="icon" href="{{ asset('favicon.ico') }}" type="image/x-icon">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    @if($scriptNonce)
        <meta name="csp-nonce" content="{{ $scriptNonce }}">
    @endif
    @vite(['resources/css/app.css', 'resources/js/app.tsx'])
    <script @if($scriptNonce) nonce="{{ $scriptNonce }}" @endif>
        window.__CSP_NONCE = '{{ $scriptNonce }}';
    </script>

    @php
        $currentLocale = app()->getLocale();
        $path = request()->path();
        $supportedLocales = ['de', 'en'];
    @endphp

    <link rel="canonical" href="{{ url($path) }}">
    @foreach($supportedLocales as $locale)
        <link rel="alternate" hreflang="{{ $locale }}" href="{{ url("/$locale$path") }}">
    @endforeach
    <link rel="alternate" hreflang="x-default" href="{{ url('/de' . $path) }}">
    <script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
</head>
<body class="bg-gray-50 text-gray-900">
    @php
        $noscriptLocale = in_array($currentLocale ?? app()->getLocale(), ['de', 'en'], true) ? ($currentLocale ?? app()->getLocale()) : 'de';
    @endphp
    <noscript>
        <style>
            main { display: none !important; }
        </style>
        <div class="min-h-screen bg-gradient-to-b from-[#0f172a] via-[#0b1224] to-[#0a0f1f] text-white" style="background:linear-gradient(180deg,#0f172a 0%,#0b1224 50%,#0a0f1f 100%);color:#fff;">
            <div class="mx-auto flex max-w-5xl flex-col gap-10 px-6 py-14">
                <header class="space-y-3">
                    <p class="text-xs font-semibold uppercase tracking-[0.2em] text-pink-300">Fotospiel</p>
                    <h1 class="text-3xl font-semibold sm:text-4xl">
                        @if ($currentLocale === 'en')
                            JavaScript required for the full Fotospiel experience
                        @else
                            JavaScript für das volle Fotospiel-Erlebnis
                        @endif
                    </h1>
                    <p class="text-base text-white/70 sm:text-lg">
                        @if ($currentLocale === 'en')
                            Enable JavaScript to explore the live galleries, pricing, and admin demo. Here’s a quick overview.
                        @else
                            Aktiviere JavaScript, um Live-Galerien, Preise und die Admin-Demo zu sehen. Hier eine schnelle Übersicht.
                        @endif
                    </p>
                </header>

                <section class="grid gap-4 sm:grid-cols-3">
                    <div class="rounded-xl border border-white/10 bg-white/5 p-4 text-sm text-white/80 shadow-sm">
                        <h3 class="text-base font-semibold text-white">PWA für Gäste</h3>
                        <p class="mt-2">Offline-fähig, QR-Login ohne Account, Likes & Teilen mit Ablaufsteuerung.</p>
                    </div>
                    <div class="rounded-xl border border-white/10 bg-white/5 p-4 text-sm text-white/80 shadow-sm">
                        <h3 class="text-base font-semibold text-white">Admin & Branding</h3>
                        <p class="mt-2">Eigene Farben/Fonts, Aufgaben & Emotion-Tags, Freigaben & Moderation.</p>
                    </div>
                    <div class="rounded-xl border border-white/10 bg-white/5 p-4 text-sm text-white/80 shadow-sm">
                        <h3 class="text-base font-semibold text-white">Datenschutz</h3>
                        <p class="mt-2">Keine öffentlichen Profile, keine Gesichtserkennung, DSGVO-ready.</p>
                    </div>
                </section>

                <div class="flex flex-wrap gap-3">
                    <a href="{{ route('marketing.contact', ['locale' => $noscriptLocale]) }}" class="inline-flex items-center justify-center rounded-full bg-pink-500 px-4 py-2 text-sm font-semibold text-white shadow-lg transition hover:bg-pink-400" style="color:#fff;text-decoration:none;background:#ec4899;">
                        @if ($currentLocale === 'en')
                            Contact support
                        @else
                            Support kontaktieren
                        @endif
                    </a>
                    <a href="{{ route('impressum', ['locale' => $noscriptLocale]) }}" class="inline-flex items-center justify-center rounded-full border border-white/20 px-4 py-2 text-sm font-semibold text-white/80 transition hover:border-white/40" style="color:#e5e7eb;text-decoration:none;border:1px solid rgba(255,255,255,0.2);">
                        Impressum
                    </a>
                    <a href="{{ route('datenschutz', ['locale' => $noscriptLocale]) }}" class="inline-flex items-center justify-center rounded-full border border-white/20 px-4 py-2 text-sm font-semibold text-white/80 transition hover:border-white/40" style="color:#e5e7eb;text-decoration:none;border:1px solid rgba(255,255,255,0.2);">
                        Datenschutz
                    </a>
                </div>
            </div>
        </div>
    </noscript>

    <main>
        @yield('content')
    </main>

    @include('partials.footer')

    @stack('scripts')
</body>
</html>
