/* ============================================================================
 * 基础层：重置 + 排版基调
 * ----------------------------------------------------------------------------
 * 全站字体基准在这里定下：默认 Light 300、正文行高 1.85。
 * 标题才用 Thin 100 —— 字重反差只出现在「标题 vs 正文」这一处，
 * 其余层次一律交给字号与留白。
 * ==========================================================================*/

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

html {
  /* 锚点跳转留出固定页头的高度，否则标题会被页头盖住 */
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--sp-5));
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--c-paper);
  color: var(--c-ink);

  font-family: var(--f-sans);
  font-weight: var(--fw-light);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  letter-spacing: var(--ls-body);

  /* 中文在细字重下尤其依赖抗锯齿，否则笔画发虚 */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;

  /* 防止固定页头遮挡时的横向抖动 */
  overflow-x: hidden;
}

/* ---------------------------------------------------------------- 标题 */

h1, h2, h3, h4 {
  margin: 0;
  font-weight: var(--fw-thin);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-title);
  /* 中文大标题避免出现「孤字换行」 */
  text-wrap: balance;
}

h1 { font-size: var(--fs-display); letter-spacing: var(--ls-display); }
h2 { font-size: var(--fs-title); }
h3 { font-size: var(--fs-h3); font-weight: var(--fw-light); line-height: var(--lh-snug); }

p {
  margin: 0;
  /* 中文长段落用 pretty 可显著减少尾行孤字 */
  text-wrap: pretty;
}

/* ---------------------------------------------------------------- 链接 */

a {
  color: inherit;
  text-decoration: none;
  /* 下划线用极细的 border 实现，比 text-decoration 更可控 */
  transition: border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              opacity var(--dur-fast) var(--ease-out);
}

/* 正文内联链接保留下划线，卡片/导航链接各自在 sections.css 中覆盖 */
.link-underline {
  border-bottom: 1px solid var(--c-rule-strong);
  padding-bottom: 1px;
}
.link-underline:hover { border-color: var(--c-ink); }

/* ------------------------------------------------------------ 语义列表 */

dl, dd, dt { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

/* ---------------------------------------------------------- 媒体与表单 */

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

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* ---------------------------------------------------------- 焦点可见性 */
/* 只在键盘导航时显示焦点圈，鼠标点击不显示 —— 保持视觉干净但不牺牲可达性 */

:focus { outline: none; }

:focus-visible {
  outline: 1px solid var(--c-ink);
  outline-offset: 3px;
}

/* -------------------------------------------------------------- 无障碍 */

/* 跳转链接：键盘用户第一个 Tab 到它，平时不可见 */
.skip-link {
  position: absolute;
  left: var(--sp-4);
  top: -100px;
  z-index: 200;
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-ink);
  color: var(--c-paper);
  font-size: var(--fs-sm);
  transition: top var(--dur-fast) var(--ease-out);
}
.skip-link:focus { top: var(--sp-4); }

/* 仅供屏幕阅读器 */
.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;
}

/* ------------------------------------------------------------ 滚动渐显 */
/* 由 js/reveal.js 添加 .is-visible。
   .no-js 时（脚本未执行）直接显示终态 —— 内容永远不依赖 JS 才可见。 */

.reveal {
  opacity: 0;
  transform: translateY(var(--reveal-shift));
  transition: opacity var(--dur-slow) var(--ease-out),
              transform var(--dur-slow) var(--ease-out);
  will-change: opacity, transform;
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
  will-change: auto;
}

.no-js .reveal { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------ 选中文本 */

::selection {
  background: var(--c-ink);
  color: var(--c-paper);
}

/* ------------------------------------------------------------ 滚动条 */
/* 极简化，避免默认滚动条在纯白页面上过于抢眼（仅 WebKit） */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--c-paper); }
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, .18);
  border: 3px solid var(--c-paper);
  border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, .34); }
