/* ============================================
   Hebrew Garden Header Navigation — Flyout Menu
   ============================================ */

.hg-nav {
    position: sticky;
    top: 0;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    line-height: 1.35;
}

/* --- Top bar --- */

.hg-nav-bar {
    display: flex;
    align-items: center;
    background: #2d2d2d;
    padding: 0 12px;
    min-height: 42px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 10;
}

/* --- Tabs --- */

.hg-nav-tabs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    flex: 1;
    justify-content: center;
}

.hg-nav-tab {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.75);
    font-size: 13px;
    font-weight: 500;
    padding: 10px 14px;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, background-color 0.15s;
    font-family: inherit;
}

.hg-nav-tab::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-right: 2.75px solid currentColor;
    border-bottom: 2.75px solid currentColor;
    transform: rotate(45deg);
    margin-left: 6px;
    margin-bottom: 3px;
    opacity: 0.6;
}

.hg-nav-tab-link::after {
    display: none;
}

.hg-nav-tab-link {
    text-decoration: none !important;
}

.hg-nav-tab:hover,
.hg-nav-tab.hg-nav-tab-active {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.07);
    border-bottom-color: #fff;
}

.hg-nav-tab.hg-nav-tab-ancestor {
    color: #fff;
    border-bottom-color: #5de09a;
}

.hg-nav-tab.hg-nav-tab-ancestor.hg-nav-tab-active {
    border-bottom-color: #fff;
}

/* --- Hamburger (mobile) --- */

.hg-nav-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 4px;
    margin-right: 8px;
}

.hg-nav-hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: #fff;
    border-radius: 1px;
    transition: transform 0.2s, opacity 0.2s;
}

.hg-nav-hamburger.hg-nav-hamburger-open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.hg-nav-hamburger.hg-nav-hamburger-open span:nth-child(2) {
    opacity: 0;
}

.hg-nav-hamburger.hg-nav-hamburger-open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ============================================
   Dropdown panel (first column)
   ============================================ */

.hg-nav-panel {
    display: none;
    position: absolute;
    /* top is set by JS based on actual bar height */
    width: max-content;
    min-width: 200px;
    max-width: 380px;
    background: #fff;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    border-radius: 0 0 6px 6px;
    border-top: 2px solid #444;
    z-index: 20;
    padding: 4px 0;
}

.hg-nav-panel.hg-nav-panel-open {
    display: block;
}

.hg-nav-panel-tree {
    padding: 0;
}

/* --- Overlay (mobile only) --- */

.hg-nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 4;
}

.hg-nav-overlay.hg-nav-overlay-show {
    display: block;
}

/* ============================================
   Menu items (inside panels & flyout columns)
   ============================================ */

.hg-menu-item {
    position: relative;
}

.hg-menu-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px 6px 12px;
    cursor: pointer;
    transition: background-color 0.1s;
    user-select: none;
}

.hg-menu-label a {
    text-decoration: none !important;
}

.hg-menu-label:hover {
    background-color: #f5f5f5;
}

/* --- Hide original chevron/dot, use right-side arrow --- */

.hg-menu-chevron,
.hg-menu-dot {
    display: none;
}

.hg-menu-has-children > .hg-menu-label::after {
    content: '\203A';
    font-size: 18px;
    font-weight: 300;
    color: #bbb;
    margin-left: auto;
    flex-shrink: 0;
    line-height: 1;
    transition: color 0.1s;
}

.hg-menu-has-children:hover > .hg-menu-label::after {
    color: #666;
}

/* --- Links and headers --- */

.hg-menu-link {
    text-decoration: none;
    color: #333;
    font-size: 14px;
    transition: color 0.1s;
}

.hg-menu-link:hover {
    color: #2ea44f;
    text-decoration: none;
}

.hg-menu-header {
    text-decoration: none;
    color: #333;
    font-size: 14px;
    transition: color 0.1s;
}

/* ============================================
   Flyout children columns
   ============================================ */

.hg-menu-children {
    display: none;
    position: absolute;
    left: calc(100% - 4px);
    top: 0;
    width: max-content;
    min-width: 200px;
    max-width: 380px;
    background: #fff;
    box-shadow: 6px 4px 20px rgba(0, 0, 0, 0.1);
    border-left: 1px solid #eaeaea;
    border-radius: 0 6px 6px 0;
    padding: 4px 0;
    z-index: 1;
}

/* Invisible bridge so mouse can travel from parent to flyout */
.hg-menu-children::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 0;
    bottom: 0;
    width: 14px;
}

/* Show flyout on hover (desktop) */
.hg-menu-has-children:hover > .hg-menu-children {
    display: block;
}

/* Highlight parent row when flyout is open */
.hg-menu-has-children:hover > .hg-menu-label {
    background-color: #f0f0f0;
}

/* ============================================
   Active page & ancestor highlights
   ============================================ */

.hg-menu-active > .hg-menu-label {
    background-color: #f0faf3;
    border-left: 3px solid #2ea44f;
    padding-left: 9px;
}

.hg-menu-active > .hg-menu-label .hg-menu-link {
    color: #2ea44f;
    font-weight: 600;
}

.hg-menu-ancestor > .hg-menu-label .hg-menu-link,
.hg-menu-ancestor > .hg-menu-label .hg-menu-header {
    color: #2a6b55;
    font-weight: 600;
}

/* ============================================
   Mobile: sidebar drawer with inline expand
   ============================================ */

@media (max-width: 768px) {
    .hg-nav-hamburger {
        display: flex;
    }

    .hg-nav-tabs {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        flex-direction: column;
        flex-wrap: nowrap;
        justify-content: flex-start;
        gap: 0;
        background: #2d2d2d;
        padding: 56px 0 20px;
        overflow-y: auto;
        z-index: 10001;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    }

    .hg-nav-tabs.hg-nav-tabs-open {
        display: flex;
    }

    .hg-nav-tab {
        text-align: left;
        padding: 12px 16px;
        border-bottom: none;
        border-left: 3px solid transparent;
        font-size: 14px;
        white-space: normal;
    }

    .hg-nav-tab:hover,
    .hg-nav-tab.hg-nav-tab-active,
    .hg-nav-tab.hg-nav-tab-ancestor {
        border-bottom: none;
        border-left-color: #5de09a;
        background-color: rgba(255, 255, 255, 0.06);
    }

    /* Panels: inline inside sidebar */
    .hg-nav-panel {
        position: static;
        width: auto;
        min-width: 0;
        max-width: none;
        box-shadow: none;
        border-top: none;
        border-radius: 0;
        background: #383838;
        padding: 4px 0;
    }

    .hg-nav-panel-tree {
        padding: 2px 8px;
    }

    /* Children: inline expand (not flyout) */
    .hg-menu-children {
        position: static;
        width: auto;
        min-width: 0;
        max-width: none;
        box-shadow: none;
        border-left: 1px solid #555;
        border-radius: 0;
        margin-left: 12px;
        padding: 0;
    }

    .hg-menu-children::before {
        display: none;
    }

    /* Disable hover-expand on touch */
    .hg-menu-has-children:hover > .hg-menu-children {
        display: none;
    }

    /* Tap-to-expand via JS-toggled class */
    .hg-menu-expanded > .hg-menu-children {
        display: block;
    }

    .hg-menu-has-children.hg-menu-expanded:hover > .hg-menu-children {
        display: block;
    }

    .hg-menu-label {
        color: #ddd;
    }

    .hg-menu-label:hover {
        background-color: rgba(255, 255, 255, 0.05);
    }

    .hg-menu-link {
        color: #ddd;
    }

    .hg-menu-header {
        color: #999;
    }

    .hg-menu-has-children > .hg-menu-label::after {
        color: #777;
    }

    .hg-menu-active > .hg-menu-label {
        background-color: rgba(46, 164, 79, 0.15);
        border-left-color: #2ea44f;
    }

    .hg-menu-active > .hg-menu-label .hg-menu-link {
        color: #5de09a;
    }

    .hg-nav-overlay.hg-nav-overlay-show {
        z-index: 10000;
        background: rgba(0, 0, 0, 0.45);
    }
}
