/* ============================================================
   Hamburger Menu Plugin — hamburger-menu.css
   All layout and animation; colours/spacing via CSS variables
   injected per-instance from the shortcode attributes.
   ============================================================ */

/* ── Wrapper (scopes CSS vars) ─────────────────────────────── */
.hm-wrapper {
    display: inline-block;
    position: relative;
    z-index: 9990;
}

/* ── Trigger button ─────────────────────────────────────────── */
.hm-trigger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    z-index: 9999;
}

.hm-trigger:focus-visible {
    outline: 2px solid var(--hm-icon-color, #fff);
    outline-offset: 4px;
    border-radius: 4px;
}

/* ── Hamburger bars (shared by trigger & close button) ──────── */
.hm-bar {
    display: block;
    width: 28px;
    height: 2px;
    background-color: var(--hm-icon-color, #ffffff);
    border-radius: 2px;
    transform-origin: center;
    transition: transform 0.35s cubic-bezier(0.77, 0, 0.18, 1),
                opacity   0.25s ease,
                width     0.25s ease;
    pointer-events: none;
}

/* Trigger → animated to X when open */
.hm-wrapper.is-open .hm-trigger .hm-bar-1 {
    transform: translateY(7px) rotate(45deg);
}
.hm-wrapper.is-open .hm-trigger .hm-bar-2 {
    opacity: 0;
    transform: scaleX(0);
}
.hm-wrapper.is-open .hm-trigger .hm-bar-3 {
    transform: translateY(-7px) rotate(-45deg);
}

/* ── Close button (inside overlay) ─────────────────────────── */
.hm-close {
    position: fixed;
    top: calc(var(--hm-margin, 40px));
    right: calc(var(--hm-margin, 40px));
    width: 44px;
    height: 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    z-index: 10001;
    opacity: 0;
    transform: rotate(-90deg);
    transition: opacity 0.3s ease 0.15s,
                transform 0.35s cubic-bezier(0.77, 0, 0.18, 1) 0.15s;
}

.hm-close:focus-visible {
    outline: 2px solid var(--hm-text-color, #fff);
    outline-offset: 4px;
    border-radius: 4px;
}

.hm-close .hm-bar {
    position: absolute;
    background-color: var(--hm-text-color, #ffffff);
}
.hm-close .hm-bar-1 { transform: rotate(45deg); }
.hm-close .hm-bar-2 { transform: rotate(-45deg); }

/* Animate close button in when overlay is open */
.hm-overlay:not([hidden]) .hm-close {
    opacity: 1;
    transform: rotate(0deg);
}

/* ── Overlay ────────────────────────────────────────────────── */
.hm-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background-color: var(--hm-bg, #0f0f0f);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;

    /* Entry animation */
    opacity: 0;
    clip-path: inset(0 0 100% 0);
    transition: opacity   0.45s cubic-bezier(0.77, 0, 0.18, 1),
                clip-path 0.45s cubic-bezier(0.77, 0, 0.18, 1);
    pointer-events: none;
    will-change: clip-path, opacity;
}

/* hidden attribute suppresses display; JS removes it to start transition */
.hm-overlay[hidden] {
    display: flex !important; /* keep flex for transition, hidden via clip-path */
    pointer-events: none;
}

.hm-overlay.hm-entering,
.hm-overlay.hm-open {
    opacity: 1;
    clip-path: inset(0 0 0% 0);
    pointer-events: auto;
}

.hm-overlay.hm-leaving {
    opacity: 0;
    clip-path: inset(0 0 100% 0);
    pointer-events: none;
}

/* ── Navigation block ───────────────────────────────────────── */
.hm-nav {
    width: 100%;
    padding: var(--hm-margin, 40px);
    box-sizing: border-box;
    overflow-y: auto;
    max-height: 100vh;
}

.hm-nav-list,
.hm-submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    text-align: right;
}

.hm-nav-list {
    display: flex;
    flex-direction: column;
    gap: var(--hm-gap, 28px);
    align-items: flex-end;
}

/* ── Nav items ──────────────────────────────────────────────── */
.hm-nav-item {
    opacity: 0;
    transform: translateX(40px);
    transition: opacity   0.4s ease,
                transform 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* Stagger each item when overlay opens */
.hm-overlay.hm-open .hm-nav-item:nth-child(1)  { transition-delay: 0.12s; }
.hm-overlay.hm-open .hm-nav-item:nth-child(2)  { transition-delay: 0.17s; }
.hm-overlay.hm-open .hm-nav-item:nth-child(3)  { transition-delay: 0.22s; }
.hm-overlay.hm-open .hm-nav-item:nth-child(4)  { transition-delay: 0.27s; }
.hm-overlay.hm-open .hm-nav-item:nth-child(5)  { transition-delay: 0.32s; }
.hm-overlay.hm-open .hm-nav-item:nth-child(6)  { transition-delay: 0.37s; }
.hm-overlay.hm-open .hm-nav-item:nth-child(7)  { transition-delay: 0.42s; }
.hm-overlay.hm-open .hm-nav-item:nth-child(8)  { transition-delay: 0.47s; }
.hm-overlay.hm-open .hm-nav-item:nth-child(n+9){ transition-delay: 0.52s; }

.hm-overlay.hm-open .hm-nav-item {
    opacity: 1;
    transform: translateX(0);
}

/* ── Links ──────────────────────────────────────────────────── */
.hm-nav-link {
    display: inline-block;
    color: var(--hm-text-color, #ffffff);
    font-family: var(--hm-font, inherit);
    font-size: var(--hm-font-size, 36px);
    font-weight: 600;
    line-height: 1.15;
    text-decoration: none;
    letter-spacing: -0.02em;
    position: relative;
    transition: opacity 0.2s ease;
}

.hm-nav-link::after {
    content: '';
    position: absolute;
    bottom: -3px;
    right: 0;
    width: 0;
    height: 2px;
    background: var(--hm-text-color, #ffffff);
    transition: width 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.hm-nav-link:hover::after,
.hm-nav-link:focus-visible::after {
    width: 100%;
}

.hm-nav-link:hover,
.hm-nav-link:focus-visible {
    opacity: 0.7;
    outline: none;
}

/* Current page link */
.current-menu-item > .hm-nav-link,
.current-page-ancestor > .hm-nav-link {
    opacity: 0.55;
}

/* ── Sub-menu ────────────────────────────────────────────────── */
.hm-submenu {
    display: flex;
    flex-direction: column;
    gap: calc(var(--hm-gap, 28px) * 0.5);
    align-items: flex-end;
    margin-top: calc(var(--hm-gap, 28px) * 0.5);
    padding-right: calc(var(--hm-margin, 40px) * 0.25);
    border-right: 2px solid currentColor;
}

.hm-submenu .hm-nav-link {
    font-size: calc(var(--hm-font-size, 36px) * 0.6);
    font-weight: 400;
    opacity: 0.75;
}

/* ── Body scroll lock ───────────────────────────────────────── */
body.hm-no-scroll {
    overflow: hidden;
}

/* ── Responsive tweaks ──────────────────────────────────────── */
@media (max-width: 480px) {
    .hm-nav-link {
        font-size: clamp(24px, 7vw, var(--hm-font-size, 36px));
    }
    .hm-close {
        top: 20px;
        right: 20px;
    }
}
