/* ==========================================================================
   拾贝 LinkMaw · 全站统一外壳（页头 / 页脚）
   命名空间 sh-，只依赖 tokens.css 的变量，不干扰 landing / site / docs 三套页面样式。
   使用方：官网 10 页 + 教程站 53 页。
   ========================================================================== */

/* ── 悬浮胶囊导航 ─────────────────────────────────────────────────────
   固定在视口顶部、离边 12px，宽度与正文容器对齐，半透明 + 毛玻璃。
   内容滚动时从它下面穿过，是整站最明显的「同一套壳」信号。 */

.sh-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: var(--sh-off) var(--s-300) 0;
  pointer-events: none;
}

.sh-bar {
  position: relative;
  z-index: 2; /* 抽屉打开时胶囊要压在抽屉之上，否则汉堡变成的 × 会被盖住点不到 */
  pointer-events: auto;
  max-width: var(--wrap);
  margin: 0 auto;
  height: var(--sh-h);
  /* 三栏 1fr / auto / 1fr：品牌与 CTA 各占一侧等宽，导航永远落在胶囊正中。
     用 flex 时品牌比 CTA 宽，导航会被整体推右（实测偏 22px），右侧留白明显。 */
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: var(--s-300);
  padding: 0 var(--s-75) 0 var(--s-200);
  border: 1px solid rgba(10, 10, 10, 0.08);
  border-radius: var(--r-xl);
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow: var(--shadow-1);
  transition: background-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

/* 滚过首屏后稍微压实一点，让「浮层」的感觉更明确 */
.sh-bar.is-scrolled {
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-2);
}

html[data-theme='dark'] .sh-bar {
  border-color: #272727;
  background: rgba(24, 24, 24, 0.8);
}

html[data-theme='dark'] .sh-bar.is-scrolled {
  background: rgba(24, 24, 24, 0.94);
}

/* 阅读进度：贴视口顶边的 2px 线，长文档里给一个位置感 */
.sh-prog {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--brand-2);
  transform: scaleX(var(--sh-p, 0));
  transform-origin: 0 50%;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
  pointer-events: none;
}

.sh-bar.is-scrolled .sh-prog {
  opacity: 1;
}

/* 品牌 */
.sh-brand {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: var(--s-75);
  flex: none;
  color: var(--ink);
}

.sh-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  flex: none;
}

.sh-word {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: var(--t-base);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

.sh-word em {
  font-style: normal;
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* 主导航 */
.sh-nav {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: var(--s-25);
}

.sh-nav a {
  position: relative;
  padding: var(--s-75) var(--s-100);
  border-radius: var(--r-md);
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease),
    background-color var(--dur-fast) var(--ease);
}

.sh-nav a:hover {
  color: var(--ink);
  background: rgba(10, 10, 10, 0.045);
}

html[data-theme='dark'] .sh-nav a:hover {
  background: rgba(255, 255, 255, 0.07);
}

.sh-nav a.sh-on {
  color: var(--ink);
  font-weight: 600;
}

/* 当前页用一枚荧光绿小点标记，比整块底色更轻 */
.sh-nav a.sh-on::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 1px;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: var(--r-full);
  background: var(--brand-2);
}

/* 主行动按钮：外圆角 16、与栏边间距 8，内圆角取 16 − 8 = 8 */
.sh-cta {
  justify-self: end;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  padding: var(--s-75) var(--s-100);
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--bg) !important;
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease),
    opacity var(--dur-fast) var(--ease);
}

.sh-cta:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

.sh-cta:active {
  transform: scale(0.98);
}

/* 汉堡：两道线在开合之间做位移动画，不是直接换图标 */
.sh-burger {
  display: none;
  position: relative;
  width: 40px;
  height: 40px;
  padding: 0;
  flex: none;
  border: 1px solid rgba(10, 10, 10, 0.1);
  border-radius: var(--r-md);
  background: transparent;
  cursor: pointer;
}

html[data-theme='dark'] .sh-burger {
  border-color: #313131;
}

.sh-burger span {
  position: absolute;
  left: 11px;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--ink);
  transition: transform var(--dur) var(--ease);
}

.sh-burger span:nth-child(1) {
  top: 17px;
}

.sh-burger span:nth-child(2) {
  top: 23px;
}

.sh-burger[aria-expanded='true'] span:nth-child(1) {
  transform: translateY(3px) rotate(45deg);
}

.sh-burger[aria-expanded='true'] span:nth-child(2) {
  transform: translateY(-3px) rotate(-45deg);
}

/* ── 移动端整屏抽屉 ─────────────────────────────────────────────────── */

.sh-drawer {
  position: fixed;
  inset: 0;
  z-index: 1;
  padding: calc(var(--sh-total) + var(--s-300)) var(--s-300) var(--s-600);
  display: flex;
  flex-direction: column;
  /* .sh-top 整体是 pointer-events: none（为了不挡住正文点击），抽屉是它的子元素，
     必须显式打开事件，否则抽屉里看着能点、实际全部穿透到下面的页面。 */
  pointer-events: auto;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  backdrop-filter: blur(24px) saturate(150%);
  overflow-y: auto;
}

.sh-drawer[hidden] {
  display: none;
}

.sh-drawer nav {
  display: flex;
  flex-direction: column;
}

.sh-drawer nav a {
  padding: var(--s-200) 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--t-2xl);
  line-height: var(--lh-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  opacity: 0;
  transform: translateY(24px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.sh-drawer nav a.sh-on {
  color: var(--brand-ink);
}

.sh-drawer.is-open nav a {
  opacity: 1;
  transform: translateY(0);
}

.sh-drawer .sh-cta {
  margin-top: var(--s-400);
  min-height: 48px;
  font-size: var(--t-base);
  border-radius: var(--r-lg);
  opacity: 0;
  transform: translateY(24px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.sh-drawer.is-open .sh-cta {
  opacity: 1;
  transform: translateY(0);
}

.sh-drawer-foot {
  margin-top: var(--s-300);
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
  color: var(--muted);
}

/* 抽屉打开时锁住页面滚动，避免背景跟着滑 */
html.sh-locked,
html.sh-locked body {
  overflow: hidden;
}

/* ── 页脚 ───────────────────────────────────────────────────────────── */

.sh-bot {
  border-top: 1px solid var(--line);
  background: var(--bg);
  margin-top: var(--s-900);
}

.sh-bin {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--s-300);
}

.sh-fgrid {
  display: grid;
  /* 四列必须给下限：用 minmax(0,1fr) 时列宽可以被压到 0，
     1180 容器里品牌列 1.6fr 又会抢走大头，剩下四列不够放「流媒体下载」
     这种五字标题，就会折成「流媒体下 / 载」两行。 */
  grid-template-columns: minmax(200px, 1.35fr) repeat(4, minmax(118px, 1fr));
  gap: var(--s-600) var(--s-500);
  padding: var(--s-800) 0 var(--s-600);
}

.sh-fbrand .sh-brand {
  margin-bottom: var(--s-200);
}

.sh-fbrand .sh-tag {
  margin-bottom: var(--s-75);
  font-size: var(--t-xl);
  line-height: var(--lh-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.sh-fbrand p {
  margin: 0;
  max-width: 32ch;
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
  color: var(--muted);
}

.sh-col h4 {
  margin: 0 0 var(--s-200);
  font-size: var(--t-xs);
  line-height: var(--lh-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.sh-col ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sh-col li {
  margin: 0;
}

.sh-col a {
  display: block;
  /* 中文没有词边界，列一窄就断在字中间。宁可整条不换行，
     靠上面的 minmax 下限保证列宽够用。 */
  white-space: nowrap;
  padding: var(--s-50) 0;
  font-size: var(--t-sm);
  line-height: var(--lh-sm);
  color: var(--ink-2);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}

.sh-col a:hover {
  color: var(--ink);
  transform: translateX(2px);
}

.sh-bbar {
  border-top: 1px solid var(--line);
}

.sh-brow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-300);
  padding: var(--s-300) var(--s-300);
  font-size: var(--t-xs);
  line-height: var(--lh-xs);
  color: var(--muted);
}

.sh-note {
  text-align: right;
}

/* 构建版本号：只用于确认「看到的是新版还是缓存」，所以故意压到最低对比度 */
.sh-ver {
  margin-left: var(--s-100);
  padding: 1px 6px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--f-mono);
  font-size: 11px;
  font-style: normal;
  letter-spacing: 0;
  vertical-align: 1px;
}

/* ── 响应式 ─────────────────────────────────────────────────────────── */

@media (max-width: 1120px) {
  .sh-bar {
    gap: var(--s-200);
  }

  .sh-nav a {
    padding: var(--s-75) var(--s-75);
  }
}

@media (max-width: 980px) {
  /* 只收导航。CTA 在这个宽度还放得下，一起收掉的话胶囊中间会空一大片，
     主按钮也没了入口——900 宽的笔记本和平板正好落在这档。 */
  .sh-nav {
    display: none;
  }

  .sh-bar {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .sh-burger {
    display: block;
    justify-self: end;
    margin-left: auto;
  }

  .sh-fgrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s-500) var(--s-300);
  }

  .sh-fbrand {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .sh-top {
    padding: var(--sh-off) var(--s-200) 0;
  }

  .sh-bar {
    height: 56px;
    padding: 0 var(--s-75) 0 var(--s-100);
    border-radius: var(--r-lg);
  }

  .sh-word em {
    display: none;
  }

  .sh-brow {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--s-75);
    padding: var(--s-300) var(--s-200);
  }

  .sh-note {
    text-align: left;
  }

  .sh-bin {
    padding: 0 var(--s-200);
  }

  .sh-bot {
    margin-top: var(--s-700);
  }
}

@media (max-width: 560px) {
  .sh-fgrid {
    grid-template-columns: minmax(0, 1fr);
  }

  /* 到这一档三个元素并排就挤了，主按钮收进抽屉（抽屉底部本来就有同一个 CTA） */
  .sh-bar > .sh-cta {
    display: none;
  }

  .sh-bar {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}
