.door-page {
    background:
        radial-gradient(ellipse at 50% 38%, #12325c 0%, #0a1f3d 52%, #04101f 100%);
    min-height: 100dvh;
    display: flex;
    perspective: 1800px;
    /* Antes overflow:hidden + centrado: en ventanas bajas recortaba el
       contenido por arriba y por abajo sin remedio. El margen auto de
       .door-stage centra cuando sobra sitio y permite scroll cuando no. */
    overflow-x: hidden;
    overflow-y: auto;
}

/* Rejilla técnica de fondo */
.door-page::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(56, 189, 248, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(56, 189, 248, 0.06) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(ellipse at 50% 45%, #000 0%, transparent 78%);
    -webkit-mask-image: radial-gradient(ellipse at 50% 45%, #000 0%, transparent 78%);
    pointer-events: none;
    z-index: 0;
}

.door-stage {
    position: relative;
    width: min(720px, 92vw);
    margin: auto; /* centrado que degrada a scroll si el alto no da */
    text-align: center;
    padding: clamp(1rem, 3vh, 3rem) 1rem;
    transform-style: preserve-3d;
    z-index: 1;
}

.door-glow {
    position: absolute;
    inset: -10% -10% auto -10%;
    height: 60vh;
    background: radial-gradient(ellipse at center, rgba(56, 189, 248, 0.18), transparent 65%);
    filter: blur(24px);
    z-index: 0;
    pointer-events: none;
}

/* ---- Tipografía hero ---- */
.door-header {
    position: relative;
    z-index: 2;
    margin-bottom: clamp(1.5rem, 4vh, 2.5rem);
    transition: opacity 1.2s var(--easing-soft), transform 1.2s var(--easing-soft);
}

.door-emblem {
    display: inline-flex;
    width: clamp(48px, 7vw, 64px);
    height: clamp(48px, 7vw, 64px);
    margin-bottom: 1rem;
    color: var(--color-tech);
    filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.5));
}

.door-emblem svg,
.door-emblem img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-eyebrow {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.65em;
    text-indent: 0.65em;
    text-transform: uppercase;
    color: var(--color-tech-soft);
    margin: 0 0 0.75rem;
    font-weight: 500;
}

.brand-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5.2vw, 3.4rem);
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0;
    color: var(--color-white);
    text-shadow: 0 1px 30px rgba(0, 0, 0, 0.45);
}

.brand-subtitle {
    font-family: var(--font-mono);
    font-size: clamp(0.9rem, 1.6vw, 1.05rem);
    font-weight: 400;
    color: var(--color-mist);
    margin: 0.85rem 0 0;
    letter-spacing: 0.18em;
}

.brand-org {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: rgba(207, 220, 236, 0.55);
    margin: 0.6rem 0 0;
}

/* ---- Marco y panel de acceso ---- */
.door-frame {
    position: relative;
    z-index: 1;
    /* El tercer término hace la puerta consciente del ALTO de la ventana
       (proporción 3:5 → altura ≈ 53dvh), con un suelo de 180px para que
       nunca quede ridícula; si aun así no cabe, .door-page hace scroll. */
    width: min(420px, 78vw, max(32dvh, 180px));
    aspect-ratio: 3 / 5;
    margin: 0 auto;
    perspective: 1400px;
    transform-style: preserve-3d;
    cursor: pointer;
}

.door-arch {
    position: absolute;
    inset: 0;
    border-radius: 12px;
    background: linear-gradient(180deg, #03101f 0%, #061a2e 60%, #02080f 100%);
    border: 1px solid rgba(56, 189, 248, 0.25);
    box-shadow:
        inset 0 0 40px rgba(0, 0, 0, 0.85),
        0 0 0 1px rgba(0, 0, 0, 0.6),
        0 30px 60px -20px rgba(0, 0, 0, 0.7),
        0 0 50px -10px rgba(56, 189, 248, 0.25);
    overflow: hidden;
    transform-style: preserve-3d;
}

/* Hojas metálicas con trazas de circuito, se deslizan a los lados */
.door {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 1.8s var(--easing-soft);
    will-change: transform;
    box-shadow:
        inset 0 0 60px rgba(0, 0, 0, 0.5),
        inset 0 4px 0 rgba(125, 211, 252, 0.08);
}

/* Trazas de circuito grabadas en cada hoja */
.door::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(56, 189, 248, 0.10) 1px, transparent 1px),
        linear-gradient(90deg, rgba(56, 189, 248, 0.10) 1px, transparent 1px);
    background-size: 26px 26px;
    opacity: 0.7;
}

.door-left {
    left: 0;
    background:
        linear-gradient(90deg, rgba(125, 211, 252, 0.10) 0%, transparent 14%, transparent 86%, rgba(0, 0, 0, 0.5) 100%),
        linear-gradient(180deg, #14315c 0%, #102a4d 50%, #0a1f3d 100%);
}

.door-right {
    right: 0;
    background:
        linear-gradient(270deg, rgba(125, 211, 252, 0.10) 0%, transparent 14%, transparent 86%, rgba(0, 0, 0, 0.5) 100%),
        linear-gradient(180deg, #14315c 0%, #102a4d 50%, #0a1f3d 100%);
}

/* Segmentos tipo pantalla / paneles de datos */
.door-panel {
    position: absolute;
    left: 14%;
    right: 14%;
    border: 1px solid rgba(56, 189, 248, 0.22);
    background:
        repeating-linear-gradient(
            180deg,
            rgba(56, 189, 248, 0.05) 0px,
            rgba(56, 189, 248, 0.05) 1px,
            transparent 1px,
            transparent 7px),
        linear-gradient(135deg, rgba(125, 211, 252, 0.05), rgba(0, 0, 0, 0.3));
    box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
}

.door-panel--top {
    top: 9%;
    height: 36%;
    border-radius: 4px;
}

.door-panel--bottom {
    top: 52%;
    height: 39%;
}

/* Tiras de luz / LED de estado en el borde interior de cada hoja */
.door-handle {
    position: absolute;
    top: 18%;
    width: 4px;
    height: 64%;
    background: linear-gradient(180deg, rgba(125, 211, 252, 0.1), var(--color-tech) 50%, rgba(125, 211, 252, 0.1));
    border-radius: 3px;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.7);
}

.door-left .door-handle {
    right: 6%;
}

.door-right .door-handle {
    left: 6%;
}

/* Costura central de luz */
.door-threshold {
    position: absolute;
    left: 50%;
    top: 4%;
    bottom: 4%;
    width: 2px;
    transform: translateX(-50%);
    background: linear-gradient(180deg, transparent, var(--color-tech-soft), transparent);
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.8);
    opacity: 0.85;
    transition: opacity 1.6s var(--easing-soft);
}

/* ---- Estado abierto: las hojas se separan deslizando ---- */
.door-page.is-opening .door-left {
    transform: translateX(-102%);
    box-shadow:
        inset 0 0 60px rgba(0, 0, 0, 0.5),
        20px 0 50px rgba(0, 0, 0, 0.5);
}

.door-page.is-opening .door-right {
    transform: translateX(102%);
    box-shadow:
        inset 0 0 60px rgba(0, 0, 0, 0.5),
        -20px 0 50px rgba(0, 0, 0, 0.5);
}

.door-page.is-opening .door-threshold {
    opacity: 1;
    width: 90%;
    left: 5%;
    top: 5%;
    bottom: 5%;
    transform: none;
    background: radial-gradient(ellipse at center, rgba(125, 211, 252, 0.75), transparent 70%);
    box-shadow: none;
    filter: blur(8px);
}

.door-page.is-opening .door-header {
    opacity: 0;
    transform: translateY(-20px);
}

.door-page.is-opening .door-actions {
    opacity: 0;
    pointer-events: none;
}

/* Velo final luminoso antes de redirigir */
.door-page.is-entering::after {
    content: "";
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, #cdeefc 0%, #ffffff 60%);
    opacity: 0;
    animation: enter-fade 0.9s var(--easing-soft) forwards;
    z-index: 999;
    pointer-events: none;
}

@keyframes enter-fade {
    0%   { opacity: 0; }
    100% { opacity: 1; }
}

/* ---- Botón Entrar ---- */
.door-actions {
    position: relative;
    z-index: 2;
    margin-top: clamp(1.5rem, 4vh, 2.5rem);
    transition: opacity 0.6s var(--easing-soft);
}

/* Enlace discreto al modo 2D bajo el botón Entrar (escotilla si la
   detección táctil no salta, y acceso alternativo en escritorio). */
.door-2d {
    display: block;
    margin-top: 1.3rem;
    color: rgba(207, 220, 236, 0.5);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    text-decoration: none;
}

.door-2d:hover,
.door-2d:focus-visible {
    color: var(--color-tech-soft);
    text-decoration: underline;
    outline: none;
}

.enter-btn {
    position: relative;
    background: transparent;
    border: 1px solid var(--color-tech);
    color: var(--color-white);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    padding: 0.9rem 2.6rem 0.9rem 3rem;
    cursor: pointer;
    overflow: hidden;
    transition: background 0.4s var(--easing-soft), color 0.4s var(--easing-soft), letter-spacing 0.4s var(--easing-soft), box-shadow 0.4s var(--easing-soft);
}

.enter-btn:hover,
.enter-btn:focus-visible {
    background: rgba(56, 189, 248, 0.14);
    letter-spacing: 0.5em;
    box-shadow: 0 0 24px -4px rgba(56, 189, 248, 0.6);
    outline: none;
}

.enter-btn:focus-visible {
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.55);
}

.enter-btn__line {
    display: block;
    width: 30px;
    height: 1px;
    background: var(--color-tech);
    margin: 0.5rem auto 0;
    opacity: 0.8;
}

/* ===== La puerta como transición sobre el visor 3D (entrada/salida) ===== */
.door-transition {
    position: fixed;
    inset: 0;
    z-index: 30;
    transition: opacity 0.7s var(--easing-soft);
}

/* Revelada la sala: la capa se desvanece y deja pasar los clics al 3D */
.door-transition.is-gone {
    opacity: 0;
    pointer-events: none;
}

/* Salida: colocamos las hojas abiertas al instante antes de cerrarlas */
.door-transition.no-anim,
.door-transition.no-anim .door,
.door-transition.no-anim .door-threshold {
    transition: none !important;
}

/* Durante la salida solo se ven las hojas cerrándose */
.door-transition.is-exiting .door-header,
.door-transition.is-exiting .door-actions {
    opacity: 0;
    pointer-events: none;
}

.door-hint {
    margin: 1.1rem 0 0;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--color-mist);
    opacity: 0.7;
}

/* Panel de controles sutil (bajo el botón Entrar) */
.door-controls {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem 1.4rem;
    margin: 1.5rem auto 0;
    padding: 0.75rem 1.2rem;
    border: 1px solid rgba(125, 211, 252, 0.22);
    border-radius: 14px;
    background: rgba(10, 26, 46, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.door-controls .ctrl {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-mist);
}

.door-controls .keys {
    display: inline-flex;
    gap: 0.22rem;
}

.door-controls kbd {
    display: inline-block;
    min-width: 1.5em;
    padding: 0.18em 0.42em;
    text-align: center;
    border: 1px solid rgba(125, 211, 252, 0.4);
    border-radius: 6px;
    background: rgba(56, 189, 248, 0.08);
    color: var(--color-white);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

/* Destello luminoso al cruzar la puerta (transición suave a la galería) */
.door-flash {
    position: fixed;
    inset: 0;
    z-index: 35;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(circle at 50% 55%,
        rgba(224, 244, 255, 0.95) 0%,
        rgba(125, 211, 252, 0.5) 32%,
        rgba(56, 189, 248, 0) 70%);
}

.door-flash.flash-on {
    animation: door-bloom 1.3s var(--easing-soft) forwards;
}

@keyframes door-bloom {
    0% { opacity: 0; transform: scale(0.55); }
    35% { opacity: 0.92; }
    100% { opacity: 0; transform: scale(1.7); }
}

@media (prefers-reduced-motion: reduce) {
    .door-flash.flash-on { animation-duration: 0.4s; }
}

@media (prefers-reduced-motion: reduce) {
    .door,
    .door-header,
    .door-threshold,
    .door-actions {
        transition-duration: 0.001s;
    }
    .door-page.is-entering::after {
        animation-duration: 0.001s;
    }
}

/* ---- Pantallas bajas (portátiles pequeños, móvil apaisado): compactar ---- */
@media (max-height: 700px) {
    .door-emblem {
        width: 40px;
        height: 40px;
        margin-bottom: 0.5rem;
    }
    .brand-eyebrow { font-size: 0.68rem; margin-bottom: 0.45rem; }
    .brand-title { font-size: clamp(1.4rem, 4.5vw, 2.1rem); }
    .brand-subtitle { margin-top: 0.45rem; font-size: 0.8rem; }
    .door-header { margin-bottom: 1rem; }
    .door-actions { margin-top: 1rem; }
    .enter-btn {
        font-size: 0.85rem;
        padding: 0.65rem 2rem 0.65rem 2.4rem;
    }
    .door-2d { margin-top: 0.85rem; }
}

@media (max-height: 460px) {
    .door-emblem { display: none; }
    .brand-subtitle { display: none; }
}
