/* Smartphone Italia — homepage overlay states (20260704-home-holistic)
   Centralizes search / cart / legacy ThemeVolty backdrop coordination on #index */

/* ── Desktop inline search: dropdown only, NO full-page dim ── */
@media (min-width: 992px) {
    body#index #wrapper::after,
    body#index #wrapper.visible::after,
    body.si-desktop-search-active #wrapper::after,
    body.si-desktop-search-active #wrapper.visible::after {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }

    body.si-desktop-search-active .tv-main-div .half-wrapper-backdrop,
    body.search-open .tv-main-div .half-wrapper-backdrop {
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }

    body.si-desktop-search-active,
    body#index.si-desktop-search-active {
        overflow: auto !important;
        touch-action: auto !important;
    }

    body#index.si-desktop-search-active .si-b2b-home,
    body#index.si-desktop-search-active #content-wrapper,
    body#index.si-desktop-search-active #content,
    body.si-desktop-search-active .si-b2b-home,
    body.si-desktop-search-active #content {
        pointer-events: auto !important;
        filter: none !important;
        -webkit-filter: none !important;
    }

    body.si-desktop-search-active .si-search-backdrop,
    body.si-desktop-search-active .full-wrapper-backdrop {
        display: none !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    /* Header stacking — dropdown above megamenu / brand bar */
    #header .tvcmsdesktop-top-header-wrapper,
    #header .tvcms-header-menu-offer-wrapper {
        position: relative;
        z-index: 10050;
    }

    #header .tvsearch-header-display-wrappper {
        position: relative;
        z-index: 10055;
    }

    #header .tvsearch-result {
        z-index: 10060 !important;
    }
}

/* ── Mobile search open: dedicated backdrop, page not tappable ── */
@media (max-width: 991px) {
    body#index.si-search-open .si-b2b-home,
    body#index.si-search-open #content-wrapper,
    body#index.si-search-open #content,
    body.si-search-open .si-b2b-home,
    body.si-search-open #content-wrapper,
    body.si-search-open #content {
        pointer-events: none !important;
        filter: none !important;
        -webkit-filter: none !important;
    }
}

/* ── Cart / account open: dim homepage content, backdrop via si-header-panels ── */
body#index.classicCartOpen .si-b2b-home,
body#index.si-cart-open .si-b2b-home,
body#index.si-account-open .si-b2b-home,
body#index.si-overlay-open .si-b2b-home,
body#index.classicCartOpen #content,
body#index.si-cart-open #content,
body#index.si-account-open #content {
    pointer-events: none !important;
    filter: brightness(0.7) !important;
    -webkit-filter: brightness(0.7) !important;
}

body#index.classicCartOpen .si-b2b-home,
body#index.si-overlay-open .si-b2b-home,
body#index.si-cart-open .si-b2b-home,
body#index.classicCartOpen .si-b2b-hero,
body#index.classicCartOpen .si-b2b-trust,
body#index.classicCartOpen .si-b2b-categories,
body#index.classicCartOpen .si-b2b-steps,
body#index.classicCartOpen .si-b2b-brands,
body#index.classicCartOpen .si-b2b-faq,
body#index.classicCartOpen .si-b2b-contact {
    z-index: auto !important;
    isolation: auto !important;
}

body#index.classicCartOpen .si-b2b-hero__main,
body#index.classicCartOpen .si-b2b-hero__card,
body#index.si-overlay-open .si-b2b-hero__main,
body#index.si-overlay-open .si-b2b-hero__card,
body#index.si-cart-open .si-b2b-hero__main,
body#index.si-cart-open .si-b2b-hero__card {
    transform: none !important;
    -webkit-transform: none !important;
    animation: none !important;
}

/* Mutual exclusion: search open → page backdrop off (JS also closes cart/account) */
body#index.si-search-open.classicCartOpen .si-cart-backdrop,
body.si-search-open.classicCartOpen .si-cart-backdrop,
body.si-search-open .si-cart-backdrop.active,
body.si-search-open .si-page-backdrop.active,
body.si-desktop-search-active .si-page-backdrop.active {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Cart / account open → hide search UI remnants */
body#index.classicCartOpen .si-search-backdrop,
body.classicCartOpen .si-search-backdrop,
body#index.si-account-open .si-search-backdrop,
body.si-account-open .si-search-backdrop {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ── Brand row + header stacking when overlays open ── */
@media (min-width: 992px) {
    .tvcms-header-menu-offer-wrapper,
    #tvdesktop-megamenu {
        position: relative;
        z-index: 10040;
    }

    body.si-desktop-search-active .tvcms-header-menu-offer-wrapper,
    body.si-desktop-search-active #tvdesktop-megamenu {
        z-index: 10040;
    }

    /* Brand row under backdrop when cart/account open */
    body.si-cart-open .tvcms-header-menu-offer-wrapper,
    body.si-account-open .tvcms-header-menu-offer-wrapper,
    body.classicCartOpen .tvcms-header-menu-offer-wrapper {
        z-index: 10040;
        pointer-events: none;
        filter: brightness(0.85);
        -webkit-filter: brightness(0.85);
    }

    /* Search dropdown stays above brand row */
    body.si-desktop-search-active .tvsearch-result {
        z-index: 10060 !important;
    }

    /* Account + cart panels above brand row and backdrop */
    .tv-account-dropdown.si-account-panel.open,
    body > .tv-account-dropdown.si-account-panel.open,
    .ttvcmscart-show-dropdown-right.open {
        z-index: 99992 !important;
    }
}

/* Account open — lock scroll (desktop) */
body.si-account-open {
    overflow: hidden !important;
    touch-action: none;
}

body.si-account-open .tv-main-div,
body.si-account-open #wrapper,
body.si-account-open #content-wrapper,
body.si-account-open #content,
body.si-account-open #main,
body.si-account-open main,
body.si-account-open .si-b2b-home {
    pointer-events: none !important;
}

/* Keep header account/cart tappable when account panel open */
body.si-account-open #header .tv-contact-account-cart-wrapper,
body.si-account-open #header .tv-account-wrapper,
body.si-account-open #header .tvcms-header-cart,
body.si-account-open .tv-account-dropdown.si-account-panel,
body.si-account-open .si-page-backdrop {
    pointer-events: auto !important;
}

/* Backdrop only when account explicitly opened (click), not ThemeVolty hover */
body:not(.si-account-open):not(.si-cart-open):not(.classicCartOpen) .si-page-backdrop.active {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}
