/* Pop up de la portada (partials/home-popup.php, popup.js). Solo se carga si hay imágenes activas. */
/* The inline ratios (width / height of the tallest image) keep every slide within the screen height. */
.home-popup {
    --home-popup-space: 4rem;
    --home-popup-ratio: var(--home-popup-ratio-desktop, 1);
    width: min(calc(100vw - 2rem), 38rem, calc((100vh - var(--home-popup-space)) * var(--home-popup-ratio, 1)));
    width: min(calc(100vw - 2rem), 38rem, calc((100dvh - var(--home-popup-space)) * var(--home-popup-ratio, 1)));
    max-width: none;
    max-height: none;
    margin: auto;
    padding: 0;
    overflow: visible;
    color: var(--white);
    background: transparent;
    border: 0;
    font-family: var(--font-sans);
    opacity: 0;
    transform: translateY(1rem) scale(0.97);
    transition: opacity 260ms var(--ease-out), transform 260ms var(--ease-out);
}
.home-popup--wide {
    width: min(calc(100vw - 2rem), 56rem, calc((100vh - var(--home-popup-space)) * var(--home-popup-ratio, 1)));
    width: min(calc(100vw - 2rem), 56rem, calc((100dvh - var(--home-popup-space)) * var(--home-popup-ratio, 1)));
}
.home-popup--carousel { --home-popup-space: 8rem; }
.home-popup.is-visible { opacity: 1; transform: none; }
.home-popup:focus { outline: none; }
.home-popup::backdrop { background: rgba(9, 31, 84, 0.62); }
html.home-popup-is-open { overflow: hidden; }

.home-popup__frame { position: relative; }
.home-popup__track {
    display: flex;
    margin: 0;
    padding: 0;
    overflow-x: auto;
    overflow-y: hidden;
    list-style: none;
    /* The shadow follows each image, so a shorter slide shows no empty card around it. */
    filter: drop-shadow(0 1.25rem 2rem rgba(0, 0, 0, 0.35));
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}
.home-popup__track::-webkit-scrollbar { display: none; }
/* Top alignment keeps the close button on the corner of shorter images. */
.home-popup__slide { display: flex; flex: 0 0 100%; align-items: flex-start; scroll-snap-align: center; scroll-snap-stop: always; }
.home-popup__link { display: block; width: 100%; }
.home-popup picture { display: block; width: 100%; }
.home-popup__image {
    display: block;
    width: 100%;
    height: auto;
    max-height: calc(100vh - var(--home-popup-space));
    max-height: calc(100dvh - var(--home-popup-space));
    object-fit: contain;
    border-radius: var(--radius-sm);
}
.home-popup__link:focus-visible { outline: 3px solid var(--white); outline-offset: -6px; }

.home-popup__close {
    position: absolute;
    z-index: 1;
    top: 0.65rem;
    right: 0.65rem;
    display: grid;
    width: 2.75rem;
    height: 2.75rem;
    place-items: center;
    color: var(--primary-deep);
    background: var(--white);
    border: 0;
    border-radius: 50%;
    box-shadow: 0 0.4rem 1.2rem rgba(9, 31, 84, 0.3);
    font-size: 1.1rem;
    cursor: pointer;
    transition: transform 160ms var(--ease-out), background 160ms ease;
}
.home-popup__close:hover { background: var(--secondary); transform: scale(1.06); }

.home-popup__controls { display: flex; margin-top: 1rem; align-items: center; justify-content: center; gap: 0.9rem; }
.home-popup__dots { display: flex; align-items: center; gap: 0.15rem; }
.home-popup__arrow {
    display: grid;
    width: 2.75rem;
    height: 2.75rem;
    place-items: center;
    color: var(--primary-deep);
    background: var(--white);
    border: 0;
    border-radius: 50%;
    font-size: 0.95rem;
    cursor: pointer;
}
.home-popup__arrow:hover { background: var(--secondary); }
/* The 1.75rem button keeps a usable touch target around the small visible dot. */
.home-popup__dot { display: grid; width: 1.75rem; height: 1.75rem; padding: 0; place-items: center; background: transparent; border: 0; cursor: pointer; }
.home-popup__dot::before { content: ""; width: 0.6rem; height: 0.6rem; background: rgba(255, 255, 255, 0.5); border-radius: var(--radius-pill); transition: width 200ms var(--ease-out), background 200ms ease; }
.home-popup__dot[aria-current="true"]::before { width: 1.4rem; background: var(--white); }
.home-popup__close:focus-visible, .home-popup__arrow:focus-visible, .home-popup__dot:focus-visible { outline: 3px solid var(--primary-soft); outline-offset: 2px; }

@media (max-width: 767px) {
    .home-popup { --home-popup-ratio: var(--home-popup-ratio-mobile, var(--home-popup-ratio-desktop, 1)); }
    .home-popup__close { top: 0.5rem; right: 0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
    .home-popup, .home-popup__close, .home-popup__dot::before { transition: none; }
    .home-popup { transform: none; }
}
