/**
 * REI — Modulo Accessibilità + Cookie Consent
 *
 * Widget flottanti visibili in tutto il sito:
 * - Pulsante accessibilità tondo blu in basso a sinistra
 * - Banner cookie consent in basso a sinistra (sopra il widget quando visibile)
 * - Pannello accessibilità laterale + modale preferenze cookie
 *
 * Posizioni studiate per NON sovrapporsi alla chat AI (in basso a destra).
 *
 * @since 1.15.0
 */

/* ==========================================================================
   WIDGET ACCESSIBILITÀ — Pulsante flottante
   ========================================================================== */
.rei-a11y-toggle {
    /* z-index altissimo + !important per garantire visibilità anche su home
       page con hero/slider con elementi a z-index elevato (v1.15.1 fix) */
    position: fixed !important;
    bottom: 24px !important;
    left: 24px !important;
    z-index: 2147483646 !important;
    width: 44px; height: 44px;
    border: 0; border-radius: 50%;
    background: linear-gradient(135deg, #20A47B 0%, #157155 100%);
    color: #fff;
    cursor: pointer;
    display: flex !important;
    align-items: center; justify-content: center;
    visibility: visible !important;
    opacity: 1 !important;
    box-shadow: 0 12px 28px rgba(67,97,238,0.45), 0 4px 10px rgba(0,0,0,0.18);
    transition: transform 0.2s ease, box-shadow 0.25s ease;
    /* Anello bianco esterno come nello screenshot */
    outline: 3px solid #fff;
    outline-offset: 0;
    box-sizing: border-box;
}
.rei-a11y-toggle:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 18px 38px rgba(67,97,238,0.6), 0 6px 14px rgba(0,0,0,0.22);
}
.rei-a11y-toggle:focus-visible {
    outline: 3px solid #D1E000; outline-offset: 2px;
}
.rei-a11y-toggle svg { width: 22px; height: 22px; }

/* ==========================================================================
   COOKIE BADGE PERSISTENTE (v1.15.1)
   Pulsante più piccolo sopra il toggle accessibilità per riaprire le
   preferenze cookie in qualsiasi momento.
   ========================================================================== */
.rei-cookie-toggle {
    position: fixed !important;
    bottom: 90px !important;
    left: 24px !important;
    z-index: 2147483646 !important;
    width: 44px; height: 44px;
    border: 0; border-radius: 50%;
    background: linear-gradient(135deg, #20A47B 0%, #157155 100%);
    color: #fff;
    cursor: pointer;
    display: flex !important;
    align-items: center; justify-content: center;
    visibility: visible !important;
    opacity: 1 !important;
    box-shadow: 0 10px 22px rgba(34,202,1,0.5), 0 3px 8px rgba(0,0,0,0.15);
    transition: transform 0.2s ease, box-shadow 0.25s ease;
    outline: 2px solid #fff;
    outline-offset: 0;
    box-sizing: border-box;
}
.rei-cookie-toggle:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 16px 30px rgba(34,202,1,0.65), 0 5px 12px rgba(0,0,0,0.2);
}
.rei-cookie-toggle:focus-visible {
    outline: 3px solid #D1E000; outline-offset: 2px;
}
.rei-cookie-toggle svg { width: 22px; height: 22px; }
/* Quando il banner cookie iniziale è aperto, nascondo il badge persistente
   per evitare doppione visivo */
.rei-cookie-banner.is-open ~ .rei-cookie-toggle {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none;
}

/* ==========================================================================
   PANNELLO ACCESSIBILITÀ — Card laterale slide-in da sinistra
   ========================================================================== */
.rei-a11y-panel {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 2147483647;
    width: 380px;
    max-width: calc(100vw - 48px);
    max-height: calc(100vh - 100px);
    background: linear-gradient(180deg, #f4f6fd 0%, #ebeefb 100%);
    border-radius: 22px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.30), 0 8px 20px rgba(0,0,0,0.15);
    overflow: hidden;
    display: flex; flex-direction: column;
    box-sizing: border-box;
    transform-origin: bottom left;
    transform: scale(0.5) translateY(40px);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.32s cubic-bezier(0.34, 1.4, 0.5, 1), opacity 0.25s ease, visibility 0s linear 0.32s;
}
.rei-a11y-panel * { box-sizing: border-box; }
.rei-a11y-panel.is-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    visibility: visible;
    transition: transform 0.36s cubic-bezier(0.34, 1.4, 0.5, 1), opacity 0.2s ease, visibility 0s linear 0s;
}

.rei-a11y-panel__head {
    background: linear-gradient(135deg, #20A47B 0%, #157155 100%);
    color: #fff;
    padding: 18px 22px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px;
}
.rei-a11y-panel__title {
    display: flex; align-items: center; gap: 12px;
    margin: 0; font-size: 22px; font-weight: 700;
    color: #fff;
    letter-spacing: -0.01em;
}
.rei-a11y-panel__icon {
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(255,255,255,0.18);
    display: flex; align-items: center; justify-content: center;
}
.rei-a11y-panel__icon svg { width: 18px; height: 18px; }

.rei-a11y-panel__head-actions {
    display: flex; align-items: center; gap: 6px;
}
.rei-a11y-panel__head-btn {
    width: 32px; height: 32px;
    background: transparent; border: 0; color: #fff;
    cursor: pointer; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
}
.rei-a11y-panel__head-btn:hover { background: rgba(255,255,255,0.18); }
.rei-a11y-panel__head-btn:focus-visible { outline: 2px solid #D1E000; outline-offset: 2px; }
.rei-a11y-panel__head-sep { opacity: 0.4; margin: 0 4px; }
.rei-a11y-panel__close svg { width: 22px; height: 22px; }

.rei-a11y-panel__body {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    flex: 1 1 auto;
    min-height: 0; /* v1.16.2: critico per iOS Safari — senza questo il body
                      con flex:1 + overflow:auto non si espande in altezza */
    width: 100%;
    -webkit-overflow-scrolling: touch;
    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: #c5c9e0 transparent;
}
.rei-a11y-panel__body::-webkit-scrollbar { width: 6px; }
.rei-a11y-panel__body::-webkit-scrollbar-thumb { background: #c5c9e0; border-radius: 3px; }

/* Gruppi (Testo / Visivo / Orientamento) */
.rei-a11y-group {
    background: #fff;
    border-radius: 16px;
    padding: 16px;
    margin: 0 0 12px;
}
.rei-a11y-group:last-child { margin-bottom: 0; }
.rei-a11y-group__title {
    margin: 0 0 12px;
    font-size: 14px; font-weight: 600; color: #6b6e85;
    letter-spacing: 0.01em;
}
.rei-a11y-group__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    align-items: stretch;
}

/* Tile pulsante azione */
.rei-a11y-tile {
    position: relative;
    background: #f4f5fb;
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 14px 12px;
    display: flex; align-items: center; gap: 10px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    font-size: 13.5px; font-weight: 500;
    color: #2a3548;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
    min-height: 64px;
    /* v1.16.4: critico per griglia regolare — senza min-width:0 la tile può
       espandersi oltre la sua colonna se il contenuto è lungo, sbilanciando
       la griglia 2x2. width:100% forza tutte le tile alla stessa larghezza. */
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}
.rei-a11y-tile:hover {
    background: #e9ebf6;
}
.rei-a11y-tile:focus-visible {
    outline: 2px solid #20A47B; outline-offset: 2px;
}
.rei-a11y-tile[aria-pressed="true"] {
    background: #e0e7ff;
    border-color: #20A47B;
    color: #1a1f4d;
}
.rei-a11y-tile__ico {
    width: 38px; height: 38px; border-radius: 50%;
    background: #fff;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: #20A47B;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.rei-a11y-tile__ico svg { width: 18px; height: 18px; }
.rei-a11y-tile[aria-pressed="true"] .rei-a11y-tile__ico {
    background: #20A47B; color: #fff;
}
.rei-a11y-tile__label {
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.25;
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}

/* Indicatore livello (es. testo 1x, 2x, 3x) */
.rei-a11y-tile__level {
    position: absolute;
    top: 6px; right: 8px;
    background: #20A47B;
    color: #fff;
    font-size: 10px; font-weight: 700;
    padding: 2px 6px;
    border-radius: 999px;
    line-height: 1;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.15s, transform 0.15s;
}
.rei-a11y-tile__level:not(:empty) {
    opacity: 1; transform: scale(1);
}

.rei-a11y-panel__foot {
    background: linear-gradient(135deg, #20A47B 0%, #157155 100%);
    color: #fff;
    padding: 12px 22px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    font-size: 13px;
}
.rei-a11y-panel__decl {
    color: #fff; text-decoration: none;
    display: inline-flex; align-items: center; gap: 6px;
    border-bottom: 1px solid rgba(255,255,255,0.35);
    padding-bottom: 1px;
}
.rei-a11y-panel__decl:hover { border-bottom-color: #fff; }
.rei-a11y-panel__brand {
    opacity: 0.85;
    font-weight: 500;
    display: flex; align-items: center; gap: 6px;
}
.rei-a11y-panel__brand::after {
    content: '';
    width: 16px; height: 16px;
    background: #fff;
    color: #20A47B;
    border-radius: 50%;
    display: inline-block;
}

.rei-a11y-panel__statement {
    background: #F4F8F6;
    border-top: 2px solid #D1E000;
    padding: 16px 22px;
    font-size: 13px; line-height: 1.5;
    color: #2a3548;
}
.rei-a11y-panel__statement p { margin: 0 0 8px; }
.rei-a11y-panel__statement p:last-child { margin-bottom: 0; }

/* Responsive pannello accessibilità — v1.16.3 fix definitivo iOS Safari
   con Display Zoom. Su mobile il pannello diventa un overlay full-screen
   come la modale cookie, così occupa sempre tutto lo spazio disponibile
   indipendentemente da zoom, orientamento o URL bar. */
@media (max-width: 768px) {
    .rei-a11y-toggle {
        bottom: max(16px, env(safe-area-inset-bottom, 16px)) !important;
        left: 16px !important;
        width: 42px !important;
        height: 42px !important;
    }
    .rei-a11y-toggle svg { width: 20px; height: 20px; }

    .rei-cookie-toggle {
        bottom: max(84px, calc(env(safe-area-inset-bottom, 16px) + 68px)) !important;
        left: 18px !important;
        width: 42px !important;
        height: 42px !important;
    }
    .rei-cookie-toggle svg { width: 20px; height: 20px; }

    /* PANNELLO A11Y → OVERLAY FULL-SCREEN SU MOBILE
       v1.16.4: uso CSS GRID con grid-template-rows: auto 1fr auto invece di
       flex. Grid su iOS Safari calcola le righe in modo deterministico anche
       con Display Zoom attivo, mentre flex+overflow ha bug noti che possono
       far collassare il body o far "galleggiare" il footer sopra il contenuto.
       L'altezza del pannello è ancorata a 100dvh (dynamic viewport) con
       fallback 100vh per browser più vecchi. */
    .rei-a11y-panel {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: none !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        /* Grid: header (auto) | body (1fr scrollabile) | footer (auto) */
        display: grid !important;
        grid-template-rows: auto 1fr auto !important;
        grid-template-columns: 1fr !important;
        /* Animazione slide-up dal basso */
        transform-origin: bottom center !important;
    }
    .rei-a11y-panel:not(.is-open) {
        transform: translateY(100%) !important;
    }
    .rei-a11y-panel.is-open {
        transform: translateY(0) !important;
    }

    .rei-a11y-panel__head {
        padding: max(14px, env(safe-area-inset-top, 14px)) 18px 14px;
        border-radius: 0;
        /* grid-row implicito: 1 (auto) */
    }
    .rei-a11y-panel__title { font-size: 18px; }
    .rei-a11y-panel__icon { width: 28px; height: 28px; }
    .rei-a11y-panel__icon svg { width: 16px; height: 16px; }
    .rei-a11y-panel__head-btn { width: 32px; height: 32px; }
    .rei-a11y-panel__close svg { width: 24px; height: 24px; }

    .rei-a11y-panel__body {
        padding: 14px !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        min-height: 0 !important;
        /* grid-row implicito: 2 (1fr scrollabile) — Grid garantisce che
           questa riga occupi esattamente lo spazio rimanente, indipendentemente
           da Display Zoom o variazione dell'URL bar Safari */
    }
    .rei-a11y-group {
        padding: 16px 14px !important;
        margin-bottom: 12px !important;
    }
    .rei-a11y-group:last-child {
        margin-bottom: 0 !important;
        /* Padding extra sotto l'ultimo gruppo per dare respiro allo scroll */
        padding-bottom: 20px !important;
    }
    .rei-a11y-group__title {
        margin-bottom: 12px;
        font-size: 13.5px;
    }
    .rei-a11y-group__grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 10px;
        align-items: stretch;
    }
    .rei-a11y-tile {
        padding: 12px 10px !important;
        min-height: 64px !important;
        font-size: 13px;
        gap: 10px;
        min-width: 0 !important;
        width: 100% !important;
    }
    .rei-a11y-tile__ico { width: 36px; height: 36px; }
    .rei-a11y-tile__ico svg { width: 18px; height: 18px; }
    .rei-a11y-tile__label { line-height: 1.25; }

    .rei-a11y-panel__foot {
        padding: 12px 18px max(12px, env(safe-area-inset-bottom, 12px));
        font-size: 12.5px;
        flex-wrap: wrap;
        gap: 10px;
        border-radius: 0;
        /* grid-row implicito: 3 (auto, sempre in fondo) */
    }
}

/* ==========================================================================
   MASCHERA DI LETTURA / GUIDA
   ========================================================================== */
.rei-a11y-reading-mask {
    position: fixed;
    left: 0; right: 0;
    height: 100vh;
    pointer-events: none;
    z-index: 999988;
    display: none;
    background:
        linear-gradient(to bottom,
            rgba(0,0,0,0.65) 0%,
            rgba(0,0,0,0.65) calc(50% - 60px),
            transparent calc(50% - 60px),
            transparent calc(50% + 60px),
            rgba(0,0,0,0.65) calc(50% + 60px),
            rgba(0,0,0,0.65) 100%);
    top: 0;
}
body.rei-a11y--reading-mask .rei-a11y-reading-mask { display: block; }

.rei-a11y-reading-guide {
    position: fixed;
    left: 0; right: 0;
    height: 4px;
    background: #D1E000;
    pointer-events: none;
    z-index: 999988;
    display: none;
    box-shadow: 0 0 12px rgba(255,180,0,0.6);
}
body.rei-a11y--reading-guide .rei-a11y-reading-guide { display: block; }

/* ==========================================================================
   APPLICAZIONI ACCESSIBILITÀ — Classi sul <body> attivate dal JS
   ========================================================================== */

/* Testo più grande (3 livelli) */
body.rei-a11y--text-1 { font-size: 18px; }
body.rei-a11y--text-2 { font-size: 21px; }
body.rei-a11y--text-3 { font-size: 24px; }
body.rei-a11y--text-1 *,
body.rei-a11y--text-2 *,
body.rei-a11y--text-3 * { font-size: 1em !important; line-height: inherit !important; }
/* Mantieni dimensione widget accessibilità anche con testo ingrandito */
body[class*="rei-a11y--text-"] .rei-a11y-toggle,
body[class*="rei-a11y--text-"] .rei-a11y-panel,
body[class*="rei-a11y--text-"] .rei-a11y-panel *,
body[class*="rei-a11y--text-"] .rei-cookie-banner,
body[class*="rei-a11y--text-"] .rei-cookie-banner *,
body[class*="rei-a11y--text-"] .rei-cookie-modal,
body[class*="rei-a11y--text-"] .rei-cookie-modal * {
    font-size: revert !important;
}

/* Altezza riga */
body.rei-a11y--spacing-1 p,
body.rei-a11y--spacing-1 li,
body.rei-a11y--spacing-1 h1,
body.rei-a11y--spacing-1 h2,
body.rei-a11y--spacing-1 h3 { line-height: 1.8 !important; letter-spacing: 0.04em !important; }
body.rei-a11y--spacing-2 p,
body.rei-a11y--spacing-2 li,
body.rei-a11y--spacing-2 h1,
body.rei-a11y--spacing-2 h2,
body.rei-a11y--spacing-2 h3 { line-height: 2.2 !important; letter-spacing: 0.08em !important; word-spacing: 0.2em !important; }

/* Allineamento testo */
body.rei-a11y--align-left p,
body.rei-a11y--align-left li,
body.rei-a11y--align-left h1,
body.rei-a11y--align-left h2,
body.rei-a11y--align-left h3 { text-align: left !important; }
body.rei-a11y--align-center p,
body.rei-a11y--align-center li,
body.rei-a11y--align-center h1,
body.rei-a11y--align-center h2,
body.rei-a11y--align-center h3 { text-align: center !important; }
body.rei-a11y--align-right p,
body.rei-a11y--align-right li,
body.rei-a11y--align-right h1,
body.rei-a11y--align-right h2,
body.rei-a11y--align-right h3 { text-align: right !important; }

/* Carattere leggibile (dyslexia-friendly: Atkinson Hyperlegible / Verdana fallback) */
body.rei-a11y--readable-font,
body.rei-a11y--readable-font p,
body.rei-a11y--readable-font li,
body.rei-a11y--readable-font h1,
body.rei-a11y--readable-font h2,
body.rei-a11y--readable-font h3,
body.rei-a11y--readable-font h4,
body.rei-a11y--readable-font a,
body.rei-a11y--readable-font span,
body.rei-a11y--readable-font div {
    font-family: Verdana, "Atkinson Hyperlegible", "Comic Sans MS", Tahoma, sans-serif !important;
    letter-spacing: 0.02em !important;
}

/* Contrasto */
body.rei-a11y--contrast-high { filter: contrast(1.4); }
body.rei-a11y--contrast-invert { filter: invert(1) hue-rotate(180deg); }
body.rei-a11y--contrast-dark { background: #000 !important; color: #fff !important; }
body.rei-a11y--contrast-dark *:not(.rei-a11y-toggle):not(.rei-a11y-panel):not(.rei-a11y-panel *):not(.rei-cookie-banner):not(.rei-cookie-banner *):not(.rei-cookie-modal):not(.rei-cookie-modal *) {
    background: #000 !important; color: #fff !important; border-color: #fff !important;
}
body.rei-a11y--contrast-dark a:not(.rei-a11y-panel a):not(.rei-cookie-banner a):not(.rei-cookie-modal a) { color: #D1E000 !important; }

/* Scala di grigi */
body.rei-a11y--grayscale { filter: grayscale(1); }
body.rei-a11y--grayscale .rei-a11y-toggle,
body.rei-a11y--grayscale .rei-a11y-panel,
body.rei-a11y--grayscale .rei-cookie-banner,
body.rei-a11y--grayscale .rei-cookie-modal { filter: grayscale(0); }

/* Combinazione grayscale + contrast */
body.rei-a11y--grayscale.rei-a11y--contrast-high { filter: grayscale(1) contrast(1.4); }

/* Nascondi immagini */
body.rei-a11y--hide-images img:not(.rei-a11y-panel img):not(.rei-cookie-banner img),
body.rei-a11y--hide-images picture:not(.rei-a11y-panel picture),
body.rei-a11y--hide-images video:not(.rei-a11y-panel video) {
    opacity: 0 !important;
    visibility: hidden !important;
}

/* Pausa animazioni */
body.rei-a11y--pause-anim *:not(.rei-a11y-toggle):not(.rei-a11y-panel):not(.rei-a11y-panel *):not(.rei-cookie-banner):not(.rei-cookie-banner *):not(.rei-cookie-modal):not(.rei-cookie-modal *) {
    animation-duration: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important;
}

/* Evidenzia link */
body.rei-a11y--highlight-links a:not(.rei-a11y-panel a):not(.rei-cookie-banner a):not(.rei-cookie-modal a) {
    background: #E4EE4D !important;
    color: #0B1733 !important;
    text-decoration: underline !important;
    padding: 2px 4px !important;
    border-radius: 3px !important;
    outline: 2px solid #D1E000;
    outline-offset: 1px;
}

/* Cursore grande */
body.rei-a11y--big-cursor,
body.rei-a11y--big-cursor * {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24' fill='%234361ee' stroke='white' stroke-width='1.5'><path d='M3 3l7 19 2-8 8-2L3 3z'/></svg>") 0 0, auto !important;
}

/* ==========================================================================
   COOKIE CONSENT BANNER — Card in basso a sinistra (scale-in)
   ========================================================================== */
.rei-cookie-banner {
    position: fixed;
    bottom: 100px; /* Sopra il pulsante a11y (24+56+20 ≈ 100) */
    left: 24px;
    z-index: 999985;
    width: 420px;
    max-width: calc(100vw - 48px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 30px 70px rgba(0,0,0,0.30), 0 10px 20px rgba(0,0,0,0.15);
    border: 1px solid rgba(34,202,1,0.18);
    transform: scale(0.5) translateY(60px);
    opacity: 0;
    visibility: hidden;
    transform-origin: bottom left;
    transition: transform 0.4s cubic-bezier(0.34, 1.4, 0.5, 1), opacity 0.3s ease, visibility 0s linear 0.4s;
}
.rei-cookie-banner.is-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    visibility: visible;
    transition: transform 0.45s cubic-bezier(0.34, 1.4, 0.5, 1), opacity 0.25s ease, visibility 0s linear 0s;
}
.rei-cookie-banner.rei-cookie-banner--paused {
    transform: scale(0.85) translateY(20px);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.25s ease, opacity 0.2s ease, visibility 0s linear 0.25s;
}

.rei-cookie-banner__inner { padding: 22px 26px 18px; }

.rei-cookie-banner__brand {
    display: flex; align-items: center; gap: 14px;
    margin: 0 0 14px;
    padding: 0 0 14px;
    border-bottom: 1px solid #eee;
    position: relative;
}
.rei-cookie-banner__title {
    margin: 0; flex: 1;
    font-size: 19px; font-weight: 700; color: #0B1733;
    letter-spacing: -0.01em;
    text-align: center;
}
.rei-cookie-banner__close {
    background: transparent; border: 0;
    width: 32px; height: 32px;
    color: #6b6e85;
    cursor: pointer; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.rei-cookie-banner__close:hover { background: #f4f5fb; color: #0B1733; }
.rei-cookie-banner__close:focus-visible { outline: 2px solid #157155; outline-offset: 1px; }

.rei-cookie-banner__desc {
    margin: 0 0 18px;
    font-size: 13.5px; line-height: 1.55; color: #4a5568;
}

.rei-cookie-banner__actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin: 0 0 14px;
}
.rei-cookie-banner__btn {
    border: 1px solid transparent;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px; font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
    line-height: 1.2;
}
.rei-cookie-banner__btn:focus-visible { outline: 2px solid #D1E000; outline-offset: 2px; }
.rei-cookie-banner__btn--accept {
    background: linear-gradient(135deg, #20A47B 0%, #157155 100%);
    color: #fff;
    box-shadow: 0 8px 20px -4px rgba(34,202,1,0.55), 0 2px 6px rgba(0,0,0,0.08);
}
.rei-cookie-banner__btn--accept:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px -4px rgba(34,202,1,0.65), 0 4px 10px rgba(0,0,0,0.1);
}
.rei-cookie-banner__btn--reject {
    background: #f4f5fb;
    color: #0B1733;
    border-color: #d6d9e8;
}
.rei-cookie-banner__btn--reject:hover { background: #e9ebf6; }
.rei-cookie-banner__btn--prefs,
.rei-cookie-banner__btn--save {
    background: #fff;
    color: #0B1733;
    border-color: #d6d9e8;
}
.rei-cookie-banner__btn--prefs:hover,
.rei-cookie-banner__btn--save:hover { background: #f4f5fb; }
.rei-cookie-banner__btn--save {
    background: #0B1733; color: #fff; border-color: #0B1733;
}
.rei-cookie-banner__btn--save:hover { background: #1a2950; color: #fff; }

.rei-cookie-banner__links {
    display: flex; justify-content: center; gap: 18px;
    padding: 4px 0 0;
    border-top: 1px solid #eee;
    padding-top: 12px;
}
.rei-cookie-banner__links a {
    font-size: 12.5px;
    color: #157155;
    text-decoration: underline;
    font-weight: 600;
}
.rei-cookie-banner__links a:hover { color: #157155; }

/* Responsive cookie banner */
@media (max-width: 480px) {
    .rei-cookie-banner {
        bottom: 84px;
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
    }
    .rei-cookie-banner__inner { padding: 18px 20px 14px; }
    .rei-cookie-banner__actions { grid-template-columns: 1fr; gap: 8px; }
}

/* ==========================================================================
   COOKIE MODALE PREFERENZE GRANULARI
   ========================================================================== */
.rei-cookie-modal {
    position: fixed; inset: 0;
    z-index: 999995;
    display: none;
    align-items: center; justify-content: center;
    padding: max(20px, env(safe-area-inset-top, 20px)) 20px max(20px, env(safe-area-inset-bottom, 20px));
}
.rei-cookie-modal.is-open { display: flex; }
.rei-cookie-modal__backdrop {
    position: absolute; inset: 0;
    background: rgba(11,23,51,0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
.rei-cookie-modal__inner {
    position: relative;
    background: #fff;
    border-radius: 22px;
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    display: flex; flex-direction: column;
    box-shadow: 0 30px 70px rgba(0,0,0,0.4);
    overflow: hidden;
    box-sizing: border-box;
    animation: rei-cookie-modal-in 0.3s cubic-bezier(0.34, 1.4, 0.5, 1);
}

/* v1.16.2: quando la modale cookie o il pannello a11y sono aperti, nascondo
   i pulsanti flottanti per non disturbare l'interazione con il contenuto. */
body:has(.rei-cookie-modal.is-open) .rei-a11y-toggle,
body:has(.rei-cookie-modal.is-open) .rei-cookie-toggle,
body:has(.rei-a11y-panel.is-open) .rei-cookie-toggle {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}
/* Fallback senza :has() per Safari < 15.4 — il JS aggiunge queste classi
   al body all'apertura/chiusura degli overlay. */
body.rei-cookie-modal-open .rei-a11y-toggle,
body.rei-cookie-modal-open .rei-cookie-toggle,
body.rei-a11y-panel-open .rei-cookie-toggle {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}
@keyframes rei-cookie-modal-in {
    from { transform: scale(0.85) translateY(20px); opacity: 0; }
    to   { transform: scale(1) translateY(0); opacity: 1; }
}

.rei-cookie-modal__head {
    padding: 20px 26px;
    border-bottom: 1px solid #eee;
    display: flex; align-items: center; justify-content: space-between;
    background: linear-gradient(135deg, #E4F6F0 0%, #D2F0E6 100%);
}
.rei-cookie-modal__title {
    margin: 0; font-size: 21px; font-weight: 700; color: #0B1733;
    letter-spacing: -0.01em;
}
.rei-cookie-modal__close {
    background: transparent; border: 0;
    width: 36px; height: 36px;
    color: #0B1733;
    cursor: pointer; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
}
.rei-cookie-modal__close:hover { background: rgba(11,23,51,0.08); }
.rei-cookie-modal__close:focus-visible { outline: 2px solid #157155; outline-offset: 1px; }

.rei-cookie-modal__body {
    overflow-y: auto;
    padding: 22px 26px;
    flex: 1;
}
.rei-cookie-modal__lead {
    margin: 0 0 20px;
    color: #2a3548; font-size: 14.5px; line-height: 1.6;
}

/* Categoria cookie con toggle switch */
.rei-cookie-cat {
    background: #f8f9fc;
    border: 1px solid #e6e9f2;
    border-radius: 12px;
    padding: 16px 18px;
    margin: 0 0 12px;
}
.rei-cookie-cat__head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px;
    margin: 0 0 8px;
}
.rei-cookie-cat__title {
    margin: 0;
    font-size: 16px; font-weight: 700; color: #0B1733;
    display: inline-flex; align-items: center; gap: 10px;
}
.rei-cookie-cat__badge {
    display: inline-block;
    background: #E4F6F0; color: #157155;
    font-size: 10px; font-weight: 700;
    padding: 3px 8px; border-radius: 999px;
    margin-left: 4px;
    letter-spacing: 0.04em; text-transform: uppercase;
}
.rei-cookie-cat__desc {
    margin: 0;
    color: #4a5568; font-size: 13px; line-height: 1.55;
}
/* Switch */
.rei-cookie-cat__switch {
    position: relative;
    width: 46px; height: 26px;
    flex-shrink: 0;
    cursor: pointer;
}
.rei-cookie-cat__switch input {
    opacity: 0; width: 0; height: 0;
}
.rei-cookie-cat__slider {
    position: absolute; inset: 0;
    background: #d6d9e8;
    border-radius: 999px;
    transition: background 0.2s ease;
}
.rei-cookie-cat__slider::before {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 20px; height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.22s ease;
}
.rei-cookie-cat__switch input:checked + .rei-cookie-cat__slider {
    background: linear-gradient(135deg, #20A47B 0%, #157155 100%);
}
.rei-cookie-cat__switch input:checked + .rei-cookie-cat__slider::before {
    transform: translateX(20px);
}
.rei-cookie-cat__switch--locked .rei-cookie-cat__slider {
    background: linear-gradient(135deg, #20A47B 0%, #157155 100%);
    opacity: 0.65;
    cursor: not-allowed;
}
.rei-cookie-cat__switch--locked .rei-cookie-cat__slider::before {
    transform: translateX(20px);
}

.rei-cookie-modal__foot {
    padding: 16px 26px;
    border-top: 1px solid #eee;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    background: #fbfbfd;
}

@media (max-width: 560px) {
    .rei-cookie-modal__foot { grid-template-columns: 1fr; }
    .rei-cookie-cat__head { flex-wrap: wrap; }
}

/* v1.16.3+: anche la modale cookie diventa full-screen su mobile per evitare
   problemi di taglio con Display Zoom o notch.
   v1.16.4: stesso fix CSS Grid del pannello a11y (3 righe deterministiche). */
@media (max-width: 768px) {
    .rei-cookie-modal {
        padding: 0 !important;
    }
    .rei-cookie-modal__inner {
        width: 100% !important;
        max-width: none !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        display: grid !important;
        grid-template-rows: auto 1fr auto !important;
        grid-template-columns: 1fr !important;
    }
    .rei-cookie-modal__head {
        padding: max(18px, env(safe-area-inset-top, 18px)) 20px 16px !important;
        border-radius: 0;
    }
    .rei-cookie-modal__title { font-size: 19px; }
    .rei-cookie-modal__body {
        min-height: 0 !important;
        padding: 18px 20px !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
    }
    .rei-cookie-modal__foot {
        padding: 14px 20px max(14px, env(safe-area-inset-bottom, 14px)) !important;
        border-radius: 0;
        grid-template-columns: 1fr !important;
        gap: 8px;
    }
}

/* v1.16.3: blocca lo scroll del body quando un overlay è aperto, per evitare
   che l'utente scrolli accidentalmente la pagina sotto l'overlay. */
body.rei-cookie-modal-open,
body.rei-a11y-panel-open {
    overflow: hidden !important;
    position: relative;
}

/* Reduced motion: rispetta preferenza utente */
@media (prefers-reduced-motion: reduce) {
    .rei-a11y-toggle,
    .rei-a11y-panel,
    .rei-cookie-banner,
    .rei-cookie-modal__inner,
    .rei-cookie-cat__slider,
    .rei-cookie-cat__slider::before {
        animation: none !important;
        transition: opacity 0.15s ease !important;
    }
}
