/* ============================================================
   Guest mega menu
   Full navigation panel behind the header hamburger. Desktop: a wide sheet
   dropping from the header. Mobile: a full-height drawer. Both share one
   markup tree and the guest design tokens.
   ============================================================ */

/* ---------- Trigger ---------- */
.gmm-trigger {
    gap: .5rem;
    padding-inline: .7rem;
}

.gmm-trigger__bars {
    display: grid;
    width: 16px;
    gap: 3.5px;
}

.gmm-trigger__bars span {
    display: block;
    height: 1.8px;
    border-radius: 2px;
    background: currentColor;
    transition: transform .2s var(--g-ease), opacity .16s var(--g-ease);
}

/* Open: the bars fold into a cross. */
.gmm-trigger[aria-expanded="true"] .gmm-trigger__bars span:nth-child(1) {
    transform: translateY(5.3px) rotate(45deg);
}

.gmm-trigger[aria-expanded="true"] .gmm-trigger__bars span:nth-child(2) {
    opacity: 0;
}

.gmm-trigger[aria-expanded="true"] .gmm-trigger__bars span:nth-child(3) {
    transform: translateY(-5.3px) rotate(-45deg);
}

/* ---------- Overlay ---------- */
.gmm {
    position: fixed;
    inset: 0;
    z-index: 1070;
}

.gmm[hidden] { display: none; }

/* Lighter scrim with a touch more blur than before (52% / 3px). The blur is
   what separates the panel from the page, so leaning on it rather than on
   opacity keeps the page recognisable underneath instead of nearly black. */
.gmm__backdrop {
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--g-navy) 42%, transparent);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    animation: gmm-fade .14s var(--g-ease);
}

.gmm__sheet {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    display: flex;
    max-height: 100vh;
    flex-direction: column;
    overflow: hidden;
    border-bottom: 1px solid var(--g-border);
    border-radius: 0 0 var(--g-r-xl) var(--g-r-xl);
    background: var(--g-surface);
    box-shadow: 0 28px 60px -26px color-mix(in srgb, var(--g-shadow-color) 30%, transparent);
    animation: gmm-drop .2s var(--g-ease);
}

[data-guest-theme="dark"] .gmm__sheet {
    box-shadow: 0 28px 60px -26px rgba(0, 0, 0, .58);
}

@keyframes gmm-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes gmm-drop {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: none; }
}

/* ---------- Head ---------- */
.gmm__head {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .9rem clamp(1rem, 4vw, 2.5rem);
    border-bottom: 1px solid var(--g-border);
}

.gmm__title {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    margin: 0;
    color: var(--g-text);
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.gmm__title i { color: var(--g-accent-ink); font-size: .9rem; }

.gmm__close {
    display: grid;
    width: 32px;
    height: 32px;
    flex: none;
    place-items: center;
    border: 1px solid var(--g-border);
    border-radius: 8px;
    background: var(--g-surface);
    color: var(--g-text-muted);
    font-size: .8rem;
    cursor: pointer;
    transition: border-color .16s var(--g-ease), background-color .16s var(--g-ease), color .16s var(--g-ease);
}

.gmm__close:hover { border-color: var(--g-border-strong); background: var(--g-surface-2); color: var(--g-text); }
.gmm__close:focus-visible { outline: 2px solid var(--g-accent); outline-offset: 2px; }

/* ---------- Body ---------- */
.gmm__body {
    flex: 1;
    min-height: 0;
    padding: clamp(1rem, 3vw, 1.75rem) clamp(1rem, 4vw, 2.5rem);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.gmm__cols {
    display: grid;
    gap: clamp(1.25rem, 3vw, 2.5rem);
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: start;
    max-width: 82rem;
    margin: 0 auto;
}

.gmm__col { min-width: 0; }

/* ---------- Signed-in module columns ----------
   When a student is signed in, the rail's module groups are appended as a
   second band of columns. Auto-placement puts them on row 2 under the first
   three columns; the notices column stretches across both rows so it reads as
   one tall column on the right rather than leaving a hole beneath itself.

   Four-column layout only. Below lg the panel drops to two columns and then
   one, where the responsive rules at the bottom of this file give notices a
   full row of its own — a two-row span and a left-hand rule would both be
   wrong there. */
@media (min-width: 992px) {
    .gmm__cols--app .gmm__col--notices {
        grid-row: span 2;
        padding-left: clamp(1.25rem, 3vw, 2.5rem);
        border-left: 1px solid var(--g-border);
        /* Pull back by half the gutter so the rule sits in the middle of it. */
        margin-left: calc(clamp(1.25rem, 3vw, 2.5rem) * -0.5);
    }

    /* A module can list fifteen destinations, so on desktop a column scrolls
       rather than making the sheet metres tall. On a phone the drawer already
       scrolls, and a nested scroller inside it is worse than a long list. */
    .gmm__col--app .gmm__list {
        max-height: 17rem;
        padding-right: .2rem;
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

.gmm__col--app .gmm__list {
    scrollbar-width: thin;
    scrollbar-color: var(--g-sb-thumb) transparent;
}
.gmm__col--app .gmm__list::-webkit-scrollbar { width: 9px; }
.gmm__col--app .gmm__list::-webkit-scrollbar-track { background: transparent; }
.gmm__col--app .gmm__list::-webkit-scrollbar-thumb {
    border: 3px solid transparent;
    border-radius: 999px;
    background: var(--g-sb-thumb);
    background-clip: padding-box;
}
.gmm__col--app .gmm__list::-webkit-scrollbar-thumb:hover {
    background: var(--g-sb-thumb-hover);
    background-clip: padding-box;
}

/* Sub-group heading inside a module column, e.g. "Programme" above a
   student's enrolments. Sentence case, because these can be database values. */
.gmm__sublabel {
    margin: .5rem .55rem .15rem;
    color: var(--g-text-faint);
    font-size: .68rem;
    font-weight: 700;
}
.gmm__sublabel:first-child { margin-top: 0; }

.gmm__col-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: 0 0 .7rem;
    padding-bottom: .55rem;
    border-bottom: 1px solid var(--g-border);
    color: var(--g-text-faint);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.gmm__col-icon {
    display: grid;
    width: 22px;
    height: 22px;
    flex: none;
    place-items: center;
    border-radius: 6px;
    background: var(--g-accent-soft);
    color: var(--g-accent-ink);
    font-size: .7rem;
}

.gmm__list {
    display: grid;
    gap: .15rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.gmm__link {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .55rem;
    border-radius: 9px;
    color: var(--g-text);
    text-decoration: none;
    transition: background-color .14s var(--g-ease), color .14s var(--g-ease);
}

.gmm__link-text {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    gap: .05rem;
}

.gmm__link-label {
    font-size: .845rem;
    font-weight: 600;
    line-height: 1.35;
}

.gmm__link-hint {
    overflow: hidden;
    color: var(--g-text-faint);
    font-size: .73rem;
    line-height: 1.4;
    text-overflow: ellipsis;
}

.gmm__link-arrow {
    flex: none;
    color: var(--g-text-faint);
    font-size: .72rem;
    opacity: 0;
    transform: translateX(-3px);
    transition: opacity .14s var(--g-ease), transform .14s var(--g-ease), color .14s var(--g-ease);
}

.gmm__link:hover {
    background: color-mix(in srgb, var(--g-accent) 6%, var(--g-surface));
    color: var(--g-accent-strong);
}

.gmm__link:hover .gmm__link-arrow,
.gmm__link:focus-visible .gmm__link-arrow {
    color: var(--g-accent-ink);
    opacity: 1;
    transform: none;
}

.gmm__link:focus-visible { outline: 2px solid var(--g-accent); outline-offset: -2px; }

/* Compact row: one line, no hint. Used by the module columns, whose labels
   come straight from the modules and have no description to show. */
.gmm__link--compact { padding-block: .36rem; }
.gmm__link--compact .gmm__link-label {
    overflow: hidden;
    font-size: .8rem;
    font-weight: 550;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The page the student is on, marked the same way the rail marks it. */
.gmm__link.is-active {
    background: color-mix(in srgb, var(--g-accent) 10%, transparent);
    color: var(--g-accent-strong);
}
.gmm__link.is-active .gmm__link-label { font-weight: 680; }
.gmm__link.is-active .gmm__link-arrow { opacity: 1; transform: none; color: var(--g-accent-ink); }

/* ---------- Latest notices column ---------- */
.gmm__notices {
    display: grid;
    gap: .2rem;
    margin: 0 0 .6rem;
    padding: 0;
    list-style: none;
    /* Six notices, two lines each at worst, is taller than the link columns
       beside it. Capped with its own scroll so the panel keeps its proportions
       on a guest page, where this column sits in a single row. Signed in it
       spans both bands and rarely reaches the cap. */
    max-height: 19rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--g-sb-thumb) transparent;
}
.gmm__notices::-webkit-scrollbar { width: 9px; }
.gmm__notices::-webkit-scrollbar-track { background: transparent; }
.gmm__notices::-webkit-scrollbar-thumb {
    border: 3px solid transparent;
    border-radius: 999px;
    background: var(--g-sb-thumb);
    background-clip: padding-box;
}
.gmm__notices::-webkit-scrollbar-thumb:hover {
    background: var(--g-sb-thumb-hover);
    background-clip: padding-box;
}

/* On a phone the drawer scrolls, so a nested scroller is worse than a long
   list — same reasoning as the module columns above. */
@media (max-width: 575.98px) {
    .gmm__notices { max-height: none; overflow-y: visible; }
}

.gmm__notice {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .45rem .5rem;
    border-radius: 9px;
    color: var(--g-text);
    text-decoration: none;
    transition: background-color .14s var(--g-ease);
}

.gmm__notice:hover { background: var(--g-surface-2); }
.gmm__notice:focus-visible { outline: 2px solid var(--g-accent); outline-offset: -2px; }

.gmm__notice-date {
    display: grid;
    width: 34px;
    flex: none;
    padding: .2rem 0;
    justify-items: center;
    border-radius: 7px;
    background: var(--g-surface-2);
    color: var(--g-text-muted);
    font-size: .6rem;
    font-weight: 600;
    line-height: 1.15;
    text-transform: uppercase;
    transition: box-shadow .14s var(--g-ease);
}

/* The row's hover colour is --g-surface-2, which is exactly what the chip sits
   on by default, so hovering made the chip dissolve into its own row. A
   neutral ring redraws its edge and leaves the fill alone, which keeps the
   date quiet while the title takes the accent.

   Drawn as an inset shadow rather than a border so the 34px box never changes
   size and the row cannot reflow under the cursor. --g-border-strong is
   already theme-aware, so one rule covers light and dark. */
.gmm__notice:hover .gmm__notice-date {
    box-shadow: inset 0 0 0 1px var(--g-border-strong);
}

.gmm__notice-date b {
    color: var(--g-text);
    font-size: .82rem;
    font-weight: 750;
}

/* Unread notice: a notification-style dot on the date tile's top-right
   corner; the tile keeps its colours. notice-read.js sets .is-unread on the
   link, and a visually-hidden "Unread:" before the title carries the state
   for screen readers. The ring matches the sheet so the dot reads as cut
   out of the corner. The dashboard reuses these rows but fills the tile
   instead (pages/dashboard.css), hence :not(.gid-notice). */
.gmm__notice:not(.gid-notice) .gmm__notice-date { position: relative; }
/* Soft accent wash on the unread tile, quieter than the dashboard's fill. */
.gmm__notice.is-unread:not(.gid-notice) .gmm__notice-date {
    background: var(--g-accent-soft);
    color: var(--g-accent-ink);
}
.gmm__notice.is-unread:not(.gid-notice) .gmm__notice-date b { color: var(--g-accent-strong); }
.gmm__notice.is-unread:not(.gid-notice) .gmm__notice-date::after {
    content: "";
    position: absolute;
    top: -3px;
    right: -3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--g-accent);
    box-shadow: 0 0 0 2px var(--g-surface);
}

/* Sentence case from shouted source — see the note on .gid-notice
   .gmm__notice-title in pages/dashboard.css. Lowercased with a capitalised
   first letter so operator titles read in one voice; max-height clamp (not
   -webkit-box) keeps ::first-letter working. The stored value is untouched,
   so the title tooltip and the opened document keep the original text. */
.gmm__notice-title {
    display: block;
    max-height: 2.8em; /* line-height 1.4 × 2 lines */
    overflow: hidden;
    font-size: .78rem;
    font-weight: 500;
    line-height: 1.4;
    text-transform: lowercase;
}
.gmm__notice-title::first-letter { text-transform: uppercase; }

.gmm__notice:hover .gmm__notice-title { color: var(--g-accent-strong); }

.gmm__all {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .2rem .5rem;
    color: var(--g-accent-ink);
    font-size: .76rem;
    font-weight: 650;
    text-decoration: none;
}

.gmm__all:hover { color: var(--g-accent-strong); }
.gmm__all:hover i { transform: translateX(2px); }
.gmm__all i { font-size: .7rem; transition: transform .14s var(--g-ease); }
.gmm__all:focus-visible { outline: 2px solid var(--g-accent); outline-offset: 2px; border-radius: 5px; }

.gmm__none {
    margin: 0;
    padding: .5rem;
    color: var(--g-text-faint);
    font-size: .78rem;
}

/* ---------- Foot: accessibility + search ---------- */
.gmm__foot {
    display: flex;
    flex: none;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem 1.5rem;
    padding: .8rem clamp(1rem, 4vw, 2.5rem);
    border-top: 1px solid var(--g-border);
    background: color-mix(in srgb, var(--g-surface-2) 45%, var(--g-surface));
}

.gmm__foot-group {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}

.gmm__foot-label {
    margin-right: .15rem;
    color: var(--g-text-faint);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.gmm__chip {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    gap: .3rem;
    padding: .25rem .6rem;
    border: 1px solid var(--g-border);
    border-radius: 999px;
    background: var(--g-surface);
    color: var(--g-text-muted);
    font-family: inherit;
    font-size: .73rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .14s var(--g-ease), background-color .14s var(--g-ease), color .14s var(--g-ease);
}

.gmm__chip i { font-size: .72rem; }
.gmm__chip:hover { border-color: var(--g-accent); background: var(--g-accent-soft); color: var(--g-accent-strong); }
.gmm__chip:focus-visible { outline: 2px solid var(--g-accent); outline-offset: 2px; }

.gmm__chip--icon {
    min-width: 30px;
    justify-content: center;
    padding-inline: .4rem;
}

.gmm__search {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    min-height: 30px;
    margin-left: auto;
    padding: .3rem .7rem;
    border: 1px solid var(--g-border);
    border-radius: 999px;
    background: var(--g-surface);
    color: var(--g-text-muted);
    font-family: inherit;
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .14s var(--g-ease), color .14s var(--g-ease);
}

.gmm__search:hover { border-color: var(--g-border-strong); color: var(--g-text); }
.gmm__search:focus-visible { outline: 2px solid var(--g-accent); outline-offset: 2px; }

.gmm__search kbd,
.gmm__chip--keys kbd {
    padding: .05rem .28rem;
    border: 1px solid var(--g-border);
    border-radius: 4px;
    background: var(--g-surface-2);
    color: var(--g-text-faint);
    font-family: inherit;
    font-size: .64rem;
}
/* On hover the chip takes the accent wash, so lift its key badge to match. */
.gmm__chip--keys:hover kbd {
    border-color: color-mix(in srgb, var(--g-accent) 35%, var(--g-border));
    color: var(--g-accent-ink);
}

/* Locking body scroll removes the scrollbar, which otherwise shifts the whole
   page to the right (a visible jerk). Pad the body by the scrollbar's width —
   measured in JS into --gmm-sbw — so the content stays put. The sticky header
   is in normal flow, so this body padding carries it along; no separate rule
   needed. */
body.gmm-open { overflow: hidden; padding-right: var(--gmm-sbw, 0px); }

/* ---------- Header collapse ----------
   The actions row would otherwise overflow a 360px viewport and force the
   whole page to scroll sideways. The theme bar is reachable from this menu's
   footer instead, so it can leave the header on small screens — leaving the
   three things a narrow screen actually needs: brand, menu, and the primary
   login/dashboard action. */
@media (max-width: 767.98px) {
    .g-header .g-themebar {
        display: none;
    }

    /* Signed-in students already reach the dashboard from the menu, so the
       header's "Enter Dashboard" button is redundant on narrow screens — drop
       it and let the menu toggle stand alone. (The guest login button stays.)
       Hooked on data-g-dashboard-cta rather than the aria-label, which is copy
       and changes. */
    .g-header .g-hbtn[data-g-dashboard-cta] {
        display: none;
    }

    /* On mobile the login button shows the short "Login" label so it fits on
       one line instead of wrapping "Student Login". */
    .g-header .g-hbtn__label--full { display: none; }
    .g-header .g-hbtn__label--short { display: inline; }
}

/* Very narrow: the institution name is the last thing that can give way, so
   it clamps to one line and ellipsises rather than widening the row. */
@media (max-width: 420px) {
    .g-header__name {
        max-width: 9.5rem;
    }

    .g-header__name-main {
        -webkit-line-clamp: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .g-header__name small {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Icon-only primary action. The accessible name is preserved by the
       aria-label on the anchor, so dropping the text costs nothing. */
    .g-header .g-hbtn.g-btn-accent {
        padding-inline: .8rem;
    }

    .g-header .g-hbtn__label {
        display: none;
    }
}

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .gmm__cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    /* Notices span the full row so two-line titles stay readable. */
    .gmm__col--notices { grid-column: 1 / -1; }
}

@media (max-width: 575.98px) {
    /* Full-height drawer: a dropdown sheet would leave an unusable sliver. */
    .gmm__sheet {
        bottom: 0;
        max-height: none;
        border-radius: 0;
    }

    .gmm__cols { grid-template-columns: 1fr; gap: 1.1rem; }
    .gmm__col--notices { grid-column: auto; }

    .gmm__foot {
        gap: .6rem;
        padding: .75rem 1rem 1rem;
    }

    .gmm__search { margin-left: 0; width: 100%; justify-content: center; }
}
