/**
 * mypopup.css — v2.3.1
 *
 * CORRECCIÓN: La animación de entrada ahora funciona correctamente.
 * El problema anterior era que @keyframes no puede animar un elemento
 * que pasa de display:none a display:flex en el mismo frame.
 * Solución: el overlay arranca con opacity:0 + visibility:hidden
 * (en lugar de display:none), y la clase .is-visible activa la
 * transición. El JS aplica display:flex ANTES de añadir .is-visible,
 * forzando el reflow para que el navegador vea los dos estados.
 */

@keyframes mypopup-content-in {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ------------------------------------------------------------------ */
/* OVERLAY                                                             */
/* ------------------------------------------------------------------ */
#custom-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 999999;
    /* Fade del overlay en sí */
    opacity: 0;
    transition: opacity 0.22s ease;
    will-change: opacity;
}

#custom-popup-overlay.is-visible {
    opacity: 1;
}

/* ------------------------------------------------------------------ */
/* CONTENIDO — animación independiente del overlay                     */
/* ------------------------------------------------------------------ */
#custom-popup-content {
    background: #fff;
    padding: 40px;
    border-radius: 10px;
    position: relative;
    max-width: 520px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    /* La animación arranca cuando el overlay se hace visible,
       ya que el contenido siempre está en el DOM */
    opacity: 0;
    transform: translateY(14px) scale(0.98);
    transition: opacity 0.26s ease 0.04s, transform 0.26s ease 0.04s;
    will-change: opacity, transform;
}

#custom-popup-overlay.is-visible #custom-popup-content {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* ------------------------------------------------------------------ */
/* BOTÓN DE CIERRE                                                     */
/* ------------------------------------------------------------------ */
.close-btn {
    background: none;
    border: none;
    padding: 0;
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #555;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.15s, color 0.15s;
}

.close-btn:hover {
    background: rgba(0, 0, 0, 0.07);
    color: #000;
}

.close-btn:focus-visible {
    outline: 2px solid #0070c0;
    outline-offset: 2px;
}

/* ------------------------------------------------------------------ */
/* CUERPO                                                              */
/* ------------------------------------------------------------------ */
.popup-custom-body {
    margin-top: 8px;
}

.popup-custom-body img {
    max-width: 100%;
    height: auto;
}

/* ------------------------------------------------------------------ */
/* ACCESIBILIDAD                                                       */
/* ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
    #custom-popup-content,
    #custom-popup-overlay {
        transition: none;
    }
}

/* ------------------------------------------------------------------ */
/* RESPONSIVE                                                          */
/* ------------------------------------------------------------------ */
@media (max-width: 576px) {
    #custom-popup-content {
        padding: 28px 20px;
        border-radius: 8px;
        max-height: 90vh;
    }

    .close-btn {
        top: 8px;
        right: 10px;
    }
}
