/* Mobile Menu (<=1024px) via Media-Query auf bestehendes Megamenu */
.menu-collapser { display: none; }
.collapse-button {
    appearance: none; border: 0; background: transparent;
    width: 44px; height: 44px; padding: 10px; cursor: pointer;
    display: inline-flex; flex-direction: column; justify-content: center; gap: 4px;
    color: #222;
}
.collapse-button .icon-bar {
    display: block; height: 2px; width: 22px;
    background: currentColor; border-radius: 1px;
    transition: transform .2s, opacity .2s;
}
body[data-menu-open] .collapse-button .icon-bar:nth-child(1) { transform: translateY(6px) rotate(45deg); }
body[data-menu-open] .collapse-button .icon-bar:nth-child(2) { opacity: 0; }
body[data-menu-open] .collapse-button .icon-bar:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 1024px) {
    .menu-collapser { display: inline-flex !important; align-items: center; }

    /* Megamenu-UL wird zum Fullscreen-Drawer (unter dem Header) */
    .header ul.megamenu {
        display: none !important;
        position: fixed !important;
        top: var(--header-height-mobile, 56px) !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important; max-width: none !important;
        height: calc(100vh - var(--header-height-mobile, 56px));
        height: calc(100dvh - var(--header-height-mobile, 56px)); /* dvh fuer mobile Browser-Leiste */
        float: none !important;
        margin: 0 !important; padding: 0 !important;
        background: #fff;
        list-style: none;
        overflow-y: auto;
        z-index: 998;
    }
    body[data-menu-open] .header ul.megamenu { display: block !important; }

    .header ul.megamenu > li {
        float: none !important;
        width: 100% !important;
        display: block !important;
        margin: 0 !important; padding: 0 !important;
        border-top: 1px solid rgba(0,0,0,.08);
        position: relative !important;
    }
    .header ul.megamenu > li:first-child { border-top: 0; }
    .header ul.megamenu > li > a {
        display: block !important;
        padding: 16px 56px 16px 12px !important;
        color: #222; font-size: 16px; font-weight: 400;
        text-decoration: none; background: transparent;
    }
    .header ul.megamenu > li.active > a,
    .header ul.megamenu > li > a.active {
        color: var(--maincolor, #0d6efd);
        background: #fafafa;
    }

    /* Desktop-Wrapper-Divs platt */
    .header ul.megamenu .mm-outer-wrapper,
    .header ul.megamenu .megamenu-wrapper,
    .header ul.megamenu .no-megamenu,
    .header ul.megamenu .megamenu-inner-wrapper {
        display: block !important;
        position: static !important;
        background: transparent !important;
        padding: 0 !important; margin: 0 !important;
        box-shadow: none !important;
        width: auto !important;
    }

    /* Sublist - volle Breite, keine farbigen Rahmen */
    .header ul.megamenu ul.lev-1 {
        display: none;
        list-style: none;
        padding: 0 !important; margin: 0 !important;
        width: 100% !important; max-width: none !important;
        background: #f5f5f5;
        border: 0 !important;
    }
    .header ul.megamenu > li.mm-open ul.lev-1 { display: block; }
    .header ul.megamenu ul.lev-1 {
        display: none;
        flex-direction: column;
    }
    .header ul.megamenu ul.lev-1 > li {
        float: none !important;
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        display: block !important;
        padding: 0 !important; margin: 0 !important;
        border-top: 1px solid rgba(0,0,0,.08);
    }
    .header ul.megamenu ul.lev-1 > li:first-child { border-top: 0; }
    .header ul.megamenu ul.lev-1 a,
    .header ul.megamenu ul.lev-1 a span,
    .header ul.megamenu ul.lev-1 a:hover,
    .header ul.megamenu ul.lev-1 a:focus,
    .header ul.megamenu ul.lev-1 a.active {
        display: block !important;
        padding: 8px 20px 8px 24px !important;
        color: #222 !important;
        font-size: 14px;
        line-height: 1.4;
        text-decoration: none !important;
        background: transparent !important;
        text-transform: none !important;
    }
    /* Thumbnails / Metaimg-Bilder in Sublink ausblenden */
    .header ul.megamenu ul.lev-1 .metaimg,
    .header ul.megamenu ul.lev-1 .metaimg-clip,
    .header ul.megamenu ul.lev-1 img,
    .header ul.megamenu ul.lev-1 picture { display: none !important; }

    /* Top-Level active: schwarz statt cyan, keine Unterstreichung */
    .header ul.megamenu > li.active > a,
    .header ul.megamenu > li > a.active,
    .header ul.megamenu li > a.active,
    .header ul.megamenu > li > a:hover,
    .header ul.megamenu > li > a:focus {
        color: #222 !important;
        background: #fafafa !important;
        border: 0 !important;
        border-bottom: 0 !important;
        text-decoration: none !important;
    }
    .header ul.megamenu > li::before,
    .header ul.megamenu > li::after,
    .header ul.megamenu > li > a::before,
    .header ul.megamenu > li > a::after {
        display: none !important;
    }

    /* Chevron-Button schwarz */
    .mm-sub-toggle {
        position: absolute; top: 0; right: 0;
        width: 56px; height: 56px;
        background: transparent; border: 0; cursor: pointer;
        display: flex; align-items: center; justify-content: center;
        color: #222;
    }
    .mm-sub-toggle::before {
        content: ''; width: 10px; height: 10px;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: rotate(45deg) translate(-2px, -2px);
        transition: transform .2s;
    }
    li.mm-open > .mm-sub-toggle::before { transform: rotate(-135deg) translate(-2px, -2px); }
}

@media (min-width: 1025px) {
    .menu-collapser, .mm-sub-toggle { display: none !important; }
}
