/* Menu block */

.block-menu {
    --menu-gap: 30px;
    --menu-padding-block: 32px;
    --menu-padding-block-scrolled: 10px;
    --menu-bg: var(--wp--preset--color--base);
    --menu-mobile-bg: var(--wp--preset--color--helder-blauw);
    --menu-close-bg: var(--wp--preset--color--white);
    --menu-color: var(--wp--preset--color--contrast);
    --menu-submenu-bg: var(--wp--preset--color--wit);
    --menu-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    position: fixed;
    /* WordPress sets this on <html> whenever the admin bar is showing, so the
       bar is cleared without needing a body class. */
    top: var(--wp-admin--admin-bar--height, 0px);
    left: 0;
    right: 0;
    z-index: 100;
    /* The rule is always there, only its colour changes — so the bar never
       shifts by a pixel when it appears. */
    border-bottom: var(--border-01) solid transparent;
    /* Clips the dropdown, so it is revealed by the bar growing rather than by
       fading in over the page. */
    overflow: hidden;
    background-color: var(--menu-bg);
    color: var(--menu-color);
    transition: border-color var(--menu-transition), transform var(--menu-transition);
}

/* Scrolling down takes the bar with the page; scrolling up brings it back.
   translate rather than top, so it never reflows the page. */
.block-menu.is-hidden {
    transform: translateY(-100%);
}

.block-menu.is-scrolled,
.block-menu:hover,
.block-menu:has(.block-menu__item.is-open) {
    border-bottom-color: var(--border-color-01);
}

.block-menu__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--menu-gap);
    box-sizing: content-box;
    max-width: var(--widest-size);
    padding: var(--menu-padding-block) var(--wp--style--root--padding-left);
    transition: padding var(--menu-transition);
    margin: auto;
}

/* Tightens up once the page has moved */
.block-menu.is-scrolled .block-menu__inner {
    padding-block: var(--menu-padding-block-scrolled);
}

/* Logo */

.block-menu__logo {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    color: inherit;
    text-decoration: none;
}

.block-menu__logo img {
    display: block;
    width: auto;
    height: 32px;
}

.block-menu__logo-text {
    font-weight: 500;
    letter-spacing: -0.02em;
}

/* Toggle (mobile only) */

.block-menu__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    cursor: pointer;
}

.block-menu__toggle svg {
    display: block;
}

/* Nav */

.block-menu__nav {
    font-family: var(--wp--preset--font-family--owners);
    position: fixed;
    inset: var(--wp-admin--admin-bar--height, 0px) 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--menu-gap);
    padding: 64px var(--wp--style--root--padding-left);
    background-color: var(--menu-mobile-bg);
    text-align: center;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity var(--menu-transition), transform var(--menu-transition), visibility var(--menu-transition);
}

/* Close button */

.block-menu__close {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-04);
    background-color: var(--menu-close-bg);
    cursor: pointer;
}

.block-menu__close svg {
    display: block;
}

.block-menu.is-open .block-menu__nav {
    opacity: 1;
    visibility: visible;
    transform: none;
}

.block-menu__list {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    width: 100%;
    /* Centres the items in the space between the close button and the button. */
    margin: auto 0;
    padding: 0;
    list-style: none;
}

.block-menu__item {
    position: relative;
    text-align: center;
    margin: auto;
}

.block-menu__link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    /* Hugs the text: "auto" on a block-level flex box would still fill the row */
    width: fit-content;
    padding: 8px 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-size: var(--wp--preset--font-size--small);
    font-weight: 700;
    letter-spacing: 0.025em;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: color var(--menu-transition);
}

/* Current page — set before the hover rules so hovering it still turns blue */
.block-menu__link.current-page,
.block-menu__sublink.current-page {
    color: var(--wp--preset--color--warm-grijs-03);
}

.block-menu__link:hover,
.block-menu__link:focus-visible {
    color: var(--wp--preset--color--energiek-blauw);
}

/* Submenu */

/* Label and chevron side by side: the label navigates, the chevron toggles */
.block-menu__parent {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.block-menu__chevron-button {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    padding: 8px;
    margin: -8px;
    border: 0;
    background: none;
    color: inherit;
    cursor: pointer;
}

.block-menu__chevron {
    width: 8px;
    height: 8px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform var(--menu-transition);
}

.block-menu__item.is-open .block-menu__chevron {
    transform: translateY(1px) rotate(-135deg);
}

/* The item is the grid container so the whole submenu collapses as one row —
   putting the 0fr row on the list itself only collapses its first <li>. */
.block-menu__item--has-submenu {
    display: grid;
    grid-template-rows: auto 0fr;
    transition: grid-template-rows var(--menu-transition);
}

.block-menu__item--has-submenu.is-open {
    grid-template-rows: auto 1fr;
}

.block-menu__submenu {
    margin: 0;
    padding: 0;
    list-style: none;
    overflow: hidden;
}

.block-menu__subitem:first-child {
    padding-top: 4px;
}

.block-menu__sublink {
    display: block;
    padding: 6px 0;
    color: inherit;
    font-size: var(--wp--preset--font-size--small);
    font-weight: 700;
    text-decoration: none;
    transition: color var(--menu-transition);
}

.block-menu__sublink:hover,
.block-menu__sublink:focus-visible {
    color: var(--wp--preset--color--energiek-blauw);
}

/* Button */

.block-menu__button {
    display: flex;
    margin-top: auto;
}

/* Smaller than the theme's buttons — this one sits in the bar with the links */
.block-menu__button .wp-block-button__link {
    font-size: var(--wp--preset--font-size--small);
    padding-left: 0 !important;
}

/* Grows to the open submenu's height, so the bar encloses it */
.block-menu__expand {
    height: 0;
    overflow: hidden;
}

/* Below the menu breakpoint the admin bar scrolls away with the page, so the
   offset only applies while the page is at the top. */
@media (max-width: 1179px) {
    .block-menu.is-scrolled {
        top: 0;
    }

    .block-menu.is-scrolled .block-menu__nav {
        inset: 0;
    }
}

/* Desktop — the toggle takes over below this */

@media (min-width: 1180px) {
    .block-menu__toggle,
    .block-menu__close {
        display: none;
    }

    .block-menu__item--home {
        display: none;
    }

    .block-menu__nav {
        position: static;
        flex-direction: row;
        align-items: center;
        gap: var(--menu-gap);
        padding: 0;
        overflow: visible;
        text-align: left;
        opacity: 1;
        visibility: visible;
        transform: none;
        background: none;
    }

    /* Back to a plain list item — the dropdown is positioned, not collapsed. */
    .block-menu__item--has-submenu {
        display: block;
    }

    .block-menu__list {
        flex-direction: row;
        align-items: center;
        gap: var(--menu-gap);
        width: auto;
        margin: 0;
    }

    .block-menu__link {
        width: auto;
        padding: 0;
        white-space: nowrap;
    }

    /* Sits in the space the bar opens up, not on top of the page */
    .block-menu__submenu {
        position: absolute;
        top: 100%;
        left: 0;
        z-index: 1;
        min-width: 200px;
        padding: var(--menu-padding-block) 0 0;
        background: none;
        overflow: visible;
        visibility: hidden;
    }

    .block-menu__item.is-open .block-menu__submenu {
        visibility: visible;
    }

    .block-menu__submenu > * {
        padding: 0;
    }

    .block-menu__subitem:first-child {
        padding-top: 0;
    }

    .block-menu__sublink {
        padding: 8px 0;
        text-align: left;
        white-space: nowrap;
    }

    .block-menu__button {
        margin-top: 0;
    }
}
