/* ==========================================================================
   Base — 重置、排版、焦点、氛围层、降级动效
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* 流体根字号：内容随屏宽整体缩放（15px → 17px），UI chrome 仍用绝对 px 不变 */
  font-size: clamp(15px, calc(0.55vw + 13.4px), 17px);
  scroll-padding-top: calc(var(--masthead-h) + 12px);
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--fs-400);
  line-height: 1.62;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* 中文正文需要更松的行高与轻微字距（见设计手册 §2） */
html[lang="zh"] body { line-height: 1.78; letter-spacing: 0.012em; }

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

/* ---- 响应式加固：杜绝移动端横向溢出 ---- */
/* 网格/弹性子项默认可收缩，长内容（URL/代码/对话）不再撑破容器 */
.shell, main, section,
.cards, .facts, .legend, .footer__grid,
.gallery--text, .citygrid, .classics,
.kit, .assistant, .partners, .planner, .stories,
.section-head, .marquee, .timeline, .toast,
.pd__grid, .pd__body, .chat__log, .msg { min-width: 0; }
/* 长串可断行，避免横向滚动 */
p, li, h1, h2, h3, h4, td, th,
.msg, .story, .chat__log, .facts dd, .stats__value { overflow-wrap: anywhere; }
table, canvas, iframe { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

/* ---- 标题：全部使用 Fraunces 展示字 ---- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  font-variation-settings: "SOFT" 0, "WONK" 1;
  line-height: 1.06;
  letter-spacing: -0.028em;
  margin: 0;
  text-wrap: balance;
}
h3, h4 { letter-spacing: -0.018em; }
p { margin: 0; text-wrap: pretty; }

/* ---- 焦点：必须可见（2px + 2px 偏移） ---- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}
:focus:not(:focus-visible) { outline: none; }

/* ---- 跳转到主内容（键盘可达） ---- */
.skip-link {
  position: absolute; top: -100px; left: var(--space-4);
  z-index: 200; padding: 12px 20px; min-height: 44px;
  background: var(--accent); color: var(--on-accent);
  font-weight: 700; text-decoration: none; border-radius: var(--radius-sm);
  transition: top var(--dur-fast) ease-out;
}
.skip-link:focus { top: 12px; }

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

/* ==========================================================================
   氛围层：渐变网格 + 噪点颗粒（见设计手册 §6）
   ========================================================================== */
.atmosphere::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(56rem 38rem at 8% -12%, rgba(62, 110, 147, 0.14), transparent 62%),
    radial-gradient(46rem 34rem at 104% 6%, rgba(169, 186, 197, 0.20), transparent 58%),
    radial-gradient(40rem 30rem at 50% 118%, rgba(44, 82, 115, 0.10), transparent 60%);
}
.grain::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 1;
  opacity: 0.05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ==========================================================================
   布局骨架
   ========================================================================== */
.shell {
  position: relative; z-index: 2;
  width: 100%; max-width: var(--page-max);
  margin-inline: auto; padding-inline: var(--page-pad);
}
main { position: relative; z-index: 2; }

.section { padding-block: clamp(72px, 11vh, var(--space-8)); position: relative; }
.section--tight { padding-block: clamp(48px, 7vh, var(--space-7)); }

/* 章节头：不对称，左对齐；朱红细线作为「红线」母题 */
.section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-5) var(--space-6);
  align-items: end;
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--space-6);
}
.section-head__index {
  font-family: var(--font-mono);
  font-size: var(--fs-300);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex; align-items: center; gap: var(--space-3);
}
.section-head__index::after {
  content: ""; height: 1px; flex: 1; background: var(--accent-line);
}
.section-head h2 {
  font-size: var(--fs-title);
  margin-top: var(--space-3);
}
.section-head__lede {
  color: var(--color-muted);
  font-size: var(--fs-500);
  line-height: 1.6;
  max-width: 46ch;
}
@media (max-width: 860px) {
  .section-head { grid-template-columns: 1fr; align-items: start; gap: var(--space-4); }
}

/* 规则线 / 装饰边框 */
.rule { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ==========================================================================
   通用文本工具
   ========================================================================== */
.kicker {
  font-family: var(--font-mono);
  font-size: var(--fs-300);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--color-muted);
}
.lede { font-size: var(--fs-500); line-height: 1.6; color: var(--paper-dim); }
.muted { color: var(--color-muted); }
.small { font-size: var(--fs-300); }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ==========================================================================
   入场编排：一次编排好的序列（错峰 60–120ms）
   ========================================================================== */
.reveal { opacity: 0; transform: translateY(22px); }
.reveal.is-in {
  opacity: 1; transform: none;
  transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
}
.stagger > .reveal:nth-child(1) { transition-delay: 0ms; }
.stagger > .reveal:nth-child(2) { transition-delay: 80ms; }
.stagger > .reveal:nth-child(3) { transition-delay: 160ms; }
.stagger > .reveal:nth-child(4) { transition-delay: 240ms; }
.stagger > .reveal:nth-child(5) { transition-delay: 320ms; }
.stagger > .reveal:nth-child(6) { transition-delay: 400ms; }

/* ---- 降级：尊重系统偏好 ---- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal, .reveal.is-in { opacity: 1; transform: none; transition: none; }
  .marquee__track { animation: none !important; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
}

/* 打印：去掉氛围层 */
@media print {
  .atmosphere::before, .grain::after, .marquee, .masthead { display: none !important; }
  body { background: #fff; color: #111; }
}
