.academy-mega {
    --mega-ink: #f7f1ff;
    --mega-muted: #c7badb;
    --mega-accent: #ffda80;
    --mega-surface: #1b1032;
    --mega-raised: #271940;
    --mega-hover: #352551;
    --mega-line: #594576;
    --mega-focus-edge: #261641;
    --mega-motion: 180ms cubic-bezier(.2, .7, .3, 1);
}

.academy-mega__bar,
.academy-mega__links {
    margin: 0;
    padding: 0;
    list-style: none;
}

.academy-mega__bar {
    display: flex;
    align-items: center;
    gap: .25rem;
    overflow-x: auto;
    scrollbar-width: thin;
    padding: 4px;
}

.academy-mega__bar > li {
    flex: 0 0 auto;
}

#header #width-navigation .academy-mega__trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    min-height: 44px;
    height: auto;
    padding: .55rem .65rem;
    border: 1px solid transparent;
    border-radius: .65rem;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: clamp(.875rem, 1.1vw, 1.05rem);
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transform: none;
    transition: background-color var(--mega-motion), color var(--mega-motion), border-color var(--mega-motion);
}

#header #width-navigation .academy-mega__trigger:hover,
#header #width-navigation .academy-mega__trigger[aria-expanded="true"] {
    border-color: var(--mega-line);
    background-color: var(--mega-raised);
    color: var(--mega-accent);
}

#header #width-navigation .academy-mega__unavailable {
    cursor: default;
}

.academy-mega__panel {
    position: absolute;
    z-index: 10;
    inset-inline: 15px;
    inset-block-start: calc(100% + 4px);
    max-height: min(40rem, calc(100vh - 6rem));
    max-height: min(40rem, calc(100dvh - 6rem));
    padding: 1.5rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: var(--mega-line) var(--mega-surface);
    border: 1px solid var(--mega-line);
    border-block-start: 2px solid var(--mega-accent);
    border-radius: 1rem;
    background: var(--mega-surface);
    box-shadow: 0 18px 45px rgba(12, 5, 27, .44);
    color: var(--mega-ink);
    text-align: start;
}

.academy-mega__panel[hidden] {
    display: none;
}

.academy-mega__panel:not([hidden]),
.academy-mega__disclosure[open] > .academy-mega__children {
    animation: academy-mega-reveal var(--mega-motion) both;
}

.academy-mega__heading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem 1rem;
    margin-block-end: 1rem;
    padding-block-end: .75rem;
    border-block-end: 1px solid var(--mega-line);
}

.academy-mega__heading h2 {
    margin: 0;
    color: var(--mega-ink);
    font-size: 1.25rem;
    font-weight: 800;
}

.academy-mega__links {
    display: grid;
    gap: .5rem;
}

.academy-mega--desktop .academy-mega__links {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.academy-mega--desktop .academy-mega__branch {
    grid-column: 1 / -1;
}

#header #width-navigation .academy-mega__link,
#header #side-navigation .academy-mega__link,
.academy-mega__disclosure > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    min-height: 44px;
    height: auto;
    padding: .5rem .85rem;
    border-radius: .6rem;
    background-color: var(--mega-raised);
    color: var(--mega-ink);
    font: inherit;
    font-size: .9375rem;
    line-height: 1.6;
    text-align: start;
    text-decoration: none;
    overflow-wrap: anywhere;
    cursor: pointer;
    transform: none;
    transition: background-color var(--mega-motion), color var(--mega-motion);
}

#header #width-navigation .academy-mega__link:hover,
#header #side-navigation .academy-mega__link:hover,
.academy-mega__disclosure > summary:hover,
.academy-mega__disclosure[open] > summary {
    background-color: var(--mega-hover);
    color: var(--mega-accent);
}

#header #width-navigation .academy-mega__overview,
#header #side-navigation .academy-mega__overview {
    width: fit-content;
    max-width: 100%;
    color: var(--mega-accent);
    font-weight: 700;
}

#header #width-navigation .academy-mega__link.academy-mega__unavailable,
#header #side-navigation .academy-mega__link.academy-mega__unavailable {
    color: var(--mega-muted);
    cursor: default;
}

.academy-mega__disclosure {
    padding: 0;
    border: 1px solid var(--mega-line);
    border-radius: .65rem;
    background-color: var(--mega-surface);
}

.academy-mega__disclosure > summary {
    list-style: none;
    font-weight: 700;
}

.academy-mega__disclosure > summary::-webkit-details-marker {
    display: none;
}

.academy-mega__children {
    padding: .65rem;
}

.academy-mega__children > .academy-mega__overview {
    margin-block-end: .5rem;
}

.academy-mega__chevron {
    flex: 0 0 auto;
    width: .48rem;
    height: .48rem;
    margin: -.22rem .2rem 0;
    border: solid currentColor;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    transition: transform var(--mega-motion);
}

.academy-mega__trigger[aria-expanded="true"] .academy-mega__chevron,
.academy-mega__disclosure[open] > summary .academy-mega__chevron {
    transform: rotate(225deg);
}

#header .academy-mega :is(a, button, summary):focus-visible {
    outline: 2px solid var(--mega-accent);
    outline-offset: -3px;
    box-shadow: inset 0 0 0 5px var(--mega-focus-edge);
}

#header #side-navigation .academy-mega--mobile {
    margin: 1rem;
    padding: .75rem;
    border: 1px solid var(--mega-line);
    border-radius: .9rem;
    background-color: var(--mega-surface);
    color: var(--mega-ink);
    font-size: 1rem;
}

#header #side-navigation .academy-mega--mobile div {
    font-size: inherit;
}

@media (min-width: 1200px) {
    #header .search-bar--mega > .container {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) 255px;
        align-items: center;
        min-height: 75px;
    }

    #header .search-bar--mega #width-navigation {
        min-width: 0;
        margin: 0 .5rem;
        padding: 0;
    }

    #header .search-bar--mega .logo,
    #header .search-bar--mega .login,
    #header .search-bar--mega .user-panel-button {
        display: inline-block;
    }

    #header .search-bar--mega .logo img {
        max-width: 135px;
        object-fit: contain;
    }

    #header .search-bar--mega .search {
        left: 220px;
    }
}

@keyframes academy-mega-reveal {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .academy-mega *,
    .academy-mega *::before,
    .academy-mega *::after {
        animation: none !important;
        transition: none !important;
    }
}
