/**
 * Site nav — "Lær" menu (desktop mega-panel) + mobile menu sheet.
 *
 * Loaded AFTER common_files/nav_bar_styles.css, which the legacy PHP nav also
 * uses: nothing here edits that file, every rule is either a new class or an
 * override scoped to a new modifier class. Node pages only.
 *
 * Brand: cream #f7f4ee surface, white cards, warm-brown ink, gold as the one
 * action colour (tokens.css --accent / --accent-deep). Never cold blue.
 */

/* ==========================================
   Desktop: Lær toggle + mega panel
   ========================================== */
.nav-new__dropdown-toggle--learn {
    font-weight: 600;
    color: #6b5a3e;
    /* Taller hit area: the panel hangs off the bottom of the 50px bar, and a
       gap between button and panel would drop the :hover before the pointer
       gets there. */
    padding-top: 0.72rem;
    padding-bottom: 0.72rem;
}

.nav-new__dropdown-toggle--learn .fa-compass {
    font-size: 0.95rem;
    color: var(--accent-deep, #d4a017);
    transition: transform 0.25s ease;
}

.nav-new__dropdown--mega:hover .nav-new__dropdown-toggle--learn .fa-compass,
.nav-new__dropdown--mega.open .nav-new__dropdown-toggle--learn .fa-compass {
    transform: rotate(-25deg);
}

/* The panel is far wider than the button, so it anchors to the viewport
   instead of the toggle — that way it can never hang off either edge. */
.nav-new__dropdown--mega .nav-new__dropdown-menu.nav-mega {
    position: fixed;
    top: 50px;
    left: 50%;
    right: auto;
    width: min(760px, calc(100vw - 32px));
    max-height: calc(100vh - 74px);
    overflow-y: auto;
    padding: 1.1rem 1.2rem 1.15rem;
    border-radius: 18px;
    background: #fffdf9;
    border: 1px solid var(--border-soft, #ece6da);
    box-shadow: 0 18px 44px rgba(107, 90, 66, 0.22);
    transform: translate(-50%, -10px);
}

.nav-new__dropdown--mega:hover .nav-new__dropdown-menu.nav-mega,
.nav-new__dropdown--mega:focus-within .nav-new__dropdown-menu.nav-mega,
.nav-new__dropdown--mega.open .nav-new__dropdown-menu.nav-mega {
    transform: translate(-50%, 0);
}

/* Invisible bridge over the last few pixels between button and panel — the
   panel is a DOM child of the dropdown, so hovering it keeps the menu open. */
.nav-new__dropdown-menu.nav-mega::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 0;
    right: 0;
    height: 12px;
}

/* Featured row — Spør Språki + Arbeid */
.nav-mega__featured {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.nav-new__dropdown-menu.nav-mega a.nav-mega__feat {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin: 0;
    padding: 0.7rem 0.85rem;
    border-radius: 14px;
    background: var(--accent-soft, #fef6dd);
    border: 1px solid rgba(212, 160, 23, 0.28);
    color: #5a4520;
    font-size: 1rem;
    font-weight: 700;
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.nav-new__dropdown-menu.nav-mega a.nav-mega__feat:hover {
    background: var(--accent, #fbc24b);
    color: #3d2e14;
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(251, 194, 75, 0.35);
}

.nav-mega__feat-ic {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: #fff;
    color: var(--accent-deep, #d4a017);
    font-size: 1rem;
}

/* Columns */
.nav-mega__cols {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 0.4rem 1rem;
}

.nav-mega__col-title {
    margin: 0 0 0.35rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-soft, #6d655b);
}

/* First column holds every learning feature — two lanes so the panel stays
   short enough to read without scrolling. */
.nav-mega__col:first-child {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-content: start;
    gap: 0 0.3rem;
}

.nav-mega__col:first-child .nav-mega__col-title {
    grid-column: 1 / -1;
}

.nav-new__dropdown-menu.nav-mega a.nav-mega__link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0;
    padding: 0.5rem 0.55rem;
    border-radius: 10px;
    color: var(--text-default, #4a4540);
    font-size: 0.92rem;
    font-weight: 500;
    line-height: 1.2;
}

.nav-new__dropdown-menu.nav-mega a.nav-mega__link i {
    width: 20px;
    flex: 0 0 20px;
    text-align: center;
    font-size: 0.95rem;
    color: var(--accent-deep, #d4a017);
    transition: transform 0.15s ease;
}

.nav-new__dropdown-menu.nav-mega a.nav-mega__link:hover {
    background: var(--accent-soft, #fef6dd);
    color: #5a4520;
}

.nav-new__dropdown-menu.nav-mega a.nav-mega__link:hover i {
    transform: scale(1.12);
}

/* Staff footer row */
.nav-mega__teacher {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.9rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border-soft, #ece6da);
}

.nav-mega__teacher-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-soft, #6d655b);
    margin-right: 0.2rem;
}

.nav-new__dropdown-menu.nav-mega a.nav-mega__teacher-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    background: #f7f4ee;
    border: 1px solid var(--border-soft, #ece6da);
    color: var(--text-muted, #5f5238);
    font-size: 0.85rem;
    font-weight: 600;
}

.nav-new__dropdown-menu.nav-mega a.nav-mega__teacher-link:hover {
    background: var(--accent-soft, #fef6dd);
    border-color: rgba(212, 160, 23, 0.35);
    color: #5a4520;
}

.nav-new__dropdown-menu.nav-mega a.nav-mega__teacher-link i {
    color: var(--accent-deep, #d4a017);
}

/* ==========================================
   Mobile bar: account button + menu button
   ========================================== */
.nav-mob__account,
.nav-mob__menu {
    display: none;               /* desktop hides the mobile bar entirely */
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    padding: 0;
    font-family: inherit;
    cursor: pointer;
    flex-shrink: 0;
}

.nav-mob__account {
    position: relative;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    color: #827153;
}

.nav-mob__account-flag {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(107, 90, 66, 0.25);
}

.nav-mob__account .nav-new__user-icon {
    width: 26px;
    height: 26px;
}

.nav-mob__account-level {
    position: absolute;
    right: -4px;
    bottom: -3px;
    min-width: 18px;
    height: 18px;
    padding: 0 3px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: #eea94d;
    border: 2px solid #f7f4ee;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 1;
}

.nav-mob__menu {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--accent-soft, #fef6dd);
    color: #7d6428;
    font-size: 1.05rem;
}

.nav-mob__menu:active {
    background: var(--accent, #fbc24b);
    color: #3d2e14;
}

.nav-mob__account:focus-visible,
.nav-mob__menu:focus-visible {
    outline: 2px solid #5a4520;
    outline-offset: 2px;
}

.nav-new-mobile__logo .nav-new__logo-text {
    font-size: 1rem;
}

.nav-new-mobile__back-tx {
    max-width: 38vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem;
}

@media (max-width: 870px) {
    .nav-mob__account,
    .nav-mob__menu {
        display: flex;
    }

    .nav-new-mobile__right {
        gap: 0.55rem;
    }
}

/* ==========================================
   Mobile menu sheet
   ========================================== */
/* [hidden] must beat the display rules below — an author `display:flex` wins
   over the UA stylesheet's [hidden]{display:none}, which would leave the sheet
   permanently on screen (same trap as the wtasks QR overlay). */
.nav-sheet[hidden],
.nav-sheet-scrim[hidden] {
    display: none;
}

.nav-sheet-scrim {
    position: fixed;
    inset: 0;
    z-index: 1400;
    background: rgba(61, 46, 20, 0.42);
    opacity: 0;
    transition: opacity 0.22s ease;
}

.nav-sheet-scrim.is-open {
    opacity: 1;
}

.nav-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1401;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    background: #fffdf9;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -14px 40px rgba(61, 46, 20, 0.28);
    transform: translateY(101%);
    transition: transform 0.26s cubic-bezier(0.22, 0.9, 0.3, 1);
}

.nav-sheet.is-open {
    transform: translateY(0);
}

.nav-sheet__head {
    position: relative;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 1.05rem 1rem 0.7rem;
    border-bottom: 1px solid var(--border-soft, #ece6da);
}

.nav-sheet__grab {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: #e0d8c8;
}

.nav-sheet__title {
    margin: 0;
    font-family: 'Fraunces', Georgia, serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-strong, #3d342a);
}

.nav-sheet__close {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 50%;
    background: #f4efe5;
    color: var(--text-muted, #5f5238);
    font-size: 1rem;
    cursor: pointer;
}

.nav-sheet__close:active {
    background: var(--accent-soft, #fef6dd);
}

.nav-sheet__body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.9rem 1rem calc(1.4rem + env(safe-area-inset-bottom, 0px));
}

.nav-sheet__home {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 0.85rem;
    margin-bottom: 0.75rem;
    border-radius: 12px;
    background: #f7f4ee;
    color: var(--text-default, #4a4540);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.98rem;
}

.nav-sheet__home i {
    color: var(--accent-deep, #d4a017);
}

.nav-sheet__featured {
    display: grid;
    gap: 0.55rem;
    margin-bottom: 1.15rem;
}

.nav-sheet__feat {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 0.9rem;
    border-radius: 16px;
    background: var(--accent-soft, #fef6dd);
    border: 1px solid rgba(212, 160, 23, 0.28);
    color: #5a4520;
    text-decoration: none;
    font-size: 1.02rem;
    font-weight: 700;
}

.nav-sheet__feat:active {
    background: var(--accent, #fbc24b);
    color: #3d2e14;
}

.nav-sheet__feat-ic {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: #fff;
    color: var(--accent-deep, #d4a017);
    font-size: 1.15rem;
}

.nav-sheet__feat-tx {
    flex: 1;
    min-width: 0;
}

.nav-sheet__feat-go {
    color: rgba(122, 100, 40, 0.55);
    font-size: 0.85rem;
}

.nav-sheet__section {
    margin-bottom: 1.15rem;
}

.nav-sheet__section-title {
    margin: 0 0 0.55rem 0.15rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-soft, #6d655b);
}

.nav-sheet__grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.55rem;
}

.nav-sheet__tile {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 56px;
    padding: 0.6rem 0.7rem;
    border-radius: 14px;
    background: #fff;
    border: 1px solid var(--border-soft, #ece6da);
    color: var(--text-default, #4a4540);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
}

.nav-sheet__tile i {
    width: 24px;
    flex: 0 0 24px;
    text-align: center;
    font-size: 1.05rem;
    color: var(--accent-deep, #d4a017);
}

.nav-sheet__tile:active {
    background: var(--accent-soft, #fef6dd);
    border-color: rgba(212, 160, 23, 0.4);
}

/* Plain link rows (info + account) */
.nav-sheet__rows {
    display: flex;
    flex-direction: column;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border-soft, #ece6da);
    background: #fff;
}

.nav-sheet__rows a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.8rem 0.9rem;
    color: var(--text-muted, #5f5238);
    text-decoration: none;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border-soft, #ece6da);
}

.nav-sheet__rows a:last-child {
    border-bottom: none;
}

.nav-sheet__rows a:active {
    background: var(--accent-soft, #fef6dd);
}

.nav-sheet__rows a i {
    width: 20px;
    flex: 0 0 20px;
    text-align: center;
    color: var(--accent-deep, #d4a017);
}

.nav-sheet__section--account .nav-sheet__rows {
    background: #f9f6f0;
}

/* Tablet+: the sheet is only ever opened below 870px, but keep it sane if a
   phone is rotated mid-open. */
@media (min-width: 600px) {
    .nav-sheet {
        left: 50%;
        right: auto;
        width: min(560px, 100vw);
        transform: translate(-50%, 101%);
    }

    .nav-sheet.is-open {
        transform: translate(-50%, 0);
    }

    .nav-sheet__grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (prefers-reduced-motion: reduce) {
    .nav-sheet,
    .nav-sheet-scrim,
    .nav-new__dropdown-menu.nav-mega,
    .nav-mega__feat {
        transition: none;
    }
}

/* ==========================================
   Mobile bottom sheets: user menu + notifications
   ========================================== */
/* On mobile the user menu (#userMenu) and the notifications popup
   (#notificationPopup) present like the nav sheet: slide up from the bottom
   edge, rounded top, grab handle, scrim (#popupScrim, toggled by
   window.sprakiMobileScrim in site_nav.js). Desktop keeps the anchored
   dropdowns — this whole block is width-gated. The top/left/right !important
   beats any anchored inline position JS may have set at a desktop width. */
@media (max-width: 870px) {
    .nav-new__user-menu,
    .notification-popup {
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0;
        width: 100%;
        max-width: none;
        border: none;
        border-radius: 22px 22px 0 0;
        box-shadow: 0 -14px 40px rgba(61, 46, 20, 0.28);
        background: #fffdf9;
    }

    /* Above the scrim (1400); the notification popup already sits at 10000. */
    .nav-new__user-menu {
        z-index: 1450;
        max-height: 86vh;
        padding-top: 1.5rem;
        padding-bottom: calc(1.125rem + env(safe-area-inset-bottom, 0px));
    }

    .notification-popup {
        max-height: 80vh;
    }

    /* The sheet body may grow to the sheet's height instead of the dropdown's
       340px cap. */
    .notification-popup__body {
        max-height: none;
    }

    .notification-popup__header {
        padding-top: 20px;
    }

    .notification-popup__footer {
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    }

    /* Grab handle, like .nav-sheet__grab. (In the scrollable user menu it
       scrolls with the content — decorative, so acceptable.) */
    .nav-new__user-menu::before,
    .notification-popup::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        border-radius: 2px;
        background: #e0d8c8;
    }

    /* Keyframes (not a transition) so the slide plays even though .active /
       .open toggle display — same trick as the old notifPopupIn fade. */
    .nav-new__user-menu.active,
    .notification-popup.open {
        animation: sheetSlideUp 0.26s cubic-bezier(0.22, 0.9, 0.3, 1);
    }
}

/* Phones rotated / small tablets: match the nav sheet's centered column. */
@media (min-width: 600px) and (max-width: 870px) {
    .nav-new__user-menu,
    .notification-popup {
        left: 50% !important;
        right: auto !important;
        width: min(560px, 100vw);
        transform: translateX(-50%);
    }

    .nav-new__user-menu.active,
    .notification-popup.open {
        animation: sheetSlideUpCentered 0.26s cubic-bezier(0.22, 0.9, 0.3, 1);
    }
}

@keyframes sheetSlideUp {
    from { transform: translateY(101%); }
    to { transform: translateY(0); }
}

@keyframes sheetSlideUpCentered {
    from { transform: translate(-50%, 101%); }
    to { transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .nav-new__user-menu.active,
    .notification-popup.open {
        animation: none;
    }
}

/* ==========================================
   User menu — language section rework
   ========================================== */
/* The learning card leads and shows a caret (it opens the switcher); the
   native language became a quiet row instead of a twin flag card, so the two
   can no longer be mistaken for each other. */
.nav-new__lang-caret {
    margin-left: 0.3rem;
    font-size: 0.7rem;
    color: #b8a88a;
    transition: transform 0.2s ease;
}

.nav-new__lang-card--learning[aria-expanded="true"] .nav-new__lang-caret {
    transform: rotate(180deg);
}

.nav-new__lang-native {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.45rem;
    padding: 0.45rem 0.6rem;
    border-radius: 10px;
    text-decoration: none;
    color: var(--color-text-muted, #5f5238);
    font-size: 0.85rem;
}

.nav-new__lang-native:hover {
    background: #faf6ec;
}

.nav-new__lang-native-flag {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.nav-new__lang-native-label {
    color: #999;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.nav-new__lang-native-name {
    font-weight: 600;
    color: var(--text-strong, #3d342a);
}

.nav-new__lang-native-edit {
    margin-left: auto;
    font-size: 0.66rem;
    color: #c9bda4;
}
