/* =================================================================
   OPTA CINEMATIC INTRO SEQUENCE
   Logo materialization → Click warp → Void reveal
   ================================================================= */

/* -----------------------------------------------------------------
   1. PRELOADER CONTAINER
   ----------------------------------------------------------------- */

.cinematic-preloader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: default;
}

.cinematic-preloader.ready {
    cursor: pointer;
}

.cinematic-preloader.exiting {
    pointer-events: none;
}

/* -----------------------------------------------------------------
   2. PARTICLE FIELD (Logo materialization)
   ----------------------------------------------------------------- */

.intro-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.intro-particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: var(--primary);
    border-radius: 50%;
    opacity: 0;
    will-change: transform, opacity;
}

/* Particle starting positions (above viewport) */
.intro-particle {
    top: -20%;
    animation: particle-fall var(--fall-duration, 1.5s) var(--fall-delay, 0s) ease-out forwards;
}

@keyframes particle-fall {
    0% {
        opacity: 0;
        transform: translateY(0) scale(0.5);
    }
    20% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateY(calc(50vh + 100px)) scale(0);
    }
}

/* -----------------------------------------------------------------
   3. LOGO CONTAINER
   ----------------------------------------------------------------- */

.intro-logo-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    transform: translateY(-100vh);
    opacity: 0;
    animation: logo-descend 2s 1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes logo-descend {
    0% {
        transform: translateY(-100vh) scale(0.8);
        opacity: 0;
    }
    60% {
        transform: translateY(10px) scale(1.02);
        opacity: 1;
    }
    80% {
        transform: translateY(-5px) scale(1);
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* -----------------------------------------------------------------
   4. LOGO RING
   ----------------------------------------------------------------- */

.intro-logo {
    position: relative;
    width: 180px;
    height: 180px;
}

.intro-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid transparent;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(168, 85, 247, 0.1)) padding-box,
                linear-gradient(135deg, var(--primary), var(--primary-glow)) border-box;
    opacity: 0;
    transform: scale(0.5);
    animation: ring-materialize 1.2s 1.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes ring-materialize {
    0% {
        opacity: 0;
        transform: scale(0.5) rotate(-30deg);
        filter: blur(10px);
    }
    50% {
        opacity: 1;
        filter: blur(2px);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
        filter: blur(0);
    }
}

/* Ring glow */
.intro-ring::after {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        rgba(139, 92, 246, 0.3) 0%,
        transparent 70%
    );
    animation: ring-glow-pulse 3s 2.5s ease-in-out infinite;
    opacity: 0;
}

@keyframes ring-glow-pulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.1); }
}

/* Core center */
.intro-core {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(
        circle,
        rgba(255, 255, 255, 0.9) 0%,
        var(--primary) 50%,
        transparent 100%
    );
    opacity: 0;
    animation: core-ignite 0.8s 2s ease-out forwards;
}

@keyframes core-ignite {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.3);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* -----------------------------------------------------------------
   5. CLICK PROMPT
   ----------------------------------------------------------------- */

.intro-prompt {
    font-family: 'Sora', -apple-system, sans-serif;
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--text-muted);
    opacity: 0;
    animation: prompt-fade-in 0.8s 2.8s ease forwards;
}

@keyframes prompt-fade-in {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.intro-prompt::after {
    content: '';
    display: block;
    width: 40px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    margin: 0.75rem auto 0;
    animation: prompt-line-pulse 2s 3s ease-in-out infinite;
}

@keyframes prompt-line-pulse {
    0%, 100% { opacity: 0.3; transform: scaleX(0.8); }
    50% { opacity: 0.7; transform: scaleX(1); }
}

/* -----------------------------------------------------------------
   6. WARP TRANSITION (On Click)
   ----------------------------------------------------------------- */

/* Core super-ignite */
.cinematic-preloader.warping .intro-core {
    animation: core-super-ignite 0.3s ease-out forwards;
}

@keyframes core-super-ignite {
    0% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 20px var(--primary);
    }
    50% {
        transform: translate(-50%, -50%) scale(3);
        box-shadow: 0 0 60px var(--primary-glow);
    }
    100% {
        transform: translate(-50%, -50%) scale(50);
        box-shadow: 0 0 100px var(--primary-glow);
        opacity: 0;
    }
}

/* Ring shatter into liquid-metal droplets */
.cinematic-preloader.warping .intro-ring {
    animation: ring-shatter 0.6s 0.1s ease-out forwards;
}

@keyframes ring-shatter {
    0% {
        transform: scale(1);
        opacity: 1;
        filter: blur(0);
    }
    30% {
        transform: scale(1.5);
        opacity: 1;
        filter: blur(2px);
    }
    100% {
        transform: scale(3);
        opacity: 0;
        filter: blur(20px);
    }
}

/* Rapid dolly-in effect */
.cinematic-preloader.warping .intro-logo-container {
    animation: dolly-in 0.5s ease-in forwards;
}

@keyframes dolly-in {
    0% {
        transform: scale(1) translateZ(0);
    }
    100% {
        transform: scale(20) translateZ(500px);
        opacity: 0;
    }
}

/* Prompt fade out */
.cinematic-preloader.warping .intro-prompt {
    animation: fade-out-fast 0.2s ease forwards;
}

@keyframes fade-out-fast {
    to { opacity: 0; }
}

/* Motion blur overlay */
.cinematic-preloader.warping::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse 30% 100% at 50% 50%,
        transparent 0%,
        rgba(139, 92, 246, 0.3) 50%,
        transparent 100%
    );
    animation: motion-blur 0.4s ease-out forwards;
    pointer-events: none;
}

@keyframes motion-blur {
    0% {
        opacity: 0;
        transform: scaleY(1);
    }
    50% {
        opacity: 1;
        transform: scaleY(3);
    }
    100% {
        opacity: 0;
        transform: scaleY(5);
    }
}

/* -----------------------------------------------------------------
   7. LIQUID METAL DROPLETS
   ----------------------------------------------------------------- */

.shatter-droplets {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
}

.cinematic-preloader.warping .shatter-droplets {
    opacity: 1;
}

.droplet {
    position: absolute;
    width: 8px;
    height: 8px;
    background: linear-gradient(135deg, #fff 0%, var(--primary) 50%, var(--primary-glow) 100%);
    border-radius: 50%;
    opacity: 0;
    will-change: transform, opacity;
}

.cinematic-preloader.warping .droplet {
    animation: droplet-fly var(--fly-duration, 0.6s) var(--fly-delay, 0s) cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes droplet-fly {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--fly-x, 0), var(--fly-y, 0)) scale(0.2);
    }
}

/* -----------------------------------------------------------------
   8. IRIS OPEN REVEAL
   ----------------------------------------------------------------- */

.cinematic-preloader.warping::after {
    content: '';
    position: absolute;
    inset: 0;
    background: #000;
    animation: iris-open 0.8s 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes iris-open {
    0% {
        clip-path: circle(0% at 50% 50%);
        opacity: 1;
    }
    100% {
        clip-path: circle(150% at 50% 50%);
        opacity: 0;
    }
}

/* -----------------------------------------------------------------
   9. EXIT SEQUENCE
   ----------------------------------------------------------------- */

.cinematic-preloader.exiting {
    animation: preloader-exit 0.3s 0.9s ease forwards;
}

@keyframes preloader-exit {
    to {
        opacity: 0;
        visibility: hidden;
    }
}

/* -----------------------------------------------------------------
   10. RESPONSIVE
   ----------------------------------------------------------------- */

@media (max-width: 768px) {
    .intro-logo {
        width: 140px;
        height: 140px;
    }

    .intro-prompt {
        font-size: 0.65rem;
    }
}

/* -----------------------------------------------------------------
   11. REDUCED MOTION
   ----------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .intro-logo-container {
        transform: none;
        opacity: 1;
        animation: none;
    }

    .intro-ring {
        opacity: 1;
        transform: none;
        animation: none;
    }

    .intro-core {
        opacity: 1;
        animation: none;
    }

    .intro-prompt {
        opacity: 1;
        animation: none;
    }

    .cinematic-preloader.warping {
        animation: fade-out 0.3s ease forwards;
    }

    .cinematic-preloader.warping .intro-logo-container,
    .cinematic-preloader.warping .intro-ring,
    .cinematic-preloader.warping .intro-core,
    .cinematic-preloader.warping::before,
    .cinematic-preloader.warping::after {
        animation: none;
    }

    @keyframes fade-out {
        to { opacity: 0; visibility: hidden; }
    }
}
