<template>
    <section
        class="relative flex min-h-screen w-full items-center justify-center overflow-hidden bg-cover bg-center bg-no-repeat px-4 py-24 text-center"
    >
        <div class="pointer-events-none absolute inset-0 bg-gradient-to-b from-[var(--c-purple)]/60 via-[var(--c-deep-navy)]/60 to-black/80"></div>

        <!-- Gold particles background effect -->
        <div class="absolute inset-0 overflow-hidden">
            <div
                v-for="i in 30"
                :key="i"
                class="gold-particle absolute"
                :style="{
                    left: `${Math.random() * 100}%`,
                    top: `${Math.random() * 100}%`,
                    width: `${Math.random() * 8 + 2}px`,
                    height: `${Math.random() * 8 + 2}px`,
                    animationDelay: `${Math.random() * 5}s`,
                    animationDuration: `${Math.random() * 10 + 10}s`,
                }"
            ></div>
        </div>

        <div class="relative z-10 mx-auto flex max-w-5xl flex-col items-center justify-between lg:flex-row">
            <!-- Text Content -->
            <div class="mb-10 lg:mb-0 lg:w-1/2">
                <h1
                    class="mb-4 transform text-4xl font-black text-white transition-all duration-700 md:text-6xl"
                    :class="isMounted ? 'translate-y-0 opacity-100' : 'translate-y-10 opacity-0'"
                >
                    Révélez Votre Voyage Intérieur
                </h1>

                <p
                    class="mb-8 transform text-lg text-white/80 transition-all delay-200 duration-1000 md:text-xl"
                    :class="isMounted ? 'translate-y-0 opacity-100' : 'translate-y-10 opacity-0'"
                >
                    Embrassez la sagesse intemporelle de l'Oracle de Kris Saint Ange, un guide stratégique pour naviguer votre destin avec clarté et
                    confiance.
                </p>

                <!-- Buttons -->
                <div
                    class="flex transform flex-wrap justify-center gap-6 transition-all delay-500 duration-1000"
                    :class="isMounted ? 'translate-y-0 opacity-100' : 'translate-y-10 opacity-0'"
                >
                    <button
                        @click="goToShuffle"
                        class="gold-trail-btn group relative inline-flex h-14 min-w-[180px] items-center justify-center overflow-hidden rounded-full bg-gradient-to-r from-[var(--c-gold)] to-yellow-400 px-8 font-bold tracking-wide text-[var(--c-purple)] shadow-lg transition-all duration-300 hover:-translate-y-0.5 hover:shadow-[var(--c-gold)]/40"
                    >
                        <span class="relative z-10 truncate">Essayez 1 carte gratuite</span>
                        <span
                            class="pointer-events-none absolute inset-0 translate-x-[-120%] -skew-x-12 bg-gradient-to-r from-transparent via-white/30 to-transparent transition-transform duration-700 group-hover:translate-x-[120%]"
                        ></span>
                    </button>

                    <button
                        @click="goToShuffle"
                        class="gold-trail-btn inline-flex h-14 min-w-[180px] items-center justify-center rounded-full border-2 border-[var(--c-purple)] bg-transparent px-8 font-bold text-white transition-all duration-300 hover:-translate-y-0.5 hover:bg-[var(--c-purple)]"
                    >
                        <span class="truncate">Découvrir les tirages</span>
                    </button>
                </div>
            </div>

            <!-- Vertical zig-zag with only two larger images -->
            <div class="relative flex h-[32rem] items-center justify-center lg:w-1/2">
                <div class="relative h-full w-[26rem]">
                    <!-- First image (top left) -->
                    <div class="zig-item zig-item-1">
                        <img class="zig-img" src="/background/IMG_2230.jpg" alt="Oracle Image 1" />
                    </div>

                    <!-- Second image (bottom right) -->
                    <div class="zig-item zig-item-2">
                        <img class="zig-img" src="/background/IMG_2245.jpg" alt="Oracle Image 2" />
                    </div>

                    <!-- gold particles -->
                    <span
                        v-for="i in 18"
                        :key="'gp-' + i"
                        class="gold-particle"
                        :style="{
                            left: `${5 + ((i * 11) % 90)}%`,
                            top: `${10 + ((i * 17) % 80)}%`,
                            width: `${6 + (i % 5)}px`,
                            height: `${6 + (i % 5)}px`,
                            animationDelay: `${(i % 7) * 0.3}s`,
                        }"
                    ></span>
                </div>
            </div>
        </div>
    </section>
</template>

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

const isMounted = ref(false);

onMounted(() => {
    setTimeout(() => {
        isMounted.value = true;
    }, 100);
});

const goToShuffle = () => {
    router.visit('/tirage');
};
</script>

<style scoped>
@keyframes float {
    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }
    33% {
        transform: translateY(-20px) rotate(5deg);
    }
    66% {
        transform: translateY(10px) rotate(-5deg);
    }
}

@keyframes textShine {
    0% {
        background-position: 0% 50%;
    }
    100% {
        background-position: 100% 50%;
    }
}

@keyframes goldParticle {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100vh) rotate(360deg);
        opacity: 0;
    }
}

.animate-float {
    animation: float 10s ease-in-out infinite;
}

.animate-text-shine {
    animation: textShine 2s ease-in-out infinite alternate;
}

/* Gold particles */
.gold-particle {
    position: absolute;
    background: radial-gradient(circle, #ffd700 30%, transparent 70%);
    border-radius: 50%;
    animation: goldParticle linear infinite;
    pointer-events: none;
}

/* Gold trail effect */
.gold-trail-btn {
    position: relative;
    overflow: hidden;
}

.gold-trail-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent, rgba(255, 215, 0, 0.2), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s;
    z-index: 1;
}

.gold-trail-btn:hover::before {
    transform: translateX(100%);
}

/* Zig-zag images - Only two larger images */
@keyframes floatSlow {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-12px);
    }
}

.zig-item {
    position: absolute;
    width: 18rem;
    height: 24rem;
    animation: floatSlow 7s ease-in-out infinite;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zig-item-1 {
    top: 5%;
    left: 5%;
    transform: rotate(-8deg);
    animation-delay: 0s;
}

.zig-item-2 {
    bottom: 5%;
    right: 5%;
    transform: rotate(6deg);
    animation-delay: 0.5s;
}

.zig-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 1rem;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    border: 3px solid rgba(255, 215, 0, 0.4);
}

/* Custom color variables */
:root {
    --c-purple: #4c1d95;
    --c-deep-navy: #1e1b4b;
    --c-gold: rgba(245, 158, 11, 0.7);
}

/* Gold particles (refined) */
@keyframes driftShimmer {
    0%,
    100% {
        opacity: 0.35;
        transform: translateY(0) scale(1);
    }
    50% {
        opacity: 0.9;
        transform: translateY(-10px) scale(1.1);
    }
}

.gold-particle {
    position: absolute;
    border-radius: 9999px;
    background: radial-gradient(circle, rgba(255, 215, 128, 0.9) 0%, rgba(255, 215, 128, 0.45) 50%, transparent 70%);
    filter: blur(0.5px);
    animation: driftShimmer 8s ease-in-out infinite;
    z-index: 3;
}
</style>
