/* ============================================================
   Reflective — where the Learn megamenu sits (design §6, §14):
   a full-width panel under the bar with a scrim from 961px, an accordion
   inside the mobile menu below. Contents and tokens: nav-mega.css.
   ============================================================ */

/* ---------- Guides by topic, Popular, the footer strip ---------- */
.ln-mega-links {
    display: grid;
    gap: 2px;
    margin-bottom: 12px;
}

.nav-links .ln-mega-links a {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 0;
    font-size: 14px;
    color: var(--text-2);
}

.ln-mega-links em {
    font-style: normal;
    font-size: 12px;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
}

.ln-mega-pop ul {
    display: grid;
    gap: 10px;
}

.nav-links .ln-mega-pop a {
    display: block;
    font-size: 14px;
    line-height: 1.4;
    color: var(--text);
}

.ln-mega-pop small {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-3);
}

.ln-mega-foot {
    border-top: 1px solid var(--hairline);
    background: var(--surface-2);
}

.ln-mega-foot .wrap {
    display: flex;
    align-items: center;
    min-height: 54px;
}


.nav-links a.ln-mega-home {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
}

/* The scrim exists only while the desktop panel is open (no fade-out, so
   it can never linger over the page). */
.ln-scrim {
    display: none;
}

/* ---------- desktop: the panel under the bar, over a scrim ---------- */
@media (min-width: 961px) {
    .nav .nav-item {
        position: static;
    }

    .ln-mega {
        position: absolute;
        inset-inline: 0;
        top: 100%;
        z-index: 60;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--mega-shadow);
        visibility: hidden;
        opacity: 0;
        transform: translateY(-8px);
        transition:
            opacity 0.16s ease-out,
            transform 0.16s ease-out,
            visibility 0s linear 0.16s;
    }

    /* Bridges the bar under the trigger so a pointer can reach the panel. */
    .ln-mega::before {
        content: '';
        position: absolute;
        inset-inline: 0;
        bottom: 100%;
        height: 14px;
    }

    .nav-item.is-open .ln-mega,
    html:not(.nav-js) .nav-item:hover .ln-mega,
    html:not(.nav-js) .nav-item:focus-within .ln-mega {
        visibility: visible;
        opacity: 1;
        transform: none;
        transition:
            opacity 0.16s ease-out,
            transform 0.16s ease-out;
    }

    .ln-mega-grid {
        display: grid;
        grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) minmax(
                0,
                0.95fr
            );
        gap: 36px;
        padding-block: 24px 22px;
    }

    .ln-mega-col {
        padding-inline-start: 32px;
        border-inline-start: 1px solid var(--hairline);
    }

    .nav.mega-open .ln-scrim {
        display: block;
        position: absolute;
        inset-inline: 0;
        top: 100%;
        z-index: 55;
        height: 100vh;
        background: var(--mega-scrim);
        animation: ln-scrim-in 0.16s ease-out;
    }
}

@keyframes ln-scrim-in {
    from {
        opacity: 0;
    }
}

/* Narrower desktops: two columns, the course under the topics. */
@media (min-width: 961px) and (max-width: 1139px) {
    .ln-mega-grid {
        grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
        grid-template-areas: 'explore topics' 'explore course';
        gap: 24px 32px;
    }

    .ln-mega-explore {
        grid-area: explore;
    }

    .ln-mega-col {
        grid-area: topics;
    }

    .ln-mega-feature {
        grid-area: course;
        flex-direction: row;
        align-items: center;
        margin-inline-start: 32px;
    }

    .ln-mega-feature-img {
        flex: 0 0 120px;
        height: 120px;
        margin: 8px 0 8px 8px;
    }
}

/* ---------- phones and tablets: an accordion in the mobile menu ---------- */
@media (max-width: 960px) {
    .ln-mega {
        display: none;
        flex-basis: 100%;
    }

    .nav.menu-open .nav-item.is-open .ln-mega {
        display: block;
    }

    .ln-mega-grid {
        padding: 0 0 12px;
    }

    /* The four sections, then the course; topics stay on desktop. */
    .ln-mega-explore .ln-mega-h,
    .ln-mega-col,
    .ln-mega-foot {
        display: none;
    }

    .nav-links .ln-mega-item {
        margin-inline: 0;
        padding-inline: 0;
    }

    .ln-mega-feature {
        flex-direction: row;
        align-items: center;
        margin-top: 10px;
    }

    .ln-mega-feature-img {
        flex: 0 0 96px;
        height: 96px;
        margin: 8px 0 8px 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ln-mega,
    .nav-item.is-open .ln-mega {
        transform: none;
        transition: none;
    }

    .nav.mega-open .ln-scrim {
        animation: none;
    }
}
