/* ============================================================
   基础层：重置 / 排版 / 焦点 / 氛围 / 降级动效
   ============================================================ */

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

html { scroll-behavior: smooth; }

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.75;
  letter-spacing: 0.02em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  cursor: none; /* 桌面端由自定义光标接管，触屏端在组件层恢复 */
}

img, video, canvas, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: none; }
ul, ol { list-style: none; }
::selection { background: var(--color-accent); color: var(--color-text); }

/* ---- 标题排版 ---- */
h1, h2, h3 {
  font-family: var(--font-cn-heavy);
  font-weight: 900;
  line-height: 1.06;
  letter-spacing: 0.01em;
}

.display-latin {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.mono-tag {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-muted);
}

/* ---- 焦点可见性：键盘用户必须有清晰描边 ---- */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ---- 氛围层：渐变网格 + 噪点颗粒 ---- */
.atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(70rem 46rem at 85% -12%, rgba(230, 51, 41, 0.16), transparent 62%),
    radial-gradient(56rem 40rem at -10% 40%, rgba(230, 51, 41, 0.07), transparent 58%),
    radial-gradient(80rem 60rem at 50% 120%, rgba(164, 30, 22, 0.1), transparent 60%);
}

.grain {
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  pointer-events: none;
  z-index: 200;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 0.9s steps(4) infinite;
}

@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 1.4%); }
  50% { transform: translate(1.6%, -1%); }
  75% { transform: translate(-1%, -1.8%); }
  100% { transform: translate(0, 0); }
}

/* ---- 主内容压在氛围层之上 ---- */
.site-header, main, .site-footer { position: relative; z-index: 2; }

/* ---- 滚动入场基类：只动 opacity / translateY ---- */
/* 渐进增强：只有 JS 确认可用时才隐藏待入场元素（html.js 由 head 内联脚本添加），
   避免任何脚本异常导致内容永久不可见 */
html.js .reveal {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity var(--dur-slow) var(--ease-out),
    transform var(--dur-slow) var(--ease-out);
}
html.js .reveal.in { opacity: 1; transform: none; }
.reveal[data-delay="1"] { transition-delay: 90ms; }
.reveal[data-delay="2"] { transition-delay: 180ms; }
.reveal[data-delay="3"] { transition-delay: 270ms; }
.reveal[data-delay="4"] { transition-delay: 360ms; }

/* ---- 降级：减少动态偏好的用户关闭一切动效 ---- */
@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;
  }
  .reveal { opacity: 1; transform: none; }
  .grain { animation: none; }
}

/* ---- 触屏设备：恢复系统光标，隐藏自定义光标 ---- */
@media (hover: none), (pointer: coarse) {
  body, button, a { cursor: auto; }
  .cursor-dot, .cursor-ring { display: none !important; }
}
