/*
 * TKM global viewport header
 * The navigation rail owns its viewport inset and never inherits page content width.
 */
:root {
    --header-viewport-gap: clamp(8px, 1.1vw, 20px);
    --header-surface: #fffdf9;
    --header-surface-strong: var(--header-surface);
    --header-border: rgba(12, 45, 82, .11);
    --header-navy: #071b3a;
    --header-ink: #10213c;
    --header-gold: #c99327;
    --header-gold-soft: #f7eedb;
    --header-shadow: 0 16px 40px rgba(7, 27, 58, .09), 0 2px 8px rgba(7, 27, 58, .035);
}

body[class*="header-surface-"] {
    background: var(--header-surface);
}

body.header-surface-home {
    --header-surface: #fff;
}

body.header-surface-account {
    --header-surface: #f6f4ef;
}

body.header-surface-forum {
    --header-surface: #fff;
}

body.header-surface-calendar {
    --header-surface: #f4f4f0;
}

body.header-surface-learning {
    --header-surface: #f7f6f2;
}

body.header-surface-lesson {
    --header-surface: #f5f1e8;
}

body.header-surface-documents {
    --header-surface: #f8fafc;
}

body.header-surface-about {
    --header-surface: #f4f0e7;
}

body.header-surface-contact,
body.header-surface-legal,
body.header-surface-public {
    --header-surface: #fffdf9;
}

body.header-surface-faq {
    --header-surface: #fbfaf7;
}

body.header-surface-auth {
    --header-surface: #f5f3ed;
}

.site-header {
    min-height: 88px;
    height: auto;
    padding: 10px 0 0;
    position: sticky;
    top: 0;
    z-index: 100;
    overflow: visible;
    isolation: isolate;
    color: var(--header-ink);
    background: transparent;
    border: 0;
    box-shadow: none;
    pointer-events: none;
}

.site-header > .header-inner {
    width: min(1920px, calc(100vw - (var(--header-viewport-gap) * 2)));
    max-width: none;
    min-height: 68px;
    height: auto;
    margin-inline: auto;
    padding: 7px 10px 7px 14px;
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: clamp(10px, 1.25vw, 22px);
    border: 1px solid var(--header-border);
    border-radius: 34px;
    background: var(--header-surface);
    box-shadow: var(--header-shadow);
    -webkit-backdrop-filter: blur(20px) saturate(135%);
    backdrop-filter: blur(20px) saturate(135%);
    pointer-events: auto;
    transition: background-color .22s ease, border-color .22s ease, box-shadow .22s ease;
}

.site-header > .header-inner::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background: linear-gradient(105deg, rgba(255,255,255,.72), transparent 42%, rgba(201,147,39,.045));
    pointer-events: none;
}

.site-header.compact > .header-inner {
    border-color: rgba(12, 45, 82, .17);
    background: var(--header-surface);
    box-shadow: 0 12px 34px rgba(7, 27, 58, .12), 0 2px 6px rgba(7, 27, 58, .04);
}

.site-header .brand {
    min-width: 190px !important;
    margin: 0;
    padding: 0 18px 0 0;
    position: relative;
    display: flex;
    align-items: center;
    gap: 9px;
    flex: 0 0 auto;
}

.site-header .brand::after {
    content: "";
    position: absolute;
    top: 9px;
    right: 0;
    bottom: 9px;
    width: 1px;
    background: linear-gradient(180deg, transparent, rgba(7, 27, 58, .18), transparent);
}

.site-header .brand img,
.site-header.compact .brand img {
    width: 52px !important;
    height: 50px !important;
    flex: 0 0 auto;
    object-fit: contain;
    filter: none !important;
}

.brand-home-lockup {
    min-width: 0;
    display: grid;
    align-content: center;
    line-height: 1;
    text-transform: uppercase;
}

.brand-home-lockup strong {
    color: var(--header-gold);
    font-size: .58rem;
    font-weight: 850;
    letter-spacing: .21em;
}

.brand-home-lockup > span {
    margin-top: 3px;
    color: var(--header-ink);
    font-size: .63rem;
    font-weight: 850;
    letter-spacing: .17em;
    white-space: nowrap;
}

.brand-home-lockup small {
    margin-top: 4px;
    color: #708097;
    font-size: .34rem;
    font-weight: 750;
    letter-spacing: .105em;
    white-space: nowrap;
}

.site-header .nav {
    min-width: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(1px, .35vw, 6px);
    overflow: visible;
}

.site-header .nav a {
    min-width: 44px;
    min-height: 46px;
    padding: 10px clamp(9px, .75vw, 15px);
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 15px;
    color: var(--header-ink);
    background: transparent;
    font-size: clamp(.72rem, .72vw, .82rem);
    font-weight: 760;
    line-height: 1;
    white-space: nowrap;
    transition: color .18s ease, background-color .18s ease, border-color .18s ease, transform .18s ease;
}

.site-header .nav a > .bi {
    display: inline-flex;
    color: #a8730e;
    font-size: .92rem;
    line-height: 1;
}

.site-header .nav a:hover,
.site-header .nav a:focus-visible {
    color: var(--header-navy);
    border-color: rgba(201, 147, 39, .2);
    background: rgba(247, 238, 219, .66);
    transform: translateY(-1px);
}

.site-header .nav a[aria-current="page"] {
    color: var(--header-navy);
    border-color: rgba(201, 147, 39, .14);
    background: linear-gradient(180deg, rgba(255,255,255,.78), rgba(247,238,219,.82));
}

.site-header .nav a[aria-current="page"]::after {
    content: "";
    position: absolute;
    right: 14px;
    bottom: 4px;
    left: 14px;
    height: 2px;
    border-radius: 999px;
    background: var(--header-gold);
}

.site-header .nav-label--mobile,
.site-header .header-action-label--mobile {
    display: none;
}

.site-header .header-actions {
    min-width: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.site-header .header-actions form {
    margin: 0;
}

.site-header .icon-btn,
.site-header .btn {
    min-width: 44px;
    min-height: 44px;
    border-radius: 15px;
}

.site-header .icon-btn {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(12, 45, 82, .13);
    color: var(--header-navy);
    background: rgba(255,255,255,.78);
}

.site-header .icon-btn:hover,
.site-header .icon-btn:focus-visible {
    border-color: rgba(201, 147, 39, .4);
    background: #fff;
}

.site-header .btn--small {
    padding: 9px 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(12, 45, 82, .14);
    font-size: .73rem;
    font-weight: 780;
    white-space: nowrap;
}

.site-header .btn--ghost {
    color: var(--header-navy);
    background: rgba(255,255,255,.82);
}

.site-header .header-auth-entry {
    min-width: 128px;
    padding-inline: 16px;
    gap: 8px;
    color: #071b3a;
    border-color: #c88f20;
    border-radius: 14px;
    background: #e0aa36;
    box-shadow: 0 5px 12px rgba(7, 27, 58, .1), inset 0 1px 0 rgba(255, 255, 255, .38);
}

.site-header .header-auth-entry:hover,
.site-header .header-auth-entry:focus-visible {
    border-color: #b77d11;
    background: #d7a02d;
    box-shadow: 0 7px 16px rgba(7, 27, 58, .14), inset 0 1px 0 rgba(255, 255, 255, .3);
}

.site-header .btn:hover,
.site-header .btn:focus-visible {
    transform: translateY(-1px);
}

.site-header a:focus-visible,
.site-header button:focus-visible {
    outline: 3px solid rgba(201, 147, 39, .42);
    outline-offset: 2px;
}

.site-header .menu-toggle {
    display: none;
    place-items: center;
}

.mobile-menu-toggle__glyph {
    width: 26px;
    height: 26px;
    display: block;
    background: url("../custom-icons/png/list.png") center/26px 26px no-repeat;
    filter: drop-shadow(0 2px 4px rgba(7, 27, 58, .16));
}

.mobile-menu-toggle__glyph i {
    display: none !important;
}

/* Premium mobile navigation drawer. */
.mobile-nav[hidden],
.mobile-nav:not(.is-open) {
    pointer-events: none;
}

.mobile-nav[hidden] {
    display: none;
}

.mobile-nav {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    grid-template-columns: 1fr auto;
    visibility: visible;
}

.mobile-nav__scrim {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(1, 9, 23, .68);
    -webkit-backdrop-filter: blur(7px);
    backdrop-filter: blur(7px);
    opacity: 0;
    cursor: pointer;
    transition: opacity .28s ease;
}

.mobile-nav__panel {
    width: min(430px, calc(100vw - 18px));
    height: 100%;
    min-height: 100dvh;
    margin-left: auto;
    position: relative;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    border-left: 1px solid rgba(226, 184, 91, .28);
    border-radius: 28px 0 0 28px;
    color: #fff;
    background: linear-gradient(154deg, #0a2449 0%, #061a38 48%, #031127 100%);
    box-shadow: -28px 0 70px rgba(1, 9, 23, .28);
    transform: translateX(102%);
    transition: transform .28s cubic-bezier(.22, 1, .36, 1);
}

.mobile-nav.is-open .mobile-nav__scrim {
    opacity: 1;
}

.mobile-nav.is-open .mobile-nav__panel {
    transform: translateX(0);
}

.mobile-nav__pattern {
    position: absolute;
    top: -100px;
    right: -120px;
    width: 340px;
    height: 340px;
    border: 1px solid rgba(221, 174, 72, .16);
    border-radius: 50%;
    pointer-events: none;
}

.mobile-nav__pattern::before,
.mobile-nav__pattern::after {
    content: "";
    position: absolute;
    border: 1px solid rgba(221, 174, 72, .11);
    border-radius: inherit;
}

.mobile-nav__pattern::before { inset: 44px; }
.mobile-nav__pattern::after { inset: 92px; }

.mobile-nav__header {
    min-height: 84px;
    padding: max(16px, env(safe-area-inset-top)) 18px 13px;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, .09);
}

.mobile-nav__brand {
    width: 76px;
    height: 58px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 15px;
    background: #fffdf8;
}

.mobile-nav__brand img {
    width: 58px;
    height: 52px;
    object-fit: contain;
}

.mobile-nav__close {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 15px;
    color: #fff;
    background: rgba(255, 255, 255, .065);
    cursor: pointer;
}

.mobile-nav__body {
    min-height: 0;
    padding: 24px 18px 21px;
    position: relative;
    z-index: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(219, 173, 75, .5) transparent;
}

.mobile-nav__intro {
    padding: 0 3px 20px;
}

.mobile-nav__intro > span {
    display: block;
    color: #e5ba5b;
    font-size: .65rem;
    font-weight: 850;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.mobile-nav__intro h2 {
    max-width: 350px;
    margin: 8px 0 0;
    color: #fff;
    font-family: var(--font-display, Georgia, serif);
    font-size: clamp(1.75rem, 7vw, 2.25rem);
    font-weight: 650;
    line-height: .98;
    letter-spacing: -.045em;
}

.mobile-nav__links {
    display: grid;
    gap: 8px;
}

.mobile-nav__links a {
    min-height: 70px;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) 28px;
    align-items: center;
    gap: 12px;
    border: 1px solid rgba(255, 255, 255, .095);
    border-radius: 17px;
    color: #edf3fb;
    background: rgba(255, 255, 255, .045);
    transition: color .18s ease, border-color .18s ease, background-color .18s ease, transform .18s ease;
}

.mobile-nav__links a:hover,
.mobile-nav__links a:focus-visible {
    border-color: rgba(224, 179, 80, .48);
    background: rgba(255, 255, 255, .085);
    transform: translateX(-2px);
}

.mobile-nav__links a[aria-current="page"] {
    color: #fff;
    border-color: rgba(230, 185, 85, .58);
    background: linear-gradient(100deg, rgba(211, 162, 58, .2), rgba(255, 255, 255, .055));
    box-shadow: inset 3px 0 #d9a83e;
}

.mobile-nav__link-icon {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(225, 180, 84, .32);
    border-radius: 14px;
    color: #efc96f;
    background: rgba(3, 14, 34, .38);
}

.mobile-nav__link-copy {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.mobile-nav__link-copy strong,
.mobile-nav__link-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-nav__link-copy strong {
    font-size: .91rem;
    line-height: 1.2;
}

.mobile-nav__link-copy small {
    color: #9eafc6;
    font-size: .69rem;
    line-height: 1.3;
}

.mobile-nav__links a[aria-current="page"] small { color: #e8c978; }
.mobile-nav__link-arrow { color: #d6ad54; font-size: .85rem; }

.mobile-nav__footer {
    padding: 14px 18px max(17px, env(safe-area-inset-bottom));
    position: relative;
    z-index: 1;
    border-top: 1px solid rgba(255, 255, 255, .09);
    background: rgba(1, 9, 23, .36);
}

.mobile-nav__guest-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.mobile-nav__account-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.mobile-nav__guest-actions a,
.mobile-nav__account-links a,
.mobile-nav__footer form button {
    min-height: 46px;
    padding: 9px 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 13px;
    color: #fff;
    background: rgba(255, 255, 255, .055);
    font-size: .75rem;
    font-weight: 780;
}

.mobile-nav__guest-actions a:first-child {
    color: #071b3a;
    border-color: #d9a83e;
    background: #d9a83e;
}

.mobile-nav__footer form,
.mobile-nav__footer form button {
    width: 100%;
    margin: 9px 0 0;
}

.mobile-nav__footer form button { cursor: pointer; }

.mobile-nav__footer p {
    margin: 12px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    color: #8fa2ba;
    font-size: .62rem;
    line-height: 1.35;
    text-align: center;
}

.mobile-nav__footer p .bi { color: #d6ad54; }

body.mobile-nav-open {
    overflow: hidden;
    overscroll-behavior: none;
}

.mobile-nav a:focus-visible,
.mobile-nav button:focus-visible {
    outline: 2px solid #f0ca70;
    outline-offset: 3px;
}

@media (max-width: 1280px) {
    .site-header .nav a {
        padding-inline: 9px;
        gap: 6px;
        font-size: .72rem;
    }

    .site-header .brand {
        min-width: 178px !important;
        padding-right: 14px;
    }

    .site-header .header-notifications,
    .site-header .header-profile {
        display: none;
    }
}

@media (max-width: 1180px) {
    .site-header .nav { display: none; }
    .site-header .menu-toggle { display: grid; }
    .site-header .header-actions { margin-left: auto; }
}

@media (max-width: 760px) {
    :root { --header-viewport-gap: 8px; }

    .site-header,
    .site-header.compact {
        min-height: 72px;
        padding-top: max(6px, env(safe-area-inset-top));
    }

    .site-header > .header-inner {
        min-height: 60px;
        padding: 5px 6px 5px 10px;
        gap: 6px;
        border-radius: 30px;
    }

    .site-header .brand {
        min-width: 142px !important;
        padding-right: 9px;
        gap: 7px;
    }

    .site-header .brand img,
    .site-header.compact .brand img {
        width: 46px !important;
        height: 44px !important;
    }

    .brand-home-lockup strong { font-size: .48rem; }
    .brand-home-lockup > span { font-size: .5rem; }
    .brand-home-lockup small { font-size: .29rem; }

    .site-header .header-actions { gap: 4px; }

    .site-header .icon-btn,
    .site-header .btn {
        min-width: 44px;
        min-height: 44px;
        border-radius: 14px;
    }

    .site-header .header-actions > .header-notifications,
    .site-header .header-actions > .header-profile,
    .site-header .header-actions > form {
        display: none;
    }

    .site-header .header-actions > .icon-btn.header-account { display: grid; }

    .site-header .header-auth-entry {
        width: 44px;
        min-width: 44px;
        padding: 0;
        border-radius: 14px;
    }

    .site-header .header-action-label--desktop { display: none; }
    .site-header .header-action-label--mobile { display: inline; }
}

@media (max-width: 430px) {
    .site-header .brand {
        min-width: 121px !important;
        padding-right: 6px;
        gap: 5px;
    }

    .site-header .brand img,
    .site-header.compact .brand img {
        width: 42px !important;
        height: 41px !important;
    }

    .brand-home-lockup strong { font-size: .41rem; }
    .brand-home-lockup > span { font-size: .43rem; }
    .brand-home-lockup small { display: none; }

    .mobile-nav__panel {
        width: calc(100% - 8px);
        border-radius: 23px 0 0 23px;
    }

    .mobile-nav__body,
    .mobile-nav__header,
    .mobile-nav__footer {
        padding-inline: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .site-header,
    .site-header *,
    .mobile-nav,
    .mobile-nav * {
        scroll-behavior: auto !important;
        transition: none !important;
        animation: none !important;
    }
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .site-header > .header-inner { background: var(--header-surface); }
    .mobile-nav__scrim { background: rgba(1, 9, 23, .8); }
}

/* Only the framed rail is painted; the surrounding sticky layer stays transparent. */
.site-header {
    background: transparent !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
}

.site-header > .header-inner,
.site-header.compact > .header-inner {
    background: var(--header-surface) !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    box-shadow: 0 1px 0 rgba(7, 27, 58, .08) !important;
}

.site-header.compact > .header-inner {
    background: var(--header-surface) !important;
    border-color: rgba(12, 45, 82, .13);
}

.site-header > .header-inner::before {
    display: none !important;
}

/* Align the global header rail with the homepage content shell. */
.site-header,
.site-header.compact {
    background: transparent !important;
}

.site-header > .header-inner,
.site-header.compact > .header-inner {
    width: min(1280px, calc(100% - 64px));
    max-width: 1280px;
}

@media (max-width: 900px) {
    .site-header > .header-inner,
    .site-header.compact > .header-inner {
        width: calc(100% - 40px);
    }
}

@media (max-width: 760px) {
    .site-header > .header-inner,
    .site-header.compact > .header-inner {
        width: calc(100% - 24px);
    }
}
