/* ============================================================
   SDD NGO Mega-Menu — Frontend
   ============================================================ */

:root {
    --sdd-mm-color-0: #023047;
    --sdd-mm-color-1: #024f69;
    --sdd-mm-color-3: #fafafa;
    --sdd-mm-color-4: #00a9cc;
    --sdd-mm-color-soft: #f0f5fa;
    --sdd-mm-color-border: #e3ebf2;
    --sdd-mm-btn-hover: #3b5c70;
    --sdd-mm-text-muted: #5d7a8a;
}

/* ============================================================
   HEADER-WRAPPER (sitzt im Astra-Masthead)
   Layout: [Nav zentriert · CTA rechts]
   Das Logo liegt bereits AUSSERHALB (Astra-Branding).
   ============================================================ */
.sdd-ngo-mm-wrap {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    gap: 24px;
    min-height: 70px;
    position: relative;
}

.sdd-ngo-mm-wrap *,
.sdd-ngo-mm-wrap *::before,
.sdd-ngo-mm-wrap *::after { box-sizing: border-box; }

/* Nav: flex:1 → bekommt allen Rest-Platz, Items darin zentriert */
.sdd-ngo-mm-nav {
    flex: 1 1 auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

.sdd-ngo-mm-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.sdd-ngo-mm-menu .menu-item {
    position: relative;
    margin: 0;
    padding: 0;
}

.sdd-ngo-mm-menu .menu-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 25px 18px;
    color: var(--sdd-mm-color-3);
    font-family: 'Lato', sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s ease;
}

.sdd-ngo-mm-menu .menu-link:hover,
.sdd-ngo-mm-menu .menu-link:focus { color: var(--sdd-mm-color-1); }

.sdd-ngo-mm-menu .caret {
    display: inline-block;
    width: 0.7em;
    height: 0.7em;
    margin-top: 2px;
    transition: transform 0.25s ease;
}

.sdd-ngo-mm-menu .caret svg { width: 100%; height: 100%; display: block; }

.sdd-ngo-mm-menu .menu-item.has-mega:hover > .menu-link .caret,
.sdd-ngo-mm-menu .menu-item.has-mega:focus-within > .menu-link .caret,
.sdd-ngo-mm-menu .menu-item.has-mega.is-open > .menu-link .caret {
    transform: rotate(180deg);
}

/* ============================================================
   CTA-BUTTON (rechts, intrinsische Breite, nicht flex-wachsend)
   ============================================================ */
.sdd-ngo-mm-cta {
    flex: 0 0 auto;
    display: inline-block;
    background: var(--sdd-mm-color-1);
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    padding: 15px 30px;
    border-radius: 100px;
    text-decoration: none;
    transition: background 0.2s ease;
    white-space: nowrap;
    margin-left: auto;
}

.sdd-ngo-mm-cta:hover,
.sdd-ngo-mm-cta:focus {
    background: var(--sdd-mm-btn-hover);
    color: #fff;
}

/* ============================================================
   MEGA PANEL — Basis
   ============================================================ */
.sdd-ngo-mm-menu .mega {
    position: absolute;
    top: 100%;
    background: #ffffff;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.16);
    border-top: 3px solid var(--sdd-mm-color-4);
    border-radius: 14px;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-50%) translateY(8px);
    left: 50%;
    transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s ease;
    z-index: 20;
}

.sdd-ngo-mm-menu .menu-item.has-mega:hover > .mega,
.sdd-ngo-mm-menu .menu-item.has-mega:focus-within > .mega,
.sdd-ngo-mm-menu .menu-item.has-mega.is-open > .mega {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.sdd-ngo-mm-menu .mega--large { width: 920px; }
.sdd-ngo-mm-menu .mega--large .mega__grid {
    display: grid;
    grid-template-columns: 1fr 1fr 0.8fr;
    gap: 28px;
    padding: 32px;
}

.sdd-ngo-mm-menu .mega--medium { width: 640px; }
.sdd-ngo-mm-menu .mega--medium .mega__grid {
    display: grid;
    grid-template-columns: 1fr 0.8fr;
    gap: 28px;
    padding: 32px;
}

.sdd-ngo-mm-menu .mega--small { width: 420px; }
.sdd-ngo-mm-menu .mega--small .mega__grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 24px;
}

.sdd-ngo-mm-menu .mega--large .mega__grid:not(:has(.mega-cta)) { grid-template-columns: 1fr 1fr; }
.sdd-ngo-mm-menu .mega--medium .mega__grid:not(:has(.mega-cta)) { grid-template-columns: 1fr; }

/* ============================================================
   EYEBROW + ITEMS + CTA-Card (unverändert)
   ============================================================ */
.sdd-ngo-mm-menu .mega-eyebrow {
    position: relative;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--sdd-mm-color-0);
    margin: 0 0 20px;
    padding-left: 24px;
}

.sdd-ngo-mm-menu .mega-eyebrow::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 2px;
    background: var(--sdd-mm-color-4);
}

.sdd-ngo-mm-menu .mega-item {
    position: relative;
    display: block;
    padding: 14px 44px 14px 22px;
    color: var(--sdd-mm-color-0);
    text-decoration: none;
    transition: padding 0.22s ease;
}

.sdd-ngo-mm-menu .mega-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 0;
    background: var(--sdd-mm-color-4);
    transition: height 0.25s ease;
}

.sdd-ngo-mm-menu .mega-item::after {
    content: "→";
    position: absolute;
    right: 22px;
    top: 50%;
    transform: translateY(-50%) translateX(-6px);
    color: var(--sdd-mm-color-4);
    font-size: 16px;
    font-weight: 700;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.22s ease;
}

.sdd-ngo-mm-menu .mega-item:not(.mega-item--compact):hover { padding-left: 32px; }
.sdd-ngo-mm-menu .mega-item:not(.mega-item--compact):hover::before { height: 68%; }
.sdd-ngo-mm-menu .mega-item:not(.mega-item--compact):hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}
.sdd-ngo-mm-menu .mega-item:hover .mega-item__title { color: var(--sdd-mm-color-1); }

.sdd-ngo-mm-menu .mega-item__body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sdd-ngo-mm-menu .mega-item__title { font-size: 15px; font-weight: 700; color: var(--sdd-mm-color-0); line-height: 1.3; transition: color 0.2s ease; }
.sdd-ngo-mm-menu .mega-item__desc { font-size: 13px; color: var(--sdd-mm-text-muted); line-height: 1.5; }
.sdd-ngo-mm-menu .mega-item__badge { color: var(--sdd-mm-text-muted); font-weight: 400; font-size: 11px; margin-left: 2px; }

.sdd-ngo-mm-menu .mega-grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; }
.sdd-ngo-mm-menu .mega-item--compact { padding: 8px 12px; border-radius: 6px; transition: background 0.15s ease; }
.sdd-ngo-mm-menu .mega-item--compact::before,
.sdd-ngo-mm-menu .mega-item--compact::after { display: none; }
.sdd-ngo-mm-menu .mega-item--compact:hover { background: var(--sdd-mm-color-soft); }
.sdd-ngo-mm-menu .mega-item--compact .mega-item__title { font-size: 14px; }

.sdd-ngo-mm-menu .mega-cta { position: relative; background: #f5f9fc; color: var(--sdd-mm-color-0); padding: 30px 28px 28px 32px; border-radius: 10px; display: flex; flex-direction: column; justify-content: space-between; gap: 20px; min-height: 100%; overflow: hidden; background-size: cover; background-position: center; }

/* Bild-Modus: Text wird weiß, Overlay schluckt das Bild für Lesbarkeit */
.sdd-ngo-mm-menu .mega-cta--image { color: #ffffff; }
.sdd-ngo-mm-menu .mega-cta--image .mega-cta__title { color: #ffffff; }
.sdd-ngo-mm-menu .mega-cta--image .mega-cta__text { color: rgba(255,255,255,0.85); }
.sdd-ngo-mm-menu .mega-cta--image .mega-cta__eyebrow { color: #ffffff; }
.sdd-ngo-mm-menu .mega-cta--image::before { background: rgba(255,255,255,0.9); }
.sdd-ngo-mm-menu .mega-cta--image::after { display: none; }

.sdd-ngo-mm-menu .mega-cta__overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.sdd-ngo-mm-menu .mega-cta__body { position: relative; z-index: 1; }
.sdd-ngo-mm-menu .mega-cta--image .mega-cta__btn { position: relative; z-index: 1; }
.sdd-ngo-mm-menu .mega-cta::before { content: ""; position: absolute; top: 24px; bottom: 24px; left: 0; width: 3px; background: var(--sdd-mm-color-4); border-radius: 0 3px 3px 0; }
.sdd-ngo-mm-menu .mega-cta::after { content: ""; position: absolute; top: -40px; right: -40px; width: 120px; height: 120px; border-radius: 50%; background: rgba(0, 169, 204, 0.08); pointer-events: none; }
.sdd-ngo-mm-menu .mega-cta__eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--sdd-mm-color-4); margin-bottom: 6px; }
.sdd-ngo-mm-menu .mega-cta__title { font-size: 22px; font-weight: 700; line-height: 1.2; color: var(--sdd-mm-color-0); margin: 0 0 10px; }
.sdd-ngo-mm-menu .mega-cta__text { font-size: 13px; color: var(--sdd-mm-text-muted); line-height: 1.55; margin: 0; }
.sdd-ngo-mm-menu .mega-cta__btn { position: relative; display: inline-flex; align-items: center; gap: 6px; background: var(--sdd-mm-color-1); color: #fff; padding: 13px 22px; border-radius: 100px; font-weight: 700; font-size: 14px; text-decoration: none; transition: background 0.2s ease, transform 0.2s ease; align-self: flex-start; z-index: 1; }
.sdd-ngo-mm-menu .mega-cta__btn:hover, .sdd-ngo-mm-menu .mega-cta__btn:focus { background: var(--sdd-mm-btn-hover); color: #fff; transform: translateX(3px); }

/* ============================================================
   MOBILE TOGGLE (Burger)
   ============================================================ */
/* Toggle als Body-Kind fixed am Viewport-Rand (Mobile) */
body > .sdd-ngo-mm-toggle {
    display: none;
    position: fixed;
    top: 16px;
    right: 20px;
    z-index: 2147483645;
    width: 48px;
    height: 48px;
    align-items: center;
    justify-content: center;
    background: rgba(2, 79, 105, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    padding: 0;
    cursor: pointer;
    color: #ffffff;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    visibility: hidden;
    transition: background 0.2s ease, transform 0.2s ease;
}

body > .sdd-ngo-mm-toggle:hover {
    background: #024f69;
    transform: scale(1.05);
}

body > .sdd-ngo-mm-toggle svg { width: 24px; height: 24px; }

/* ============================================================
   RESPONSIVE — Breakpoint SYNCHRON zu Astras Default (921px),
   damit Astra und wir gleichzeitig auf Mobile-Layout umschalten.
   ============================================================ */
@media (max-width: 1300px) {
    .sdd-ngo-mm-menu .menu-link { padding: 25px 14px; font-size: 15px; }
    .sdd-ngo-mm-menu .mega--large { width: 92vw; max-width: 920px; }
}

@media (max-width: 921px) {
    body > .sdd-ngo-mm-toggle {
        display: inline-flex !important;
        visibility: visible !important;
    }

    /* BRECHSTANGE — alle Astra-Header-Container (Desktop + Mobile Variante)
       zwingen, die volle Viewport-Breite zu nutzen. Ein Element davon
       schneidet bisher die Row ab → Logo wird gequetscht. */
    #masthead,
    .site-header,
    #ast-desktop-header,
    .ast-desktop-header,
    .ast-desktop-header-content,
    .ast-main-header-wrap,
    .main-header-bar-wrap,
    .ast-primary-header,
    .ast-primary-header-bar,
    .ast-mobile-header-bar,
    .ast-mobile-header-content,
    .main-header-bar,
    .site-primary-header-wrap,
    .ast-builder-grid-row-container,
    .ast-builder-grid-row-container-inner,
    .ast-builder-grid-row,
    .ast-builder-grid-row-has-sides,
    .ast-container,
    .ast-container-fluid,
    .ast-mobile-header-wrap,
    .ast-mobile-header-stack .ast-mobile-header-content,
    .ast-desktop-header .ast-builder-grid-row,
    .site-header-primary-section-left,
    .site-header-primary-section-right,
    .site-header-primary-section-center,
    .site-header-section,
    .ast-builder-grid-row-center,
    .ast-builder-grid-row-right,
    .ast-builder-grid-row-left {
        width: 100% !important;
        max-width: 100vw !important;
        min-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Die Row-Elemente stretchen */
    .ast-builder-grid-row,
    .ast-builder-grid-row-container-inner,
    .site-primary-header-wrap {
        display: flex !important;
        flex: 1 1 100% !important;
        justify-content: space-between !important;
    }

    /* Nav-Wrap: nimmt vorhandenen Raum rechts vom Logo ein */
    .sdd-ngo-mm-wrap {
        display: block !important;
        flex: 1 1 auto !important;
        width: auto !important;
        min-width: 0 !important;
        min-height: 40px;
    }

    /* Body/Page selbst dürfen auch nicht zu schmal sein */
    body,
    #page,
    .site {
        min-width: 100% !important;
    }

    /* Auf Mobile blenden wir die Desktop-Nav und CTA IM HEADER aus —
       wir portalen sie via JS ins <body> zum Drawer-Rendern. */
    .sdd-ngo-mm-wrap > .sdd-ngo-mm-nav,
    .sdd-ngo-mm-wrap > .sdd-ngo-mm-cta,
    .sdd-ngo-mm-wrap .sdd-ngo-mm-nav,
    .sdd-ngo-mm-wrap .sdd-ngo-mm-cta { display: none !important; }

    /* Drawer + Overlay sind als direkte Body-Kinder gerendert */
    body > .sdd-ngo-mm-drawer {
        position: fixed;
        top: 0;
        right: 0;
        width: min(420px, 100vw);
        height: 100vh;
        max-height: 100vh;
        background: #ffffff;
        box-shadow: -20px 0 60px rgba(0, 0, 0, 0.22);
        transform: translateX(100%);
        transition: transform 0.28s ease;
        overflow-y: auto;
        z-index: 2147483647; /* oberster Wert → schlägt jeden Stacking-Context */
        padding: 72px 0 40px;
    }

    body > .sdd-ngo-mm-drawer.is-open { transform: translateX(0); }

    body > .sdd-ngo-mm-drawer .sdd-ngo-mm-menu {
        flex-direction: column;
        align-items: stretch;
    }

    body > .sdd-ngo-mm-drawer .menu-item {
        border-bottom: 1px solid var(--sdd-mm-color-border);
    }

    body > .sdd-ngo-mm-drawer .menu-link {
        color: var(--sdd-mm-color-0);
        padding: 18px 28px;
        font-size: 17px;
        justify-content: space-between;
        width: 100%;
    }

    body > .sdd-ngo-mm-drawer .sdd-ngo-mm-cta {
        display: block;
        margin: 20px 28px 0;
        text-align: center;
    }

    /* Mega wird auf Mobile zum Accordion-Panel
       !important überall, um Desktop-Absolute-Positionierung komplett zu killen */
    body > .sdd-ngo-mm-drawer .mega {
        position: static !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        width: 100% !important;
        max-width: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        transform: none !important;
        box-shadow: none !important;
        border-top: none !important;
        border-radius: 0 !important;
        background: var(--sdd-mm-color-soft);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    body > .sdd-ngo-mm-drawer .menu-item.has-mega.is-open > .mega { max-height: 3000px; }

    body > .sdd-ngo-mm-drawer .mega__grid {
        display: flex !important;
        flex-direction: column;
        gap: 18px !important;
        padding: 20px 28px !important;
    }

    body > .sdd-ngo-mm-drawer .mega-grid-2col { grid-template-columns: 1fr; }

    body > .sdd-ngo-mm-drawer .mega-item { padding: 12px 28px 12px 22px; }
    body > .sdd-ngo-mm-drawer .mega-item:hover { padding-left: 22px; }
    body > .sdd-ngo-mm-drawer .mega-item::before,
    body > .sdd-ngo-mm-drawer .mega-item::after { display: none; }

    body > .sdd-ngo-mm-drawer .mega-cta { padding: 20px 22px; }

    body > .sdd-ngo-mm-overlay {
        position: fixed;
        inset: 0;
        background: rgba(2, 48, 71, 0.5);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.28s ease, visibility 0.28s ease;
        z-index: 2147483646;
    }

    body > .sdd-ngo-mm-overlay.is-visible { opacity: 1; visibility: visible; }

    body > .sdd-ngo-mm-drawer .sdd-ngo-mm-close {
        position: absolute !important;
        top: 20px !important;
        right: 20px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-sizing: border-box !important;
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
        max-width: 40px !important;
        max-height: 40px !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        border-radius: 50% !important;
        background: var(--sdd-mm-color-soft) !important;
        font-size: 24px !important;
        line-height: 1 !important;
        text-align: center !important;
        cursor: pointer;
        color: var(--sdd-mm-color-0) !important;
        z-index: 2;
        font-family: inherit;
        -webkit-appearance: none;
        appearance: none;
    }
}

@media (min-width: 922px) {
    body > .sdd-ngo-mm-drawer,
    body > .sdd-ngo-mm-overlay { display: none !important; }
}

/* ============================================================
   MOBILE DEFENSIVE — 921px synchron zu Astra.
   ============================================================ */
@media (max-width: 921px) {
    /* Branding-Container: garantiert sichtbar */
    .ast-site-identity,
    .site-branding,
    .ast-builder-layout-element[data-section*="site-identity"] {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        min-width: 0 !important;
    }

    /* Logo-Image sichtbar mit sinnvoller Größe */
    .site-branding img,
    .ast-site-identity img,
    .site-logo-img img,
    a.custom-logo-link img {
        display: inline-block !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: auto !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: 44px !important;
    }

    /* Astra-Default-Mobile-Toggle neutralisieren */
    .ast-mobile-menu-buttons,
    .menu-toggle.ast-mobile-menu-buttons-minimal,
    .ast-builder-menu-mobile-trigger,
    .ast-builder-menu-mobile,
    .main-header-menu-toggle,
    .ast-button-wrap .menu-toggle,
    .ast-builder-layout-element[data-section*="mobile-trigger"] {
        display: none !important;
    }
}

/* Kleine Phones — Burger etwas kompakter */
@media (max-width: 480px) {
    body > .sdd-ngo-mm-toggle {
        top: 12px;
        right: 12px;
        width: 42px;
        height: 42px;
    }
    body > .sdd-ngo-mm-toggle svg { width: 20px; height: 20px; }

    .site-branding img,
    .ast-site-identity img,
    .site-logo-img img,
    a.custom-logo-link img {
        max-height: 38px !important;
    }
}

@media (max-width: 360px) {
    body > .sdd-ngo-mm-toggle {
        top: 10px;
        right: 10px;
        width: 38px;
        height: 38px;
    }
    body > .sdd-ngo-mm-toggle svg { width: 18px; height: 18px; }
    .site-branding img,
    .ast-site-identity img,
    .site-logo-img img,
    a.custom-logo-link img {
        max-height: 34px !important;
    }
}
