/* =====================================================
   PAGE TRANSITIONS - Animaciones profesionales
   ===================================================== */

/* --- Base Transition Styles --- */
.page-transition {
    animation-fill-mode: both;
    will-change: transform, opacity;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =====================================================
   1. SLIDE + SCALE (iOS/macOS Style)
   ===================================================== */
.page-transition.slide-scale {
    animation-duration: 0.35s;
    animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

.page-transition.slide-scale.fade-in {
    animation-name: slideScaleIn;
}

.page-transition.slide-scale.fade-out {
    animation-name: slideScaleOut;
}

@keyframes slideScaleIn {
    0% {
        opacity: 0;
        transform: translateX(40px) scale(0.96);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes slideScaleOut {
    0% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateX(-40px) scale(0.96);
    }
}

/* =====================================================
   2. MORPH/ZOOM (Framer Style)
   ===================================================== */
.page-transition.morph-zoom {
    animation-duration: 0.4s;
    animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
}

.page-transition.morph-zoom.fade-in {
    animation-name: morphZoomIn;
}

.page-transition.morph-zoom.fade-out {
    animation-name: morphZoomOut;
}

@keyframes morphZoomIn {
    0% {
        opacity: 0;
        transform: scale(0.92) translateY(20px);
        filter: blur(8px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
        filter: blur(0);
    }
}

@keyframes morphZoomOut {
    0% {
        opacity: 1;
        transform: scale(1) translateY(0);
        filter: blur(0);
    }
    100% {
        opacity: 0;
        transform: scale(1.05) translateY(-20px);
        filter: blur(8px);
    }
}

/* =====================================================
   3. BLUR + FADE (Windows 11/Fluent) ⭐ Elegante
   ===================================================== */
.page-transition.blur-fade {
    animation-duration: 0.32s;
    animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

.page-transition.blur-fade.fade-in {
    animation-name: blurFadeIn;
}

.page-transition.blur-fade.fade-out {
    animation-name: blurFadeOut;
}

@keyframes blurFadeIn {
    0% {
        opacity: 0;
        transform: translateY(8px) scale(0.995);
        filter: blur(6px) saturate(0.9);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0) saturate(1);
    }
}

@keyframes blurFadeOut {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0) saturate(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-6px) scale(0.995);
        filter: blur(4px) saturate(0.9);
    }
}

/* =====================================================
   4. 3D ROTATE (Cinematic)
   ===================================================== */
.page-transition.rotate-3d {
    animation-duration: 0.5s;
    animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1);
    perspective: 1000px;
    transform-style: preserve-3d;
}

.page-transition.rotate-3d.fade-in {
    animation-name: rotate3DIn;
}

.page-transition.rotate-3d.fade-out {
    animation-name: rotate3DOut;
}

@keyframes rotate3DIn {
    0% {
        opacity: 0;
        transform: rotateY(-15deg) rotateX(5deg) translateZ(-50px) scale(0.95);
        filter: blur(5px);
    }
    100% {
        opacity: 1;
        transform: rotateY(0) rotateX(0) translateZ(0) scale(1);
        filter: blur(0);
    }
}

@keyframes rotate3DOut {
    0% {
        opacity: 1;
        transform: rotateY(0) rotateX(0) translateZ(0) scale(1);
        filter: blur(0);
    }
    100% {
        opacity: 0;
        transform: rotateY(15deg) rotateX(-5deg) translateZ(-50px) scale(0.95);
        filter: blur(5px);
    }
}

/* =====================================================
   5. FLIP VERTICAL (Card Style)
   ===================================================== */
.page-transition.flip {
    animation-duration: 0.5s;
    animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1);
    perspective: 1000px;
    transform-style: preserve-3d;
}

.page-transition.flip.fade-in {
    animation-name: flipVerticalIn;
}

.page-transition.flip.fade-out {
    animation-name: flipVerticalOut;
}

@keyframes flipVerticalIn {
    0% {
        opacity: 0;
        transform: rotateX(-90deg) translateY(40px);
        transform-origin: top center;
    }
    100% {
        opacity: 1;
        transform: rotateX(0) translateY(0);
        transform-origin: top center;
    }
}

@keyframes flipVerticalOut {
    0% {
        opacity: 1;
        transform: rotateX(0) translateY(0);
        transform-origin: bottom center;
    }
    100% {
        opacity: 0;
        transform: rotateX(90deg) translateY(-40px);
        transform-origin: bottom center;
    }
}

/* =====================================================
   6. CUBE ROTATION
   ===================================================== */
.page-transition.cube {
    animation-duration: 0.6s;
    animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1);
    perspective: 1200px;
    transform-style: preserve-3d;
}

.page-transition.cube.fade-in {
    animation-name: cubeRotateIn;
}

.page-transition.cube.fade-out {
    animation-name: cubeRotateOut;
}

@keyframes cubeRotateIn {
    0% {
        opacity: 0;
        transform: rotateY(-90deg) scale(0.8);
        transform-origin: center right;
    }
    100% {
        opacity: 1;
        transform: rotateY(0) scale(1);
        transform-origin: center right;
    }
}

@keyframes cubeRotateOut {
    0% {
        opacity: 1;
        transform: rotateY(0) scale(1);
        transform-origin: center left;
    }
    100% {
        opacity: 0;
        transform: rotateY(90deg) scale(0.8);
        transform-origin: center left;
    }
}

/* =====================================================
   7. ELASTIC (Playful)
   ===================================================== */
.page-transition.elastic {
    animation-duration: 0.6s;
    animation-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.page-transition.elastic.fade-in {
    animation-name: elasticIn;
}

.page-transition.elastic.fade-out {
    animation-name: elasticOut;
}

@keyframes elasticIn {
    0% {
        opacity: 0;
        transform: scale(0.5) rotate(-5deg);
    }
    60% {
        transform: scale(1.05) rotate(2deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0);
    }
}

@keyframes elasticOut {
    0% {
        opacity: 1;
        transform: scale(1) rotate(0);
    }
    40% {
        transform: scale(1.05) rotate(-2deg);
    }
    100% {
        opacity: 0;
        transform: scale(0.5) rotate(5deg);
    }
}

/* =====================================================
   8. GLITCH (Tech/Cyberpunk)
   ===================================================== */
.page-transition.glitch {
    animation-duration: 0.4s;
    animation-timing-function: steps(5);
}

.page-transition.glitch.fade-in {
    animation-name: glitchIn;
}

.page-transition.glitch.fade-out {
    animation-name: glitchOut;
}

@keyframes glitchIn {
    0% {
        opacity: 0;
        transform: translateX(-10px);
        clip-path: inset(0 100% 0 0);
    }
    20% {
        clip-path: inset(0 80% 0 0);
        transform: translateX(-5px);
    }
    40% {
        clip-path: inset(0 60% 0 0);
        transform: translateX(5px);
    }
    60% {
        clip-path: inset(0 40% 0 0);
        transform: translateX(-3px);
    }
    80% {
        clip-path: inset(0 20% 0 0);
        transform: translateX(2px);
    }
    100% {
        opacity: 1;
        clip-path: inset(0 0 0 0);
        transform: translateX(0);
    }
}

@keyframes glitchOut {
    0% {
        opacity: 1;
        clip-path: inset(0 0 0 0);
        transform: translateX(0);
    }
    20% {
        clip-path: inset(0 0 0 20%);
        transform: translateX(2px);
    }
    40% {
        clip-path: inset(0 0 0 40%);
        transform: translateX(-3px);
    }
    60% {
        clip-path: inset(0 0 0 60%);
        transform: translateX(5px);
    }
    80% {
        clip-path: inset(0 0 0 80%);
        transform: translateX(-5px);
    }
    100% {
        opacity: 0;
        clip-path: inset(0 0 0 100%);
        transform: translateX(10px);
    }
}

/* =====================================================
   REDUCED MOTION
   ===================================================== */
@media (prefers-reduced-motion: reduce) {
    .page-transition {
        animation-duration: 0.8s !important;
        animation-timing-function: linear !important;
    }

    .page-transition.fade-in {
        animation-name: simpleFadeIn !important;
    }

    .page-transition.fade-out {
        animation-name: simpleFadeOut !important;
    }

    @keyframes simpleFadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    @keyframes simpleFadeOut {
        from { opacity: 1; }
        to { opacity: 0; }
    }
}
