/* ==========================================================================
   BASE — 字体加载 / 重置 / 排版 / 可访问性 / 氛围层
   ========================================================================== */

/* --- 字体：自托管，避免外链依赖与 FOUT 抖动 ------------------------- */
@font-face {
  font-family: "Archivo Black";
  src: url("../fonts/archivo-black-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
/* IBM Plex Sans 拿到的是可变字体：单文件覆盖 300–700，正文层级靠它精确控制 */
@font-face {
  font-family: "IBM Plex Sans";
  src: url("../fonts/ibm-plex-sans-var.woff2") format("woff2-variations"),
       url("../fonts/ibm-plex-sans-var.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 96px; /* 锚点跳转避开吸顶导航 */
}

body {
  margin: 0;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

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

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

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

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

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

hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: 0;
}

/* --- 排版 ------------------------------------------------------------ */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: var(--ls-display);
  line-height: var(--lh-tight);
  text-transform: uppercase;
  text-wrap: balance;
}

h1 { font-size: clamp(38px, 7.4vw, var(--fs-7xl)); }
h2 { font-size: clamp(30px, 4.6vw, var(--fs-5xl)); }
h3 { font-size: clamp(21px, 2.4vw, var(--fs-2xl)); }
h4 { font-size: var(--fs-lg); letter-spacing: var(--ls-tight); }

p { text-wrap: pretty; }

/* 工业风标注：等宽小字 + 宽字距，用于区块编号、字段标签 */
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.eyebrow::before {
  content: "";
  width: 24px;
  height: 2px;
  background: var(--color-accent);
  flex: none;
}

/* 数据、编号、规格一律等宽 + 表格数字对齐 */
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.lead {
  font-size: clamp(var(--fs-md), 1.35vw, var(--fs-lg));
  line-height: var(--lh-loose);
  color: var(--color-text-muted);
  max-width: 62ch;
}

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

/* --- 布局工具 -------------------------------------------------------- */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.wrap--narrow { max-width: var(--wrap-narrow); }

.section { padding-block: clamp(var(--sp-9), 8vw, var(--sp-11)); }
.section--tight { padding-block: clamp(var(--sp-8), 5vw, var(--sp-9)); }
.section--ink {
  background: var(--color-ink);
  color: var(--color-text-on-ink);
}

/* 深色区块上的规则线 */
.section--ink hr { border-color: var(--color-border-on-ink); }

.skip-link {
  position: absolute;
  left: var(--sp-4);
  top: -100px;
  z-index: 200;
  background: var(--color-ink);
  color: var(--color-text-on-ink);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius-sm);
  transition: top var(--dur-fast) var(--ease-out);
}
.skip-link:focus { top: var(--sp-4); }

/* --- 焦点可见 -------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}
.section--ink :focus-visible { outline-color: var(--color-accent); }

/* --- 氛围层：技术图纸网格 -------------------------------------------- */
/* 全站底噪：等距网格，暗示工程图纸语境 */
.grid-bg { position: relative; }
.grid-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(to right,  var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  mask-image: radial-gradient(120% 90% at 50% 0%, #000 20%, transparent 78%);
  -webkit-mask-image: radial-gradient(120% 90% at 50% 0%, #000 20%, transparent 78%);
}
.section--ink.grid-bg::before { background-image:
    linear-gradient(to right,  var(--grid-line-ink) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line-ink) 1px, transparent 1px); }
.grid-bg > * { position: relative; z-index: 1; }

/* 橡胶颗粒噪点：透明度克制，只做材质暗示 */
.grain::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  opacity: 0.035;
  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");
}

/* --- 入场编排 ----------------------------------------------------------
   两层策略，目标是在任何脚本失效的情况下内容都可见：

   1. 首屏 .boot —— 纯 CSS 动画，完全不依赖 JS。
      即使所有脚本都加载失败，首屏照样有编排好的入场，且内容一定出现。
   2. 滚动区 .reveal —— 渐进增强。
      只有 head 内联脚本成功给 <html> 加上 .js，待入场元素才被隐藏；
      main.js 负责在滚动到位时显示。再加一层超时兜底（内联脚本里），
      保证 main.js 没跑起来时也会解除隐藏。
   ---------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {

  /* --- 1. 首屏：纯 CSS，零 JS 依赖 --- */
  .boot { animation: boot-rise 520ms var(--ease-out) both; }
  .boot:nth-child(1) { animation-delay: 30ms; }
  .boot:nth-child(2) { animation-delay: 100ms; }
  .boot:nth-child(3) { animation-delay: 170ms; }
  .boot:nth-child(4) { animation-delay: 240ms; }
  .boot:nth-child(5) { animation-delay: 310ms; }
  .boot:nth-child(6) { animation-delay: 380ms; }

  @keyframes boot-rise {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: none; }
  }

  /* --- 2. 滚动区：仅在 JS 确认可用时才隐藏 --- */
  .js .reveal {
    opacity: 0;
    transform: translateY(22px);
    transition:
      opacity var(--dur-base) var(--ease-out),
      transform var(--dur-base) var(--ease-out);
  }
  .js .reveal.is-in { opacity: 1; transform: none; }
}

/* 降级：用户要求减少动态时，一切静态呈现 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal, .boot { opacity: 1 !important; transform: none !important; }
}

/* --- 打印 ------------------------------------------------------------ */
@media print {
  .site-header, .site-footer, .cta-band, .marquee { display: none; }
  body { background: #fff; }
}
