/*
 * maDDma Filter Drawer 0.3.1
 * ================================================================
 * SINGLE NATIVE FILTER + RELOAD-PERSISTENZ
 * + Trustami/Bottom-Bar-Abstand
 * + Akkordeon
 * + max. 10 Werte / weitere anzeigen
 *
 * Es bleibt EIN originaler Plenty-Filter.
 */

:root {
    --maddma-filter-bottom-offset: 0px;
}

.maddma-filter-drawer-backdrop,
.maddma-filter-drawer-header,
.maddma-filter-drawer-footer {
    display: none;
}

@media (min-width: 768px) {

    body.maddma-filter-drawer-open {
        overflow: hidden;
    }

    /*
     * Originaler Plenty-Collapse als linker Drawer.
     *
     * 1) body.maddma-filter-drawer-open:
     *    normales Oeffnen
     *
     * 2) html.maddma-filter-drawer-resume:
     *    sofortige Wiederherstellung nach Plenty-Seitenreload
     */
    body.maddma-filter-drawer-open
    .list-wrapper >
    .filter-wrapper >
    .filter-collapse,

    html.maddma-filter-drawer-resume
    .list-wrapper >
    .filter-wrapper >
    .filter-collapse {
        display: block !important;

        position: fixed !important;
        top: 66px !important;
        right: auto !important;

        /*
         * 76px = eigener Footer.
         * Dazu kommt automatisch die Hoehe einer erkannten festen
         * Bottom-Bar (z.B. Trustami: aktuell 47px).
         */
        bottom: calc(
            76px + var(--maddma-filter-bottom-offset, 0px)
        ) !important;

        left: 0 !important;

        width: 420px !important;
        max-width: 92vw !important;

        height: auto !important;
        max-height: none !important;

        margin: 0 !important;
        padding: 0 !important;

        z-index: 11010 !important;

        background: #fff !important;

        visibility: visible !important;
        opacity: 1 !important;
        transform: none !important;

        overflow-x: hidden !important;
        overflow-y: auto !important;

        box-shadow: 4px 0 18px rgba(0, 0, 0, 0.12);
    }

    body.maddma-filter-drawer-open
    .list-wrapper >
    .filter-wrapper >
    .filter-collapse.collapsing,

    html.maddma-filter-drawer-resume
    .list-wrapper >
    .filter-wrapper >
    .filter-collapse.collapsing {
        display: block !important;
        height: auto !important;
    }

    body.maddma-filter-drawer-open
    .list-wrapper >
    .filter-wrapper >
    .filter-collapse >
    .container-max.page-content,

    body.maddma-filter-drawer-open
    .list-wrapper >
    .filter-wrapper >
    .filter-collapse >
    .container-max,

    html.maddma-filter-drawer-resume
    .list-wrapper >
    .filter-wrapper >
    .filter-collapse >
    .container-max.page-content,

    html.maddma-filter-drawer-resume
    .list-wrapper >
    .filter-wrapper >
    .filter-collapse >
    .container-max {
        display: block !important;

        width: 100% !important;
        max-width: none !important;

        margin: 0 !important;
        padding: 0 22px 28px !important;

        background: #fff !important;
    }

    body.maddma-filter-drawer-open
    .list-wrapper >
    .filter-wrapper
    .filter-collapse .card-columns,

    html.maddma-filter-drawer-resume
    .list-wrapper >
    .filter-wrapper
    .filter-collapse .card-columns {
        display: block !important;
        column-count: 1 !important;
        column-gap: 0 !important;

        margin: 0 !important;
    }

    body.maddma-filter-drawer-open
    .list-wrapper >
    .filter-wrapper
    .filter-collapse .card,

    html.maddma-filter-drawer-resume
    .list-wrapper >
    .filter-wrapper
    .filter-collapse .card {
        display: block !important;
        width: 100% !important;

        margin: 0 !important;
        padding: 0 !important;

        border: 0 !important;
        border-bottom: 1px solid #ececec !important;
        border-radius: 0 !important;

        break-inside: avoid;
        background: #fff !important;
    }

    /*
     * Originaler Plenty-"Schliessen"-Button im Panel ausblenden.
     */
    body.maddma-filter-drawer-open
    .list-wrapper >
    .filter-wrapper
    .filter-collapse
    button[data-toggle="collapse"][href^="#filter-collapse_"],

    html.maddma-filter-drawer-resume
    .list-wrapper >
    .filter-wrapper
    .filter-collapse
    button[data-toggle="collapse"][href^="#filter-collapse_"] {
        display: none !important;
    }

    /* ============================================================
       AKKORDEON
       ============================================================ */

    .maddma-filter-facet-toggle {
        position: relative;

        display: flex !important;
        align-items: center;
        justify-content: space-between;

        width: 100%;

        margin: 0 !important;
        padding: 16px 32px 16px 0 !important;

        cursor: pointer;
        user-select: none;
    }

    .maddma-filter-facet-toggle::after {
        content: "+";

        position: absolute;
        top: 50%;
        right: 2px;

        transform: translateY(-50%);

        font-size: 1.35rem;
        font-weight: 400;
        line-height: 1;
    }

    .maddma-filter-facet-card.maddma-filter-facet-open
    .maddma-filter-facet-toggle::after {
        content: "−";
    }

    /*
     * JS markiert nur vorhandene Plenty-Elemente als Facetteninhalt.
     * Keine Originalelemente werden verschoben.
     */
    .maddma-filter-facet-card.maddma-filter-facet-collapsed
    .maddma-filter-facet-content {
        display: none !important;
    }

    .maddma-filter-facet-card.maddma-filter-facet-open
    .maddma-filter-facet-content {
        display: block;
    }

    /* ============================================================
       MAX. 10 WERTE
       ============================================================ */

    .maddma-filter-value-hidden {
        display: none !important;
    }

    /*
     * Angewaehlte Werte duerfen niemals durch das 10er-Limit
     * versteckt werden.
     */
    .maddma-filter-value-hidden:has(input[type="checkbox"]:checked) {
        display: block !important;
    }

    .maddma-filter-more {
        display: block;

        width: 100%;
        margin: 8px 0 12px;
        padding: 8px 0;

        border: 0;
        background: transparent;

        color: inherit;
        text-align: left;
        font: inherit;
        font-weight: 600;

        cursor: pointer;
    }

    /* ============================================================
       EIGENE RAHMEN-UI AUSSERHALB DES VUE-FILTER-DOM
       ============================================================ */

    .maddma-filter-drawer-backdrop {
        position: fixed;
        inset: 0;

        z-index: 11000;

        display: block;

        background: rgba(0, 0, 0, 0.32);

        opacity: 0;
        visibility: hidden;
        pointer-events: none;

        transition: opacity 180ms ease, visibility 180ms ease;
    }

    .maddma-filter-drawer-backdrop.is-open {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .maddma-filter-drawer-header {
        position: fixed;
        top: 0;
        left: 0;

        z-index: 11020;

        display: none;
        align-items: center;
        justify-content: space-between;

        width: 420px;
        max-width: 92vw;
        min-height: 66px;

        padding: 0 22px;

        border-bottom: 1px solid #e5e5e5;
        background: #fff;
    }

    .maddma-filter-drawer-header.is-open {
        display: flex;
    }

    .maddma-filter-drawer-title {
        font-size: 1.25rem;
        font-weight: 600;
        line-height: 1.2;
    }

    .maddma-filter-drawer-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;

        width: 44px;
        height: 44px;
        padding: 0;

        border: 0;
        background: transparent;

        color: inherit;
        font-size: 2rem;
        line-height: 1;

        cursor: pointer;
    }

    .maddma-filter-drawer-footer {
        position: fixed;
        left: 0;

        /*
         * Automatisch ueber Trustami / einer anderen erkannten
         * festen Bottom-Bar.
         */
        bottom: var(--maddma-filter-bottom-offset, 0px);

        z-index: 11020;

        display: none;

        width: 420px;
        max-width: 92vw;

        padding: 14px 22px 16px;

        border-top: 1px solid #e5e5e5;
        background: #fff;
    }

    .maddma-filter-drawer-footer.is-open {
        display: block;
    }

    .maddma-filter-drawer-finish {
        display: block;

        width: 100%;
        min-height: 48px;

        padding: 12px 18px;

        border: 0;
        border-radius: 2px;

        background: #d10816;
        color: #fff;

        font: inherit;
        font-weight: 600;
        line-height: 1.2;

        cursor: pointer;
    }
}

/*
 * :has() ist in aktuellen Chrome/Edge-Versionen vorhanden.
 * Falls ein aelterer Browser es nicht kann, setzt JS bei angewaehlten
 * Werten zusaetzlich maddma-filter-value-selected.
 */
.maddma-filter-value-selected {
    display: block !important;
}

@media (prefers-reduced-motion: reduce) and (min-width: 768px) {
    .maddma-filter-drawer-backdrop {
        transition: none;
    }
}
