/* ==========================================================
 * 文件: shared/site-nav.css
 * 版本: 0.1.0 · 更新: 2026-10-24 · 作者: Claude（为李泓锐）
 * 用途: Public 全站统一顶栏（shared/site-nav.js 渲染；每页 HTML 里有一份同结构的静态首帧）。
 *   结构参考 apple.com 全局导航：44px 细栏、毛玻璃深色半透明底、底部极淡分隔线、12–13px 灰字 hover 变白；
 *   品牌左、6 个分类居中、工具区右；悬停后在顶栏下方整宽展开 flyout，页面其余部分轻微变暗。
 *   - 三栏网格左右两栏等宽（minmax(0, 1fr)），中间分类的 x 坐标只取决于窗口宽度，与身份无关
 *   - 颜色只用落地页已有的冰蓝 / 白字三档 / 深海蓝（landing-story.css 同款），不新增颜色 token
 *   - 换页：@view-transition + view-transition-name: site-nav，顶栏不参与淡入淡出，正文淡入
 *   - prefers-reduced-motion：关掉所有过渡、动画和换页动画
 * ========================================================== */

/* ---------- 外壳：fixed，背景用伪元素画，跟着 flyout 一起变高（像苹果那样整块往下长） ---------- */
.site-nav {
  position: fixed;
  inset: 0 0 auto;
  z-index: 70;
  height: 44px;
  font-family: "Inter", -apple-system, "PingFang SC", "Noto Sans SC", sans-serif;
  font-size: 13px;
  letter-spacing: -0.01em;
  color: rgba(255, 255, 255, 0.8);
  view-transition-name: site-nav;
}

.site-nav::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  z-index: -1;
  height: calc(44px + var(--fly-h, 0px));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(6, 10, 28, 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  transition: height 240ms var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)), background 240ms var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
}

.site-nav.is-open::before { background: rgba(6, 10, 28, 0.94); }

/* 不支持毛玻璃的浏览器：实色兜底 */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .site-nav::before { background: #060a1c; }
}

.site-nav :focus-visible {
  outline: 2px solid #8fb8ff;
  outline-offset: 2px;
  border-radius: 6px;
}

.site-nav a { color: inherit; text-decoration: none; }
.site-nav button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

/* ---------- 一行三栏 ---------- */
.site-nav__bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  height: 44px;
  padding: 0 clamp(16px, 3vw, 40px);
}

.site-nav__brand {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  font-family: "General Sans", "Inter", -apple-system, "PingFang SC", sans-serif;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.92);
  transition: color 200ms;
}

.site-nav__brand:hover { color: #fff; }

.site-nav__mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: url("../assets/logo-mark-128.png") center / cover no-repeat;
}

/* ---------- 中间 6 个分类 ---------- */
.site-nav__links { justify-self: center; }

.site-nav__list {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav__item { position: relative; }

.site-nav__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 44px;
  padding: 0 14px;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.8);
  transition: color 200ms;
}

.site-nav__link:hover,
.site-nav__item.is-hot .site-nav__link { color: #fff; }

.site-nav__link[aria-current] { color: #fff; }

/* 当前分类：只有一道细下划线（换页时其他一切不变） */
.site-nav__link[aria-current]::after {
  content: "";
  position: absolute;
  inset: auto 14px 9px;
  height: 1px;
  background: currentColor;
  opacity: 0.85;
}

/* 键盘用的小箭头：平时看不见，分类获得焦点时出现在文字右边；绝对定位，不占位置 */
.site-nav__chev {
  position: absolute;
  top: 50%;
  right: -4px;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms;
}

.site-nav__item:focus-within .site-nav__chev { opacity: 1; pointer-events: auto; }
.site-nav__chev-icon { width: 12px; height: 12px; transition: transform 240ms var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)); }
.site-nav__chev[aria-expanded="true"] .site-nav__chev-icon { transform: rotate(180deg); }

/* ---------- 右侧工具区：固定宽度，靠右排 ---------- */
.site-nav__tools {
  justify-self: end;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  width: min(264px, 100%);
}

.site-nav__btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.8);
  transition: color 200ms, background 200ms;
}

.site-nav__btn:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.site-nav__icon { width: 16px; height: 16px; }

/* 身份槽：登录 / 头像 / 分享 / 模式切换 */
.site-nav__id {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.site-nav__signin {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  transition: border-color 200ms, color 200ms;
}

.site-nav__signin:hover { color: #fff; border-color: rgba(143, 184, 255, 0.7); }

.site-nav__me {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 4px;
  border-radius: 8px;
  white-space: nowrap;
}

.site-nav__me:hover { background: rgba(255, 255, 255, 0.06); }

.site-nav__avatar {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  color: #06051a;
  background: radial-gradient(circle at 35% 30%, #fff, #8fb8ff 60%, #3d6bff);
}

.site-nav__tier {
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid rgba(143, 184, 255, 0.35);
  font-size: 11px;
  font-weight: 600;
  color: #8fb8ff;
}

/* 账户小菜单 */
.site-nav__account {
  position: absolute;
  top: 48px;
  right: clamp(16px, 3vw, 40px);
  display: grid;
  gap: 4px;
  width: 240px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(8, 12, 32, 0.96);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}

.site-nav__account[hidden] { display: none; }
.site-nav__account-name { font-size: 13px; color: #fff; }
.site-nav__account-tier { margin-bottom: 6px; font-size: 12px; color: #8fb8ff; }

.site-nav__account-link {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 13px;
  text-align: left;
  transition: background 200ms, color 200ms;
}

.site-nav__account-link:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }

.site-nav__mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  margin-top: 6px;
  padding: 2px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.site-nav__mode-btn {
  display: grid;
  place-items: center;
  min-height: 32px;
  border-radius: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

.site-nav__mode-btn[aria-current="true"] { color: #fff; background: rgba(143, 184, 255, 0.18); }

/* ---------- flyout：整宽，在顶栏下方展开 ---------- */
.site-fly {
  position: absolute;
  top: 44px;
  left: 0;
  right: 0;
  height: var(--fly-h, 0px);
  overflow: hidden;
  transition: height 240ms var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
}

.site-fly__inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 36px clamp(16px, 3vw, 40px) 56px;
  opacity: 0;
  transition: opacity 160ms;
}

.site-nav.is-open .site-fly__inner { opacity: 1; transition-duration: 0ms; }

.site-fly__cols {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 40px;
}

/* 每次换内容（新元素插入）都从上方 8px 淡入 */
.site-nav.is-open .site-fly__cols { animation: site-fly-in 240ms var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) both; }

@keyframes site-fly-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

.site-fly__head {
  margin: 0 0 14px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
}

.site-fly__list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-fly__link {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  transition: color 200ms;
}

.site-fly__link:hover { color: #fff; }

.site-fly__col--big .site-fly__list { gap: 8px; }

.site-fly__col--big .site-fly__link {
  font-family: "Satoshi", "General Sans", "Inter", -apple-system, "PingFang SC", sans-serif;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: rgba(255, 255, 255, 0.92);
}

html[lang="zh-CN"] .site-fly__col--big .site-fly__link { font-family: "PingFang SC", "Noto Sans SC", sans-serif; letter-spacing: 0; }

.site-fly__col--big .site-fly__link:hover { color: #8fb8ff; }

/* 页面其余部分轻微变暗（只压暗不模糊；遮罩在顶栏下面，不挡点击） */
.site-scrim {
  position: fixed;
  inset: 0;
  z-index: 69;
  background: rgba(2, 4, 14, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
}

.site-scrim.is-on { opacity: 1; }

/* ---------- 汉堡 + 全屏面板（834px 以下） ---------- */
.site-nav__burger {
  display: none;
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

.site-nav__burger-line {
  position: absolute;
  left: 11px;
  width: 14px;
  height: 1.5px;
  border-radius: 1px;
  background: currentColor;
  transition: transform 240ms var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
}

.site-nav__burger-line:first-child { top: 14px; }
.site-nav__burger-line:last-child { top: 20px; }
.site-nav.is-sheet .site-nav__burger-line:first-child { transform: translateY(3px) rotate(45deg); }
.site-nav.is-sheet .site-nav__burger-line:last-child { transform: translateY(-3px) rotate(-45deg); }

.site-sheet {
  position: fixed;
  inset: 44px 0 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 24px 48px;
  background: #04071a;
}

.site-sheet[hidden] { display: none; }
.site-sheet:not([hidden]) { animation: site-sheet-in 240ms var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) both; }

@keyframes site-sheet-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

html.site-sheet-open { overflow: hidden; }

.site-sheet__id {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.site-sheet__id .site-nav__mode { margin-top: 0; min-width: 200px; }

.site-sheet__primary,
.site-sheet__chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 14px;
}

.site-sheet__cat { border-bottom: 1px solid rgba(255, 255, 255, 0.06); }

.site-sheet__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
}

.site-sheet__cat-link {
  font-family: "Satoshi", "General Sans", "Inter", -apple-system, "PingFang SC", sans-serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: rgba(255, 255, 255, 0.92);
}

.site-sheet__cat-link[aria-current] { color: #8fb8ff; }

.site-sheet__toggle {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
}

.site-sheet__toggle .site-nav__chev-icon { width: 16px; height: 16px; }
.site-sheet__toggle[aria-expanded="true"] .site-nav__chev-icon { transform: rotate(180deg); }

.site-sheet__links {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0 0 16px;
  list-style: none;
}

.site-sheet__links[hidden] { display: none; }

.site-sheet__link {
  display: flex;
  align-items: center;
  min-height: 40px;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.72);
}

.site-sheet__link--big { font-size: 17px; font-weight: 600; color: rgba(255, 255, 255, 0.9); }

.site-sheet__lang {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-top: 16px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.72);
}

/* ---------- 响应式 ---------- */
/* 1080 以下：分享和模式切换收进头像菜单（身份槽不变宽，中间分类位置照旧只看窗口宽度） */
@media (max-width: 1079px) {
  .site-nav__btn--wide { display: none; }
}

@media (max-width: 833px) {
  .site-nav__links,
  .site-fly,
  .site-nav__account,
  .site-nav__id,
  .site-nav__tools [data-action="toggle-lang"] { display: none; }
  .site-nav__tools { width: auto; }
  .site-nav__burger { display: inline-block; }
  /* 品牌 | 搜索 | 汉堡 */
  .site-nav__bar { grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px; }
}

@media (min-width: 834px) {
  .site-sheet { display: none !important; }
}

/* nav-map 里的演示渲染：不 fixed，不参与换页动画 */
.site-nav--demo {
  position: relative;
  z-index: auto;
  view-transition-name: none;
}

/* ---------- 换页：顶栏不闪，正文淡入（浏览器不支持就正常跳转） ---------- */
@view-transition { navigation: auto; }

::view-transition-group(site-nav) { animation: none; }
::view-transition-old(site-nav) { display: none; }
::view-transition-new(site-nav) { animation: none; }
::view-transition-old(root) { animation: 160ms cubic-bezier(0.4, 0, 1, 1) both site-vt-out; }
::view-transition-new(root) { animation: 240ms cubic-bezier(0, 0, 0.2, 1) both site-vt-in; }

@keyframes site-vt-out { to { opacity: 0; } }
@keyframes site-vt-in { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .site-nav *,
  .site-nav::before,
  .site-scrim,
  .site-sheet { transition: none !important; animation: none !important; }
}
