/* ============================================================================
   ChipWorld — Base Layer
   ----------------------------------------------------------------------------
   1. reset  2. 排版默认值  3. 布局容器  4. 通用工具类  5. 背景装饰  6. 动效基元
   ========================================================================== */

/* ==== 1. reset ============================================================= */
*,
*::before,
*::after { box-sizing: border-box; }

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* 锚点跳转时给 sticky 头部留出空间 */
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  min-height: 100vh;
  background-color: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: var(--fw-regular);
  /* 字体渲染：深色底上的浅色字必须关掉次像素渲染，否则会“发胖” */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

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

img { height: auto; }

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

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

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}
a:hover { color: var(--cyan-500); }

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

/* 统一聚焦样式：键盘可见、鼠标不打扰 */
:focus-visible {
  outline: 2px solid var(--cyan-500);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}
:focus:not(:focus-visible) { outline: none; }

::selection {
  background: rgba(124, 92, 255, .28);
  color: #fff;
}

/* 深色滚动条 */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(124, 92, 255, .28) transparent;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: var(--bg-inset); }
*::-webkit-scrollbar-thumb {
  background: rgba(124, 92, 255, .22);
  border-radius: var(--r-pill);
  border: 2px solid var(--bg-inset);
}
*::-webkit-scrollbar-thumb:hover { background: rgba(124, 92, 255, .4); }

/* ==== 2. 排版默认值 ======================================================== */
h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  line-height: var(--lh-heading);
  letter-spacing: var(--ls-tight);
  text-wrap: balance;   /* 支持时自动平衡断行，避免西里尔长词孤字 */
}

h1 { font-size: var(--fs-display); line-height: var(--lh-tight); font-weight: var(--fw-black); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }

p { text-wrap: pretty; }

strong { font-weight: var(--fw-semibold); color: #fff; }

/* 数字与型号统一等宽，表格/统计对齐不跳动 */
.num,
.pn {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
  letter-spacing: -0.01em;
}

/* ==== 3. 布局容器 ========================================================== */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

.section {
  position: relative;
  padding-block: var(--section-py);
}

/* 可插拔区块：每个首页模块都是独立 <section class="section">，
   增删模块不影响其它模块的样式 —— 对应架构方案“模块化”要求。 */
.section + .section { border-top: 1px solid var(--line-subtle); }

/* ==== 4. 通用工具类 ======================================================== */
.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;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: var(--z-modal);
  padding: 10px 18px;
  border-radius: var(--r-sm);
  background: var(--cyan-500);
  color: var(--text-on-accent);
  font-weight: var(--fw-semibold);
}
.skip-link:focus { top: 12px; color: var(--text-on-accent); }

/* 眉标：等宽大写小字 + 前置电光短线 */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  /* 用柔紫而非 #7C5CFF：12px 小字在卡片底上 #7C5CFF 只有 4.26:1，不达标 */
  color: var(--violet-300);
}
.eyebrow::before {
  content: '';
  width: 22px;
  height: 1px;
  background: var(--violet-500);
  box-shadow: 0 0 8px var(--violet-500);
}

/* 区块标题组 */
.section-head {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  max-width: 720px;
  margin-bottom: var(--sp-7);
}
.section-head p {
  color: var(--text-secondary);
  font-size: var(--fs-body-lg);
}
.section-head--center {
  max-width: 760px;
  margin-inline: auto;
  text-align: center;
  align-items: center;
}

/* 渐变文字：只用于短标题，长段落用渐变会牺牲可读性 */
.text-grad {
  background: var(--grad-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  /* 不支持 background-clip:text 的浏览器回退到纯色 */
  -webkit-text-fill-color: transparent;
}
@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
  .text-grad { -webkit-text-fill-color: currentColor; color: var(--cyan-300); }
}

.hairline {
  height: 1px;
  background: var(--grad-hairline);
  border: 0;
}

/* ==== 5. 全局背景装饰 ====================================================== */
/* 网格：单一 fixed 图层，纯 CSS，零 JS 成本 */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: var(--z-bg);
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(150, 130, 220, .055) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(150, 130, 220, .055) 1px, transparent 1px);
  background-size: 64px 64px;
  /* 中心可见、边缘淡出，避免整屏网格“脏” */
  -webkit-mask-image: radial-gradient(120% 90% at 50% 0%, #000 0%, rgba(0, 0, 0, .55) 45%, transparent 78%);
  mask-image: radial-gradient(120% 90% at 50% 0%, #000 0%, rgba(0, 0, 0, .55) 45%, transparent 78%);
}

/* 顶部大面积色晕：radial-gradient 而非 blur 滤镜，性能友好 */
.bg-aurora {
  position: absolute;
  inset: 0;
  z-index: var(--z-bg);
  pointer-events: none;
  /* 两层径向光斑（左 247° / 右 222°）+ 一层顶部冷白，纯 CSS 零图片
     这是参考图「科技氛围」的主要来源，比任何位图都便宜 */
  background: var(--grad-radial);
}

/* ==== 6. 动效基元 ========================================================== */
/* 滚动进场：由 main.js 的 IntersectionObserver 添加 .is-in。
   只动 transform 与 opacity，绝不触发 layout / paint 重排。

   ⚠️ 必须挂在 html.js-reveal 之下（「上膛」开关）：
   如果 main.js 因为 CDN 拦截 / 网络抖动 / 脚本报错没跑起来，这个类不会被加载，
   内容就保持默认可见——宁可少一个动画，也不能让 33 个 .reveal 永远停在 opacity:0。
   开关由 index.html 头部的一小段内联脚本加上，并带 1.6s 自愈超时。 */
.js-reveal .reveal {
  opacity: 0;
  transform: translate3d(0, 24px, 0);
  transition:
    opacity var(--dur-reveal) var(--ease-out),
    transform var(--dur-reveal) var(--ease-out);
  will-change: opacity, transform;
}
.js-reveal .reveal.is-in {
  opacity: 1;
  transform: none;
  will-change: auto;
}
.js-reveal .reveal[data-delay="1"] { transition-delay: 60ms; }
.js-reveal .reveal[data-delay="2"] { transition-delay: 120ms; }
.js-reveal .reveal[data-delay="3"] { transition-delay: 180ms; }
.js-reveal .reveal[data-delay="4"] { transition-delay: 240ms; }
.js-reveal .reveal[data-delay="5"] { transition-delay: 300ms; }

/* 呼吸光：仅用于强调少量元素（CTA 描边、状态点） */
@keyframes breathe {
  0%, 100% { opacity: .55; }
  50%      { opacity: 1; }
}

/* 扫描线：Hero 专用，一条 1px 光线自上而下循环 */
@keyframes scanline {
  0%   { transform: translate3d(0, -8%, 0); opacity: 0; }
  12%  { opacity: .9; }
  88%  { opacity: .9; }
  100% { transform: translate3d(0, 108%, 0); opacity: 0; }
}

/* 品牌墙无缝滚动 */
@keyframes marquee {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(-50%, 0, 0); }
}

/* ==== 7. 降级：尊重系统“减少动效” ========================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }

  /* 进场元素必须可见，不能因为动画被禁用而永远停在 opacity:0 */
  .reveal {
    opacity: 1 !important;
    transform: none !important;
  }

  .marquee__track { animation: none !important; transform: none !important; }
}
