/* 全站复用同一页头，固定时保留原高度占位，避免正文跳动。 */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  margin: auto;
  padding: 18px var(--page-gutter);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: block;
  flex: none;
  width: 242px;
  max-width: 100%;
  color: var(--ink);
  line-height: 1;
  text-decoration: none;
}
.brand-logo {
  display: block;
  width: 100%;
  height: auto;
}
.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.site-header nav a {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 6px 10px;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 550;
  text-decoration: none;
  transition:
    color 160ms ease,
    background-color 160ms ease;
}
.site-header nav a[aria-current] {
  color: var(--accent);
}
.site-header nav a[aria-current]::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 24px;
  height: 2px;
  border-radius: 1px;
  background: var(--accent);
  transform: translateX(-50%);
}
@media (hover: hover) {
  .site-header nav a:hover {
    color: var(--brand-action-hover);
    background: var(--brand-tint);
  }
}
.site-header nav a:focus-visible {
  color: var(--brand-action-hover);
  background: var(--brand-tint);
  outline: 3px solid var(--brand-focus);
  outline-offset: 4px;
}
@media (prefers-reduced-motion: reduce) {
  .site-header nav a {
    transition: none;
  }
}
@media (max-width: 900px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }
  .site-header nav {
    gap: 10px 4px;
  }
}
/* v4横版图左侧约有129/2172透明留白；此补偿属于本站品牌适配。 */
.brand-logo,
.footer-brand img {
  transform: translateX(-5.93923%);
}
.site-header-space {
  display: none;
}
@media screen and (min-width: 601px) {
  html {
    scroll-padding-top: 84px;
  }
  body[data-page] .skip {
    position: fixed;
    z-index: 30;
  }
  body.has-compact-header .site-header-space {
    display: block;
    height: var(--site-header-height);
  }
  body[data-page].has-compact-header .site-header {
    position: fixed;
    inset: 0 0 auto;
    z-index: 20;
    max-width: none;
    flex-direction: row;
    align-items: center;
    gap: 24px;
    padding: 6px
      max(var(--page-gutter), calc((100% - var(--page-max-width)) / 2 + var(--page-gutter)));
    background: var(--white);
    border-color: var(--line);
    box-shadow: 0 3px 14px #5e231209;
  }
  body[data-page].has-compact-header .brand {
    width: 156px;
  }
  body.has-compact-header .site-header nav {
    flex-wrap: nowrap;
    min-width: 0;
    overflow-x: auto;
  }
  body.has-compact-header .site-header nav a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 6px 10px;
    white-space: nowrap;
    flex-shrink: 0;
  }
}
@media screen and (min-width: 601px) and (max-width: 900px) {
  body[data-page].has-compact-header .brand {
    width: 135px;
  }
  body.has-compact-header .site-header nav {
    gap: 4px;
  }
  body.has-compact-header .site-header nav a {
    font-size: 12px;
  }
}

/* 长详情的目录留在导航下方；短视口下允许整个目录滚动。 */
@media screen and (min-width: 801px) {
  .detail-nav,
  .toc {
    top: 84px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
  }
  .detail-nav nav {
    max-height: none;
    overflow: visible;
  }
}
@media screen and (max-width: 600px) {
  html {
    scroll-padding-top: 104px;
  }
  body[data-page] .site-header {
    position: sticky;
    top: -76px;
    z-index: 20;
    max-width: none;
    padding: 10px var(--page-gutter) 0;
    gap: 6px;
    background: var(--white);
  }
  body[data-page] .brand {
    width: 180px;
    height: 60px;
  }
  body[data-page] .site-header nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    min-height: 88px;
    gap: 0 12px;
  }
  body[data-page] .site-header nav a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 6px 4px;
    font-size: 12px;
    white-space: nowrap;
    justify-content: center;
  }
  body[data-page] .skip {
    position: fixed;
    z-index: 30;
  }
}
@media screen and (max-width: 360px) {
  body[data-page] .site-header nav a {
    font-size: 11px;
  }
}
