/* ==========================================================================
   青花狸 V2 · Design System — Layer 2: Base
   Reset / Typography / Grid / Layout Primitives / Utilities
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + var(--s-6));
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) { color-scheme: dark; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink-900);
  font-family: var(--font-sans);
  font-size: var(--t-body);
  line-height: var(--lh-base);
  font-feature-settings: "kern" 1, "liga" 1, "cv05" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background-color var(--dur-4) var(--ease-out),
              color var(--dur-4) var(--ease-out);
}

/* 纸感纹理：仅作用于浅色大面积区，2% 不透明度 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: var(--tex-grain);
  opacity: .028;
  pointer-events: none;
  z-index: 1;
  mix-blend-mode: multiply;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) body::before { mix-blend-mode: screen; opacity: .05; }
}
:root[data-theme="dark"] body::before { mix-blend-mode: screen; opacity: .05; }
:root[data-theme="light"] body::before { mix-blend-mode: multiply; opacity: .028; }

/* ---------- 标题 ---------- */
h1, h2, h3, h4, h5 {
  margin: 0;
  font-weight: 600;
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
  color: var(--ink-900);
  text-wrap: balance;
}

h1 { font-size: var(--t-h1); }
h2 { font-size: var(--t-h2); }
h3 { font-size: var(--t-h3); line-height: var(--lh-snug); letter-spacing: -.012em; }
h4 { font-size: var(--t-h4); line-height: var(--lh-snug); letter-spacing: -.008em; }

p { margin: 0; }

/* ---------- 链接 ---------- */
a {
  color: var(--brand-700);
  text-decoration: none;
  transition: color var(--dur-2) var(--ease-out);
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) a { color: var(--brand-400); }
}
:root[data-theme="dark"] a { color: var(--brand-400); }

a:hover { color: var(--brand-600); }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) a:hover { color: var(--brand-200); }
}

/* ---------- 焦点态：全站统一，键盘可见、鼠标不可见 ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--brand-600);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) :focus-visible { outline-color: var(--brand-400); }
}

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--s-4);
  z-index: 200;
  padding: var(--s-3) var(--s-5);
  background: var(--brand-700);
  color: #fff;
  border-radius: var(--r-sm);
  font-size: var(--t-sm);
  font-weight: 600;
  transition: top var(--dur-2) var(--ease-out);
}
.skip-link:focus { top: var(--s-3); color: #fff; }

/* 视觉隐藏但屏幕阅读器可读：用于表单控件的隐藏 label */
.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;
}

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

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

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

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

/* ==========================================================================
   布局原语
   ========================================================================== */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
  position: relative;
  z-index: 2;
}

.container--narrow { max-width: var(--container-narrow); }

/* 12 列栅格 */
.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--grid-gap);
}

.span-3  { grid-column: span 3; }
.span-4  { grid-column: span 4; }
.span-5  { grid-column: span 5; }
.span-6  { grid-column: span 6; }
.span-7  { grid-column: span 7; }
.span-8  { grid-column: span 8; }
.span-9  { grid-column: span 9; }
.span-12 { grid-column: 1 / -1; }

/* 窄屏（≤860px）12 列栅格整体塌成单列。
   不塌的话 .span-6 等半宽单元仍被分到左右两栏，右半栏起点已越过视口，
   内部固定宽度元素（如 320px 吉祥物图）会撑出屏幕造成横向滚动。 */
@media (max-width: 860px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .span-3, .span-4, .span-5,
  .span-6, .span-7, .span-8, .span-9 { grid-column: 1 / -1; }
}

/* 栅格内图片等替换元素不得超出席位宽度 */
.grid img,
[class*="span-"] img { max-width: 100%; height: auto; }

/* 区块 */
.section {
  padding-block: clamp(var(--s-11), 8vw, var(--s-14));
  position: relative;
}
.section--tight { padding-block: clamp(var(--s-10), 6vw, var(--s-12)); }
.section--surface { background: var(--surface-2); }

/* 深色区块：冰裂纹底纹 */
.section--dark {
  background: var(--bg-dark);
  color: rgba(255, 255, 255, .72);
}
.section--dark h1,
.section--dark h2,
.section--dark h3,
.section--dark h4 { color: #fff; }

.crackle::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--tex-crackle);
  opacity: .05;
  pointer-events: none;
  z-index: 0;
}
.crackle > * { position: relative; z-index: 1; }

/* ==========================================================================
   排版工具类
   ========================================================================== */

.lead {
  font-size: var(--t-lead);
  line-height: 1.72;
  color: var(--ink-600);
  max-width: 56ch;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .lead { color: var(--ink-500); }
}

.text-muted { color: var(--ink-500); }
.text-sm { font-size: var(--t-sm); }
.text-xs { font-size: var(--t-xs); }
.mono {
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
}

/* 眉标：英文 + 短横线 */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  font-weight: 500;
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--brand-600);
}
.eyebrow::before {
  content: "";
  width: 22px;
  height: 1px;
  background: currentColor;
  opacity: .5;
}
.section--dark .eyebrow { color: var(--brand-300); }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .eyebrow { color: var(--brand-400); }
}

/* 区块标题组 */
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-6);
  flex-wrap: wrap;
  margin-bottom: clamp(var(--s-9), 4vw, var(--s-11));
}
.section-head__main { max-width: 58ch; }
.section-head__main h2 { margin-top: var(--s-3); }
.section-head__main .lead { margin-top: var(--s-4); }

/* ==========================================================================
   滚动显现 · 第二代实现
   --------------------------------------------------------------------------
   设计约束：内容在任何环境下都必须可见。
   方案 A（现代浏览器）：CSS 滚动驱动动画 animation-timeline: view()
   方案 B（不支持时）：元素保持静态可见，仅无动画
   JS 完全不参与判定 —— 杜绝 V1 的「观察器不回调 → 整页白屏」问题。
   ========================================================================== */

[data-reveal] {
  opacity: 1;
  transform: none;
}

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    [data-reveal] {
      animation: reveal-rise linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 62%;
    }
  }
}

@keyframes reveal-rise {
  from { opacity: 0; transform: translate3d(0, 14px, 0); }
  to   { opacity: 1; transform: none; }
}

/* 用户偏好减弱动效：全部静态呈现 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  [data-reveal] { opacity: 1 !important; transform: none !important; }
}

/* ==========================================================================
   打印
   ========================================================================== */
@media print {
  .site-header, .site-footer, .nav-toggle, .mobile-menu, .skip-link { display: none !important; }
  body { background: #fff; color: #000; }
  body::before { display: none; }
}
