/* ==========================================================================
   base.css · reset / 排版基线 / 无障碍工具类 / 占位组件 / 动效兜底
   只允许引用 tokens.css 的变量，不出现任何色值/字号/间距字面量。
   ========================================================================== */

/* ---------- 1. reset ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  letter-spacing: var(--ls-tight);
  font-weight: var(--fw-regular);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.is-locked { overflow: hidden; }

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd, ol, ul {
  margin: 0;
}

ol, ul {
  padding: 0;
  list-style: none;
}

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

img { height: auto; }

svg { flex: none; }

a {
  color: var(--color-accent-ink);
  text-decoration: none;
}

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

input, textarea, select { font: inherit; }

table {
  border-collapse: collapse;
  border-spacing: 0;
}

[hidden] { display: none !important; }

/* ---------- 2. 标题与正文基线 ---------- */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);   /* 全站标题最大 600，避开 SimSun 伪粗体 */
  color: var(--color-ink);
  letter-spacing: var(--ls-normal);
  text-wrap: balance;
}

h1 { font-size: var(--fs-h1); line-height: var(--lh-h1); }
h2 { font-size: var(--fs-h2); line-height: var(--lh-h2); }
h3 { font-size: var(--fs-h3); line-height: var(--lh-h3); }

h4 {
  font-family: var(--font-body);
  font-size: var(--fs-h4);
  line-height: var(--lh-h4);
  font-weight: var(--fw-semibold);
  color: var(--color-ink);
  letter-spacing: var(--ls-tight);
}

p {
  max-width: var(--measure);
  line-height: var(--lh-body);
}

p + p { margin-top: var(--space-5); }

strong, b { font-weight: var(--fw-semibold); }

em { font-style: normal; }

small { font-size: var(--fs-caption); }

code, kbd, samp { font-family: var(--font-num); }

hr {
  border: 0;
  border-top: 1px solid var(--color-divider);
  margin: var(--space-7) 0;
}

/* 正文内的行内文字链接：统一带下划线，避免只靠颜色区分 */
p a,
li a.inline-link {
  color: var(--color-accent-ink);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--color-line-strong);
  transition: color var(--dur-fast) var(--ease-state),
              text-decoration-color var(--dur-fast) var(--ease-state);
}

p a:hover,
li a.inline-link:hover {
  color: var(--color-accent);
  text-decoration-color: var(--color-accent);
}

/* ---------- 3. 焦点态（全站统一定稿） ---------- */
:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: inherit;
}

.on-dark :focus-visible,
.page-header--deep :focus-visible,
.drawer :focus-visible,
.footer :focus-visible,
.screen--vision :focus-visible {
  outline-color: var(--color-focus-inverse);
}

/* 不用 outline: none 之后的空实现；仅移除鼠标点击时的默认环，保留键盘环 */
:focus:not(:focus-visible) { outline: none; }

/* ---------- 4. 无障碍工具类 ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-5);
  top: -60px;
  z-index: var(--z-skip);
  background: var(--color-ink);
  color: var(--color-ink-inverse);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-1);
  font-size: var(--fs-sm);
  transition: top var(--dur-base) var(--ease-out);
}

.skip-link:focus {
  top: var(--space-3);
  color: var(--color-ink-inverse);
}

main:focus { outline: none; }

/* 锚点目标不被固定导航遮挡（site-spec A11） */
[id] { scroll-margin-top: calc(var(--nav-h) + var(--space-4)); }

/* ---------- 5. 中英混排 ---------- */
[lang="en"] { letter-spacing: var(--ls-normal); }

/* ---------- 6. 滚动进入（失败安全） ----------
   关键：隐藏态只存在于动画关键帧里，不在默认样式里。
   JS 只负责加 .is-in；若 IO 不回调（旧内核 / 无绘制环境 / 脚本未加载），
   页面表现为「没有动画」而不是「内容全部不可见」。 */
.reveal.is-in {
  animation: reveal-rise var(--dur-enter) var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}

@keyframes reveal-rise {
  from { opacity: 0; transform: translateY(var(--space-4)); }
  to   { opacity: 1; transform: none; }
}

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .reveal,
  .reveal.is-in {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .hero__media { transform: none !important; }
}

/* ---------- 7. 打印样式 ---------- */
@media print {
  html { scroll-behavior: auto; }

  body {
    background: var(--color-surface-hover);
    color: var(--color-ink);
  }

  .topbar,
  .drawer,
  .progress,
  .progress-bar,
  .to-top,
  .skip-link,
  .screen__more,
  .hero__scroll,
  .hero__scrim-a,
  .hero__scrim-b,
  .hero__landing,
  .screen--vision .vision__media,
  .tabs__list { display: none !important; }

  .reveal,
  .js .reveal {
    opacity: 1 !important;
    transform: none !important;
  }

  a[href^="http"]::after { content: " (" attr(href) ")"; }

  thead { display: table-header-group; }
}
