/* ==========================================================================
   Joomla 6 - mod_menu Override: Mehrstufiges Menue
   Theme: an den dunkelblauen ("navy") Header von Dufrenne-Eiden angepasst -
   transparent im Header, weisse Schrift, aktiver Punkt als weisse Pille
   (wie die CTA-Buttons im Hero), Dropdown im "Frosted Glass"-Look passend
   zur Info-Karte im Hero.
   Scope: alles unter .jmm-wrapper, um Konflikte mit anderen Modulen
   oder dem Template-CSS zu vermeiden.
   ========================================================================== */

.jmm-wrapper {
    --jmm-text: #ffffff;
    --jmm-hover-bg: rgba(255, 255, 255, 0.1);
    --jmm-active-bg: #ffffff;
    --jmm-active-text: #1f3a5c;
    --jmm-accent: #bdd3ff;
    --jmm-border: rgba(255, 255, 255, 0.22);
    --jmm-dropdown-bg: rgba(58, 79, 114, 0.94);
    --jmm-dropdown-border: rgba(255, 255, 255, 0.18);
    --jmm-dropdown-hover-bg: rgba(255, 255, 255, 0.08);
    --jmm-shadow: 0 16px 36px rgba(4, 8, 18, 0.45);
    --jmm-radius: 8px;
    --jmm-height: 56px;
    --jmm-transition: 180ms ease;

    position: relative;
    font-family: inherit;
    background: transparent;
}

.jmm-wrapper * {
    box-sizing: border-box;
}

/* Hamburger-Button, nur mobil sichtbar */
.jmm-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    width: 44px;
    height: 44px;
    margin: 6px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--jmm-border);
    border-radius: 8px;
    cursor: pointer;
}

.jmm-toggle-bar {
    display: block;
    width: 20px;
    height: 2px;
    background: #ffffff;
    border-radius: 2px;
    transition: transform var(--jmm-transition), opacity var(--jmm-transition);
}

.jmm-toggle[aria-expanded="true"] .jmm-toggle-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.jmm-toggle[aria-expanded="true"] .jmm-toggle-bar:nth-child(2) {
    opacity: 0;
}
.jmm-toggle[aria-expanded="true"] .jmm-toggle-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.jmm-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Ebene 1 (horizontal) ---------- */
.jmm-wrapper .nav-menu {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 4px;
}

.jmm-wrapper .nav-menu > li {
    position: relative;
    display: flex;
    align-items: stretch;
}

.jmm-wrapper .nav-menu > li > a,
.jmm-wrapper .nav-menu > li > span {
    display: flex;
    align-items: center;
    height: var(--jmm-height);
    padding: 0 16px;
    color: var(--jmm-text);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.2px;
    white-space: nowrap;
    border-radius: var(--jmm-radius);
    cursor: pointer;
    transition: background var(--jmm-transition), color var(--jmm-transition);
}

/* Deutlich sichtbarer Fokus-Rahmen fuer Tastaturbedienung (Barrierefreiheit).
   currentColor sorgt dafuer, dass der Rahmen auf dem weissen "aktiv"-Pill
   automatisch navy wird und sonst ueberall weiss bleibt. */
.jmm-wrapper a:focus-visible,
.jmm-wrapper span:focus-visible,
.jmm-wrapper button:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.jmm-wrapper .nav-menu > li > a:hover,
.jmm-wrapper .nav-menu > li > a:focus-visible {
    background: var(--jmm-hover-bg);
}

/* Aktiver Menuepunkt: weisse Pille, analog zu den CTA-Buttons im Hero */
.jmm-wrapper .nav-menu > li.current > a {
    background: var(--jmm-active-bg);
    color: var(--jmm-active-text);
}

/* Pfeil-Indikator fuer Eintraege mit Untermenue (currentColor = passt sich
   automatisch an weissen/navy Text an) */
.jmm-wrapper li.parent > a::after,
.jmm-wrapper li.parent > span::after {
    content: "";
    width: 7px;
    height: 7px;
    margin-left: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform var(--jmm-transition);
    flex-shrink: 0;
    opacity: 0.8;
}

.jmm-wrapper li.parent.jmm-open > a::after {
    transform: rotate(-135deg);
}

/* Trennlinie (separator-Eintraege) */
.jmm-wrapper li.divider {
    display: flex;
    align-items: center;
    padding: 0 6px;
}
.jmm-wrapper li.divider > * {
    display: none;
}
.jmm-wrapper .nav-menu > li.divider::before {
    content: "";
    width: 1px;
    height: 22px;
    background: var(--jmm-border);
    align-self: center;
}

/* ---------- Dropdowns (Ebene 2+) ---------- */
/* !important auf den Box-Eigenschaften: verhindert, dass vorhandenes
   Template-CSS fuer die generischen Joomla-Klassen .nav-menu/.nav-child
   (z. B. Breite, Rahmen) das Dropdown-Erscheinungsbild verfaelscht. */
.jmm-wrapper .nav-child {
    list-style: none !important;
    margin: 0 !important;
    padding: 6px !important;
}

.jmm-wrapper .nav-menu .nav-child {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    z-index: 200 !important;
    width: max-content !important;
    min-width: 200px !important;
    max-width: 320px !important;
    margin-top: 10px !important;
    background: var(--jmm-dropdown-bg) !important;
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    border: 1px solid var(--jmm-dropdown-border) !important;
    border-top: 2px solid rgba(255, 255, 255, 0.35) !important;
    border-radius: var(--jmm-radius) !important;
    box-shadow: var(--jmm-shadow) !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity 200ms ease, transform 200ms ease, visibility 200ms ease;
}

/* Unsichtbare Bruecke ueber die 10px Luecke, damit die Maus beim Wechsel
   vom Menuepunkt zum Dropdown nicht "durchfaellt" und es sich schliesst. */
.jmm-wrapper .nav-menu .nav-child::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -10px;
    height: 10px;
}

/* Untermenues ab Ebene 3 klappen seitlich auf */
.jmm-wrapper .nav-child .nav-child {
    top: -7px !important;
    left: 100% !important;
    margin-top: 0 !important;
    margin-left: 8px !important;
    border-top: 1px solid var(--jmm-dropdown-border) !important;
}
.jmm-wrapper .nav-child .nav-child::before {
    left: -8px;
    top: 0;
    right: auto;
    bottom: 0;
    width: 8px;
    height: auto;
}

/* Desktop: per Hover/Fokus oeffnen */
@media (min-width: 992px) {
    .jmm-wrapper li.parent:hover > .nav-child,
    .jmm-wrapper li.parent:focus-within > .nav-child,
    .jmm-wrapper li.parent.jmm-open > .nav-child {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateY(0);
    }

    .jmm-wrapper .nav-child li.parent:hover > .nav-child,
    .jmm-wrapper .nav-child li.parent:focus-within > .nav-child,
    .jmm-wrapper .nav-child li.parent.jmm-open > .nav-child {
        transform: translateX(0);
    }

    .jmm-wrapper .nav-child > li {
        width: 100% !important;
    }

    .jmm-wrapper .nav-child > li + li {
        margin-top: 2px;
    }

    .jmm-wrapper .nav-child > li > a,
    .jmm-wrapper .nav-child > li > span {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 10px 12px !important;
        border-radius: 7px !important;
        color: var(--jmm-text) !important;
        text-decoration: none !important;
        font-size: 0.92rem;
        font-weight: 500;
        white-space: nowrap;
        background: transparent !important;
    }

    .jmm-wrapper .nav-child > li > a:hover,
    .jmm-wrapper .nav-child > li > a:focus-visible {
        background: var(--jmm-dropdown-hover-bg) !important;
        color: var(--jmm-accent) !important;
    }

    .jmm-wrapper .nav-child > li.current > a {
        color: var(--jmm-accent) !important;
        font-weight: 600;
    }

    .jmm-wrapper .nav-child > li.current > a::after {
        content: "";
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--jmm-accent);
        flex-shrink: 0;
    }
}

/* ---------- Mobile: Akkordeon ---------- */
@media (max-width: 991.98px) {
    .jmm-toggle {
        display: inline-flex;
    }

    .jmm-wrapper .nav-menu {
        display: none;
        flex-direction: column;
        width: 100%;
        gap: 0;
        padding: 6px;
        background: var(--jmm-dropdown-bg);
        backdrop-filter: blur(14px) saturate(140%);
        -webkit-backdrop-filter: blur(14px) saturate(140%);
        border-radius: 0 0 var(--jmm-radius) var(--jmm-radius);
        box-shadow: var(--jmm-shadow);
    }

    .jmm-wrapper .nav-menu.jmm-show {
        display: flex;
    }

    .jmm-wrapper .nav-menu > li {
        flex-direction: column;
        width: 100%;
    }

    .jmm-wrapper .nav-menu > li > a,
    .jmm-wrapper .nav-menu > li > span {
        width: 100%;
        height: auto;
        padding: 13px 14px;
        border-radius: 7px;
    }

    .jmm-wrapper .nav-menu > li.current > a {
        background: var(--jmm-active-bg);
        color: var(--jmm-active-text);
    }

    .jmm-wrapper .nav-child,
    .jmm-wrapper .nav-child .nav-child {
        position: static;
        top: auto;
        left: auto;
        margin: 4px 0 4px 0 !important;
        min-width: 0;
        width: 100%;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        background: rgba(255, 255, 255, 0.06) !important;
        backdrop-filter: none;
        padding: 0 !important;
        opacity: 1;
        visibility: visible;
        transform: none;

        display: grid;
        grid-template-rows: 0fr;
        overflow: hidden;
        transition: grid-template-rows var(--jmm-transition);
    }

    .jmm-wrapper .nav-child > * {
        min-height: 0;
    }

    .jmm-wrapper li.parent.jmm-open > .nav-child {
        grid-template-rows: 1fr;
    }

    .jmm-wrapper .nav-child {
        display: grid;
    }

    .jmm-wrapper .nav-child ul.nav-child {
        padding-left: 14px !important;
    }

    .jmm-wrapper .nav-child > li > a,
    .jmm-wrapper .nav-child > li > span {
        display: block;
        padding: 11px 14px 11px 26px;
        color: var(--jmm-text);
        text-decoration: none;
        border-radius: 0;
    }

    .jmm-wrapper .nav-child > li > a:active,
    .jmm-wrapper .nav-child > li.current > a {
        color: var(--jmm-accent);
        background: transparent;
    }

    .jmm-wrapper li.parent > a::after {
        margin-left: auto;
    }

    .jmm-wrapper .nav-menu > li.parent {
        flex-wrap: wrap;
    }

    .jmm-wrapper .nav-menu > li.parent > a {
        flex: 1;
    }
}

/* Reduzierte Bewegung respektieren */
@media (prefers-reduced-motion: reduce) {
    .jmm-wrapper * {
        transition: none !important;
    }
}
