/* 官网页头：logo、导航、语言、主题、登录 / Site header. */
/* 页头 / header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--txy-bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--txy-border);
}
.header-row {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 76px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--txy-text);
  text-decoration: none;
}
.menu-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--txy-border-strong);
  border-radius: 10px;
  background: var(--txy-surface);
  color: var(--txy-text);
  cursor: pointer;
}
.nav-panel {
  display: none;
}
.nav-panel.is-open {
  display: block;
  position: absolute;
  top: 76px;
  left: 0;
  right: 0;
  padding: 16px 20px 24px;
  background: var(--txy-surface);
  border-bottom: 1px solid var(--txy-border);
  box-shadow: 0 16px 32px rgb(0 0 0 / 0.12);
}
.nav-links,
.lang-links,
.footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-links a {
  display: block;
  padding: 10px 4px;
  color: var(--txy-text);
  text-decoration: none;
  font-weight: 500;
}
.nav-links a:hover {
  color: var(--txy-brand-text);
}
.nav-login {
  margin-top: 12px;
}

/* 右侧工具：语言、主题、登录、菜单；窄屏也一直露在页头 / header tools, always visible */
.header-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-login {
  display: none;
}

/* 图标按钮：40×40（WCAG 2.2 目标尺寸） / 40px icon buttons */
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--txy-border-strong);
  border-radius: 10px;
  background: var(--txy-surface);
  color: var(--txy-text-secondary);
  cursor: pointer;
  list-style: none;
}
.icon-button:hover {
  color: var(--txy-text);
}
.icon-button::-webkit-details-marker {
  display: none;
}
/* 没开脚本时主题按钮点不动，就不显示 / the toggle needs JS */
html:not(.js) .theme-toggle,
:root[data-theme="dark"] .icon-moon,
:root:not([data-theme="dark"]) .icon-sun {
  display: none;
}

/* 语言菜单：从按钮下方弹出，当前语言前面打勾 / language popover with a check on the current item */
.lang-menu {
  position: relative;
}
.lang-menu[open] > summary {
  color: var(--txy-text);
  border-color: var(--txy-brand);
}
.lang-links {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  min-width: 168px;
  padding: 6px;
  border: 1px solid var(--txy-border);
  border-radius: 12px;
  background: var(--txy-surface);
  box-shadow: 0 16px 32px rgb(0 0 0 / 0.14);
}
.lang-links a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--txy-text);
  text-decoration: none;
  font-size: 14px;
}
.lang-links a::before {
  content: "";
  width: 14px;
  height: 8px;
  flex: none;
}
.lang-links a:hover {
  background: var(--txy-surface-muted);
}
.lang-links a[aria-current="page"] {
  color: var(--txy-brand-soft-text);
  font-weight: 600;
}
.lang-links a[aria-current="page"]::before {
  width: 10px;
  height: 5px;
  margin: 0 2px 3px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
}

@media (min-width: 1240px) {
  .menu-button,
  .nav-login {
    display: none;
  }
  .header-login {
    display: inline-flex;
    margin-left: 4px;
  }
  .header-tools {
    margin-left: 0;
  }
  .nav-panel,
  .nav-panel.is-open {
    display: flex;
    position: static;
    flex: 1;
    align-items: center;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
  }
  .nav-links {
    display: flex;
    gap: 4px;
    margin-left: 16px;
  }
  .nav-links a {
    padding: 8px 10px;
    font-size: 15px;
  }
}

/* 导航和登录不折行 / keep header items on one line */
.nav-links a,
.lang-links a,
.button-small {
  white-space: nowrap;
}

/* 1240–1400 宽时收紧间距，英文导航词长也放得下 / tighter spacing so English fits */
@media (min-width: 1240px) and (max-width: 1399px) {
  .nav-links {
    margin-left: 8px;
    gap: 0;
  }
  .nav-links a {
    padding: 8px 7px;
  }
}
