/* =========================================================
   A&T Popup — stile del frontend
   =========================================================

   I colori arrivano dal singolo popup come variabili CSS scritte
   nell'attributo style dell'overlay: --avp-bg, --avp-text, --avp-accent.
   Qui ci sono solo i ripieghi, per il caso in cui manchino.

   L'overlay nasce con l'attributo hidden e viene scoperto dal JavaScript
   solo dopo aver controllato i cookie. È voluto: senza, su una pagina
   servita dalla cache il popup lampeggerebbe per un istante anche a chi
   ha già risposto.
   ========================================================= */

.avp-overlay {
    --avp-bg: #fff;
    --avp-text: #1a1a1a;
    --avp-accent: #27ae60;

    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, .75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease, visibility .25s ease;
}

.avp-overlay[hidden] { display: none; }
.avp-overlay.avp-visible { opacity: 1; visibility: visible; }

/* ---- Il riquadro ---- */

.avp-box {
    position: relative;
    width: 100%;
    max-width: 480px;

    /* Senza questo il riquadro misura 480 + 72 di padding, e su un telefono
       il 100% di larghezza più il padding esce dallo schermo. I temi non
       impongono box-sizing su ogni div, quindi va detto qui. */
    box-sizing: border-box;

    padding: 44px 36px 36px;
    border-radius: 16px;
    background: var(--avp-bg);
    color: var(--avp-text);
    text-align: center;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .35);
    transform: translateY(20px);
    transition: transform .3s ease;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}

.avp-overlay.avp-visible .avp-box { transform: translateY(0); }

.avp-layout-fullscreen .avp-box {
    max-width: none;
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}

.avp-layout-fullscreen .avp-box > * { max-width: 620px; width: 100%; }

/* Il marchio +18 e' l'eccezione, e va detta subito dopo.
   La riga qui sopra allarga a tutta larghezza ogni figlio diretto del
   riquadro — ed e' giusto per titolo, testo e pulsanti. Sul marchio no:
   ha `border-radius: 50%`, quindi allargato a 620px non diventa un
   cerchio grande ma un'ellisse schiacciata. Serve una regola di pari
   specificita', perche' `.avp-badge` da sola perde il confronto. */
.avp-layout-fullscreen .avp-box > .avp-badge { width: 96px; }

/* ---- Chiusura ---- */

.avp-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--avp-text);
    opacity: .5;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    transition: opacity .15s ease, background .15s ease;
}

.avp-close:hover { opacity: 1; background: rgba(0, 0, 0, .07); }

.avp-layout-fullscreen .avp-close { top: 18px; right: 20px; }

/* ---- Bollino +18 ---- */

.avp-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 96px;
    height: 96px;
    margin-bottom: 22px;
    border-radius: 50%;
    background: #c0392b;
    color: #fff;
    line-height: 1;
    box-shadow: 0 4px 16px rgba(192, 57, 43, .45);
}

.avp-badge .avp-plus { margin-top: -6px; font: 900 36px/1 Arial, sans-serif; }
.avp-badge .avp-num  { font: 900 48px/1 Arial, sans-serif; letter-spacing: -2px; }

/* ---- Contenuto ---- */

.avp-image {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto 20px;
    border-radius: 10px;
}

.avp-type-image .avp-image { margin-bottom: 0; }
.avp-image-link { display: block; }

.avp-heading {
    margin: 0 0 12px;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
    color: inherit;
}

.avp-text {
    margin: 0 0 26px;
    font-size: 15px;
    line-height: 1.6;
    opacity: .85;
}

.avp-text p:last-child { margin-bottom: 0; }
.avp-text a { color: var(--avp-accent); }
.avp-text img { max-width: 100%; height: auto; }

/* ---- Pulsanti ---- */

.avp-buttons { display: flex; flex-direction: column; gap: 12px; }

.avp-btn {
    display: block;
    width: 100%;
    padding: 14px 20px;
    border: 0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: filter .2s ease, transform .1s ease;
}

.avp-btn:active { transform: scale(.98); }

.avp-btn-yes {
    background: var(--avp-accent);
    color: #fff;
}

.avp-btn-yes:hover { filter: brightness(.92); color: #fff; }

.avp-btn-no {
    background: transparent;
    color: inherit;
    opacity: .65;
    border: 2px solid currentColor;
}

.avp-btn-no:hover { opacity: 1; }

/* ---- Modulo di iscrizione ---- */

.avp-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }

.avp-field input {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid rgba(0, 0, 0, .18);
    border-radius: 8px;
    background: #fff;
    color: #1a1a1a;
    font-family: inherit;
    font-size: 15px;
    box-sizing: border-box;
}

.avp-field input:focus {
    outline: 2px solid var(--avp-accent);
    outline-offset: 1px;
}

.avp-consent {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    font-size: 13px;
    line-height: 1.5;
    opacity: .8;
}

.avp-consent input { margin-top: 3px; flex: 0 0 auto; }
.avp-consent a { color: var(--avp-accent); }

.avp-form-msg { margin: 0; font-size: 14px; min-height: 0; }
.avp-form-msg.avp-ok    { color: #1e7e46; }
.avp-form-msg.avp-error { color: #b32d2e; }

.avp-form.avp-done .avp-field,
.avp-form.avp-done .avp-consent,
.avp-form.avp-done .avp-btn { display: none; }

/* Nasconde l'etichetta lasciandola ai lettori di schermo. */
.avp-overlay .screen-reader-text {
    position: absolute !important;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---- Schermi piccoli ---- */

@media (max-width: 520px) {
    .avp-box { padding: 34px 22px 28px; }

    .avp-badge { width: 78px; height: 78px; margin-bottom: 18px; }
    .avp-layout-fullscreen .avp-box > .avp-badge { width: 78px; }
    .avp-badge .avp-plus { font-size: 27px; }
    .avp-badge .avp-num  { font-size: 37px; }

    .avp-heading { font-size: 19px; }
    .avp-text    { font-size: 14px; }
    .avp-btn     { font-size: 15px; padding: 13px 16px; }
}

/* Chi ha chiesto meno animazioni non deve subire la transizione. */
@media (prefers-reduced-motion: reduce) {
    .avp-overlay, .avp-box { transition: none; }
    .avp-box { transform: none; }
}
