/*
 * Unified site header (Spec 0038). One stylesheet shared by SiteHeader.astro
 * (the Astro layouts) and — in Phase 2 — the lesson route injection, so every
 * surface has one header look. Namespaced under `cs-sh-`; falls back to literal
 * shades when the platform tokens are absent (e.g. on the lesson surface).
 */

.cs-sh {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #fff;
  border-bottom: 1px solid var(--rule, #dee2e6);
  font-family: var(--font, 'Plus Jakarta Sans', system-ui, sans-serif);
}
.cs-sh-inner {
  /* Spec 0043: match the member dashboard content width (960px) so the header
     logo/nav line up with the page body. */
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.cs-sh-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink, #1a1e24);
  font-weight: 700;
  font-size: 0.875rem;
  letter-spacing: -0.01em;
  flex: none;
}
.cs-sh-brand img {
  display: block;
  width: 28px;
  height: 28px;
}
.cs-sh-brand:hover {
  color: var(--teal-dk, #009e7c);
}
.cs-sh-badge {
  font-family: var(--mono, 'DM Mono', monospace);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--teal, #00c49a);
  color: #fff;
  padding: 2px 8px;
  border-radius: 999px;
}
.cs-sh-home,
.cs-sh-link {
  color: var(--ink, #1a1e24);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.cs-sh-home:hover,
.cs-sh-link:hover,
.cs-sh-link.is-active {
  background: var(--surface, #f8f9fa);
  color: var(--teal-dk, #009e7c);
}
.cs-sh-account {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 14px;
}
.cs-sh-name {
  font-family: var(--mono, 'DM Mono', monospace);
  font-size: 0.688rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted, #6c757d);
}
/* Spec 0043: "Owner" chip beside the name for the account owner. */
.cs-sh-owner {
  font-family: var(--mono, 'DM Mono', monospace);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--teal-lt, #e0faf4);
  color: var(--teal-dk, #009e7c);
  padding: 2px 8px;
  border-radius: 999px;
}
.cs-sh-muted {
  color: var(--muted, #6c757d);
}
.cs-sh-muted:hover {
  color: var(--red, #e53935);
  background: var(--red-lt, #fff5f5);
}

.cs-sh-burger {
  display: none;
  margin-left: auto;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--rule, #dee2e6);
  border-radius: 8px;
  background: #fff;
  color: var(--ink, #1a1e24);
  cursor: pointer;
  flex: none;
}
.cs-sh-burger:hover {
  background: var(--surface, #f8f9fa);
  color: var(--teal-dk, #009e7c);
  border-color: var(--teal, #00c49a);
}
.cs-sh-burger-close {
  display: none;
}
.cs-sh-burger[aria-expanded='true'] .cs-sh-burger-open {
  display: none;
}
.cs-sh-burger[aria-expanded='true'] .cs-sh-burger-close {
  display: block;
}

.cs-sh-drawer {
  display: none;
}

@media (max-width: 768px) {
  .cs-sh-home,
  .cs-sh-link,
  .cs-sh-account {
    display: none;
  }
  .cs-sh-burger {
    display: inline-flex;
  }
  .cs-sh-inner {
    padding: 10px 14px;
    gap: 10px;
  }
  .cs-sh-drawer:not([hidden]) {
    display: block;
    border-top: 1px solid var(--rule, #dee2e6);
    background: #fff;
  }
  .cs-sh-drawer-who {
    display: block;
    padding: 11px 18px;
    font-family: var(--mono, 'DM Mono', monospace);
    font-size: 0.688rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted, #6c757d);
    border-bottom: 1px solid var(--rule, #dee2e6);
  }
  .cs-sh-drawer-link {
    display: block;
    padding: 14px 18px;
    color: var(--ink, #1a1e24);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--rule, #dee2e6);
  }
  .cs-sh-drawer-link:last-child {
    border-bottom: none;
  }
  .cs-sh-drawer-link:hover {
    background: var(--surface, #f8f9fa);
    color: var(--teal-dk, #009e7c);
  }
  .cs-sh-drawer-muted {
    color: var(--muted, #6c757d);
  }

  /* Accessibility control folded into the drawer (Spec 0036 Phase 2). */
  .cs-sh-a11y-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    background: none;
    border: none;
    border-bottom: 1px solid var(--rule, #dee2e6);
    font-family: inherit;
    cursor: pointer;
    color: var(--ink, #1a1e24);
  }
  .cs-sh-a11y-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
  }
  .cs-sh-a11y-chev {
    flex: none;
    color: var(--muted, #6c757d);
    transition: transform 0.15s ease;
  }
  .cs-sh-a11y-btn[aria-expanded='true'] .cs-sh-a11y-chev {
    transform: rotate(180deg);
  }
  .cs-sh-a11y-panel {
    padding: 2px 18px 8px;
    background: var(--surface, #f8f9fa);
    border-bottom: 1px solid var(--rule, #dee2e6);
  }
  .cs-sh-a11y-panel[hidden] {
    display: none;
  }
}

body.high-contrast .cs-sh {
  background: #fff !important;
  border-bottom: 3px solid #000;
}
body.high-contrast .cs-sh-brand,
body.high-contrast .cs-sh-home,
body.high-contrast .cs-sh-link,
body.high-contrast .cs-sh-drawer-link,
body.high-contrast .cs-sh-burger {
  color: #000 !important;
}
body.high-contrast .cs-sh-burger {
  border: 2px solid #000 !important;
}

/*
 * Lesson host (Spec 0038 Phase 2). On a served lesson the header is injected
 * into Craig's raw HTML, which already carries a fixed course rail and a
 * calculator FAB, so here the header becomes fixed above them and the body,
 * rail and open-fab are offset beneath it, and Craig's legacy navy `.a11y-bar`
 * is hidden (its controls live in the floating pill). All gated on the
 * `cs-sh-host` body flag, so the Astro pages, where the header flows naturally
 * in the document, are completely untouched. Values mirror the proven Spec 0034
 * lesson-header offsets (52px header, 66px open-fab).
 */
body.cs-sh-host .cs-sh {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1100;
}
body.cs-sh-host {
  padding-top: 52px;
}
body.cs-sh-host .a11y-bar {
  display: none !important;
}
body.cs-sh-host .cs-sidenav {
  top: 52px;
  height: calc(100vh - 52px);
}
body.cs-sh-host .cs-open-fab {
  top: 66px;
}
/*
 * Spec 0055: Craig's served funnel pages (the tier syllabi and the Study
 * Planner) carry their own sticky `.topbar` pinned at top:0. Offset it below
 * our fixed 52px header so it pins under the header instead of colliding with,
 * and hiding behind, it on scroll.
 */
body.cs-sh-host .topbar {
  top: 52px;
}
/*
 * Spec 0045: the lesson surface now folds its accessibility control into the
 * mobile drawer, exactly like the platform pages (and the floating pill is
 * hidden on mobile, see cs-a11y.css). So the drawer's accessibility section is
 * no longer suppressed on lessons. Desktop lessons keep the pill (the drawer
 * only exists on mobile). Previously (Spec 0036 Phase 2) the drawer control was
 * suppressed here to avoid two controls; that carve-out is intentionally gone.
 */
