/* =====================================================
   基础层：重置、排版、布局原语、动效原语
   ===================================================== */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 24px);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-16);
  line-height: 1.75;
  color: var(--text-1);
  background-color: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background-color .3s ease, color .3s ease;
}

body.is-locked { overflow: hidden; }

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -.012em;
  color: var(--text-1);
  text-wrap: balance;
}

/* text-wrap: pretty 避免中文段落末行只剩一两个字（孤字）；
   不支持的浏览器会忽略，不影响布局 */
p { margin: 0; text-wrap: pretty; }
a { color: inherit; text-decoration: none; }
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }

::selection { background: rgba(26, 102, 240, .22); color: var(--text-1); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------------- 布局原语 ---------------- */
.shell {
  width: 100%;
  /* 内容区宽度恒定：max-width 随 gutter 补偿，避免断点处内容区突然收窄 */
  max-width: calc(var(--container) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  position: relative;
  padding-block: clamp(64px, 8vw, 120px);
}
.section--tight { padding-block: clamp(48px, 5vw, 72px); }
.section--alt { background: var(--bg-1); }
.section--line { border-top: 1px solid var(--border); }

/* ---------------- 栅格原语 ---------------- */
.grid { display: grid; gap: var(--sp-4); }
.grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
.grid--auto { grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); }
@media (min-width: 620px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1000px) {
  .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* 页面背景：光晕 + 细网格 + 噪点，全部由 CSS 生成，无图片请求 */
.page-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    var(--glow-2),
    var(--glow),
    var(--bg-0);
}
.page-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 72%);
  -webkit-mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 72%);
}

/* ---------------- 文本工具 ---------------- */
.grad-text {
  background: var(--gradient-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.muted { color: var(--text-2); }
.small { font-size: var(--fs-14); color: var(--text-3); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------------- 章节标题 ---------------- */
.sec-head {
  max-width: 720px;
  margin-bottom: var(--sp-8);
}
.sec-head--center { margin-inline: auto; text-align: center; }

.sec-index {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--sp-4);
  font-family: var(--font-mono);
  font-size: var(--fs-13);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent);
}
.sec-index::before {
  content: "";
  width: 28px;
  height: 1px;
  background: currentColor;
  opacity: .55;
}

.sec-title {
  font-size: clamp(1.75rem, 3.4vw, 2.6rem);
  margin-bottom: var(--sp-4);
}
.sec-desc {
  color: var(--text-2);
  font-size: var(--fs-16);
  max-width: 62ch;
}
.sec-head--center .sec-desc { margin-inline: auto; }

/* ---------------- 动效：滚动揭示 ---------------- */
/* 只有 JS 可用时才隐藏首屏内容，避免脚本失效导致页面空白 */
.js .reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .7s var(--ease-out), transform .7s var(--ease-out);
  will-change: opacity, transform;
}
.js .reveal.is-in { opacity: 1; transform: none; }

@keyframes float-y {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@keyframes spin-slow {
  to { transform: rotate(360deg); }
}
@keyframes pulse-opacity {
  0%, 100% { opacity: .35; }
  50% { opacity: .8; }
}

/* ---------------- 可访问性 ---------------- */
.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;
}
.skip-link {
  position: absolute;
  left: 50%;
  top: -60px;
  z-index: 2000;
  transform: translateX(-50%);
  padding: 10px 20px;
  /* 用文字/底色配对而非品牌色：深色主题下 --accent 偏亮，白字仅 3.2:1 */
  background: var(--text-1);
  color: var(--bg-0);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  transition: top .2s;
}
.skip-link:focus { top: 0; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .js .reveal { opacity: 1; transform: none; }
}

@media print {
  :root { --bg-0: #fff; --bg-1: #fff; --text-1: #000; --text-2: #333; }
  .site-header, .site-footer, .scroll-progress, .fab-top { display: none !important; }
}
