/* Dropdown submenus for the header navigation (see assets/js/nav-dropdown.js) */
.gh-head-menu .nav > li.has-subnav {
    position: relative;
    display: flex;
    align-items: center;
    gap: 2px;
}

.gh-subnav-toggle {
    width: 16px;
    height: 16px;
    padding: 0;
    cursor: pointer;
    background: none;
    border: 0;
    color: inherit;
}

.gh-subnav-toggle::after {
    display: block;
    width: 6px;
    height: 6px;
    margin: 0 auto;
    content: "";
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
}

.gh-subnav {
    padding: 0;
    margin: 0;
    list-style: none;
}

.gh-subnav li {
    margin: 0;
}

@media (min-width: 768px) {
    .gh-subnav {
        position: absolute;
        top: 100%;
        left: -16px;
        z-index: 100;
        min-width: 200px;
        padding: 12px 0;
        visibility: hidden;
        opacity: 0;
        background-color: var(--background-color, #fff);
        border-radius: 6px;
        box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.12);
        transform: translateY(6px);
        transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    }

    /* Bridges the gap between the parent link and the panel so hover isn't lost */
    .has-subnav::after {
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        height: 16px;
        content: "";
    }

    .has-subnav:hover > .gh-subnav,
    .has-subnav:focus-within > .gh-subnav,
    .has-subnav.is-subnav-open > .gh-subnav {
        visibility: visible;
        opacity: 1;
        transform: translateY(0);
    }

    .gh-subnav a {
        display: block;
        padding: 8px 20px;
        white-space: nowrap;
    }

    .gh-subnav a:hover {
        opacity: 0.6;
    }
}

/* Mobile: accordion sections with large tap targets */
.gh-subnav-all {
    display: none;
}

@media (max-width: 767px) {
    .gh-head-menu .nav {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 0;
    }

    .gh-head-menu .nav > li {
        width: 100%;
        text-align: center;
        border-bottom: 1px solid var(--color-light-gray, rgba(0, 0, 0, 0.08));
    }

    .gh-head-menu .nav > li:last-child {
        border-bottom: 0;
    }

    #gh-head .gh-head-menu .nav > li > a {
        display: flex;
        justify-content: center;
        width: 100%;
        min-height: 64px;
        align-items: center;
    }

    .gh-head-menu .nav > li.has-subnav {
        display: block;
    }

    /* Arrow is a visual cue; the whole row is the tap target */
    .gh-subnav-toggle {
        position: absolute;
        top: 0;
        right: 0;
        width: 64px;
        height: 64px;
    }

    .gh-subnav-toggle::after {
        width: 12px;
        height: 12px;
        border-width: 2.5px;
        transition: transform 0.25s ease;
    }

    .is-subnav-open > .gh-subnav-toggle::after {
        transform: translateY(3px) rotate(-135deg);
    }

    .gh-subnav {
        display: none;
        padding: 0 0 16px;
        text-align: center;
    }

    .has-subnav.is-subnav-open > .gh-subnav {
        display: block;
    }

    .gh-subnav-all {
        display: block;
    }

    /* Don't inherit the theme's staggered fade-in for top-level items */
    #gh-head .gh-subnav li {
        opacity: 1;
        transform: none;
        transition: none;
    }

    #gh-head .gh-subnav a {
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 52px;
        padding: 0 16px;
        font-size: 2.2rem;
        font-weight: 500;
        opacity: 0.75;
    }

    #gh-head .gh-subnav .gh-subnav-all a {
        font-weight: 700;
        opacity: 1;
        color: var(--ghost-accent-color, inherit);
    }

    #gh-head .gh-subnav a:active {
        opacity: 1;
        background: rgba(0, 0, 0, 0.04);
    }
}

/* Inside the theme's own "More" overflow menu, show children inline */
.gh-dropdown .gh-subnav {
    position: static;
    display: block;
    min-width: 0;
    padding: 0 0 0 12px;
    visibility: visible;
    opacity: 1;
    background: none;
    box-shadow: none;
    transform: none;
}

.gh-dropdown .gh-subnav-toggle {
    display: none;
}
