/* ==========================================================
   CITYPOLSTER – Navigation
   ========================================================== */

:root {
    --nav-text:         #1a1a1a;
    --nav-hamburger:    #1a1a1a;
    --nav-brand:        #77020a;
    --nav-dark-panel:   #1a1a1a;
    --nav-light-panel:  #ffffff;
    --nav-sub-bg:       #f5f5f5;
    --nav-mobile-bg:    #ffffff;
    --nav-overlay:      rgba(0, 0, 0, 0.35);
    --nav-shadow:       0 8px 40px rgba(0, 0, 0, 0.13);
    --nav-left-w:       230px;
    --nav-right-w:      320px;
    --nav-transition:   0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================
   OVERLAY
   ========================================================== */

.overlay {
    position: fixed;
    inset: 0;
    background: var(--nav-overlay);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--nav-transition), visibility var(--nav-transition);
    z-index: 90;
    pointer-events: none;
}
.overlay.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ==========================================================
   HAMBURGER
   ========================================================== */

#menubutton {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 110;
    position: relative;
    line-height: 0;
    display: none; /* shown only on mobile via media query */
}
.hamburger {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 24px;
}
.hamburger .line {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--nav-hamburger);
    transition: transform 0.26s ease, opacity 0.26s ease;
    transform-origin: center;
}
#menubutton.open .hamburger .line:nth-child(1) { transform: translateY(7px) rotate(45deg); }
#menubutton.open .hamburger .line:nth-child(2) { opacity: 0; transform: scaleX(0); }
#menubutton.open .hamburger .line:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ==========================================================
   DESKTOP  ≥ 1210 px
   ========================================================== */

@media (min-width: 1210px) {

    .main-mobile-menu-wrap {
        display: block !important;
        position: static !important;
        transform: none !important;
        width: auto !important;
        height: auto !important;
        background: none !important;
        overflow: visible !important;
    }

    /* Nav-Wrapper füllt den gesamten verbleibenden Platz nach dem Logo */
    #div_block-9-2486 {
        flex: 1;
    }
    #main-top-nav-wrap,
    .city-main-top-nav,
    .city-main-top-nav .menu-main-top-container {
        width: 100%;
    }

    /* ---- Top-level list ---- */
    .city-main-top-nav .menu-main-top-container > ul {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        list-style: none;
        margin: 0;
        padding: 0;
        width: 100%;
    }

    .city-main-top-nav .menu-main-top-container > ul > li {
        position: relative;
    }

    .city-main-top-nav .menu-main-top-container > ul > li > a,
    .city-main-top-nav .menu-main-top-container > ul > li > span {
        display: block;
        padding: 8px 12px;
        color: var(--nav-text);
        font-size: 0.78rem;
        font-weight: 600;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        text-decoration: none;
        white-space: nowrap;
        transition: color 0.2s;
        cursor: pointer;
    }

    .city-main-top-nav .menu-main-top-container > ul > li:hover > a,
    .city-main-top-nav .menu-main-top-container > ul > li.active > a,
    .city-main-top-nav .menu-main-top-container > ul > li:hover > span {
        color: var(--nav-brand);
    }

    /* Subtle active indicator bar */
    .city-main-top-nav .menu-main-top-container > ul > li.active > a::after,
    .city-main-top-nav .menu-main-top-container > ul > li.active > span::after {
        content: "";
        display: block;
        height: 2px;
        background: var(--nav-brand);
        position: absolute;
        bottom: -2px;
        left: 12px;
        right: 12px;
    }

    /* ----------------------------------------------------------------
       DROPDOWN BASE
       Uses visibility + opacity (not display:none) so flex layout
       is established before the dropdown becomes visible — this is
       required for the right panel (flex child) to have correct height.
    ----------------------------------------------------------------- */

    .sub-menu-wrapper {
        display: flex;
        flex-direction: row;
        position: absolute;
        top: 100%;
        left: 0;
        z-index: 200;
        background: var(--nav-light-panel);
        box-shadow: var(--nav-shadow);
        min-width: 200px;
        /* Hidden state */
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateY(-6px);
        transition: opacity 0.18s ease, visibility 0.18s ease, transform 0.18s ease;
    }

    /* Unsichtbare Brücke: verhindert dass mouseleave beim Überfahren des Abstands feuert */
    .sub-menu-wrapper::before {
        content: "";
        position: absolute;
        top: -8px;
        left: -10px;
        right: -10px;
        height: 8px;
    }

    /* Visible state — only triggered by top-level .active */
    .menu-main-top-container > ul > li.menu-item-has-children.active > .sub-menu-wrapper {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateY(0);
    }

    /* Sub-menu-inner: left panel by default */
    .sub-menu-inner {
        flex: 1;
        padding: 10px 0;
    }

    /* Standard dropdown links (non-col items) */
    .city-custom-sub-menu {
        list-style: none;
        margin: 0;
        padding: 0;
    }
    .city-custom-sub-menu > li > a {
        display: block;
        padding: 9px 22px;
        color: #3a3a3a;
        font-size: 0.82rem;
        text-decoration: none;
        transition: background 0.15s, color 0.15s;
        white-space: nowrap;
    }
    .city-custom-sub-menu > li > a:hover {
        background: var(--nav-brand);
        color: #fff;
    }

    /* Always hide back button on desktop */
    .nav-back-btn { display: none !important; }

    /* Always hide image spans (JS reads them, CSS doesn't use them) */
    .item-preview-image { display: none !important; }

    /* ----------------------------------------------------------------
       THREE-COL: dark left panel + light right panel
       Both panels are real flex children → correct height always
    ----------------------------------------------------------------- */

    .sub-menu-wrapper.three-col {
        background: var(--nav-dark-panel);
        min-width: calc(var(--nav-left-w) + var(--nav-right-w));
    }

    /* Left panel */
    .sub-menu-wrapper.three-col > .sub-menu-inner {
        width: var(--nav-left-w);
        flex: none;
        padding: 8px 0;
        background: var(--nav-dark-panel);
    }

    /* Hide original nested sub-wrappers (JS clones them into the right panel) */
    .sub-menu-wrapper.three-col .city-custom-sub-menu > li > .sub-menu-wrapper {
        display: none !important;
    }

    /* Left-panel links */
    .sub-menu-wrapper.three-col > .sub-menu-inner .city-custom-sub-menu > li > a {
        color: rgba(255, 255, 255, 0.7);
        padding: 11px 22px;
        font-size: 0.82rem;
        background: transparent;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    .sub-menu-wrapper.three-col > .sub-menu-inner .city-custom-sub-menu > li > a::after {
        content: "›";
        opacity: 0;
        font-size: 1rem;
        transition: opacity 0.15s;
    }
    .sub-menu-wrapper.three-col > .sub-menu-inner .city-custom-sub-menu > li > a:hover,
    .sub-menu-wrapper.three-col > .sub-menu-inner .city-custom-sub-menu > li.left-active > a {
        background: var(--nav-brand);
        color: #fff;
    }
    .sub-menu-wrapper.three-col > .sub-menu-inner .city-custom-sub-menu > li > a:hover::after,
    .sub-menu-wrapper.three-col > .sub-menu-inner .city-custom-sub-menu > li.left-active > a::after {
        opacity: 1;
    }

    /* Right panel: injected by JS */
    .sub-menu-wrapper.three-col .dropdown-right-panel {
        flex: 1;
        background: var(--nav-sub-bg);
        padding: 0;
        min-width: var(--nav-right-w);
        border-left: 1px solid #e0e0e0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    /* Vorschaubild im three-col Right Panel */
    .sub-menu-wrapper.three-col .dropdown-right-panel .right-panel-header-image {
        width: 100%;
        height: 130px;
        background-size: cover;
        background-position: center;
        flex-shrink: 0;
    }

    /* Cloned sub-menu links inside the right panel */
    .sub-menu-wrapper.three-col .dropdown-right-panel .sub-menu-inner {
        padding: 8px 0;
        background: transparent;
    }
    .sub-menu-wrapper.three-col .dropdown-right-panel .city-custom-sub-menu > li > a {
        color: #3a3a3a;
        padding: 9px 22px;
        font-size: 0.82rem;
        background: transparent;
    }
    .sub-menu-wrapper.three-col .dropdown-right-panel .city-custom-sub-menu > li > a:hover {
        background: var(--nav-brand);
        color: #fff;
    }

    /* ----------------------------------------------------------------
       TWO-COL: light left panel + image right panel
    ----------------------------------------------------------------- */

    .sub-menu-wrapper.two-col {
        background: var(--nav-light-panel);
        min-width: calc(var(--nav-left-w) + var(--nav-right-w));
    }

    /* Left panel */
    .sub-menu-wrapper.two-col > .sub-menu-inner {
        width: var(--nav-left-w);
        flex: none;
        padding: 8px 0;
        background: var(--nav-light-panel);
        border-right: 1px solid #eee;
    }

    /* Left-panel links */
    .sub-menu-wrapper.two-col > .sub-menu-inner .city-custom-sub-menu > li > a {
        color: #3a3a3a;
        padding: 11px 22px;
        font-size: 0.82rem;
        background: transparent;
    }
    .sub-menu-wrapper.two-col > .sub-menu-inner .city-custom-sub-menu > li > a:hover,
    .sub-menu-wrapper.two-col > .sub-menu-inner .city-custom-sub-menu > li.left-active > a {
        background: var(--nav-brand);
        color: #fff;
    }

    /* Right panel: injected by JS */
    .sub-menu-wrapper.two-col .dropdown-right-panel {
        flex: 1;
        min-width: var(--nav-right-w);
        min-height: 200px;
        background: #e8e8e8;
    }

    /* Preview image */
    .right-panel-image {
        width: 100%;
        height: 100%;
        min-height: 200px;
        background-size: cover;
        background-position: center;
        display: block;
    }

}

/* ==========================================================
   MOBILE  < 1210 px
   ========================================================== */

@media (max-width: 1209px) {

    #menubutton {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Slide-in panel */
    .main-mobile-menu-wrap {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(320px, 85vw);
        background: var(--nav-mobile-bg);
        transform: translateX(100%);
        transition: transform var(--nav-transition);
        z-index: 100;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
    }
    .main-mobile-menu-wrap.open {
        transform: translateX(0);
    }

    .mobile-overflow-wrap {
        padding: 60px 0 32px;
    }

    .city-main-top-nav .menu-main-top-container > ul {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    /* Top-level links */
    .city-main-top-nav .menu-main-top-container > ul > li > a,
    .city-main-top-nav .menu-main-top-container > ul > li > span {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 20px;
        color: var(--nav-text);
        font-size: 0.9rem;
        font-weight: 600;
        text-decoration: none;
        border-bottom: 1px solid #f0f0f0;
        cursor: pointer;
    }

    /* Chevron for items with sub-menus */
    .menu-item-has-children > a::after,
    .menu-item-has-children > span::after {
        content: "›";
        font-size: 1.1rem;
        opacity: 0.4;
        transition: transform 0.2s, opacity 0.2s;
    }
    .menu-item-has-children.mobile-active > a::after,
    .menu-item-has-children.mobile-active > span::after {
        transform: rotate(90deg);
        opacity: 0.8;
    }

    /* Sub-menus: hidden by default */
    .sub-menu-wrapper {
        display: none;
        background: var(--nav-sub-bg);
    }
    .menu-item-has-children.mobile-active > .sub-menu-wrapper {
        display: block;
    }

    .sub-menu-inner { display: block; }

    .city-custom-sub-menu {
        list-style: none;
        margin: 0;
        padding: 0;
    }
    .city-custom-sub-menu > li > a {
        display: block;
        padding: 11px 26px;
        color: #444;
        font-size: 0.85rem;
        text-decoration: none;
        border-bottom: 1px solid #eaeaea;
    }
    .city-custom-sub-menu > li > a:active {
        background: var(--nav-brand);
        color: #fff;
    }

    /* Hide desktop-only elements */
    .dropdown-right-panel,
    .item-preview-image { display: none; }

    /* Back button */
    .nav-back-btn {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        padding: 11px 20px;
        background: #f0f0f0;
        border: none;
        border-bottom: 1px solid #e0e0e0;
        color: #555;
        font-size: 0.8rem;
        font-weight: 500;
        cursor: pointer;
        text-align: left;
        transition: background 0.15s;
    }
    .nav-back-btn:active { background: #e8e8e8; }

}
