/* ============================================
   TRANSICIONES PROFESIONALES DE PÁGINA
   ============================================ */

@keyframes pageFadeIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pageSlideIn {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pageScaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

body {
    animation: pageFadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-transition {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    overflow: hidden;
}

.page-transition.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

/* Animación simple para navegación entre servicios */
.page-transition.service-transition {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-transition.service-transition.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

/* Ocultar los rectángulos y el logo en transición de servicios */
.page-transition.service-transition .page-transition-part,
.page-transition.service-transition .transition-logo {
    display: none;
}

/* Prevenir scroll cuando la transición está activa */
body.transition-active {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
    height: 100%;
}

.page-transition-part {
    position: fixed;
    top: 0;
    width: 25%;
    height: 100vh;
    transform: translateY(100%);
    transition: transform 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    overflow: hidden;
    will-change: transform;
    z-index: 99998;
    box-shadow: 
        0 0 60px rgba(0, 0, 0, 0.4),
        inset 0 0 150px rgba(0, 0, 0, 0.2);
    perspective: 1000px;
    opacity: 1;
    visibility: visible;
}

/* Cuando se activa la transición al hacer clic, los rectángulos aparecen instantáneamente arriba */
.page-transition.active:not(.exit) .page-transition-part {
    transform: translateY(0);
    transition: none; /* Sin transición, aparecen instantáneamente */
}

/* Esta regla se usa solo cuando se carga la nueva página */
.page-transition.active.exit .page-transition-part {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    transition: transform 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Cuando la página se carga con transición, los rectángulos suben poco a poco */
.page-transition.active.exit .page-transition-part {
    transform: translateY(0);
    opacity: 1;
    transition: transform 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Textura sutil con patrón de líneas mejorado */
.page-transition-part::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.2;
    background-image: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 1px,
            rgba(255, 255, 255, 0.05) 1px,
            rgba(255, 255, 255, 0.05) 2px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 1px,
            rgba(0, 102, 255, 0.03) 1px,
            rgba(0, 102, 255, 0.03) 2px
        );
    pointer-events: none;
    mix-blend-mode: overlay;
}

/* Efecto de profundidad adicional */
.page-transition-part::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 50% 50%, transparent 0%, rgba(0, 0, 0, 0.4) 100%);
    pointer-events: none;
    opacity: 0.6;
}

/* Rectángulo vertical 1 (izquierda) - Diseño acorde a la página */
.page-transition-part:nth-child(1) {
    left: 0;
    transition-delay: 0s;
    background: 
        radial-gradient(ellipse at 30% 40%, rgba(0, 102, 255, 0.08) 0%, transparent 60%),
        linear-gradient(180deg, 
            #f8f8f8 0%, 
            #ffffff 30%,
            #f5f5f5 60%,
            #ffffff 100%);
    box-shadow: 
        inset 0 0 100px rgba(0, 102, 255, 0.05),
        0 0 40px rgba(0, 0, 0, 0.1),
        0 0 80px rgba(0, 102, 255, 0.15);
    border-right: 1px solid rgba(0, 102, 255, 0.1);
}

/* Rectángulo vertical 2 - Azul corporativo acorde a la página */
.page-transition-part:nth-child(2) {
    left: 25%;
    transition-delay: 0.05s;
    background: 
        radial-gradient(ellipse at 70% 30%, rgba(255, 255, 255, 0.2) 0%, transparent 50%),
        radial-gradient(ellipse at 30% 70%, rgba(0, 102, 255, 0.3) 0%, transparent 60%),
        linear-gradient(180deg, 
            #0066ff 0%, 
            #0052cc 25%,
            #0066ff 50%,
            #0040b3 75%,
            #0052cc 100%);
    box-shadow: 
        inset 0 0 120px rgba(255, 255, 255, 0.1),
        inset 0 0 80px rgba(0, 102, 255, 0.2),
        0 0 60px rgba(0, 102, 255, 0.4),
        0 0 100px rgba(0, 102, 255, 0.2);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    border-right: 1px solid rgba(0, 102, 255, 0.2);
}

/* Rectángulo vertical 3 - Diseño acorde a la página */
.page-transition-part:nth-child(3) {
    left: 50%;
    transition-delay: 0.1s;
    background: 
        radial-gradient(ellipse at 70% 60%, rgba(0, 102, 255, 0.08) 0%, transparent 60%),
        linear-gradient(180deg, 
            #ffffff 0%, 
            #f8f8f8 30%,
            #ffffff 60%,
            #f5f5f5 100%);
    box-shadow: 
        inset 0 0 100px rgba(0, 102, 255, 0.05),
        0 0 40px rgba(0, 0, 0, 0.1),
        0 0 80px rgba(0, 102, 255, 0.15);
    border-left: 1px solid rgba(0, 102, 255, 0.1);
    border-right: 1px solid rgba(0, 102, 255, 0.1);
}

/* Rectángulo vertical 4 (derecha) - Azul corporativo acorde a la página */
.page-transition-part:nth-child(4) {
    left: 75%;
    transition-delay: 0.15s;
    background: 
        radial-gradient(ellipse at 30% 30%, rgba(255, 255, 255, 0.2) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 70%, rgba(0, 102, 255, 0.3) 0%, transparent 60%),
        linear-gradient(180deg, 
            #0052cc 0%, 
            #0066ff 25%,
            #0052cc 50%,
            #0066ff 75%,
            #0040b3 100%);
    box-shadow: 
        inset 0 0 120px rgba(255, 255, 255, 0.1),
        inset 0 0 80px rgba(0, 102, 255, 0.2),
        0 0 60px rgba(0, 102, 255, 0.4),
        0 0 100px rgba(0, 102, 255, 0.2);
    border-left: 1px solid rgba(0, 102, 255, 0.2);
}

/* Contenedor para capturar la nueva página */
.page-transition-part-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 400%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
}

/* Logo KONTEX animado */
.transition-logo {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: none;
}

.page-transition.active.exit .transition-logo {
    /* Se controla desde JavaScript después de que todos los rectángulos suban */
}

@keyframes logoBounce {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.15);
        opacity: 1;
    }
    70% {
        transform: translate(-50%, -50%) scale(0.95);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.page-transition.exit .transition-logo {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
}

.logo-letters {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.logo-letter {
    font-family: 'GingerBrand', sans-serif;
    font-size: 4.5rem;
    font-weight: normal;
    color: var(--color-white);
    opacity: 0;
    transform: scale(0.3) translateY(40px);
    animation: letterAppear 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    letter-spacing: 1px;
    position: relative;
    line-height: 1;
    display: inline-block;
    filter: blur(6px);
}

.logo-letter[data-letter="K"] {
    animation-delay: 0s;
    color: #0066ff;
    text-shadow: 
        0 0 10px rgba(0, 102, 255, 0.8),
        0 0 20px rgba(0, 102, 255, 0.6),
        0 0 30px rgba(0, 102, 255, 0.4),
        0 0 40px rgba(0, 102, 255, 0.2);
    filter: drop-shadow(0 0 8px rgba(0, 102, 255, 0.6));
}

.logo-letter[data-letter="O"] {
    animation-delay: 0.05s;
    color: #ffffff;
    text-shadow: 
        0 0 10px rgba(255, 255, 255, 0.9),
        0 0 20px rgba(255, 255, 255, 0.7),
        0 0 30px rgba(0, 102, 255, 0.5),
        0 0 40px rgba(0, 102, 255, 0.3);
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5));
}

.logo-letter[data-letter="N"] {
    animation-delay: 0.1s;
    color: #0066ff;
    text-shadow: 
        0 0 10px rgba(0, 102, 255, 0.8),
        0 0 20px rgba(0, 102, 255, 0.6),
        0 0 30px rgba(0, 102, 255, 0.4),
        0 0 40px rgba(0, 102, 255, 0.2);
    filter: drop-shadow(0 0 8px rgba(0, 102, 255, 0.6));
}

.logo-letter[data-letter="T"] {
    animation-delay: 0.12s;
    color: #ffffff;
    text-shadow: 
        0 0 10px rgba(255, 255, 255, 0.9),
        0 0 20px rgba(255, 255, 255, 0.7),
        0 0 30px rgba(0, 102, 255, 0.5),
        0 0 40px rgba(0, 102, 255, 0.3);
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5));
}

.logo-letter[data-letter="E"] {
    animation-delay: 0.12s;
    color: #0066ff;
    text-shadow: 
        0 0 10px rgba(0, 102, 255, 0.8),
        0 0 20px rgba(0, 102, 255, 0.6),
        0 0 30px rgba(0, 102, 255, 0.4),
        0 0 40px rgba(0, 102, 255, 0.2);
    filter: drop-shadow(0 0 8px rgba(0, 102, 255, 0.6));
}

.logo-letter[data-letter="X"] {
    animation-delay: 0.1s;
    color: #ffffff;
    text-shadow: 
        0 0 10px rgba(255, 255, 255, 0.9),
        0 0 20px rgba(255, 255, 255, 0.7),
        0 0 30px rgba(0, 102, 255, 0.5),
        0 0 40px rgba(0, 102, 255, 0.3);
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5));
}

@keyframes letterAppear {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(40px);
        filter: blur(8px);
    }
    60% {
        opacity: 0.9;
        transform: scale(1.1) translateY(-5px);
        filter: blur(2px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
        filter: blur(0);
    }
}

/* Animación de brillo continuo profesional */
.page-transition.active .logo-letter {
    animation: letterAppear 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
               letterGlow 2.5s ease-in-out infinite;
}

.page-transition.active .logo-letter[data-letter="K"] {
    animation: letterAppear 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s forwards,
               letterGlowBlue 2.5s ease-in-out 0.8s infinite;
}

.page-transition.active .logo-letter[data-letter="O"] {
    animation: letterAppear 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s forwards,
               letterGlowWhite 2.5s ease-in-out 0.9s infinite;
}

.page-transition.active .logo-letter[data-letter="N"] {
    animation: letterAppear 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s forwards,
               letterGlowBlue 2.5s ease-in-out 1s infinite;
}

.page-transition.active .logo-letter[data-letter="T"] {
    animation: letterAppear 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.4s forwards,
               letterGlowWhite 2.5s ease-in-out 1.1s infinite;
}

.page-transition.active .logo-letter[data-letter="E"] {
    animation: letterAppear 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.5s forwards,
               letterGlowBlue 2.5s ease-in-out 1.2s infinite;
}

.page-transition.active .logo-letter[data-letter="X"] {
    animation: letterAppear 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.6s forwards,
               letterGlowWhite 2.5s ease-in-out 1.3s infinite;
}

@keyframes letterGlow {
    0%, 100% {
        text-shadow: 
            0 0 10px currentColor,
            0 0 20px currentColor,
            0 0 30px currentColor;
        filter: drop-shadow(0 0 8px currentColor);
    }
    50% {
        text-shadow: 
            0 0 15px currentColor,
            0 0 30px currentColor,
            0 0 45px currentColor;
        filter: drop-shadow(0 0 12px currentColor);
    }
}

@keyframes letterGlowBlue {
    0%, 100% {
        text-shadow: 
            0 0 10px rgba(0, 102, 255, 0.8),
            0 0 20px rgba(0, 102, 255, 0.6),
            0 0 30px rgba(0, 102, 255, 0.4);
        filter: drop-shadow(0 0 8px rgba(0, 102, 255, 0.6));
    }
    50% {
        text-shadow: 
            0 0 20px rgba(0, 102, 255, 1),
            0 0 40px rgba(0, 102, 255, 0.8),
            0 0 60px rgba(0, 102, 255, 0.6);
        filter: drop-shadow(0 0 15px rgba(0, 102, 255, 0.9));
    }
}

@keyframes letterGlowWhite {
    0%, 100% {
        text-shadow: 
            0 0 10px rgba(255, 255, 255, 0.9),
            0 0 20px rgba(255, 255, 255, 0.7),
            0 0 30px rgba(0, 102, 255, 0.5);
        filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5));
    }
    50% {
        text-shadow: 
            0 0 20px rgba(255, 255, 255, 1),
            0 0 40px rgba(255, 255, 255, 0.8),
            0 0 60px rgba(0, 102, 255, 0.6);
        filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.8));
    }
}

/* Animación de salida (las partes bajan para revelar la nueva página) */
.page-transition.exit .page-transition-part {
    transform: translateY(100%);
    transition: transform 1.2s cubic-bezier(0.4, 0, 0.2, 1), opacity 1.2s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
}

.page-transition.exit .page-transition-part:nth-child(1) {
    transition-delay: 0.3s;
}

.page-transition.exit .page-transition-part:nth-child(2) {
    transition-delay: 0.2s;
}

.page-transition.exit .page-transition-part:nth-child(3) {
    transition-delay: 0.1s;
}

.page-transition.exit .page-transition-part:nth-child(4) {
    transition-delay: 0s;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.5;
    }
}

section {
    animation: pageFadeIn 0.8s cubic-bezier(0.4, 0, 0.2, 1) both;
}

section:nth-child(1) { animation-delay: 0.1s; }
section:nth-child(2) { animation-delay: 0.2s; }
section:nth-child(3) { animation-delay: 0.3s; }
section:nth-child(4) { animation-delay: 0.4s; }
section:nth-child(5) { animation-delay: 0.5s; }
section:nth-child(6) { animation-delay: 0.6s; }

.fade-in {
    animation: fadeInUp 0.8s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* Efectos de carga suave */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.loading-shimmer {
    background: linear-gradient(
        90deg,
        var(--color-primary) 0%,
        var(--color-secondary) 50%,
        var(--color-primary) 100%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* Transición suave para elementos interactivos */
a, button, .btn, .nav-link, .service-link {
    position: relative;
    overflow: hidden;
}

a::before, button::before, .btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

a:active::before, button:active::before, .btn:active::before {
    width: 300px;
    height: 300px;
}
