<template>
    <section
        class="relative flex min-h-screen w-full items-center justify-center overflow-hidden bg-gradient-to-br from-[var(--c-deep-navy)] via-[var(--c-purple)] to-black px-4 py-24"
    >
        <!-- Background mystical elements -->
        <div class="absolute inset-0 overflow-hidden">
            <!-- Subtle cosmic pattern -->
            <div class="absolute inset-0 opacity-10">
                <div class="cosmic-pattern"></div>
            </div>

            <!-- Mystic glow effects -->
            <div class="mystic-glow glow-1"></div>
            <div class="mystic-glow glow-2"></div>
            <div class="mystic-glow glow-3"></div>

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

        <div class="relative z-10 mx-auto flex max-w-6xl flex-col items-center lg:flex-row lg:items-center">
            <!-- Text Content - Left Side -->
            <div class="mb-10 lg:mb-0 lg:w-1/2 lg:pr-10">
                <h1
                    class="mb-6 transform text-4xl font-black text-white transition-all duration-700 md:text-5xl lg:text-6xl"
                    :class="isMounted ? 'translate-y-0 opacity-100' : 'translate-y-10 opacity-0'"
                >
                    <span class="text-accent-gradient">Découvrez Votre Chemin</span> avec les Lectures Mystiques
                </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'"
                >
                    Débloquez la sagesse de l'univers grâce à des lectures de cartes oracle personnalisées. Choisissez votre tirage et commencez votre
                    voyage de découverte de soi.
                </p>

                <!-- Buttons -->
                <div
                    class="flex transform flex-wrap gap-4 transition-all delay-500 duration-1000"
                    :class="isMounted ? 'translate-y-0 opacity-100' : 'translate-y-10 opacity-0'"
                >
                    <button
                        @click="goToShuffle"
                        class="mystic-btn mystic-btn-primary group relative inline-flex h-12 min-w-[160px] items-center justify-center overflow-hidden rounded-full px-6 font-bold tracking-wide text-white shadow-lg transition-all duration-300 hover:-translate-y-0.5 md:h-14 md:min-w-[180px] md:px-8"
                    >
                        <span class="relative z-10 truncate">Tirer 1 Carte</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="mystic-btn mystic-btn-secondary inline-flex h-12 min-w-[160px] items-center justify-center rounded-full border-2 px-6 font-bold text-white transition-all duration-300 hover:-translate-y-0.5 md:h-14 md:min-w-[180px] md:px-8"
                    >
                        <span class="truncate">Tirer 3 Cartes</span>
                    </button>
                </div>
            </div>

            <!-- Oracle Images - Right Side -->
            <div class="relative lg:w-1/2">
                <div class="oracle-images-container relative h-80 w-full md:h-96 lg:h-[500px]">
                    <!-- Main oracle image -->
                    <div class="oracle-image-main absolute inset-0 flex items-center justify-center">
                        <div class="relative h-full w-full max-w-md">
                            <img
                                src="/background/IMG_2230.jpg"
                                alt="Oracle Card"
                                class="oracle-img h-full w-full rounded-2xl object-cover shadow-2xl"
                            />
                            <div class="border-gold/50 absolute inset-0 rounded-2xl border-2 shadow-lg"></div>
                            <div class="gold-frame"></div>
                        </div>
                    </div>

                    <!-- Secondary image floating to the side -->
                    <div class="oracle-image-secondary absolute right-0 bottom-10 z-10 md:right-10">
                        <div class="relative h-48 w-32 md:h-56 md:w-40">
                            <img
                                src="/background/IMG_2245.jpg"
                                alt="Oracle Card"
                                class="oracle-img h-full w-full rounded-xl object-cover shadow-xl"
                            />
                            <div class="border-gold/30 absolute inset-0 rounded-xl border-2 shadow-lg"></div>
                        </div>
                    </div>

                    <!-- Decorative elements -->
                    <div class="floating-symbols">
                        <div class="symbol symbol-1">✦</div>
                        <div class="symbol symbol-2">✧</div>
                        <div class="symbol symbol-3">☆</div>
                        <div class="symbol symbol-4">★</div>
                    </div>
                </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);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes floatSlow {
    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }
    33% {
        transform: translateY(-8px) rotate(2deg);
    }
    66% {
        transform: translateY(4px) rotate(-2deg);
    }
}

@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;
    }
}

@keyframes mysticGlow {
    0%,
    100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

@keyframes symbolFloat {
    0%,
    100% {
        transform: translateY(0) rotate(0deg);
        opacity: 0.7;
    }
    50% {
        transform: translateY(-15px) rotate(180deg);
        opacity: 1;
    }
}

/* Cosmic pattern background */
.cosmic-pattern {
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(120, 119, 198, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(255, 215, 0, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(125, 91, 166, 0.1) 0%, transparent 50%);
    background-size:
        50% 50%,
        30% 30%,
        40% 40%;
    background-position:
        0 0,
        100% 100%,
        50% 50%;
}

/* Mystic glow effects */
.mystic-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    animation: mysticGlow 8s ease-in-out infinite;
    pointer-events: none;
}

.glow-1 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(125, 91, 166, 0.3) 0%, transparent 70%);
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.glow-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.2) 0%, transparent 70%);
    bottom: 10%;
    right: 10%;
    animation-delay: 2s;
}

.glow-3 {
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, rgba(79, 70, 229, 0.2) 0%, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: 4s;
}

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

/* Oracle images styling */
.oracle-images-container {
    perspective: 1000px;
}

.oracle-image-main {
    animation: floatSlow 8s ease-in-out infinite;
}

.oracle-image-secondary {
    animation: float 6s ease-in-out infinite;
    animation-delay: 1s;
}

.oracle-img {
    transition: transform 0.3s ease;
}

.oracle-image-main:hover .oracle-img,
.oracle-image-secondary:hover .oracle-img {
    transform: scale(1.02);
}

.gold-frame {
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border: 2px solid transparent;
    border-radius: 24px;
    background: linear-gradient(45deg, transparent, rgba(255, 215, 0, 0.5), transparent) border-box;
    mask:
        linear-gradient(#fff 0 0) padding-box,
        linear-gradient(#fff 0 0);
    mask-composite: exclude;
    animation: frameGlow 3s ease-in-out infinite alternate;
}

@keyframes frameGlow {
    0% {
        opacity: 0.5;
    }
    100% {
        opacity: 1;
    }
}

/* Floating symbols */
.floating-symbols {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.symbol {
    position: absolute;
    color: rgba(255, 215, 0, 0.6);
    font-size: 1.5rem;
    animation: symbolFloat 10s ease-in-out infinite;
}

.symbol-1 {
    top: 10%;
    left: 15%;
    animation-delay: 0s;
}

.symbol-2 {
    top: 70%;
    left: 20%;
    animation-delay: 2s;
}

.symbol-3 {
    top: 30%;
    right: 25%;
    animation-delay: 4s;
}

.symbol-4 {
    top: 80%;
    right: 15%;
    animation-delay: 6s;
}

/* Buttons */
.mystic-btn {
    position: relative;
    overflow: hidden;
}

.mystic-btn-primary {
    background: linear-gradient(135deg, rgba(125, 91, 166, 0.9) 0%, rgba(79, 70, 229, 0.9) 100%);
    box-shadow: 0 0 20px rgba(125, 91, 166, 0.7);
}

.mystic-btn-primary:hover {
    box-shadow: 0 0 30px rgba(125, 91, 166, 0.9);
}

.mystic-btn-secondary {
    border-color: rgba(255, 215, 0, 0.5);
    background: rgba(255, 215, 0, 0.1);
    backdrop-filter: blur(10px);
}

.mystic-btn-secondary:hover {
    background: rgba(255, 215, 0, 0.2);
    border-color: rgba(255, 215, 0, 0.8);
}

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

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

/* Text gradient */
.text-accent-gradient {
    background: linear-gradient(135deg, #ffd700 0%, #f59e0b 50%, #d97706 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    background-size: 200% auto;
    animation: textShine 3s ease-in-out infinite alternate;
}

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

.border-gold {
    border-color: rgba(255, 215, 0, 0.5);
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .oracle-images-container {
        height: 400px;
    }
}

@media (max-width: 768px) {
    .oracle-images-container {
        height: 300px;
    }

    .oracle-image-secondary {
        display: none;
    }

    .floating-symbols {
        display: none;
    }
}
</style>
