/* =========================================================================
   基础层：重置、排版、布局原语
   ========================================================================= */
@layer base {

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

  * { margin: 0; }

  html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    /* 页头吸顶，锚点跳转时留出空间 */
    scroll-padding-top: calc(var(--header-h) + var(--topbar-h) + 1rem);
    /* 移动端导航抽屉靠 translateX(100%) 停在视口右侧之外，
       用 clip（而非 hidden）裁掉它，避免产生横向滚动条——
       clip 不会把根元素变成滚动容器，因此不影响 position: sticky。 */
    overflow-x: clip;
  }

  body {
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    line-height: var(--lh-body);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    overflow-x: clip;
  }

  /* 移动端抽屉打开时锁定背景滚动 */
  body.is-locked { overflow: hidden; }

  h1, h2, h3, h4, h5, h6 {
    line-height: var(--lh-tight);
    font-weight: 700;
    letter-spacing: var(--tracking-tight);
    text-wrap: balance;
  }

  p { text-wrap: pretty; }

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

  a {
    color: var(--brand);
    text-decoration: none;
    transition: color var(--dur-fast) var(--ease-out);
  }
  a:hover { color: var(--brand-strong); }

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

  button, input, select, textarea {
    font: inherit;
    color: inherit;
  }

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

  table { border-collapse: collapse; width: 100%; }

  /* 键盘可见焦点 */
  :focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 3px;
    border-radius: var(--radius-xs);
  }
  .on-dark :focus-visible { outline-color: var(--brass-400); }

  ::selection { background: var(--indigo-600); color: #fff; }

  /* ---------- 无障碍 ---------- */
  .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;
    top: -100px;
    left: var(--space-4);
    z-index: calc(var(--z-modal) + 1);
    padding: 0.7rem 1.2rem;
    background: var(--brand);
    color: #fff;
    border-radius: 0 0 var(--radius) var(--radius);
    font-weight: 600;
    transition: top var(--dur) var(--ease-out);
  }
  .skip-link:focus { top: 0; color: #fff; }

  /* ---------- 布局原语 ---------- */
  .wrap {
    width: min(100% - var(--gutter) * 2, var(--container));
    margin-inline: auto;
  }
  .wrap--narrow { width: min(100% - var(--gutter) * 2, var(--container-narrow)); }

  .section {
    padding-block: var(--section-y);
    position: relative;
  }
  .section--tint { background: var(--bg-tint); }
  .section--soft { background: var(--bg-soft); }
  .section--raised { position: relative; z-index: 1; }
  .section--deep { background: var(--bg-deep); color: var(--text-invert); }

  /* 深色区块里的默认文字色修正 */
  .section--deep h1, .section--deep h2, .section--deep h3 { color: #fff; }
  .section--deep a { color: var(--brass-400); }
  .section--deep a:hover { color: var(--brass-300); }

  /* 段落文字区 */
  .prose {
    color: var(--text-soft);
    line-height: var(--lh-body);
  }
  .prose p + p { margin-top: 1.1em; }
  .prose strong { color: var(--text); font-weight: 700; }
  .prose--lg { font-size: 1.05em; }
  .prose__highlight {
    padding-left: var(--space-4);
    border-left: 3px solid var(--accent);
    color: var(--text);
    font-weight: 600;
  }
  .on-dark .prose, .section--deep .prose { color: var(--text-soft); }

  /* ---------- 小标签 ---------- */
  .eyebrow {
    font-family: var(--font-mono);
    font-size: var(--fs-2xs);
    font-weight: 600;
    letter-spacing: var(--tracking-wider);
    text-transform: uppercase;
    color: var(--accent-strong);
    line-height: 1.6;
  }
  .on-dark .eyebrow, .section--deep .eyebrow { color: var(--brass-400); }

  /* 「更多」链接 */
  .link-more {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--brand);
    padding-bottom: 2px;
    border-bottom: 1px solid transparent;
    transition: gap var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out), color var(--dur-fast);
  }
  .link-more:hover { gap: 0.75rem; border-bottom-color: currentColor; }
  .section--deep .link-more { color: var(--brass-400); }

  /* ---------- 章节标题 ---------- */
  .sec-head { max-width: 62ch; margin-bottom: clamp(2rem, 4vw, 3.25rem); }
  .sec-head--center { margin-inline: auto; text-align: center; }
  .sec-head__title {
    font-size: var(--fs-h2);
    margin-top: var(--space-3);
    color: var(--text);
  }
  .sec-head__lead {
    margin-top: var(--space-4);
    color: var(--text-soft);
    font-size: 1.02em;
    line-height: var(--lh-body);
  }
  .sec-head .link-more { margin-top: var(--space-5); }
  .on-dark .sec-head__title, .section--deep .sec-head__title { color: #fff; }
  .on-dark .sec-head__lead, .section--deep .sec-head__lead { color: var(--text-soft); }

  /* ---------- 图标 ---------- */
  .icon { width: 1.5rem; height: 1.5rem; flex: none; }
  .icon--xl { width: 2.5rem; height: 2.5rem; }
  .icon--lg { width: 1.75rem; height: 1.75rem; }
  .icon--sm { width: 1.15rem; height: 1.15rem; }
  .icon--xs { width: 0.95rem; height: 0.95rem; }

  /* ---------- 刻度分隔线（母题） ---------- */
  .rule-scale {
    height: 9px;
    background-image: var(--pattern-scale);
    background-repeat: repeat-x;
    background-position: 0 0;
    opacity: 0.5;
  }

  /* ---------- 打印 ---------- */
  @media print {
    .site-header, .site-footer, .to-top, .cta-band, .catalog-toolbar { display: none !important; }
    body { color: #000; }
    a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #555; }
  }
}
