/* <site-header> -- the one and only Cloud Academy topbar, same on every
   page (mirrors what assets/site-footer.js already does for the footer,
   ADR 0009). Light DOM, not Shadow DOM: CloudAcademyAuth.renderAuthSlot()
   looks #navAuthSlot up with plain document.getElementById, and every
   page already shares the same --ink/--signal/etc. token names, so
   there's nothing a shadow boundary would protect here -- it would only
   get in the way of both. Every selector is scoped under the site-header
   tag itself so it can never leak into a page's own same-named class
   (courses.html's own unrelated .chip filter pills, for one).

   Folded in from the old assets/nav-menu.css (the mobile hamburger,
   CAP-14) and the .navGroup/.chip/.theme-toggle/.wordmark/.nav/.btn
   rules every page used to carry its own copy of. */

/* Sticky footer on every page (CAP-80). <site-footer> already asks to sit at
   the bottom (:host{margin-top:auto}), but that only works when <body> is a
   flex column at least as tall as the viewport. Pages used to set that up
   one by one, and the ones that did not (catalogue, home, topics, help, the
   document pages) left the footer floating mid-screen on short content. One
   rule here, in the stylesheet every page with a footer loads. Scoped to
   pages that have a footer, so the redirect pages are untouched. */
body:has(> site-footer){
  min-height:100vh;min-height:100dvh;
  display:flex;flex-direction:column;
}

/* One width for the header and footer on every page (CAP-81). They size
   themselves from --sheet-max, which pages also set for their own content
   (1320px on most, 1240px on home and My courses, 900px for the lesson
   column), so the logo and nav jumped 40px sideways between pages -- more
   visibly once View Transitions animate it. Set on the elements themselves,
   so no page's own value reaches them. The site width is 1320px (DESIGN.md). */
site-header,site-footer{--sheet-max:1320px}

/* Page-to-page transitions (CAP-81): the browser keeps the old page on
   screen until the new one is ready, holds the header and footer in place
   (matching view-transition-names) and cross-fades only the content, instead
   of blanking the whole page. Cross-document View Transitions: Chrome/Edge
   126+, Safari 18.2+; other browsers navigate exactly as before. Skipped for
   people who ask for reduced motion. Both pages must load this stylesheet. */
@media (prefers-reduced-motion:no-preference){
  @view-transition{navigation:auto}
}
site-header{view-transition-name:site-header}
site-footer{view-transition-name:site-footer}
/* The header swaps in one frame instead of cross-fading, so a different
   active link or account slot never shows as a fade. The solid background
   stands in for backdrop-filter, which snapshots do not carry. */
::view-transition-group(site-header){animation:none;background:var(--blueprint)}
::view-transition-old(site-header){display:none}
::view-transition-new(site-header){animation:none}
/* Keeps the scrollbar's width reserved on short pages, so the header does
   not slide sideways between pages with and without a scrollbar. */
html{scrollbar-gutter:stable}

site-header{
  display:block;position:sticky;top:0;z-index:40;
  /* A plain bar (home redesign): solid ground, no blur, no rule; a tone step separates it from the page. */
  background:var(--blueprint-deep,var(--blueprint));
}
site-header .topbar__in{
  max-width:var(--sheet-max,1240px);margin:0 auto;
  display:flex;align-items:center;justify-content:space-between;gap:24px;
  padding:14px clamp(20px,5vw,64px);
}
site-header .wordmark{display:flex;align-items:baseline;gap:12px;text-decoration:none;flex:none;color:inherit}
site-header .wordmark__markbg{display:flex;align-items:center;justify-content:center;flex:none;width:28px;height:32px;color:var(--ink)}
site-header .wordmark__mark{width:24px;height:30px;display:block;align-self:center;flex:none}
site-header .wordmark b{font-weight:800;font-size:19px;letter-spacing:-.02em;white-space:nowrap}
/* Every property set here: pages' own .mono differ (login/signup drop the
   uppercase, home uses .16em), which changed the label between pages. */
site-header .wordmark .rev{font-size:13px;font-weight:600;color:var(--ink-2);white-space:nowrap}

site-header .nav{display:flex;align-items:center;gap:22px;min-width:0}
site-header .nav a{text-decoration:none;font-size:14px;font-weight:500;color:var(--ink-2);white-space:nowrap;transition:color .18s ease}
site-header .nav a:hover{color:var(--ink)}
site-header .nav a[aria-current="page"]{color:var(--ink);box-shadow:0 2px 0 var(--signal)}
site-header .nav .btn{color:var(--chalk-ink)}
site-header .nav .btn:hover{color:var(--chalk-ink)}
site-header .nav .btn--ghost{color:var(--ink)}
site-header .nav .btn--ghost:hover{color:var(--ink)}

/* .navGroup holds whatever renderAuthSlot() injects (signed-out CTAs, or
   signed-in: role links + profile chip + sign out). */
site-header .navGroup{display:flex;align-items:center;gap:16px;min-width:0}
site-header .btn{
  display:inline-flex;align-items:center;gap:10px;
  font-family:var(--font);font-weight:600;font-size:14px;letter-spacing:.01em;
  padding:11px 18px;background:var(--chalk);color:var(--chalk-ink);
  border:1px solid var(--chalk);border-radius:var(--radius);
  text-decoration:none;cursor:pointer;white-space:nowrap;
  transition:transform .16s ease,box-shadow .16s ease,background .16s ease;
}
site-header .btn:hover{transform:translateY(-1px);box-shadow:0 6px 0 -2px rgba(0,0,0,.25)}
site-header .btn:active{transform:translateY(0);box-shadow:none}
site-header .btn--ghost{background:transparent;color:var(--ink);border-color:var(--rule-strong)}
site-header .btn--ghost:hover{border-color:var(--ink);box-shadow:none}
site-header .btn__tick{font-family:var(--mono);font-size:12px;opacity:.7}

site-header .chip{display:inline-flex;align-items:center;gap:9px;padding:5px 12px 5px 5px;border:1px solid var(--rule-strong);border-radius:var(--radius);max-width:200px;min-width:0;text-decoration:none;color:inherit}
site-header .chip__avatar{width:26px;height:26px;border-radius:50%;flex:none;overflow:hidden;background:var(--signal);color:var(--signal-ink);display:flex;align-items:center;justify-content:center;font-weight:700;font-size:12px}
site-header .chip__who{display:flex;flex-direction:column;gap:1px;min-width:0}
site-header .chip__name{font-size:13px;font-weight:600;color:var(--ink);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
site-header .chip__email{font-family:var(--mono);font-size:10.5px;color:var(--ink-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
site-header .streak-pill{display:inline-flex;align-items:center;gap:4px;padding:4px 9px;border:1px solid var(--rule-strong);border-radius:99px;color:#E8871E;font-weight:700;font-size:13px;text-decoration:none}
site-header .streak-pill:hover{border-color:#E8871E}
@media (max-width:1360px){site-header .streak-pill{display:none}}
site-header .signout{text-decoration:none;color:var(--ink-2);white-space:nowrap}
site-header .signout:hover{color:var(--ink)}

site-header .theme-toggle{
  width:32px;height:32px;flex:none;display:inline-flex;align-items:center;justify-content:center;
  background:transparent;color:var(--ink-2);
  border:1px solid var(--rule-strong);border-radius:50%;cursor:pointer;
  transition:border-color .16s ease,color .16s ease;
}
site-header .theme-toggle:hover{border-color:var(--ink-2);color:var(--ink)}
site-header .theme-toggle__icon{width:16px;height:16px}
site-header .theme-toggle__icon--sun circle{fill:currentColor}
site-header .theme-toggle__icon--sun path{stroke:currentColor;stroke-width:1.4;stroke-linecap:round;fill:none}
site-header .theme-toggle__icon--moon path{fill:currentColor}
site-header .theme-toggle__icon--moon{display:block}
site-header .theme-toggle__icon--sun{display:none}
:root[data-theme="light"] site-header .theme-toggle__icon--moon{display:none}
:root[data-theme="light"] site-header .theme-toggle__icon--sun{display:block}

/* Language switch (CAP-87): the last item of the bar, in its right corner. */
site-header .lang-switch{display:inline-flex;flex:none;border:1px solid var(--rule-strong);border-radius:var(--radius);overflow:hidden}
site-header .lang-switch button{
  font:inherit;font-size:12px;font-weight:700;letter-spacing:.04em;
  min-width:38px;height:30px;padding:0 8px;border:0;background:transparent;color:var(--ink-2);cursor:pointer;
}
site-header .lang-switch button:hover{color:var(--ink)}
site-header .lang-switch button[aria-pressed="true"]{background:var(--chalk);color:var(--chalk-ink)}
site-header .lang-switch button:focus-visible{outline:2px solid var(--signal);outline-offset:-2px}
site-header .lang-switch[hidden]{display:none}

/* ---------- mobile hamburger menu (CAP-14) ---------- */
site-header .nav-menu-btn{
  display:none;
  width:40px;height:40px;flex:none;align-items:center;justify-content:center;
  padding:0;background:transparent;color:var(--ink);
  border:1px solid var(--rule-strong);border-radius:var(--radius);cursor:pointer;
  transition:border-color .16s ease,background .16s ease;
}
site-header .nav-menu-btn:hover{border-color:var(--ink-2)}
site-header .nav-menu-btn[aria-expanded="true"]{background:var(--blueprint-deep);border-color:var(--ink-2)}
site-header .nav-menu-btn:focus-visible{outline:2px solid var(--signal);outline-offset:2px}
site-header .nav-menu-btn svg{width:20px;height:20px;display:block}
site-header .nav-menu-btn path{fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round}
site-header .nav-menu-btn__x{display:none}
site-header .nav-menu-btn[aria-expanded="true"] .nav-menu-btn__bars{display:none}
site-header .nav-menu-btn[aria-expanded="true"] .nav-menu-btn__x{display:inline}

/* Position context comes from site-header's own position:sticky above. */
site-header .nav-menu{
  display:none;
  position:absolute;left:0;right:0;top:100%;
  max-height:calc(100vh - 72px);overflow-y:auto;
  padding:4px clamp(16px,5vw,64px) 14px;
  background:var(--blueprint);
  border-bottom:1px solid var(--rule-strong);
  box-shadow:0 22px 32px -22px rgba(0,0,0,.6);
}
site-header .nav-menu__link{
  display:flex;align-items:center;justify-content:space-between;gap:16px;
  min-height:48px;padding:8px 6px;
  font-family:var(--font);font-size:16px;font-weight:500;line-height:1.3;
  color:var(--ink);text-decoration:none;
  border-top:1px solid var(--rule);
}
site-header .nav-menu__link:first-child{border-top:0}
site-header .nav-menu__link:hover{background:var(--blueprint-deep)}
site-header .nav-menu__link:focus-visible{outline:2px solid var(--signal);outline-offset:-2px}
site-header .nav-menu__link[aria-current="page"]{box-shadow:inset 3px 0 0 var(--signal);padding-left:14px}
site-header .nav-menu__link--account{flex-direction:column;align-items:flex-start;justify-content:center;gap:2px;border-top:1px solid var(--rule-strong);margin-top:6px}
site-header .nav-menu__name{font-weight:600}
site-header .nav-menu__email{font-family:var(--mono);font-size:11.5px;font-weight:400;color:var(--ink-3);max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

@media (max-width:1024px){
  site-header .nav a:not(.btn):not(.signout){display:none}
  site-header .nav-menu-btn{display:inline-flex}
  site-header .nav-menu.is-open{display:block}
}
/* Signed in, between the menu breakpoint and a wide desktop: role links,
   the full profile chip and Sign out did not fit. Keep the avatar and
   move the name/email off-screen for screen readers, so the link keeps
   its accessible name. */
@media (min-width:1025px) and (max-width:1360px){
  site-header .chip{padding:5px}
  site-header .chip__who{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
}
@media (max-width:1200px){ site-header .wordmark .rev{display:none} }
/* Signed in (the profile chip is present), the role links, chip, Sign out
   and theme toggle leave no room for the "by CSecurity" line at any desktop
   width: the header's content has a fixed max width, and with it shown the
   chip overlapped Sign out (seen 2026-09-25, professor account, 1300-1500px).
   Signed-out visitors keep it. */
site-header:has(.chip) .wordmark .rev{display:none}
@media (max-width:720px){ site-header .wordmark b{display:none} }
@media (max-width:480px){
  site-header .nav-menu-btn{width:36px;height:36px}
  site-header .lang-switch button{min-width:32px;padding:0 6px}
  site-header .nav{gap:8px}
  site-header .navGroup{gap:6px}
  site-header .nav .btn{padding-inline:12px}
  site-header .nav .btn__tick{display:none}
}
/* Signed out on a phone, the bar holds the menu, Sign in, the theme toggle and
   the language switch; "Start learning" no longer fits beside them (it ran under
   the switch at 390px). The page's own sign-up buttons cover it. */
@media (max-width:480px){
  site-header #navAuthSlot .btn:not(.btn--ghost){display:none}
}
/* 320px phones: the theme toggle also gives way (it follows the system setting). */
@media (max-width:340px){
  site-header .theme-toggle{display:none}
}
@media (prefers-reduced-motion:no-preference){
  site-header .nav-menu.is-open{animation:navMenuIn .16s ease-out}
  @keyframes navMenuIn{from{opacity:0;transform:translateY(-6px)}to{opacity:1;transform:none}}
}
/* Phone: the small standalone links on the sign-in and sign-up cards get a 24px+ tap target; the negative margin keeps the layout. */
@media (max-width:600px){
  .field-row a,.authcard__foot a{display:inline-block;padding-block:6px;margin-block:-6px}
}
