/* =========================================================
   BURO210 Mega Menu - layout="dropdown"
   Compact cascading dropdown. L1 drop centered under the top
   item, deeper levels fly out to the right (.is-flipped: left).
   Mobile (<= 1119px, Breakdance "Tablet Landscape"): hamburger
   with a panel under the header bar and accordion submenus.

   Tokens: override the --b210-menu-* properties per project.
   The panel positions against the nearest positioned ancestor
   on mobile, so give the header bar position: relative.
   ========================================================= */

.b210-menu {
    --b210-menu-text: var(--donkerblauw, #0E2A47);
    --b210-menu-icon-color: var(--blauw-alt-02, #3F577A);
    --b210-menu-hover-bg: var(--lichtbeige-02, #EDE9E2);
    --b210-menu-panel-bg: var(--wit, #FFFFFF);
    --b210-menu-border: var(--lichtbeige-02, #EDE9E2);
    --b210-menu-shadow: 0 12px 32px 0 rgba(14, 42, 71, 0.12);
    --b210-menu-drop-width: 320px;
    /* afstand tussen onderkant top-item en dropdown (Figma: 17px tot onderkant balk + 8px) */
    --b210-menu-drop-offset: 25px;
    --b210-menu-corner: 18px;
    --b210-menu-transition: 200ms ease;

    position: relative;
    color: var(--b210-menu-text);
}

.b210-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Alleen menulinks: de gekloonde CTA houdt de kleuren van zijn eigen (button-)stijl */
.b210-menu__list a {
    color: var(--b210-menu-text);
    text-decoration: none;
}

.b210-menu__list a:hover,
.b210-menu__list a:focus-visible {
    color: var(--b210-menu-text);
}

.b210-menu button {
    appearance: none;
    margin: 0;
    border: 0;
    background: transparent;
    color: var(--b210-menu-text);
    font: inherit;
    cursor: pointer;
}

.b210-menu :focus-visible {
    outline: 2px solid var(--blauw, #6F86A5);
    outline-offset: 2px;
}

.b210-menu__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;
}

.b210-menu__chevron {
    display: block;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    transition: transform var(--b210-menu-transition);
}

.b210-menu__icon {
    display: block;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.b210-menu__toggle,
.b210-menu__cta {
    display: none;
}

/* =========================================================
   Desktop (> 1119px)
   ========================================================= */
@media (min-width: 1120px) {

    .b210-menu__list {
        display: flex;
        align-items: center;
        gap: 4px;
    }

    /* Top items */
    .b210-menu__item {
        position: relative;
        display: flex;
        align-items: center;
        transition: background-color var(--b210-menu-transition);
    }

    .b210-menu__link {
        display: flex;
        align-items: center;
        padding: 10px 12px;
        font-size: 15px;
        font-weight: 600;
        line-height: 1.2;
        white-space: nowrap;
    }

    .b210-menu__item.has-children > .b210-menu__link {
        padding-right: 0;
    }

    .b210-menu__item > .b210-menu__toggle {
        display: flex;
        align-items: center;
        align-self: stretch;
        padding: 0 12px 0 4px;
    }

    .b210-menu__item:hover,
    .b210-menu__item:focus-within,
    .b210-menu__item.is-open,
    .b210-menu__item.is-current,
    .b210-menu__item.is-ancestor {
        background-color: var(--b210-menu-hover-bg);
    }

    .b210-menu__item:hover > .b210-menu__toggle .b210-menu__chevron,
    .b210-menu__item:focus-within > .b210-menu__toggle .b210-menu__chevron,
    .b210-menu__item.is-open > .b210-menu__toggle .b210-menu__chevron {
        transform: rotate(180deg);
    }

    /* Drop panels (all levels) */
    .b210-menu__sub {
        display: none;
        position: absolute;
        z-index: 10;
        width: var(--b210-menu-drop-width);
        padding: 8px;
        background: var(--b210-menu-panel-bg);
        box-shadow: var(--b210-menu-shadow);
        text-align: left;
    }

    /* L1 drop: centered under the top item, --b210-menu-shift (JS) keeps it in the viewport */
    .b210-menu__sub--l2 {
        top: calc(100% + var(--b210-menu-drop-offset));
        left: 50%;
        transform: translateX(calc(-50% + var(--b210-menu-shift, 0px)));
    }

    /* hover-brug over de ruimte tussen top-item en dropdown */
    .b210-menu__sub--l2::before {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        bottom: 100%;
        height: var(--b210-menu-drop-offset);
    }

    .b210-menu__item:hover > .b210-menu__sub,
    .b210-menu__item:focus-within > .b210-menu__sub,
    .b210-menu__item.is-open > .b210-menu__sub {
        display: block;
    }

    /* Deeper levels: next to the parent drop, top aligned */
    .b210-menu__sub .b210-menu__sub {
        top: 0;
        left: 100%;
        border-left: 1px solid var(--b210-menu-border);
    }

    .b210-menu__sub.is-flipped > .b210-menu__sub-list > .b210-menu__sub-item > .b210-menu__sub {
        left: auto;
        right: 100%;
        border-left: 0;
        border-right: 1px solid var(--b210-menu-border);
    }

    .b210-menu__sub-item.is-active > .b210-menu__sub,
    .b210-menu__sub-item:focus-within > .b210-menu__sub {
        display: block;
    }

    /* Hide a sibling's flyout while another item is hovered */
    .b210-menu__sub-list:has(> .b210-menu__sub-item.is-active) > .b210-menu__sub-item:not(.is-active):not(:hover) > .b210-menu__sub {
        display: none;
    }

    /* Sub items */
    .b210-menu__sub-item {
        position: static;
        display: flex;
        align-items: center;
        transition: background-color var(--b210-menu-transition);
    }

    .b210-menu__sub-link {
        display: flex;
        flex: 1 1 auto;
        align-items: center;
        gap: 12px;
        min-width: 0;
        padding: 12px 16px;
        font-size: 16px;
        font-weight: 400;
        line-height: 1.6;
    }

    .b210-menu__sub-item.has-children > .b210-menu__sub-link {
        padding-right: 0;
    }

    .b210-menu__sub-text {
        flex: 1 1 auto;
        min-width: 0;
    }

    .b210-menu__sub-toggle {
        display: flex;
        align-items: center;
        align-self: stretch;
        padding: 0 16px 0 12px;
    }

    .b210-menu__sub-item:hover,
    .b210-menu__sub-item.is-active,
    .b210-menu__sub-item:focus-within {
        position: relative;
        background-color: var(--b210-menu-hover-bg);
    }

    /* Het flyout-panel moet tegen de parent-drop positioneren, niet tegen het item */
    .b210-menu__sub-item.has-children:hover,
    .b210-menu__sub-item.has-children.is-active,
    .b210-menu__sub-item.has-children:focus-within {
        position: static;
    }

    /* Hoekje rechtsboven (signatuurvorm uit het logo), uitgesneden in de panelkleur.
       1px buiten het item (zoals in Figma: top/right -1), zodat bij afronding op halve
       pixels geen dun randje van de hover-kleur langs het hoekje zichtbaar blijft. */
    .b210-menu__sub-item:hover > .b210-menu__sub-link::after,
    .b210-menu__sub-item.is-active > .b210-menu__sub-link::after,
    .b210-menu__sub-item:focus-within > .b210-menu__sub-link::after {
        content: "";
        position: absolute;
        top: -1px;
        right: -1px;
        width: var(--b210-menu-corner);
        height: var(--b210-menu-corner);
        background: var(--b210-menu-panel-bg);
        clip-path: polygon(25.79% 0, 100% 0, 100% 100%);
        pointer-events: none;
    }

    /* Items with children are position: static, so anchor their corner with a wrapper-less trick */
    .b210-menu__sub-item.has-children > .b210-menu__sub-link {
        position: relative;
    }

    .b210-menu__sub-item.has-children > .b210-menu__sub-link::after {
        right: calc(-1 * (16px + 16px + 12px) - 1px);
    }

    .b210-menu__heading {
        padding: 12px 16px;
        font-size: 16px;
        font-weight: 700;
        line-height: 1.2;
    }
}

/* =========================================================
   Mobile (<= 1119px)
   ========================================================= */
@media (max-width: 1119px) {

    .b210-menu {
        position: static;
    }

    .b210-menu__toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        padding: 0;
    }

    .b210-menu__toggle-icon {
        position: relative;
        display: block;
        width: 24px;
        height: 16px;
    }

    .b210-menu__toggle-icon span {
        position: absolute;
        left: 0;
        width: 100%;
        height: 2px;
        background: currentColor;
        transition: transform var(--b210-menu-transition), opacity var(--b210-menu-transition), top var(--b210-menu-transition);
    }

    .b210-menu__toggle-icon span:nth-child(1) { top: 0; }
    .b210-menu__toggle-icon span:nth-child(2) { top: 7px; }
    .b210-menu__toggle-icon span:nth-child(3) { top: 14px; }

    .b210-menu.is-open .b210-menu__toggle-icon span:nth-child(1) { top: 7px; transform: rotate(45deg); }
    .b210-menu.is-open .b210-menu__toggle-icon span:nth-child(2) { opacity: 0; }
    .b210-menu.is-open .b210-menu__toggle-icon span:nth-child(3) { top: 7px; transform: rotate(-45deg); }

    /* Panel under the header bar (nearest positioned ancestor) */
    .b210-menu__panel {
        display: none;
        position: absolute;
        z-index: 10;
        top: calc(100% + 8px);
        left: 0;
        right: 0;
        max-height: calc(100dvh - var(--wp-admin--admin-bar--height, 0px) - 120px);
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 8px;
        background: var(--b210-menu-panel-bg);
        box-shadow: var(--b210-menu-shadow);
    }

    .b210-menu.is-open .b210-menu__panel {
        display: block;
    }

    .b210-menu__item,
    .b210-menu__sub-item {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
    }

    .b210-menu__link,
    .b210-menu__sub-link {
        display: flex;
        flex: 1 1 0;
        align-items: center;
        gap: 12px;
        min-width: 0;
        padding: 12px 16px;
    }

    .b210-menu__link {
        font-size: 16px;
        font-weight: 600;
        line-height: 1.2;
    }

    .b210-menu__sub-link {
        font-size: 16px;
        font-weight: 400;
        line-height: 1.4;
    }

    .b210-menu__item.is-current > .b210-menu__link,
    .b210-menu__item.is-ancestor > .b210-menu__link,
    .b210-menu__sub-item.is-current > .b210-menu__sub-link {
        background-color: var(--b210-menu-hover-bg);
    }

    .b210-menu__item > .b210-menu__toggle,
    .b210-menu__sub-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 48px;
        height: 48px;
        padding: 0;
    }

    /* Chevrons point down on mobile, flip when open */
    .b210-menu__sub-toggle .b210-menu__chevron {
        transform: rotate(90deg);
    }

    .b210-menu__item.is-open > .b210-menu__toggle .b210-menu__chevron {
        transform: rotate(180deg);
    }

    .b210-menu__sub-item.is-open > .b210-menu__sub-toggle .b210-menu__chevron {
        transform: rotate(270deg);
    }

    .b210-menu__sub {
        display: none;
        flex-basis: 100%;
        padding-left: 16px;
    }

    .b210-menu__item.is-open > .b210-menu__sub,
    .b210-menu__sub-item.is-open > .b210-menu__sub {
        display: block;
    }

    .b210-menu__heading {
        display: none;
    }

    .b210-menu__item + .b210-menu__item {
        border-top: 1px solid var(--b210-menu-border);
    }

    /* Losse CTA (gekloond via data-cta) onderaan het panel, blijft in beeld bij scrollen */
    .b210-menu__cta:not([hidden]) {
        display: block;
        position: sticky;
        bottom: -8px;
        margin: 0 -8px -8px;
        padding: 16px 24px;
        border-top: 1px solid var(--b210-menu-border);
        background: var(--b210-menu-panel-bg);
    }

    .b210-menu__cta > *,
    .b210-menu__cta a {
        display: flex;
        justify-content: center;
        width: 100%;
    }
}
