/* Commercial Popup — overlay pubblico */

/* Con ricerca aperta il banner non deve catturare scroll/tap */
html.gs-search-open #cp-ad-overlay,
body.gs-search-open #cp-ad-overlay {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.cp-ad-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: auto;
    overscroll-behavior: contain;
    z-index: 100050;
}

.cp-ad-overlay.cp-open {
    opacity: 1;
    visibility: visible;
}

.cp-ad-dialog {
    position: relative;
    width: min(92vw, 560px);
    max-height: min(88vh, 720px);
    overflow: auto;
    background: #fff;
    border-radius: 0.5rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    touch-action: auto;
    overscroll-behavior: contain;
}

.cp-ad-close {
    position: absolute;
    top: 0.35rem;
    right: 0.45rem;
    z-index: 2;
    width: 2.25rem;
    height: 2.25rem;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.06);
    color: #212529;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.cp-ad-close:hover,
.cp-ad-close:focus {
    background: rgba(0, 0, 0, 0.12);
    outline: none;
    outline-offset: 2px;
}

.cp-ad-content img {
    max-width: 100%;
    height: auto;
}

/* Isolamento leggero: evita che tipografia/box del popup “esca” dal dialog */
.cp-ad-content {
    isolation: isolate;
    /* layout/style only: "content" puo' clippare paint di CTA con testo largo */
    contain: layout style;
}

/*
 * Newsletter CTA: il CSS del blocco viene scopato a runtime
 * (.cp-ad-content .popup-newsletter-btn) e puo' ristabilire width:40%.
 * Serve specificita' + !important per vincere sull'<style> iniettato.
 */
.cp-ad-overlay .cp-ad-content button.popup-newsletter-btn,
.cp-ad-overlay .cp-ad-content button.popup-newsletter-success-btn,
.cp-ad-overlay .cp-ad-content .popup-newsletter-btn,
.cp-ad-overlay .cp-ad-content .popup-newsletter-success-btn {
    box-sizing: border-box !important;
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding: 12px 1.25rem !important;
    font-size: clamp(0.95rem, 4.2vw, 1.125rem) !important;
    line-height: 1.25 !important;
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
}

.cp-ad-content .g-recaptcha {
    position: absolute;
    left: 0;
    top: 0;
    width: 1px;
    height: 1px;
    overflow: visible;
    opacity: 0.01;
    z-index: -1;
}

.cp-ad-content .grecaptcha-badge {
    visibility: hidden !important;
    opacity: 0 !important;
}

/*
 * Strategia lock: NESSUNA modifica a body/html (niente position:fixed, overflow, top).
 * Lo scroll pagina si blocca solo via JS (wheel/touch/keys). Header e spacer restano intatti.
 */

/* Finestra breve dopo chiusura: evita che :hover sticky su touch colorisca i CTA sotto l'overlay */
body.cp-popup-just-closed a,
body.cp-popup-just-closed button {
    transition: none !important;
}

@media (prefers-reduced-motion: reduce) {
    .cp-ad-overlay {
        transition: none;
    }
}
