/**
 * View Transitions API Styles
 * Smooth animations between page navigation
 */

/* Enable view transitions for all navigation */
@supports (view-transition-name: auto) {
    /* Main page container */
    main#primary {
        view-transition-name: page-transition;
    }

    /* Header transition */
    header#masthead {
        view-transition-name: header-transition;
    }

    /* Footer transition */
    footer {
        view-transition-name: footer-transition;
    }

    /* Fade in/out animation for page transitions */
    @view-transition {
        duration: 0.6s;
        timing-function: ease-in-out;
    }

    /* Smooth fade transition for the entire page */
    ::view-transition-old(root) {
        animation: fadeOutRight 0.5s cubic-bezier(0.4, 0, 1, 1);
    }

    ::view-transition-new(root) {
        animation: fadeInRight 0.5s cubic-bezier(0, 0, 0.2, 1);
    }

    /* Specific animations for main content */
    ::view-transition-old(page-transition) {
        animation: slideOutRight 0.5s cubic-bezier(0.4, 0, 1, 1);
    }

    ::view-transition-new(page-transition) {
        animation: slideInRight 0.5s cubic-bezier(0, 0, 0.2, 1);
    }

    /* Header stays relatively fixed */
    ::view-transition-old(header-transition) {
        animation: fadeOut 0.3s ease-in-out;
    }

    ::view-transition-new(header-transition) {
        animation: fadeIn 0.3s ease-in-out;
    }

    /* Footer transition */
    ::view-transition-old(footer-transition) {
        animation: fadeOut 0.3s ease-in-out;
    }

    ::view-transition-new(footer-transition) {
        animation: fadeIn 0.3s ease-in-out;
    }
}

/* Animation keyframes */
@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

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

/* Fade desde la derecha - Salida */
@keyframes fadeOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-60px);
        opacity: 0;
    }
}

/* Fade desde la derecha - Entrada */
@keyframes fadeInRight {
    from {
        transform: translateX(60px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutUp {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(-30px);
        opacity: 0;
    }
}

@keyframes slideInUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideOutDown {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(30px);
        opacity: 0;
    }
}

@keyframes slideInDown {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-60px);
        opacity: 0;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(60px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    @view-transition {
        duration: 0.01ms;
    }
}
