/* Have Anything Mobile (HAM) menu.
   Only loaded at the HAM breakpoint and below (Customize → Site Builder,
   800px by default). Above it, style.css keeps #mMenu hidden.
   Colors come from the theme tokens. To resize or recolor HAM, override
   these variables in your header's CSS. */

:root {
    --hamMenuSliceHeight: 3px;
    --hamMenuSize: 28px;
    --hamAnimationTime: 200ms;
    --hamHeaderHeight: 72px;   /* the burger centers itself in this */
    --hamRight: 24px;
    --hamSliceColor: var(--color-ink);
    --hamPanelBg: var(--color-surface);
    --hamPanelHover: var(--color-surface-2);
    --hamPanelBorder: var(--color-border);
    --hamPanelText: var(--color-ink);
    --hamAdminBar: var(--wp-admin--admin-bar--height, 0px);
}

body {
    overflow-x: hidden;
}

/* Only swap menus when ham.js is running; without JS the desktop links stay. */
.ham-js #dMenu,
.ham-js .ham-hide {
    display: none;
}

.ham-js #mMenu {
    display: block;
}

#mLayerMenu ul {
    list-style: none;
    margin: 0;
    padding-left: 0px;
}

#mLayerMenu a {
    display: block;
    padding: 14px 24px;
    border-bottom: 1px solid var(--hamPanelBorder);
    color: var(--hamPanelText);
    text-decoration: none;
    transition: background-color 200ms;
}

#mLayerMenu a:hover,
#mLayerMenu .current-menu-item > a {
    background-color: var(--hamPanelHover);
}

/* ---- Sub-menus (nested WordPress menu items) ---- */
#mLayerMenu li {
    position: relative;
}

#mLayerMenu li > ul {
    display: none;
}

#mLayerMenu li.hamSubOpen > ul {
    display: block;
}

#mLayerMenu li > ul a {
    padding-left: 40px;
    font-size: 0.95em;
}

#mLayerMenu li > ul ul a {
    padding-left: 56px;
}

#mLayerMenu li:has(> .hamSubToggle) > a {
    padding-right: 64px;
}

.hamSubToggle {
    position: absolute;
    top: 0;
    right: 0;
    width: 52px;
    height: calc(28px + 1.6em);
    padding: 0;
    border: 0;
    border-left: 1px solid var(--hamPanelBorder);
    background: none;
    color: var(--hamPanelText);
    cursor: pointer;
}

.hamSubToggle::before {
    content: "";
    display: block;
    width: 8px;
    height: 8px;
    margin: -4px auto 0;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform var(--hamAnimationTime);
}

.hamSubOpen > .hamSubToggle::before {
    margin-top: 2px;
    transform: rotate(-135deg);
}

/* ---- The burger ---- */
#hamMenu {
    width: var(--hamMenuSize);
    height: var(--hamMenuSize);
    position: fixed;
    top: calc((var(--hamHeaderHeight) - var(--hamMenuSize)) / 2 + var(--hamAdminBar));
    right: var(--hamRight);
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    z-index: 999;
}

.hamMenuSlice {
    background-color: var(--hamSliceColor);
    width: var(--hamMenuSize);
    height: var(--hamMenuSliceHeight);
    border-radius: var(--hamMenuSliceHeight);
    position: absolute;
    left: 50%;
    translate: -50% -50%;
}

#hamMenuMid {
    top: 50%;
    bottom: 50%;
}

.rpAnimations {
    animation-duration: var(--hamAnimationTime);
    animation-fill-mode: forwards;
}

#hamMenuTop {
    top: calc(0px + (var(--hamMenuSliceHeight) / 2));
    transform: rotate(0deg);
}

.hamMenuTopOpen {
    animation-name: hamMenuTopO;
}

@keyframes hamMenuTopO {
    0% {
        top: 50%;
        transform: rotate(45deg);
    }
    100% {
        top: calc(0px + (var(--hamMenuSliceHeight) / 2));
        transform: rotate(0deg);
    }
}

.hamMenuTopClose {
    animation-name: hamMenuTopC;
}

@keyframes hamMenuTopC {
    0% {
        top: calc(0px + (var(--hamMenuSliceHeight) / 2));
        transform: rotate(0deg);
    }
    100% {
        top: 50%;
        transform: rotate(45deg);
    }
}

#hamMenuMid {
    opacity: 1;
}

.hamMenuMidOpen {
    animation-name: hamMenuMidO;
}

@keyframes hamMenuMidO {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

.hamMenuMidClose {
    animation-name: hamMenuMidC;
}

@keyframes hamMenuMidC {
    0% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

#hamMenuBot {
    top: calc(var(--hamMenuSize) - (var(--hamMenuSliceHeight) / 2));
    transform: rotate(0deg);
}

.hamMenuBotOpen {
    animation-name: hamMenuBotO;
}

@keyframes hamMenuBotO {
    0% {
        top: 50%;
        transform: rotate(-45deg);
    }
    100% {
        top: calc(var(--hamMenuSize) - (var(--hamMenuSliceHeight) / 2));
        transform: rotate(0deg);
    }
}

.hamMenuBotClose {
    animation-name: hamMenuBotC;
}

@keyframes hamMenuBotC {
    0% {
        top: calc(var(--hamMenuSize) - (var(--hamMenuSliceHeight) / 2));
        transform: rotate(0deg);
    }
    100% {
        top: 50%;
        transform: rotate(-45deg);
    }
}

/* ---- The slide-out panel ---- */
#mLayerMenu {
    display: block;
    position: fixed;
    width: 80vw;
    height: 100vh;
    height: 100dvh;
    top: 0;
    right: -80vw;
    overflow-y: auto;
    overscroll-behavior: contain;
    background-color: var(--hamPanelBg);
    border-left: 1px solid var(--hamPanelBorder);
    padding-top: calc(var(--hamHeaderHeight) + var(--hamAdminBar));
    z-index: 998;
}

.mLayerMenuClose {
    animation-name: mLayerMenuC;
}

@keyframes mLayerMenuC {
    0% {
        right: -80vw;
    }
    100% {
        right: 0;
    }
}

.mLayerMenuOpen {
    animation-name: mLayerMenuO;
}

@keyframes mLayerMenuO {
    0% {
        right: 0;
    }
    100% {
        right: -80vw;
    }
}

/* ---- Page blur behind the panel ---- */
#fullPageBlur {
    position: fixed;
    width: 100vw;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 500;
}

.fullPageBlurOpen {
    animation-name: fullPageBlurO;
}

@keyframes fullPageBlurO {
    0% {
        backdrop-filter: blur(3px);
    }
    99% {
        backdrop-filter: blur(0px);
    }
    100% {
        width: 0px;
        height: 0px;
    }
}

.fullPageBlurClose {
    animation-name: fullPageBlurC;
}

@keyframes fullPageBlurC {
    0% {
        width: 100vw;
        height: 100vh;
    }
    1% {
        backdrop-filter: blur(0px);
    }
    100% {
        backdrop-filter: blur(3px);
    }
}

@media (prefers-reduced-motion: reduce) {
    :root {
        --hamAnimationTime: 1ms;
    }
}
