/* ==========================================================================
   base.css — v4.0 重置 / 排版 / 角线 / 颗粒 / 标题遮罩行 / 活字悬停（桌面增益）
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 26px);
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.72;
  letter-spacing: 0.002em;
  min-height: 100vh;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color var(--dur-2) var(--ease-out),
    color var(--dur-2) var(--ease-out);
}

body.theme-anim *,
body.theme-anim *::before,
body.theme-anim *::after {
  transition: background-color var(--dur-2) var(--ease-out),
    color var(--dur-2) var(--ease-out),
    border-color var(--dur-2) var(--ease-out),
    opacity var(--dur-2) var(--ease-out) !important;
}

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

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

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

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: var(--display-tracking);
  line-height: var(--display-leading);
  text-wrap: balance;
}

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

::-webkit-scrollbar {
  width: 10px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--line);
  border: 3px solid var(--bg);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--ink-3);
}

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

.skip-link {
  position: fixed;
  top: -100px;
  left: 14px;
  z-index: 320;
  padding: 10px 18px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  transition: top var(--dur-1) var(--ease-out);
}
.skip-link:focus-visible {
  top: 14px;
}

/* ==========================================================================
   印刷角线
   ========================================================================== */
.cropmarks {
  position: fixed;
  inset: 0;
  z-index: 115;
  pointer-events: none;
}
.cropmarks i {
  position: absolute;
  width: 18px;
  height: 18px;
  opacity: 0.5;
}
.cropmarks i::before,
.cropmarks i::after {
  content: "";
  position: absolute;
  background: var(--ink-3);
}
.cropmarks i::before {
  width: 100%;
  height: 1px;
}
.cropmarks i::after {
  width: 1px;
  height: 100%;
}
.cropmarks i:nth-child(1) { top: 10px; left: 10px; }
.cropmarks i:nth-child(1)::before { top: 0; left: 0; }
.cropmarks i:nth-child(1)::after { top: 0; left: 0; }
.cropmarks i:nth-child(2) { top: 10px; right: 10px; }
.cropmarks i:nth-child(2)::before { top: 0; right: 0; }
.cropmarks i:nth-child(2)::after { top: 0; right: 0; }
.cropmarks i:nth-child(3) { bottom: 10px; left: 10px; }
.cropmarks i:nth-child(3)::before { bottom: 0; left: 0; }
.cropmarks i:nth-child(3)::after { bottom: 0; left: 0; }
.cropmarks i:nth-child(4) { bottom: 10px; right: 10px; }
.cropmarks i:nth-child(4)::before { bottom: 0; right: 0; }
.cropmarks i:nth-child(4)::after { bottom: 0; right: 0; }

/* ==========================================================================
   颗粒
   ========================================================================== */
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 118;
  pointer-events: none;
}
.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: var(--grain);
  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='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 140px 140px;
}
/* 单主题（纸面）：颗粒做正片叠底 */
.atmosphere::after {
  mix-blend-mode: multiply;
}

/* ==========================================================================
   通用
   ========================================================================== */
.container {
  width: min(var(--container), 100% - var(--gutter) * 2);
  margin-inline: auto;
}

.mono-label {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 400;
}

.accent {
  color: var(--accent);
}

.serif-italic {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.01em;
}

/* ==========================================================================
   活字：可变字重悬停（物理回应的核心件）
   JS 把文本拆成 .type-char；悬停时字重 900 → 480，基线微沉。
   ========================================================================== */
.type-char {
  display: inline-block;
  font-variation-settings: "wght" var(--wght-rest);
  transition: font-variation-settings 0.45s var(--spring),
    transform 0.45s var(--spring), color 0.45s var(--ease-out);
  will-change: font-variation-settings;
}
.type-char:hover {
  font-variation-settings: "wght" var(--wght-hover);
  transform: translateY(0.04em);
  color: var(--ink);
}
.type-char.is-accent:hover {
  color: var(--accent);
}

/* ==========================================================================
   标题遮罩行：ungate 后按 --ri 级联升起（B 类揭幕；padding+负 margin 护下伸部）
   ========================================================================== */
.hero__title .row {
  display: block;
  overflow: hidden;
  padding-bottom: 0.14em;
  margin-bottom: -0.14em;
}
.hero__title .row__inner {
  display: block;
  transform: translateY(112%);
  transition: transform 0.9s var(--spring) calc(var(--ri, 0) * 0.14s + 0.05s);
  will-change: transform;
}
html:not(.booting) .hero__title .row__inner {
  transform: none;
}

/* ==========================================================================
   降级与门控
   ========================================================================== */
html.no-js .splash {
  display: none;
}
html.no-js [data-reveal],
html.no-js .mosaic__cell,
html.no-js .hero__title .row__inner {
  opacity: 1 !important;
  transform: none !important;
  filter: none !important;
  clip-path: none !important;
}

html.booting [data-reveal],
html.booting .hero__title .row__inner {
  transition: none !important;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
