/* ============================================================
   base.css — 重置、排版、氛围层、无障碍基础
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 88px; /* 锚点跳转避开固定头部 */
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.7;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* 纸面纹理：极轻的颗粒，避免纯色平背景 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: multiply;
  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='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* 顶部暖光：模拟厂房侧光 */
body::after {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 60vh;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(
    70rem 32rem at 78% -12%,
    rgba(210, 64, 30, 0.09),
    transparent 62%
  );
}

img,
svg {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -0.028em;
  color: var(--ink);
}

p {
  margin: 0;
  max-width: 42em;
}

a {
  color: inherit;
  text-decoration-color: var(--hair-strong);
  text-underline-offset: 3px;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* --- 焦点可见：2px 描边 + 2px 偏移 --- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- 跳过导航 --- */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--gutter);
  z-index: 100;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  text-decoration: none;
  transition: top var(--dur-fast) var(--ease-out);
}
.skip-link:focus {
  top: 12px;
}

/* --- 布局容器 --- */
.shell {
  position: relative;
  z-index: 2;
  width: min(100% - var(--gutter) * 2, var(--measure));
  margin-inline: auto;
}

.section {
  position: relative;
  z-index: 2;
  padding-block: clamp(56px, 9vw, var(--sp-8));
  border-top: 1px solid var(--hair);
}

/* --- 章节标题（编辑式编号） --- */
.section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}

.section-index {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-text);
}

.section-title {
  font-size: var(--fs-h2);
  max-width: 22ch;
  text-wrap: balance;
}
/* 标题内按语义分句：每句作为整体换行，避免把词拆开 */
.tpart {
  display: inline-block;
}

.section-desc {
  max-width: 46ch;
  color: var(--muted);
  font-size: var(--fs-lead);
  margin-top: var(--sp-3);
}

@media (min-width: 900px) {
  .section-head {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    align-items: end;
    gap: var(--sp-6);
  }
  .section-desc {
    margin-top: 0;
    justify-self: end;
  }
}

/* --- 入场编排：滚动触发的 reveal --- */
.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);
}

/* 首屏为一次性编排序列，用 animation 而非 observer */
.hero-stagger > * {
  opacity: 0;
  transform: translateY(18px);
  animation: rise var(--dur-slow) var(--ease-out) forwards;
}
.hero-stagger > *:nth-child(1) { animation-delay: 60ms; }
.hero-stagger > *:nth-child(2) { animation-delay: 150ms; }
.hero-stagger > *:nth-child(3) { animation-delay: 240ms; }
.hero-stagger > *:nth-child(4) { animation-delay: 330ms; }
.hero-stagger > *:nth-child(5) { animation-delay: 420ms; }

@keyframes rise {
  to {
    opacity: 1;
    transform: none;
  }
}

/* --- 动效降级：系统减少动态时全部静止 --- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .reveal,
  .reveal.is-in,
  .hero-stagger > * {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
    animation: none !important;
  }
  .ticker__track {
    animation: none !important;
  }
}

/* --- 通用小工具 --- */
.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;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
