<script setup lang="ts">
import { Head, Link } from '@inertiajs/vue3';
import { onMounted, ref, onUnmounted } from 'vue';

import BackgroundStars from '@/components/Welcome/BackgroundStars.vue';
import HeroCanvas from '@/components/Welcome/HeroCanvas.vue';
import BonusSection from '@/components/Welcome/BonusSection.vue';
import SocialSection from '@/components/Welcome/SocialSection.vue';

const props = defineProps<{
    canRegister: boolean;
    bonuses: any[];
}>();

const isScrolled = ref(false);

const handleScroll = () => {
    if (typeof window !== 'undefined') {
        isScrolled.value = window.scrollY > 80;
    }
};

onMounted(() => {
    window.addEventListener('scroll', handleScroll);
});

onUnmounted(() => {
    window.removeEventListener('scroll', handleScroll);
});
</script>

<template>
    <Head title="Welcome">
        <link
            rel="stylesheet"
            href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"
        />
    </Head>

    <div
        class="bratanbonus-theme relative min-h-screen overflow-x-hidden scroll-smooth font-sans text-white"
    >
        <BackgroundStars />

        <nav
            :class="[
                'fixed z-100 flex w-full items-center justify-between border-b border-transparent px-8 py-5 shadow-lg transition-all duration-400 ease-in-out',
                isScrolled
                    ? 'border-white/10 bg-[#0f172a]/70 pt-3 pb-3 backdrop-blur-md hover:bg-gradient-to-r hover:from-purple-500 hover:to-blue-500 hover:backdrop-blur-none'
                    : 'bg-gradient-to-r from-purple-500 to-blue-500',
            ]"
        >
            <div class="text-2xl font-black tracking-tighter uppercase italic">
                BRATANBONUS.NET
            </div>
            <div
                class="hidden items-center gap-10 text-xs font-bold tracking-widest uppercase md:flex"
            >
                <a href="#bonuses" class="transition hover:opacity-70"
                    >Bonus Deals</a
                >
                <a href="#find-me" class="transition hover:opacity-70"
                    >Community</a
                >

                <template v-if="$page.props.auth.user">
                    <Link
                        href="/dashboard"
                        class="rounded-full bg-white px-6 py-2 text-black transition hover:scale-105"
                    >
                        Dashboard
                    </Link>
                </template>
                <template v-else>
                    <Link
                        href="/login"
                        class="rounded-full bg-white px-6 py-2 text-black transition hover:scale-105"
                    >
                        Login
                    </Link>
                    <Link
                        v-if="canRegister"
                        href="/register"
                        class="rounded-full border border-white/30 bg-white/20 px-6 py-2 text-white transition hover:scale-105 hover:bg-white hover:text-black"
                    >
                        Register
                    </Link>
                </template>
            </div>
        </nav>

        <HeroCanvas />

        <div
            class="h-[1px] bg-gradient-to-r from-transparent via-purple-500/30 to-blue-500/30 to-transparent"
        ></div>

        <BonusSection :bonuses="bonuses" />

        <div
            class="h-[1px] bg-gradient-to-r from-transparent via-purple-500/30 to-blue-500/30 to-transparent"
        ></div>

        <SocialSection />

        <footer
            class="relative z-10 border-t border-white/5 bg-black/50 py-16 text-center"
        >
            <div class="container mx-auto px-6">
                <div
                    class="mb-8 text-2xl font-black text-white italic opacity-60"
                >
                    BRATANBONUS.NET
                </div>
                <div
                    class="mb-10 flex flex-wrap justify-center gap-8 text-sm text-gray-500"
                >
                    <Link
                        href="/datenschutz"
                        class="transition hover:text-white"
                        >Datenschutz</Link
                    >
                    <Link href="/agb" class="transition hover:text-white"
                        >AGB</Link
                    >
                    <Link href="/impressum" class="transition hover:text-white"
                        >Impressum</Link
                    >
                    <Link
                        href="/verantwortungsbewusstes-spielen"
                        class="transition hover:text-white"
                        >Verantwortungsbewusstes Spielen</Link
                    >
                </div>
                <p class="mb-4 text-xs tracking-widest text-gray-700 uppercase">
                    &copy; 2026 | Alle Rechte vorbehalten
                </p>
                <p
                    class="mx-auto max-w-lg rounded-xl border border-red-500/20 p-4 text-[10px] text-red-500/50"
                >
                    Glücksspiel kann süchtig machen. Bitte spiele
                    verantwortungsbewusst. Teilnahme erst ab 18 Jahren.
                </p>
            </div>
        </footer>
    </div>
</template>

<style scoped>
/* Base theme variables to override whatever tailwind might inherit */
.bratanbonus-theme {
    color: white;
}
</style>
