/* SolutionTee Edu Academy — navigation
   =========================================================================
   The header, its mega menus, and the mobile sheet.

   The header is the one component on every page, so it is the one that
   has to be right in every context: over the hero's aurora, over a white
   card, over a dark band, at the top of a CBT paper. It solves that by
   being MATERIAL rather than a colour — transparent while the page is at
   the top, frosted glass the moment it is not.

   Loaded after glass.css and sections.css, so it wins over the
   pre-rebuild header styling in components.css.
   ====================================================================== */


/* ==========================================================================
   HEADER
   ==========================================================================
   At the top of the page the header has no ground at all — the hero's
   aurora runs behind it uninterrupted and the logo appears to sit on the
   sky. A flat --canvas bar there is visibly a different colour from the
   aurora behind it, which is exactly the seam this replaces.

   Past 24px, interactions.js sets [data-scrolled] on <html> and the bar
   frosts. That state is driven from an attribute rather than from a
   scroll class toggled here because CSS cannot read scroll position, and
   doing it in JS means the header settles in one place instead of two.
   ========================================================================== */

.header {
  position: sticky;
  inset-block-start: 0;
  z-index: var(--z-header);
  background: transparent;
  border-block-end: 1px solid transparent;
  transition: background-color var(--dur-slow) var(--ease-out),
              border-color var(--dur-slow) var(--ease-out),
              box-shadow var(--dur-slow) var(--ease-out),
              backdrop-filter var(--dur-slow) var(--ease-out);
}

[data-scrolled] .header {
  background: color-mix(in srgb, var(--canvas) 72%, transparent);
  border-block-end-color: var(--edge);
  /* --shadow-2, not a hard-coded black. A 35%-black shadow under the bar
     is invisible on the dark canvas and dirty grey on the light one; the
     token is navy-tinted on light and deep on dark. */
  box-shadow: 0 1px 0 var(--edge-highlight) inset, var(--shadow-2);
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  [data-scrolled] .header {
    -webkit-backdrop-filter: var(--blur-heavy);
    backdrop-filter: var(--blur-heavy);
  }
}

/* Without backdrop-filter the bar has to be opaque, or the page scrolls
   visibly through it and the navigation becomes unreadable. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  [data-scrolled] .header {
    background: var(--canvas);
  }
}

/* A page with no hero has nothing for a transparent header to sit on, so
   it starts frosted rather than waiting for a scroll that may never come
   on a short page. */
.page--flat .header,
.auth .header,
.admin .header {
  background: color-mix(in srgb, var(--canvas) 80%, transparent);
  border-block-end-color: var(--edge);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  min-block-size: var(--header-h);
}


/* ==========================================================================
   BRAND
   ========================================================================== */

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  /* The mark is 34px, which made the whole link a 34px target. On a
     phone the brand is how you get home, so it takes the full 44px. */
  min-block-size: 44px;
  text-decoration: none;
  color: var(--ink);
  flex: none;
}

.brand__mark {
  inline-size: 34px;
  block-size: 34px;
  flex: none;
  transition: transform var(--dur-slow) var(--ease-spring);
}

.brand:hover .brand__mark {
  transform: rotate(-6deg) scale(1.06);
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand__name {
  font-family: var(--font-display);
  font-size: var(--step-0);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  color: var(--ink);
}

/* The tagline is the brand promise and it is set in the display face at
   the smallest step, tracked open. It is deliberately quiet: it is read
   once and then never again, and a tagline competing with the name is a
   tagline that has misunderstood its job. */
.brand__tagline {
  font-family: var(--font-display);
  font-size: 0.62rem;
  font-weight: var(--weight-medium);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

@media (max-width: 420px) {
  .brand__tagline { display: none; }
}


/* ==========================================================================
   PRIMARY NAV
   ==========================================================================
   Hidden below 1024px, where the mobile sheet takes over. The two are
   different navigation systems sharing one data source, not one system at
   two widths.
   ========================================================================== */

.nav {
  display: none;
}

/* 1100, not 1024. The bar carries five groups now that Contact is in
   it, plus the account control — at 1024 they collided with the brand.
   The mobile sheet covers everything below. */
@media (min-width: 1100px) {
  .nav {
    display: flex;
    align-items: center;
    gap: var(--space-1);
  }
}

.nav__item {
  position: relative;
}

.nav__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--r-2);
  font-family: var(--font-display);
  font-size: var(--step--1);
  font-weight: var(--weight-medium);
  color: var(--ink-muted);
  text-decoration: none;
  background: none;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out);
}

.nav__link:hover,
.nav__link[aria-expanded="true"] {
  color: var(--ink);
  background: var(--glass-2);
}

.nav__chevron {
  transition: transform var(--dur-base) var(--ease-out);
  opacity: 0.6;
}

.nav__link[aria-expanded="true"] .nav__chevron {
  transform: rotate(180deg);
  opacity: 1;
}


/* ==========================================================================
   MEGA MENU
   ========================================================================== */

.megamenu {
  position: absolute;
  inset-block-start: calc(100% + var(--space-3));
  inset-inline-start: 0;
  z-index: var(--z-drawer);
  inline-size: max-content;
  max-inline-size: min(640px, calc(100vw - var(--space-7)));
  padding: var(--space-5);
  background: var(--panel-raised);
  border: 1px solid var(--edge-strong);
  border-radius: var(--r-4);
  box-shadow: var(--glow-inset), var(--shadow-3);
}

@supports (backdrop-filter: blur(1px)) {
  .megamenu {
    background: color-mix(in srgb, var(--panel-raised) 86%, transparent);
    -webkit-backdrop-filter: var(--blur-heavy);
    backdrop-filter: var(--blur-heavy);
  }
}

/* The panel animates open. It is [hidden] when closed, so there is no
   state where a keyboard user can tab into something invisible — the
   animation only ever plays on something already in the tree. */
.js .megamenu:not([hidden]) {
  animation: menu-in var(--dur-base) var(--ease-out) both;
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.megamenu__intro {
  margin-block-end: var(--space-4);
  padding-block-end: var(--space-4);
  border-block-end: 1px solid var(--edge);
  font-size: var(--step--1);
  line-height: var(--lh-snug);
  color: var(--ink-faint);
  max-inline-size: 46ch;
}

.megamenu__list {
  display: grid;
  gap: var(--space-1);
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}

.megamenu__link {
  display: block;
  padding: var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--r-3);
  text-decoration: none;
  color: var(--ink);
  transition: background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}

.megamenu__link:hover {
  background: var(--glass-2);
  border-color: var(--edge);
  color: var(--ink);
}

.megamenu__label {
  display: block;
  font-family: var(--font-display);
  font-size: var(--step--1);
  font-weight: var(--weight-bold);
  color: var(--ink);
}

.megamenu__summary {
  display: block;
  margin-block-start: 2px;
  font-size: var(--step--2);
  line-height: var(--lh-snug);
  color: var(--ink-faint);
}


/* ==========================================================================
   HEADER ACTIONS
   ========================================================================== */

.header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
}

/* An icon with a count, not the word "Messages". The bar has five
   navigation items in it now and the label was the least load-bearing
   text there — the envelope plus a number says the same thing in a
   fifth of the width, and the accessible name still reads "Messages, 3
   unread". */
.header__messages {
  position: relative;
  display: none;
  align-items: center;
  justify-content: center;
  min-inline-size: 42px;
  min-block-size: 42px;
  border-radius: var(--r-3);
  color: var(--ink-muted);
  text-decoration: none;
  transition: background-color var(--dur-base) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}

.header__messages:hover {
  background: var(--glass-2);
  color: var(--ink);
}

/* THE ICON, NOT THE BUTTON.

   The 42px above is the tap target and it is correct — that is the
   minimum a thumb needs. What was missing was a size for the glyph
   inside it, so the SVG had only a viewBox to go on and stretched to
   fill its box edge to edge. A 42px bell in a 42px button has no
   optical padding at all: it read as an oversized graphic dropped into
   the bar rather than a control, which is exactly how it looked.

   18px matches the theme toggle beside it (`.icon-btn svg`), so the two
   controls in that corner are now the same weight. */
.header__messages-icon {
  inline-size: 18px;
  block-size: 18px;
  flex: none;
}

.header__badge {
  position: absolute;
  inset-block-start: 4px;
  inset-inline-end: 2px;
}

.header__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-inline-size: 20px;
  block-size: 20px;
  padding-inline: 5px;
  background: var(--grad-accent);
  border-radius: var(--r-pill);
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
  color: var(--ink-on-accent);
}

@media (min-width: 720px) {
  .header__messages { display: inline-flex; }
}

/* Below 1024 the sheet carries sign-in and the account link, so the bar
   keeps only the theme toggle and the menu button. */
.header__login,
.header__cta,
.header__signout {
  display: none;
}

@media (min-width: 1100px) {
  .header__login,
  .header__cta { display: inline-flex; }
  .nav-toggle { display: none; }
}

/* The account control is the one header item that stays at every width:
   below 1100 the sheet carries navigation, but signing out and finding
   your dashboard should never require opening a menu to find a menu. */
.profile { display: none; }

@media (min-width: 560px) {
  .profile { display: block; }
}

/* ---- Theme toggle ------------------------------------------------------
   The rules moved to glass.css, which every shell loads. They lived here
   and nav.css is loaded ONLY by the public site — so on every console
   page and on the sign-in page the sun and the moon both rendered,
   inside one button, and the control read as two icons jammed together
   with no way to tell which was the state and which was the action. */


/* ==========================================================================
   MOBILE SHEET
   ==========================================================================
   A full-height panel, rendered in the document rather than built by
   script so the whole structure exists for search engines and for a
   visitor whose JavaScript failed.
   ========================================================================== */

.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  overflow-y: auto;
  overscroll-behavior: contain;
}

@supports (backdrop-filter: blur(1px)) {
  .mobile-menu {
    background: color-mix(in srgb, var(--canvas) 92%, transparent);
    -webkit-backdrop-filter: var(--blur-heavy);
    backdrop-filter: var(--blur-heavy);
  }
}

.js .mobile-menu:not([hidden]) {
  animation: sheet-in var(--dur-slow) var(--ease-out) both;
}

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.mobile-menu__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-block-size: var(--header-h);
  padding-inline: var(--gutter);
  border-block-end: 1px solid var(--edge);
}

.mobile-menu__body {
  flex: 1;
  padding: var(--space-5) var(--gutter) var(--space-8);
}

.mobile-group + .mobile-group {
  border-block-start: 1px solid var(--edge);
}

.mobile-group__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  inline-size: 100%;
  padding-block: var(--space-4);
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-weight: var(--weight-bold);
  color: var(--ink);
  text-align: start;
  text-decoration: none;
  background: none;
  cursor: pointer;
}

.mobile-group__toggle[aria-expanded="true"] .nav__chevron {
  transform: rotate(180deg);
}

.mobile-group__panel {
  padding-block-end: var(--space-4);
}

.mobile-group__link {
  display: block;
  padding-block: var(--space-3);
  padding-inline-start: var(--space-4);
  border-inline-start: 1px solid var(--edge);
  font-size: var(--step-0);
  color: var(--ink-muted);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}

.mobile-group__link:hover {
  color: var(--ink);
  border-inline-start-color: var(--edge-gold);
}

.mobile-menu__actions {
  display: grid;
  gap: var(--space-3);
  margin-block-start: var(--space-7);
}


/* ==========================================================================
   FOOTER
   ========================================================================== */

.footer {
  position: relative;
  padding-block: var(--section-y) var(--space-7);
  background: var(--canvas-deep);
  border-block-start: 1px solid var(--edge);
}

.footer::before {
  content: "";
  position: absolute;
  inset-block-start: -1px;
  inset-inline: 0;
  block-size: 1px;
  background: var(--grad-rule);
}

.footer__nav {
  display: grid;
  gap: var(--space-7) var(--grid-gap);
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  padding-block-end: var(--space-7);
  border-block-end: 1px solid var(--edge);
}

.footer__heading {
  margin-block-end: var(--space-4);
  font-family: var(--font-display);
  font-size: var(--step--2);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--ink-accent);
}

.footer__list {
  display: grid;
  gap: var(--space-2);
}

.footer__list a {
  font-size: var(--step--1);
  color: var(--ink-muted);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}

.footer__list a:hover {
  color: var(--ink);
}

.footer__base {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-6);
  justify-content: space-between;
  padding-block-start: var(--space-6);
  font-size: var(--step--2);
  color: var(--ink-faint);
}

.footer__disclaimer {
  max-inline-size: 52ch;
}


/* ==========================================================================
   PROFILE MENU
   ==========================================================================
   One control for everything that belongs to the account. The bar used
   to carry Messages, a name button and a Sign out form side by side —
   three account controls competing with the navigation, and the reason
   there was no room for Contact.

   It reuses the mega menu's markup contract (data-nav-item / -trigger /
   -panel), so nav.js already closes it on Escape, on an outside click
   and on focus leaving. A second dropdown implementation would be a
   second set of those bugs.
   ========================================================================== */

.profile {
  position: relative;
  flex: none;
}

.profile__trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-block-size: 44px;
  padding: var(--space-1) var(--space-2) var(--space-1) var(--space-1);
  background: var(--glass-2);
  border: 1px solid var(--edge);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background-color var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out);
}

.profile__trigger:hover,
.profile__trigger[aria-expanded="true"] {
  background: var(--glass-3);
  border-color: var(--edge-strong);
}

.profile__name {
  font-family: var(--font-display);
  font-size: var(--step--1);
  font-weight: var(--weight-semibold);
  color: var(--ink);
  white-space: nowrap;
}

/* The name is the first thing to go when the bar gets tight — the
   avatar still identifies the account, and the menu repeats the full
   name the moment it opens. */
@media (max-width: 860px) {
  .profile__name { display: none; }
}

.avatar--sm {
  inline-size: 30px;
  block-size: 30px;
  font-size: var(--step--2);
}

.avatar {
  display: inline-grid;
  place-items: center;
  inline-size: 38px;
  block-size: 38px;
  flex: none;
  overflow: hidden;
  border: 2px solid color-mix(in srgb, var(--panel-raised) 85%, transparent);
  border-radius: 50%;
  background: var(--grad-brand);
  box-shadow: 0 5px 16px rgb(11 31 68 / 18%);
  color: var(--ink-on-brand);
  font-family: var(--font-display);
  font-size: var(--step--2);
  font-weight: var(--weight-bold);
  letter-spacing: .02em;
}

/* ---- The panel --------------------------------------------------------- */
.profile__menu {
  position: absolute;
  inset-block-start: calc(100% + var(--space-3));
  inset-inline-end: 0;
  z-index: var(--z-drawer);
  inline-size: 17rem;
  max-inline-size: calc(100vw - var(--space-6));
  padding: var(--space-3);
  background: var(--panel-raised);
  border: 1px solid var(--edge-strong);
  border-radius: var(--r-4);
  box-shadow: var(--glow-inset), var(--shadow-3);
}

@supports (backdrop-filter: blur(1px)) {
  .profile__menu {
    background: color-mix(in srgb, var(--panel-raised) 90%, transparent);
    -webkit-backdrop-filter: var(--blur-heavy);
    backdrop-filter: var(--blur-heavy);
  }
}

.js .profile__menu:not([hidden]) {
  animation: menu-in var(--dur-base) var(--ease-out) both;
}

/* ---- Who you are -------------------------------------------------------
   The full name and the address, stated once. A shared computer is the
   normal case for a student, and knowing WHICH account you are signed
   into before you pay for something is worth two lines. */
.profile__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  margin-block-end: var(--space-2);
  border-block-end: 1px solid var(--edge);
}

.profile__who {
  display: flex;
  flex-direction: column;
  min-inline-size: 0;
}

.profile__full {
  font-family: var(--font-display);
  font-size: var(--step--1);
  font-weight: var(--weight-bold);
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile__email {
  font-size: var(--step--2);
  color: var(--ink-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- The links ---------------------------------------------------------- */
.profile__list {
  display: grid;
  gap: 1px;
}

.profile__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  inline-size: 100%;
  min-block-size: 44px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--r-3);
  font-family: var(--font-display);
  font-size: var(--step--1);
  font-weight: var(--weight-medium);
  color: var(--ink-muted);
  text-decoration: none;
  text-align: start;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}

.profile__link:hover {
  background: var(--glass-2);
  color: var(--ink);
}

.profile__icon {
  flex: none;
  color: var(--ink-faint);
}

.profile__link:hover .profile__icon {
  color: var(--ink-accent);
}

.profile__link .badge {
  margin-inline-start: auto;
}

/* ---- Sign out -----------------------------------------------------------
   Separated by a rule and set quieter than the destinations above it.
   It is the one thing in this menu nobody opens the menu to do. */
.profile__signout {
  margin-block-start: var(--space-2);
  padding-block-start: var(--space-2);
  border-block-start: 1px solid var(--edge);
}

.profile__link--quiet {
  color: var(--ink-faint);
}

.profile__link--quiet:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.profile__link--quiet:hover .profile__icon {
  color: var(--danger);
}

/* The arrow points out of the door rather than into it. */
.profile__icon--out {
  transform: rotate(180deg);
}


/* A heading inside the mobile sheet. The sheet carries the bar's five
   items first, then everything else under "More", then the account — and
   without a label those three runs read as one undifferentiated list. */
.mobile-menu__label {
  padding-block: var(--space-5) var(--space-2);
  font-family: var(--font-display);
  font-size: var(--step--2);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--ink-faint);
}

.mobile-group__toggle .badge {
  margin-inline-start: auto;
}


/* ==========================================================================
   THE BELL IN THE PUBLIC HEADER
   ==========================================================================
   `.dropdown__panel` anchors to the end edge of its container, which is
   correct in the console bar and wrong here: the bell sits near the
   right of a full-width header, and a 21rem panel hanging off it runs
   past the viewport on a laptop.

   Pinned to the header's own right gutter instead, and given the header
   a stacking context to sit above.
   ========================================================================== */

.header__bell {
  display: inline-flex;
}

.header__bell .dropdown__panel {
  inset-inline-end: 0;
  inset-block-start: calc(100% + var(--space-3));
}

@media (max-width: 30rem) {
  /* No room to anchor anything on a phone: the panel takes the gutter
     width and centres under the bar. */
  .header__bell .dropdown__panel {
    position: fixed;
    inset-inline: var(--gutter);
    inline-size: auto;
    max-inline-size: none;
  }
}


/* The role, under the address in the account menu. An administrator and
   a student see different menus now, and saying which one is open is
   what makes that legible rather than confusing. */
.profile__role {
  display: block;
  margin-block-start: var(--space-1);
  font-family: var(--font-display);
  font-size: var(--step--2);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--ink-accent);
}


/* An uploaded photograph, in the same circle the initial uses. */
.avatar--img {
  display: block;
  object-fit: cover;
  object-position: center;
  padding: 0;
  background: var(--panel-sunken);
}
