/* ================================================================
   Hamburger Nav Pro – hamburger-nav.css
   Uses CSS custom properties set inline by PHP (var(--hnp-*))
   All layout, animation, accessibility, responsive styles here.
   ================================================================ */

/* ---------------------------------------------------------------
   0. Skip link (accessibility)
---------------------------------------------------------------- */
.hnp-skip-link {
    position: absolute;
    top: -9999px;
    left: -9999px;
    z-index: 99999;
    background: #000;
    color: #fff;
    padding: 8px 16px;
    font-size: 14px;
    text-decoration: none;
    border-radius: 0 0 4px 0;
}
.hnp-skip-link:focus {
    top: 0;
    left: 0;
}

/* ---------------------------------------------------------------
   1. Hamburger Button
---------------------------------------------------------------- */
.hnp-btn {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 44px;          /* WCAG min touch target */
    height: 44px;
    padding: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 1001;
    position: relative;
    border-radius: 4px;
    /* Visible focus */
    outline: 2px solid transparent;
    outline-offset: 2px;
}
.hnp-btn:focus-visible {
    outline-color: var(--hnp-active-color, #0073aa);
}

.hnp-btn--sticky {
    position: fixed;
    top: 12px;
    left: 16px;
    z-index: 10000;
    background: var(--hnp-bg, #fff);
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
    border-radius: 6px;
}

.hnp-btn__bar {
    display: block;
    width: var(--hnp-icon-size, 24px);
    height: var(--hnp-icon-thick, 2px);
    background: var(--hnp-icon-color, #1a1a1a);
    border-radius: 2px;
    transform-origin: center;
    transition: transform var(--hnp-speed, 300ms) ease-in-out,
                opacity  var(--hnp-speed, 300ms) ease-in-out;
}

/* Animate to × when active */
.hnp-btn--animate[aria-expanded="true"] .hnp-btn__bar--top {
    transform: translateY(calc(var(--hnp-icon-thick, 2px) * 2 + 5px)) rotate(45deg);
}
.hnp-btn--animate[aria-expanded="true"] .hnp-btn__bar--mid {
    opacity: 0;
    transform: scaleX(0);
}
.hnp-btn--animate[aria-expanded="true"] .hnp-btn__bar--bot {
    transform: translateY(calc((var(--hnp-icon-thick, 2px) * 2 + 5px) * -1)) rotate(-45deg);
}

/* ---------------------------------------------------------------
   2. Overlay
---------------------------------------------------------------- */
.hnp-overlay {
    position: fixed;
    inset: 0;
    background: var(--hnp-overlay, rgba(0,0,0,.4));
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--hnp-speed, 300ms) ease-in-out,
                visibility var(--hnp-speed, 300ms) ease-in-out;
}
.hnp-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

/* ---------------------------------------------------------------
   3. Nav panel (the sliding menu)
---------------------------------------------------------------- */
.hnp-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--hnp-width, 320px);
    max-width: 90vw;
    height: 100%;
    background: var(--hnp-bg, #fff);
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform var(--hnp-speed, 300ms) ease-in-out;
    padding-top: env(safe-area-inset-top, 0);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    /* Accessible: shadow for visual depth */
    box-shadow: 2px 0 16px rgba(0,0,0,.12);
}

.hnp-nav.is-open {
    transform: translateX(0);
}

/* Push content mode */
body.hnp-push .hnp-nav {
    position: absolute;
}

/* ---------------------------------------------------------------
   4. Menu list (root <ul>)
---------------------------------------------------------------- */
.hnp-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
}

/* ---------------------------------------------------------------
   5. Menu item + separator
---------------------------------------------------------------- */
.hnp-item {
    position: relative;
    margin: 0;
    padding: 0;
    border-bottom: var(--hnp-sep-size, 1px) solid var(--hnp-sep-color, #e0e0e0);
    list-style: none;
}

/* Remove border from nested items (handled per level) */
.hnp-submenu .hnp-item {
    border-bottom: none;
    border-top: var(--hnp-sep-size, 1px) solid var(--hnp-sep-color, #e0e0e0);
}

/* ---------------------------------------------------------------
   6. Links
---------------------------------------------------------------- */
.hnp-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: var(--hnp-pad-v, 14px) var(--hnp-pad-h, 20px);
    color: var(--hnp-color, #1a1a1a);
    font-family: var(--hnp-font-family, inherit);
    font-size: var(--hnp-font-size, 16px);
    font-weight: var(--hnp-font-weight, 400);
    text-decoration: none;
    line-height: 1.4;
    width: 100%;
    box-sizing: border-box;
    /* Reserve space for toggle button */
    padding-right: calc(var(--hnp-pad-h, 20px) + 44px);
    transition: background var(--hnp-speed, 300ms) ease,
                color var(--hnp-speed, 300ms) ease;
    /* Visible focus */
    outline: 2px solid transparent;
    outline-offset: -2px;
    border-radius: 2px;
}

.hnp-link:hover,
.hnp-link:focus-visible {
    background: var(--hnp-hover-bg, #f5f5f5);
    color: var(--hnp-hover-color, #000);
    text-decoration: underline;
}

.hnp-link:focus-visible {
    outline-color: var(--hnp-active-color, #0073aa);
}

/* Active / current page */
.hnp-link--active,
.hnp-link[aria-current="page"] {
    color: var(--hnp-active-color, #0073aa);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Items without children don't need reserved space */
.hnp-item:not(.hnp-item--has-children) .hnp-link {
    padding-right: var(--hnp-pad-h, 20px);
}

/* ---------------------------------------------------------------
   7. Item icon
---------------------------------------------------------------- */
.hnp-item-icon {
    flex-shrink: 0;
    width: 1.25em;
    height: 1.25em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ---------------------------------------------------------------
   8. Badge / label
---------------------------------------------------------------- */
.hnp-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.4;
    background: var(--hnp-active-color, #0073aa);
    color: #fff;
    margin-left: 8px;
    white-space: nowrap;
    vertical-align: middle;
}

/* ---------------------------------------------------------------
   9. Toggle button (submenu expand)
---------------------------------------------------------------- */
.hnp-toggle {
    position: absolute;
    top: 0;
    right: 0;
    width: 44px;
    height: 44px;
    min-height: 44px;   /* WCAG minimum touch target */
    padding: 0;
    background: transparent;
    border: none;
    border-left: var(--hnp-sep-size, 1px) solid var(--hnp-sep-color, #e0e0e0);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--hnp-color, #1a1a1a);
    z-index: 2;
    /* Visible focus */
    outline: 2px solid transparent;
    outline-offset: -2px;
    border-radius: 2px;
    transition: background var(--hnp-speed, 300ms) ease;
}

.hnp-toggle:hover,
.hnp-toggle:focus-visible {
    background: var(--hnp-hover-bg, #f5f5f5);
}
.hnp-toggle:focus-visible {
    outline-color: var(--hnp-active-color, #0073aa);
}

/* Triangle icon */
.hnp-toggle-icon {
    display: block;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid currentColor;
    transition: transform var(--hnp-speed, 300ms) ease-in-out;
}

/* Rotate when expanded */
.hnp-toggle[aria-expanded="true"] .hnp-toggle-icon {
    transform: rotate(180deg);
}

/* ---------------------------------------------------------------
   10. Submenu
---------------------------------------------------------------- */
.hnp-submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    /* Accordion: hidden by default */
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--hnp-speed, 300ms) ease-in-out;
    background: color-mix(in srgb, var(--hnp-bg, #fff) 95%, #000 5%);
    /* Indent per depth (set via JS per open) */
}

.hnp-submenu.is-open {
    max-height: 2000px; /* Large enough for any menu */
}

/* Indent subcategories */
.hnp-submenu--depth-1 .hnp-link {
    padding-left: calc(var(--hnp-pad-h, 20px) + 16px);
}
.hnp-submenu--depth-2 .hnp-link {
    padding-left: calc(var(--hnp-pad-h, 20px) + 32px);
    font-size: calc(var(--hnp-font-size, 16px) * 0.95);
}
.hnp-submenu--depth-3 .hnp-link {
    padding-left: calc(var(--hnp-pad-h, 20px) + 48px);
    font-size: calc(var(--hnp-font-size, 16px) * 0.9);
}

/* ---------------------------------------------------------------
   11. Admin notice (only visible to admins when no menu assigned)
---------------------------------------------------------------- */
.hnp-notice {
    padding: 12px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    font-size: 14px;
    margin: 8px;
}

/* ---------------------------------------------------------------
   12. Reduced motion preference
---------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .hnp-nav,
    .hnp-overlay,
    .hnp-submenu,
    .hnp-btn__bar,
    .hnp-toggle-icon,
    .hnp-link {
        transition: none !important;
        animation: none !important;
    }
}

/* ---------------------------------------------------------------
   13. High contrast mode
---------------------------------------------------------------- */
@media (forced-colors: active) {
    .hnp-btn__bar         { background: ButtonText; }
    .hnp-link             { color: LinkText; }
    .hnp-link:focus-visible { outline-color: Highlight; }
    .hnp-toggle           { border-color: ButtonText; }
}

/* ---------------------------------------------------------------
   14. Zoom up to 200% without horizontal scroll
---------------------------------------------------------------- */
@media (max-width: 600px) {
    .hnp-nav {
        width: min(var(--hnp-width, 320px), 92vw);
    }
}
