/* ========================================================================
   基础重置与排版
   ======================================================================== */
@font-face {
  font-family: "Maple Mono CN Common SC";
  src: url("/static/fonts/MapleMono-CN-Common-SC.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Maple Mono CN Common TC";
  src: url("/static/fonts/MapleMono-CN-Common-TC.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Maple Mono CN";
  src: url("/static/fonts/MapleMono-CN-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Maple Mono CN Locale Menu";
  src: url("/static/fonts/MapleMono-CN-LocaleMenu.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; }

/* 主题切换：用 View Transitions 整屏交叉淡化（theme.js 触发），统一不割裂 */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: .45s;
  animation-timing-function: ease;
}
/* 切换瞬间禁掉元素自身过渡，避免悬浮元素实时渐变与整屏淡化不同步 */
.vt-active *, .vt-active *::before, .vt-active *::after {
  transition: none !important;
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  transition: background-color .3s var(--ease), color .3s var(--ease);
  min-height: 100vh;
}

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 700; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { max-width: 100%; display: block; }

button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

code, kbd, .mono { font-family: var(--font-mono); }

::selection { background: var(--accent-soft); }

/* 滚动条（夜间 TUI 感） */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 99px;
}

/* 可访问性：隐藏但保留给读屏 */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* 段落标题节奏 */
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 .4em;
}

.section-title {
  font-size: var(--fs-xl);
  margin: 0 0 var(--space-5);
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
}
.section-title .count {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-weight: 400;
}

.muted { color: var(--text-muted); }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ========================================================================
   布局外壳：透明顶栏 + 全局浮动按钮
   ======================================================================== */
/* 顶部不做横条、也不占位：品牌在左，独立悬浮入口在右。 */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: var(--z-toolbar);
  width: 100%; max-width: 100vw; min-width: 0;
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: transparent;
  pointer-events: none;
  transition: opacity .25s var(--ease);
}
.topbar .topbar__identity, .topbar .brand, .topbar .topnav, .topbar .topbar__tools,
.topbar .topbar__navigation { pointer-events: auto; }
/* 向下滚动时淡出，让贴顶的搜索栏接管顶部；回到顶部再出现 */
.topbar.is-hidden { opacity: 0; }
.topbar.is-hidden .topbar__identity, .topbar.is-hidden .brand, .topbar.is-hidden .topnav,
.topbar.is-hidden .topbar__tools, .topbar.is-hidden .topbar__navigation { pointer-events: none; }

.topbar__identity {
  display: flex; align-items: stretch; flex: 0 0 auto; min-width: 0;
}

/* logo+站名：平时轻量悬浮，hover 才显出按钮感 */
.brand {
  display: inline-flex; align-items: center; gap: var(--space-2);
  color: var(--text); font-weight: 700;
  /* 四周内边距一致(6px)，logo 到外框上下左右等距；
     圆角矩形与 logo 圆角(34px 显示时约 2.3px)同心：外框圆角 ≈ 2.3 + 6 ≈ 9px */
  padding: 6px; border-radius: var(--radius-sm);
  /* 持久玻璃底，和下方内容区隔开，避免悬浮 logo 与内容重叠看不清 */
  background: rgb(var(--glass) / .72); backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  box-shadow: 0 2px 12px rgb(var(--shadow) / .12);
  transition: background-color .15s var(--ease), border-color .15s var(--ease), transform .08s var(--ease);
}
.brand:hover { text-decoration: none; background: var(--accent-soft); border-color: var(--accent); }
.brand:active { transform: translateY(1px); }
.brand__logo { width: 34px; height: 34px; display: block; object-fit: contain; border-radius: 0; }
.brand__text { display: flex; flex-direction: column; gap: 1px; line-height: 1.05; }
.brand__name { font-size: var(--fs-base); }
.brand__tagline { font-size: 11px; color: var(--text-muted); font-weight: 500; white-space: nowrap; }

.topbar__tools {
  display: flex; align-items: center; justify-content: flex-end;
  flex: 1 1 auto; min-width: 0; gap: 0; margin-left: auto;
}
.topbar__navigation {
  display: flex; align-items: center; justify-content: flex-end;
  flex: 1 1 auto; min-width: 0;
}
.topbar__tools .fab {
  width: 40px; height: 40px;
  background: rgb(var(--glass) / .72); backdrop-filter: blur(10px);
  border: 1px solid var(--line); box-shadow: 0 2px 12px rgb(var(--shadow) / .12);
}
.topbar__tools .fab:hover { border-color: var(--accent); background: var(--accent-soft); }
.topbar__tools .fab svg { width: 17px; height: 17px; }
.topbar__tools .about-link svg { width: 20px; height: 20px; }
.about-link.is-active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* 开发板分类：与右侧工具同层，但保留独立分组和横向滚动能力。 */
.topnav {
  display: flex; align-items: center; gap: 6px;
  min-width: 0;
}
.top-categories {
  overflow: visible;
}
.top-categories::-webkit-scrollbar { display: none; }
.topnav__link {
  display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto;
  height: 40px; padding: 0 14px; border-radius: var(--radius-pill);
  color: var(--text-muted); font-size: var(--fs-sm); font-weight: 600;
  background: rgb(var(--glass) / .72); backdrop-filter: blur(10px);
  border: 1px solid var(--line); box-shadow: 0 2px 12px rgb(var(--shadow) / .12);
  transition: color .15s var(--ease), border-color .15s var(--ease), background-color .15s var(--ease);
}
.topnav__link svg { width: 18px; height: 18px; }
.topnav__link:hover { color: var(--text); border-color: var(--accent); text-decoration: none; }
.topnav__link.is-active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.top-category__item[aria-pressed="true"] {
  border-color: currentColor;
  background: var(--accent-soft);
}
.topbar__actions {
  display: flex; align-items: center; gap: var(--space-2); flex: 0 0 auto;
  margin-left: var(--space-4);
}
.mobile-about-link, .topbar__tools .site-menu-toggle { display: none; }
.menu-toggle__icon {
  width: 18px; height: 14px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.menu-toggle__icon > span {
  display: block; width: 100%; height: 2px; border-radius: 99px;
  background: currentColor;
  transform-origin: center;
  transition: transform .18s var(--ease), opacity .18s var(--ease);
}
.site-menu-toggle[aria-expanded="true"] .menu-toggle__icon > span:first-child {
  transform: translateY(6px) rotate(45deg);
}
.site-menu-toggle[aria-expanded="true"] .menu-toggle__icon > span:nth-child(2) { opacity: 0; }
.site-menu-toggle[aria-expanded="true"] .menu-toggle__icon > span:last-child {
  transform: translateY(-6px) rotate(-45deg);
}

/*
 * 分类导航按实际可用宽度折叠：theme.js 在完整分类即将被裁切时添加
 * is-compact-menu。中等宽度只收起分类，品牌文字继续完整显示；真正的
 * 窄屏再由下方 760px/640px 规则逐级精简品牌。
 */
.topbar.is-compact-menu .topbar__tools { flex: 0 0 auto; }
.topbar.is-compact-menu .topbar__identity {
  flex: 0 1 auto; min-width: 0;
  align-items: center; overflow: hidden;
}
.topbar.is-compact-menu .topbar__identity .brand { flex: 0 0 auto; }
.topbar.is-compact-menu .topbar__navigation {
  position: absolute; top: calc(100% + 2px); left: var(--space-4); right: var(--space-4);
  display: block; max-height: calc(100dvh - 76px); padding: 8px;
  overflow-y: auto; overscroll-behavior: contain;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: rgb(var(--glass) / .96); backdrop-filter: blur(18px);
  box-shadow: 0 16px 40px rgb(var(--shadow) / .2);
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(-6px) scale(.985); transform-origin: top right;
  transition: opacity .16s var(--ease), transform .16s var(--ease), visibility .16s;
}
.topbar.is-compact-menu.is-menu-open { z-index: calc(var(--z-toolbar) + 10); }
.topbar.is-compact-menu.is-menu-open .topbar__navigation {
  opacity: 1; visibility: visible; pointer-events: auto;
  transform: translateY(0) scale(1);
}
.topbar.is-compact-menu .top-categories {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px; width: 100%; overflow: visible;
}
.topbar.is-compact-menu .top-category__item,
.topbar.is-compact-menu .mobile-about-link {
  width: 100%; height: 44px; justify-content: flex-start;
  padding-inline: 14px; border-radius: var(--radius-sm); box-shadow: none;
  background: transparent; backdrop-filter: none;
}
.topbar.is-compact-menu .mobile-about-link {
  display: inline-flex; margin-top: 6px;
  border-color: transparent;
}
.topbar.is-compact-menu .mobile-about-link svg { width: 18px; height: 18px; }
.topbar.is-compact-menu .site-menu-toggle { display: grid; place-items: center; }
.topbar.is-compact-menu .topbar-about-link { display: none; }
.topbar.is-compact-menu .topbar__actions { gap: 6px; margin-left: 0; }
.topbar.is-compact-menu .topbar__tools .fab { width: 40px; height: 40px; }

@media (max-width: 1100px) {
  .top-categories {
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none;
    overscroll-behavior-inline: contain;
  }
  /* 横向滚动容器会裁切投影；窄屏直接用清晰边框，避免阴影连成灰条。 */
  .top-category__item { box-shadow: none; }
}

/* 主题图标切换 */
#theme-toggle .i-sun { display: none; }
#theme-toggle .i-moon { display: block; }
:root[data-theme="night"] #theme-toggle .i-sun { display: block; }
:root[data-theme="night"] #theme-toggle .i-moon { display: none; }

/* 国际化入口：统一地球图标，点击展开语言菜单。 */
.locale-switch { position: relative; display: flex; }
.locale-toggle {
  color: var(--text-muted);
}
.locale-glyph { width: 21px; height: 21px; display: block; }
.locale-menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: max-content; min-width: 174px; max-width: calc(100vw - 2 * var(--space-2));
  padding: 5px; border: 1px solid var(--line); border-radius: var(--radius);
  background: rgb(var(--glass) / .94); backdrop-filter: blur(14px);
  box-shadow: 0 12px 32px rgb(var(--shadow) / .18);
}
.topbar.is-locale-menu-open { z-index: calc(var(--z-toolbar) + 10); }
.locale-menu[hidden] { display: none; }
.locale-menu button {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text); text-align: left; cursor: pointer;
  white-space: nowrap;
}
.locale-menu button > span { flex: 0 0 auto; white-space: nowrap; }
/* 英文页会重定义全局字体；菜单中的简/繁中文始终与中文页一致。 */
.locale-menu button[data-locale="zh-CN"],
.locale-menu button[data-locale="zh-TW"] {
  font-family: "Maple Mono CN Locale Menu", "Maple Mono CN", ui-sans-serif, system-ui, "PingFang SC",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-weight: 400;
}
.locale-menu button[data-locale="zh-CN"] small,
.locale-menu button[data-locale="zh-TW"] small {
  font-family: "Maple Mono CN Locale Menu", "Maple Mono CN", "Maple Mono", ui-monospace, monospace;
  font-weight: 400;
}
.locale-menu button:hover, .locale-menu button[aria-current="true"] { background: var(--accent-soft); }
.locale-menu button small {
  flex: 0 0 auto; min-width: 46px; color: var(--text-muted); font-family: var(--font-mono);
  text-align: right;
}

.site-footer {
  display: flex; justify-content: center; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  padding: var(--space-6) var(--space-5) var(--space-5);
  color: var(--text-muted); font-size: var(--fs-xs); line-height: 1.6;
}
.site-footer a { color: inherit; }
.site-footer span + span::before { content: "·"; margin-right: var(--space-3); color: var(--line); }
body[data-page="home"] .site-footer {
  position: fixed; left: 50%; bottom: 8px; transform: translateX(-50%); z-index: 3;
  padding: 0 var(--space-3); white-space: nowrap;
}

/* 全局回到顶部 */
.fab--totop { position: fixed; right: var(--space-5); bottom: var(--space-5); z-index: calc(var(--z-fab) + 1); }
.fab--totop[hidden] { display: none; }

@media (max-width: 760px) {
  .topbar__tools { flex: 0 0 auto; }
  .topbar__identity {
    flex: 1 1 auto; min-width: 0;
    align-items: center; overflow: hidden;
  }
  .topbar__identity .brand { flex: 0 0 auto; }
  .brand__text { display: none; }
  .topbar__navigation {
    position: absolute; top: calc(100% + 2px); left: var(--space-4); right: var(--space-4);
    display: block; max-height: calc(100dvh - 76px); padding: 8px;
    overflow-y: auto; overscroll-behavior: contain;
    border: 1px solid var(--line); border-radius: var(--radius);
    background: rgb(var(--glass) / .96); backdrop-filter: blur(18px);
    box-shadow: 0 16px 40px rgb(var(--shadow) / .2);
    opacity: 0; visibility: hidden; pointer-events: none;
    transform: translateY(-6px) scale(.985); transform-origin: top right;
    transition: opacity .16s var(--ease), transform .16s var(--ease), visibility .16s;
  }
  .topbar.is-menu-open { z-index: calc(var(--z-toolbar) + 10); }
  .topbar.is-menu-open .topbar__navigation {
    opacity: 1; visibility: visible; pointer-events: auto;
    transform: translateY(0) scale(1);
  }
  .top-categories {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px; width: 100%; overflow: visible;
  }
  .top-category__item, .mobile-about-link {
    width: 100%; height: 44px; justify-content: flex-start;
    padding-inline: 14px; border-radius: var(--radius-sm); box-shadow: none;
    background: transparent; backdrop-filter: none;
  }
  .mobile-about-link {
    display: inline-flex; margin-top: 6px;
    border-color: transparent;
  }
  .mobile-about-link svg { width: 18px; height: 18px; }
  .topbar__tools .site-menu-toggle { display: grid; place-items: center; }
  .topbar__actions .topbar-about-link { display: none; }
  .topbar__actions { gap: 6px; margin-left: 0; }
  .topbar__tools .fab { width: 40px; height: 40px; }
}

@media (max-width: 640px) {
  .topbar { padding: var(--space-2) var(--space-4); gap: var(--space-2); }
  /* 手机窄屏：logo 使用轻量无底样式。 */
  .brand {
    padding: 4px; background: none; backdrop-filter: none;
    border: 1px solid transparent; box-shadow: none;
  }
  .brand:hover, .brand:focus-visible {
    background: var(--accent-soft); border-color: var(--accent);
  }
  .fab--totop { right: var(--space-4); bottom: calc(var(--space-4) + 56px); }
  /* 备案信息不再固定悬浮（会各种遮挡），改为跟随内容排在底部 */
  body[data-page="home"] .site-footer {
    position: static; left: auto; bottom: auto; transform: none;
    white-space: normal; padding: var(--space-6) var(--space-4);
  }
}

@media (max-width: 360px) {
  .topbar { padding-inline: var(--space-2); }
  .topbar__navigation { left: var(--space-2); right: var(--space-2); }
  .topbar__actions { gap: 5px; }
}
