/* ============================================================
   CMS POPUP
   ============================================================ */

body.pop-up-cms2-open {
    overflow: hidden;
}

#pop-up-cms2 {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

#pop-up-cms2.pop-up-hidden {
    display: none !important;
}

.pop-up-cms2__background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 9998;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.5s ease;
}

#pop-up-cms2.is-visible .pop-up-cms2__background {
    opacity: 1;
}

.pop-up-cms2__content {
    position: relative;
    display: flex;
    width: 90%;
    max-width: 1100px;
    max-height: 90vh;
    max-height: 90svh;
    overflow-y: auto;
    background: #ffffff;
    z-index: 10000;
    align-items: stretch;
    opacity: 0;
    transform: translateY(28px);
    transition: opacity 0.55s ease 0.15s,
                transform 0.55s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.15s;
}

#pop-up-cms2.is-visible .pop-up-cms2__content {
    opacity: 1;
    transform: translateY(0);
}

.pop-up-cms2__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    background: transparent;
    color: var(--primary-color);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    padding: 0;
    line-height: 1;
    transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.pop-up-cms2__close:hover {
    background-color: rgba(0, 0, 0, 0.08);
    transform: scale(1.1);
}

#pop-up-cms2 .pop-up-cms2__close:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}

.pop-up-cms2__image {
    flex: 0 0 50%;
    background-color: var(--accent-color);
}

.pop-up-cms2__image img {
    display: block;
    width: 100%;
    height: auto;
}

/* Escritorio/portátil: mitad imagen, mitad texto SIEMPRE (50/50). La imagen no aporta altura: rellena su mitad y se ajusta
   entera (object-fit: contain, sin recorte) sea cual sea su proporción y la altura de la pantalla */
@media (min-width: 577px) {
    #pop-up-cms2.pop-up-cms2--full .pop-up-cms2__content {
        min-height: min(700px, 90vh);
        min-height: min(700px, 90svh);
    }

    #pop-up-cms2.pop-up-cms2--full .pop-up-cms2__image {
        position: relative;
    }

    #pop-up-cms2.pop-up-cms2--full .pop-up-cms2__image img {
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        object-fit: fill;
    }
}

.pop-up-cms2__text {
    flex: 1;
    padding: 56px 34px 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
    background: #ffffff;
}

.pop-up-cms2__text__title {
    display: block;
    font-family: var(--font-family-title);
    font-size: 30px;
    line-height: 1.25;
    color: var(--primary-color);
}

.pop-up-cms2__text__description {
    font-family: var(--font-family-body);
    color: var(--text-color);
}

.pop-up-cms2__text__description h1,
.pop-up-cms2__text__description h2 {
    font-family: var(--font-family-title);
    color: var(--primary-color);
    margin: 0 0 8px;
    line-height: 1.2;
}

.pop-up-cms2__text__description h1 {
    font-size: 26px;
}

.pop-up-cms2__text__description h2 {
    font-size: 18px;
    margin-top: 14px;
}

.pop-up-cms2__text__description p {
    margin: 0 0 8px;
}

.pop-up-cms2__text__description p:last-child {
    margin-bottom: 0;
}

#pop-up-cms2 .button {
    align-self: flex-start;
    margin-top: unset;
}

@media (max-width: 992px) {
    .pop-up-cms2__content {
        width: 88%;
    }

    .pop-up-cms2__text {
        padding: 56px 28px 40px;
    }

}

/* Tablet y móvil (hasta 1024px, iPad mini incluido): estado imagen + texto sin imagen, solo el texto
   (el estado image-only conserva la imagen porque ES el popup) */
@media (max-width: 1024px) {
    #pop-up-cms2.pop-up-cms2--full .pop-up-cms2__image {
        display: none;
    }

    #pop-up-cms2.pop-up-cms2--full .pop-up-cms2__content {
        min-height: 0;
        max-width: 640px;
    }

    .pop-up-cms2__text__title {
        font-size: 36px;
    }
}

/* Móvil: imagen arriba, texto debajo, scroll interno + indicador de scroll */
@media (max-width: 576px) {
    .pop-up-cms2__content {
        flex-direction: column;
        width: 94%;
        max-height: 90vh;
        max-height: 90svh;
        overflow-y: auto;
    }

    .pop-up-cms2__image {
        display: block;
        flex: 0 0 auto;
        max-width: 100%;
    }

    .pop-up-cms2__image img {
        width: 100%;
        max-width: 100%;
        height: auto;
    }

    .pop-up-cms2__close {
        background-color: #ffffff;
    }

    .pop-up-cms2__text {
        flex: 0 0 auto;
        padding: 36px 24px;
        overflow-y: visible;
    }

    /* Sin imagen arriba, más aire superior para que la X de cierre no tape el título */
    #pop-up-cms2.pop-up-cms2--full .pop-up-cms2__text {
        padding-top: 56px;
    }

    .pop-up-cms2__text__title {
        font-size: 28px;
    }

    .pop-up-cms2__text__description h1 {
        font-size: 22px;
    }

    /* Indicador de scroll: degradado + flecha pegados al borde inferior */
    .pop-up-cms2__content::after {
        content: "";
        flex: 0 0 auto;
        position: sticky;
        bottom: 0;
        height: 72px;
        margin-top: -72px;
        pointer-events: none;
        background:
            url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235a4524' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 9l7 7 7-7'/%3E%3C/svg%3E") no-repeat center bottom 8px / 28px 28px,
            linear-gradient(to top, #ffffff 35%, rgba(255, 255, 255, 0));
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    #pop-up-cms2.pop-up-cms2--scrollable:not(.pop-up-cms2--scrolled-end) .pop-up-cms2__content::after {
        opacity: 1;
    }
}

@media (max-width: 576px) and (prefers-reduced-motion: no-preference) {
    #pop-up-cms2.pop-up-cms2--scrollable:not(.pop-up-cms2--scrolled-end) .pop-up-cms2__content::after {
        animation: pop-up-cms2-scroll-hint 1.4s ease-in-out infinite;
    }

    @keyframes pop-up-cms2-scroll-hint {
        0%, 100% { background-position: center bottom 8px, 0 0; }
        50%      { background-position: center bottom 2px, 0 0; }
    }
}

/* ============================================================
   ESTADO: SOLO IMAGEN (.pop-up-cms2--image-only)
   La imagen ancha lleva el texto y el botón dentro: se muestra entera y enlaza al motor
   ============================================================ */

#pop-up-cms2.pop-up-cms2--image-only .pop-up-cms2__content {
    display: block;
    width: 96%;
    max-width: 1200px;
    max-height: none;
    background: transparent;
    overflow: visible;
}

#pop-up-cms2.pop-up-cms2--image-only .pop-up-cms2__content::after {
    display: none;
}

#pop-up-cms2.pop-up-cms2--image-only .pop-up-cms2__close {
    background-color: #ffffff;
    font-size: 0;
}

/* La X se dibuja con dos líneas para quedar centrada exacta en el círculo (el glifo ✕ queda descentrado) */
#pop-up-cms2.pop-up-cms2--image-only .pop-up-cms2__close::before,
#pop-up-cms2.pop-up-cms2--image-only .pop-up-cms2__close::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 2px;
    background-color: var(--primary-color);
    border-radius: 1px;
    transform: translate(-50%, -50%) rotate(45deg);
}

#pop-up-cms2.pop-up-cms2--image-only .pop-up-cms2__close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

#pop-up-cms2.pop-up-cms2--image-only .pop-up-cms2__image {
    display: block;
    flex: none;
    max-width: 100%;
    overflow: visible;
    background: transparent;
}

#pop-up-cms2.pop-up-cms2--image-only .pop-up-cms2__image a {
    display: block;
}

#pop-up-cms2.pop-up-cms2--image-only .pop-up-cms2__image a:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}

/* Imagen ENTERA con su proporción natural (sin recortes, nunca más alta que la pantalla) */
#pop-up-cms2.pop-up-cms2--image-only .pop-up-cms2__image img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 90vh;
    max-height: 90svh;
    margin: 0 auto;
}

/* Móvil sin imagen específica: la imagen apaisada a 360px dejaría su texto ilegible; se muestra más grande y se desplaza
   en horizontal. El scroll lo hace la imagen (no el contenedor) para que la X se quede fija en su esquina */
@media (max-width: 767px) {
    #pop-up-cms2.pop-up-cms2--image-only:not(.pop-up-cms2--has-mobile-image) .pop-up-cms2__image {
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }

    #pop-up-cms2.pop-up-cms2--image-only:not(.pop-up-cms2--has-mobile-image) .pop-up-cms2__image img {
        max-width: none;
        width: 720px;
        max-height: none;
    }

    /* Aviso de desplazamiento: degradado + flecha en el borde derecho mientras quede imagen por ver */
    #pop-up-cms2.pop-up-cms2--image-only:not(.pop-up-cms2--has-mobile-image) .pop-up-cms2__content::after {
        content: "";
        display: block;
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: auto;
        width: 64px;
        height: auto;
        margin: 0;
        pointer-events: none;
        background:
            url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 5l7 7-7 7'/%3E%3C/svg%3E") no-repeat right 8px center / 28px 28px,
            linear-gradient(to left, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    #pop-up-cms2.pop-up-cms2--image-only.pop-up-cms2--scrollable:not(.pop-up-cms2--scrolled-end):not(.pop-up-cms2--has-mobile-image) .pop-up-cms2__content::after {
        opacity: 1;
    }
}

@media (max-width: 767px) and (prefers-reduced-motion: no-preference) {
    #pop-up-cms2.pop-up-cms2--image-only.pop-up-cms2--scrollable:not(.pop-up-cms2--scrolled-end):not(.pop-up-cms2--has-mobile-image) .pop-up-cms2__content::after {
        animation: pop-up-cms2-scroll-hint-x 1.4s ease-in-out infinite;
    }

    @keyframes pop-up-cms2-scroll-hint-x {
        0%, 100% { background-position: right 8px center, 0 0; }
        50%      { background-position: right 2px center, 0 0; }
    }
}

/* Móvil con imagen específica (descripción movil o mobile): imagen vertical o cuadrada entera, sin desplazamiento */
@media (max-width: 767px) {
    #pop-up-cms2.pop-up-cms2--has-mobile-image .pop-up-cms2__content {
        width: auto;
        max-width: 94%;
    }

    #pop-up-cms2.pop-up-cms2--has-mobile-image .pop-up-cms2__image img {
        width: auto;
        max-width: 100%;
        max-height: 90svh;
    }
}

/* ============================================================
   ESTADO: SOLO TEXTO (.pop-up-cms2--text-only)
   ============================================================ */

#pop-up-cms2.pop-up-cms2--text-only .pop-up-cms2__content {
    max-width: 560px;
}
