/**
 * GEC Academy primary navigation — the desktop dropdown panel.
 *
 * A file of its own, and it owns the panel outright: navbar.css keeps the bar, the items
 * and the links, this keeps everything about the panel that drops out of them. Splitting it
 * here rather than layering overrides on top means one rule set has one owner.
 *
 * It is also the only way a change to this behaviour reaches people. LiteSpeed names its
 * combined stylesheet after the LIST of sources, and serves it with max-age=31557600, so
 * editing a file already in that list leaves the URL identical and every browser that has
 * ever loaded the page keeps the old bytes for a year. A new file changes the list.
 *
 * @package GEC_Academy_Child
 * @since 7.6.0
 */

/**
 * How long a dropdown stays open after the pointer leaves it.
 *
 * Long enough to cross the panel's own edge and come back, short enough that a menu the visitor
 * has walked away from does not linger over the page.
 *
 * It is declared in this file, beside the rules that read it, and every `var()` below repeats it
 * as a fallback. Putting it in navbar.css cost a deploy: that file's combined stylesheet keeps its
 * URL and its year-long cache, so a returning browser had the rules from here and the token from
 * there — the token resolved to nothing, which made the whole `transition` shorthand invalid and
 * the close delay silently zero. A token and its consumer have to ship together.
 */
.gec-navbar { --nav-submenu-close-delay: 320ms; }

.gec-navbar__caret { font-size: .625rem; }

/**
 * The dropdown sits --space-2 below its parent item, and it used to toggle with `display`.
 * Both halves of that broke the same gesture: moving the pointer down toward an item crossed
 * 8px of dead space where neither the parent nor the panel was hovered, and `display` cannot be
 * transitioned, so the panel vanished the instant that happened — with no grace period to move
 * back. A slight diagonal made it worse, because the pointer left the parent sideways first.
 *
 * Two fixes, both needed. A transparent bridge fills the gap so the hover path is continuous
 * (hover propagates to ancestors, so hovering the bridge still hovers the parent item), and the
 * panel now closes on a delay: opening stays instant, closing waits.
 */
.gec-navbar__submenu {
    position: absolute;
    inset: calc(100% + var(--space-2)) auto auto 0;
    z-index: var(--z-dropdown);

    /**
     * Stated even though nothing here hides the panel with `display` any more.
     *
     * A returning visitor may still hold the previous combined stylesheet — same URL, served
     * with max-age=31557600 — which carries the old `display: none`. That sheet loads before
     * this one, so without this line the panel would stay display:none while this file quietly
     * animated a visibility nobody could see, and the menu would never open for them at all.
     */
    display: block;

    visibility: hidden;
    opacity: 0;
    transform: translateY(-.25rem);
    min-inline-size: 15rem;
    margin: 0;
    padding: var(--space-2);
    border: var(--border-width) var(--border-style) var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    box-shadow: var(--shadow-lg);
    list-style: none;
    transition:
        opacity var(--duration-fast, 150ms) var(--ease-standard, ease) var(--nav-submenu-close-delay, 320ms),
        transform var(--duration-fast, 150ms) var(--ease-standard, ease) var(--nav-submenu-close-delay, 320ms),
        visibility 0s linear calc(var(--nav-submenu-close-delay, 320ms) + var(--duration-fast, 150ms));
}

/* Covers the gap above the panel; only reachable while the panel is visible. */
.gec-navbar__submenu::before {
    content: "";
    position: absolute;
    inset: calc(var(--space-2) * -1) 0 100% 0;
}

.gec-navbar__item:hover > .gec-navbar__submenu,
.gec-navbar__item:focus-within > .gec-navbar__submenu {
    visibility: visible;
    opacity: 1;
    transform: none;
    transition-delay: 0s, 0s, 0s;
}

.gec-navbar__submenu .gec-navbar__link { inline-size: 100%; min-block-size: 42px; padding-inline: var(--space-3); }
.gec-navbar__submenu .gec-navbar__submenu { inset: 0 auto auto calc(100% + var(--space-2)); }

/* A nested panel opens sideways, so its bridge is on the inline-start edge, not the top. */
.gec-navbar__submenu .gec-navbar__submenu::before {
    inset: 0 100% 0 calc(var(--space-2) * -1);
}

@media (prefers-reduced-motion: reduce) {
    .gec-navbar__submenu {
        transform: none;
        transition:
            opacity 0s linear var(--nav-submenu-close-delay, 320ms),
            visibility 0s linear var(--nav-submenu-close-delay, 320ms);
    }

    .gec-navbar__item:hover > .gec-navbar__submenu,
    .gec-navbar__item:focus-within > .gec-navbar__submenu { transition-delay: 0s, 0s; }
}

