/* ===== base.css =====
   重置、排版基线、布局原语、无障碍基线、动效降级。
   依赖 tokens.css 中的变量。 */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scrollbar-color: var(--brass-dim) var(--bg-0);
}

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

html.lenis,
html.lenis body {
  height: auto;
}

body {
  margin: 0;
  background: var(--bg-0);
  color: var(--ink-1);
  font-family: var(--font-serif);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  letter-spacing: var(--track-cn);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  min-height: 100svh;
  font-feature-settings: "palt" 1;
}

/* 细颗粒噪点，全站固定覆盖（纯 CSS，无图片依赖） */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
}

@media (prefers-reduced-motion: reduce) {
  body::before {
    opacity: 0.03;
  }
}

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

img {
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
}

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

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

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

::selection {
  background: var(--brass);
  color: var(--bg-0);
}

/* --- 焦点 --- */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 3px;
  border-radius: var(--radius);
}

/* --- 排版原语 --- */
.label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  line-height: 1.4;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--ink-2);
  font-weight: 400;
}

.label--brass {
  color: var(--brass);
}

.body-text {
  max-width: var(--measure);
  color: var(--ink-1);
  text-wrap: pretty;
}

.body-text + .body-text {
  margin-top: 1.15em;
}

.body-text strong {
  color: var(--ink-0);
  font-weight: 600;
}

h1,
h2,
h3 {
  font-weight: 600;
  color: var(--ink-0);
  line-height: var(--lh-tight);
  letter-spacing: var(--track-display);
  text-wrap: balance;
}

/* --- 布局原语 --- */
.wrap {
  width: 100%;
  max-width: var(--w-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.theme-dark {
  background: var(--bg-0);
}

.theme-raised {
  background: var(--bg-1);
}

.rule {
  height: 1px;
  background: var(--line);
  border: 0;
}

.vh {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --- 跳转链接 --- */
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 200;
  padding: 10px 16px;
  background: var(--bg-0);
  border: 1px solid var(--brass);
  color: var(--brass-hi);
  font-size: 13px;
  transform: translateY(-200%);
  transition: transform var(--t-fast) var(--ease);
}

.skip-link:focus {
  transform: none;
}

/* --- 滚动条 --- */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-0);
}

::-webkit-scrollbar-thumb {
  background: #2a2722;
  border: 3px solid var(--bg-0);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--brass-dim);
}

/* --- 图片占位（未加载时也有底色，避免 CLS） --- */
img {
  background: var(--bg-2);
}

/* --- 长文本可读性 --- */
.f-prose .body-text {
  color: var(--ink-1);
}

/* --- 动效降级兜底：所有 reveal 元素默认可见，由 core.js 提升为动画态 --- */
[data-reveal],
.reveal {
  opacity: 1;
  transform: none;
}

html.js [data-reveal],
html.js .reveal {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 700ms var(--ease-out),
    transform 900ms var(--ease-out);
  transition-delay: calc(var(--d, 0ms));
  will-change: opacity, transform;
}

html.js [data-reveal].is-in,
html.js .reveal.is-in {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html.js [data-reveal],
  html.js .reveal {
    opacity: 1;
    transform: none;
    transition: opacity 120ms linear !important;
  }
}

/* --- 打印（档案可读） --- */
@media print {
  body {
    background: #fff;
    color: #111;
  }

  body::before {
    display: none;
  }

  .site-head,
  .site-foot,
  .drawer,
  .skip-link,
  .scroll-line {
    display: none !important;
  }
}
