:root {
  --site-header-height: 78px;
}

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  height: var(--site-header-height);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-family: "Manrope", system-ui, sans-serif;
}

.site-header-inner {
  max-width: 1440px;
  height: 100%;
  margin: 0 auto;
  padding: 0 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

/* The course reader follows the full-width layout with its sidebar. */
.course-page .site-header-inner {
  max-width: none;
}

.site-brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.site-brand-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid var(--ink);
  border-radius: 50%;
  object-fit: cover;
  object-position: center 32%;
  filter: grayscale(1);
}

.site-brand-copy {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
}

.site-brand-name-compact { display: none; }

.site-brand-copy strong {
  font: 700 12px/1.25 "Manrope", sans-serif;
  letter-spacing: -.025em;
}

.site-brand-copy small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: .03em;
}

.site-header .mobile-menu {
  position: relative;
  flex: 0 0 auto;
}

.site-header-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.site-header .arcade-link,
.site-header .theme-toggle,
.site-header .language-trigger,
.site-header .mobile-menu > summary {
  min-height: 44px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  font: 600 13px/1.5 "Manrope", system-ui, sans-serif;
}

.site-header .theme-toggle, .site-header .arcade-link { width: 44px; height: 44px; padding: 0; text-decoration: none; }
.site-header .arcade-link svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.site-header .arcade-link[aria-current="page"] { background: var(--selected); border-color: var(--ink); }
.site-header .language-trigger { min-width: 64px; padding-inline: 12px; }
.site-header .arcade-link:hover,
.site-header .theme-toggle:hover,
.site-header .language-trigger:hover,
.site-header .mobile-menu > summary:hover { background: var(--hover); }

.site-header summary::-webkit-details-marker {
  display: none;
}

.site-nav,
.language-options {
  position: absolute;
  top: 52px;
  right: 0;
  width: min(224px, calc(100vw - 40px));
  max-height: calc(100dvh - var(--site-header-height) - 16px);
  overflow-y: auto;
  padding: 8px;
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--popover-bg);
  color: var(--ink);
  box-shadow: var(--popup-shadow);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
}

.site-nav a,
.site-nav button,
.language-option {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-start;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.site-nav form {
  margin: 0;
}

[data-student-logout][hidden],
[data-student-home-login][hidden],
[data-student-home-active][hidden],
[data-student-results-login][hidden] {
  display: none;
}

.site-nav a:hover,
.site-nav button:hover,
.language-option:hover {
  background: var(--hover);
}

.site-header :focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

html {
  scroll-padding-top: calc(var(--site-header-height) + 20px);
}

@media (max-width: 640px) {
  :root { --site-header-height: 70px; }
  .site-header-inner { padding: 0 20px; gap: 10px; }
  .site-brand-copy .site-brand-role, .site-brand-university span { display: none; }
  .site-brand-copy .site-brand-university { font-size: 9px; }
  .site-brand-copy strong { max-width: 170px; line-height: 1.3; overflow-wrap: anywhere; }
  .site-brand-avatar { width: 40px; height: 40px; }
}

.language-switch { margin: 0; flex: 0 0 auto; font: inherit; }
.language-menu { position: relative; }
.language-trigger svg,
.language-option svg { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.language-trigger svg { transition: transform .12s ease; }
.language-menu[open] .language-trigger svg { transform: rotate(180deg); }
.language-trigger:disabled { cursor: default; opacity: .6; }
.language-options .language-option { justify-content: space-between; gap: 16px; }
.language-option svg { visibility: hidden; }
.language-option[aria-current="true"],
.language-option[aria-checked="true"] { background: var(--selected); color: var(--ink); }
.language-option[aria-current="true"] svg,
.language-option[aria-checked="true"] svg { visibility: visible; }
.site-nav a:focus-visible,
.site-nav button:focus-visible,
.language-option:focus-visible { outline-offset: -2px; }
@media (max-width: 600px) { .site-header-actions { gap: 6px; } }
@media (prefers-reduced-motion: reduce) { .language-trigger svg { transition: none; } }
:lang(zh-Hans){font-family:system-ui,"PingFang SC","Microsoft YaHei","Noto Sans CJK SC",sans-serif}

/* Accessible descriptions must remain hidden in gradebook pages as well. */
.site-header .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

@media (max-width: 480px) {
  .site-header-inner { padding-inline: 16px; gap: 8px; }
  .site-brand { gap: 8px; }
  .site-brand-avatar { width: 32px; height: 32px; }
  .site-brand-copy .site-brand-university,
  .site-brand-name-full { display: none; }
  .site-brand-name-compact { display: inline; }
  .site-brand-copy strong { min-width: 0; }
  .site-header summary { padding-inline: 10px; font-size: 13px; }
}

@media (max-width: 360px) {
  .site-brand-avatar { display: none; }
}

@media (max-width: 400px) {
  .site-header-inner { padding-inline: 12px; }
  .site-brand-avatar { display: none; }
  .site-brand-copy strong { font-size: 11px; }
  .site-header-actions { gap: 5px; }
  .site-header .mobile-menu > summary { padding-inline: 10px; }
}
