/* Forzar pantalla completa absoluta ignorando restricciones de contenedores de Elementor */
.elementor-widget-portada_interactiva {
    width: 100vw !important;
    max-width: 100vw !important;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
}

.pi-wrapper {
    position: relative;
    width: 100vw;
    height: 100svh;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    box-sizing: border-box;
    background-color: transparent;
    /* Margen lateral único: lo usan el texto, los botones y la barra de progreso,
       así los tres quedan siempre alineados. Se reduce en tablet y móvil (más abajo). */
    --pi-pad-x: 4rem;
}

.pi-media-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.pi-video {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1.15);
    min-width: 100%;
    min-height: 100%;
    width: 100vw;
    height: 100svh;
    object-fit: cover;
    will-change: transform;
}

/* --- Cross-fade entre videos ---
   Hay dos <video> apilados. El que entra se desvanece por encima (is-active) y el que sale
   se mantiene opaco hasta que el otro termina de aparecer, así nunca se ve el fondo. */
.pi-video {
    opacity: 0;
    z-index: 1;
    transition: opacity 0s linear var(--pi-fade, 0.8s);
}

.pi-video.is-active {
    opacity: 1;
    z-index: 2;
    transition: opacity var(--pi-fade, 0.8s) ease;
}

/* El texto se desvanece y reaparece con el cambio de estación */
.pi-text-box {
    transition: opacity calc(var(--pi-fade, 0.8s) / 2) ease;
}

.pi-text-box.is-swapping {
    opacity: 0;
}

/* Overlay de contraste: entre el video (z 1) y los textos/botones (z 10) */
.pi-contrast-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    opacity: 0;
    pointer-events: none;
}

.pi-ui-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    z-index: 10;
    width: 100%;
    padding: 3rem var(--pi-pad-x) calc(3rem + env(safe-area-inset-bottom, 0px));
    gap: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    box-sizing: border-box;
    pointer-events: none; /* Dejar pasar el mouse para el parallax de fondo */
}

.pi-text-box, 
.pi-controls-fixed {
    pointer-events: auto; /* Permitir interacción exclusiva en textos y botones */
}

.pi-text-box {
    flex: 0 1 auto;
    min-width: 0;            /* permite que el texto se encoja y no empuje los botones fuera del marco */
    max-width: 600px;
    color: #ffffff;
    overflow-wrap: break-word;
}

.pi-title {
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 700;
    margin-bottom: 0.5rem;
    line-height: 1.1;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.pi-subtitle {
    font-size: clamp(1rem, 2vw, 1.25rem);
    opacity: 0.9;
    margin: 0;
    text-shadow: 0 1px 5px rgba(0,0,0,0.5);
}

.pi-controls-fixed {
    display: flex;
    flex: 0 0 auto;          /* los botones nunca se encogen ni se salen del marco */
    gap: 1rem;
    z-index: 20;
}

.pi-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    background: rgba(0, 0, 0, 0.6);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px; /* tamaño del icono (se puede cambiar desde el panel de Elementor) */
    line-height: 1;
    -webkit-backdrop-filter: blur(4px); /* Safari */
    backdrop-filter: blur(4px);
    transition: background 0.3s ease;
    z-index: 30;
}

.pi-btn:hover {
    background: rgba(0, 0, 0, 0.9);
}

.pi-btn:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 3px;
}

/* --- Iconos nativos de Elementor dentro de los botones --- */
.pi-btn .pi-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.pi-btn .pi-ico i {
    font-size: inherit;
    line-height: 1;
}

.pi-btn .pi-ico svg {
    width: 1em;
    height: 1em;
    fill: currentColor;
}

/* Por defecto: se ve Pausa y Silencio. Las otras variantes se muestran según el estado. */
.pi-btn .pi-ico-play,
.pi-btn .pi-ico-vol-on {
    display: none;
}

.pi-wrapper.is-paused .pi-btn .pi-ico-play {
    display: inline-flex;
}

.pi-wrapper.is-paused .pi-btn .pi-ico-pause {
    display: none;
}

.pi-wrapper:not(.is-muted) .pi-btn .pi-ico-vol-on {
    display: inline-flex;
}

.pi-wrapper:not(.is-muted) .pi-btn .pi-ico-vol-off {
    display: none;
}

/* --- Barra de progreso segmentada (un segmento por estación) --- */
.pi-progress {
    position: absolute;
    left: var(--pi-pad-x);
    right: var(--pi-pad-x);
    bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    z-index: 15;
    display: flex;
    gap: 6px;
    pointer-events: none;
}

.pi-seg {
    flex: 1 1 0;
    height: 3px;
    overflow: hidden;
    border-radius: 999px;
    background-color: rgba(255, 255, 255, 0.35);
}

.pi-seg-fill {
    display: block;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    transform: scaleX(0);
    transform-origin: left center;
    will-change: transform;
}

/* --- Tablet: márgenes laterales más cortos --- */
@media (max-width: 1024px) {
    .pi-wrapper {
        --pi-pad-x: 2rem;
    }

    .pi-ui-overlay {
        padding-top: 2.5rem;
        padding-bottom: calc(2.75rem + env(safe-area-inset-bottom, 0px));
    }
}

/* --- Móvil: texto, botones y barra pegados al borde, todo dentro del marco --- */
@media (max-width: 767px) {
    .pi-wrapper {
        --pi-pad-x: 1.25rem;
    }

    .pi-ui-overlay {
        gap: 0.75rem;
        padding-bottom: calc(2.5rem + env(safe-area-inset-bottom, 0px));
    }

    .pi-controls-fixed {
        gap: 0.5rem;
    }

    .pi-btn {
        width: 2.5rem;
        height: 2.5rem;
    }

    .pi-progress {
        bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    }
}