/* 十页共用页头，以及页脚口号与字标的对齐。后于 home.css / site.css 加载。 */

:root {
  --gutter: clamp(16px, 4.45vw, 64px);
  --lock-w: 199.519px;
  /* 简锁 viewBox 0 0 7296.271 805；页脚字标大写高 24px → 宽 250.158 */
  --full-w: 250.158px;
  --word-frac: 0.1969678;
}
:root[data-theme="light"] { --word-frac: 0.1969678; }
:root[data-theme="dark"] { --word-frac: 0.2018214; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --word-frac: 0.2018214; }
}
@media (max-width: 719px) {
  :root { --lock-w: 146.873px; }
}

.hd {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
  min-height: 84px;
  padding: 24px var(--gutter, 16px) 12px;
  background: var(--bg);
  color: var(--fg);
  border-bottom: 1px solid var(--line, var(--border));
}
.hd .brand {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  width: var(--lock-w);
  max-width: 100%;
  flex: 0 0 auto;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}
.logo {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 7296.271 / 805;
  overflow: hidden;
}
.hd .logo img.on-light,
.hd .logo img.on-dark,
.ft .logo img.on-light,
.ft .logo img.on-dark {
  position: absolute;
  left: 0;
  top: 50%;
  width: 100%;
  height: auto;
  margin: 0;
  max-width: none;
  transform: translateY(-50%);
}
.hd .on-dark,
.ft .on-dark { display: none !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hd .on-light,
  :root:not([data-theme="light"]) .ft .on-light { display: none !important; }
  :root:not([data-theme="light"]) .hd .on-dark,
  :root:not([data-theme="light"]) .ft .on-dark { display: block !important; }
}
:root[data-theme="dark"] .hd .on-light,
:root[data-theme="dark"] .ft .on-light { display: none !important; }
:root[data-theme="dark"] .hd .on-dark,
:root[data-theme="dark"] .ft .on-dark { display: block !important; }
:root[data-theme="light"] .hd .on-dark,
:root[data-theme="light"] .ft .on-dark { display: none !important; }
:root[data-theme="light"] .hd .on-light,
:root[data-theme="light"] .ft .on-light { display: block !important; }

.hd .tagline {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-family: var(--mono, ui-monospace, Consolas, monospace);
  font-size: 10px;
  line-height: 1;
  color: var(--muted);
}
.hd .nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-left: auto;
  font-size: 15px;
  font-weight: 500;
}
.hd .tool.nav-toggle { display: none; }
.hd .nav-panel {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 22px;
}
.hd .nav-links,
.hd .nav-anchors {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 22px;
}
.hd .nav-links a,
.hd .nav-anchors a {
  color: var(--fg);
  text-decoration: none;
}
.hd .nav-links a:hover,
.hd .nav-anchors a:hover { color: var(--accent); }
.hd .nav-links a[aria-current="page"] {
  color: var(--accent);
  font-weight: 600;
}
.hd .tools { display: inline-flex; align-items: center; gap: 6px; }
.hd .tool {
  height: 32px;
  min-width: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line, var(--border));
  background: transparent;
  color: var(--fg);
  font-family: var(--mono, ui-monospace, Consolas, monospace);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
}
.hd .tool:hover { background: var(--surface-2, var(--surface)); color: var(--fg); }
.hd .tool-icon { width: 32px; padding: 0; }
.hd .nav-toggle .icon-close { display: none; }
.hd.is-open .nav-toggle .icon-open { display: none; }
.hd.is-open .nav-toggle .icon-close { display: block; }
.hd .cta-sm {
  height: 40px;
  padding: 0 18px;
  font-size: 15px;
  text-decoration: none;
}

.ft { align-items: flex-start; }
.ft-lock {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  width: var(--lock-w);
  max-width: 100%;
}
.ft .logo { aspect-ratio: 7296.271 / 805; }
.ft-lock .ft-tag {
  align-self: flex-start;
  margin: 0 0 0 calc(var(--word-frac) * 100%);
  padding: 0;
  font-family: var(--mono, ui-monospace, Consolas, monospace);
  font-size: 12px;
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--muted);
}

@media (max-width: 959px) {
  .hd { flex-wrap: nowrap; }
  .hd .nav { flex-wrap: nowrap; gap: 8px; }
  .hd .tool.nav-toggle { display: inline-flex; }
  .hd .nav-panel {
    display: none;
    position: absolute;
    z-index: 30;
    left: 0;
    right: 0;
    top: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 8px var(--gutter, 16px) 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--line, var(--border));
  }
  .hd.is-open .nav-panel { display: flex; }
  .hd .nav-links,
  .hd .nav-anchors {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }
  .hd .nav-links a,
  .hd .nav-anchors a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}
@media (max-width: 719px) {
  .hd { min-height: 72px; padding-top: 20px; padding-bottom: 7px; }
  .hd .tool, .hd .cta-sm { white-space: nowrap; }
  .hd .tool { height: 44px; min-width: 44px; padding: 0 8px; }
  .hd .tool-icon { width: 44px; padding: 0; }
  .hd .cta-sm { height: 44px; padding: 0 12px; font-size: 13px; }
}
@media (max-width: 400px) {
  .hd .tagline { font-size: 9px; }
}

/* H2-c③：只作用于英文，且不进 390。≥960 字号 14、项间距 20、不折行；960–1439 四个首页锚点折入 ≡。 */
@media (min-width: 960px) {
  html[lang="en"] .hd,
  html[lang="en"] .hd .nav,
  html[lang="en"] .hd .nav-panel,
  html[lang="en"] .hd .nav-links,
  html[lang="en"] .hd .nav-anchors { flex-wrap: nowrap; }
  html[lang="en"] .hd .nav { font-size: 14px; }
  html[lang="en"] .hd .cta-sm { font-size: 14px; white-space: nowrap; }
  html[lang="en"] .hd .nav-links a,
  html[lang="en"] .hd .nav-anchors a { white-space: nowrap; }
  html[lang="en"] .hd .nav-links,
  html[lang="en"] .hd .nav-anchors,
  html[lang="en"] .hd .cta-sm,
  html[lang="en"] .hd .tools,
  html[lang="en"] .hd .tool { flex-shrink: 0; }
  html[lang="en"] .hd .tool { white-space: nowrap; }
  html[lang="en"] .hd .nav-panel,
  html[lang="en"] .hd .nav-links,
  html[lang="en"] .hd .nav-anchors { column-gap: 20px; }
}
@media (max-width: 1439px) and (min-width: 960px) {
  html[lang="en"] .hd .tool.nav-toggle { display: inline-flex; }
  html[lang="en"] .hd .nav-anchors { display: none; }
  html[lang="en"] .hd.is-open .nav-anchors {
    display: flex;
    position: absolute;
    z-index: 40;
    top: calc(100% + 8px);
    right: var(--gutter, 16px);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    min-width: 220px;
    padding: 8px;
    background: var(--bg);
    border: 1px solid var(--line, var(--border));
    border-radius: 8px;
  }
  html[lang="en"] .hd.is-open .nav-anchors a {
    min-height: 40px;
    display: flex;
    align-items: center;
  }
}
@media (min-width: 1440px) {
  html[lang="en"] .hd .nav,
  html[lang="en"] .hd .nav-panel,
  html[lang="en"] .hd .nav-links,
  html[lang="en"] .hd .nav-anchors { column-gap: 12px; }
}
.hd .nav-fold,
.hd .nav-terms-menu { display: none; }
@media (max-width: 1100px) and (min-width: 960px) {
  .hd .tool.nav-toggle { display: inline-flex; }
  .hd .nav-links .nav-terms { display: none; }
  html:not([lang="en"]) .hd.is-open .nav-fold,
  html[lang="en"] .hd.is-open .nav-anchors .nav-terms-menu {
    display: flex;
  }
  html:not([lang="en"]) .hd.is-open .nav-fold {
    position: absolute;
    z-index: 40;
    top: calc(100% + 8px);
    right: var(--gutter, 16px);
    flex-direction: column;
    align-items: stretch;
    min-width: 220px;
    padding: 8px;
    background: var(--bg);
    border: 1px solid var(--line, var(--border));
    border-radius: 8px;
  }
  html:not([lang="en"]) .hd.is-open .nav-fold a,
  html[lang="en"] .hd.is-open .nav-anchors .nav-terms-menu {
    min-height: 40px;
    align-items: center;
    color: var(--fg);
    text-decoration: none;
  }
}
