/* ============================================================
   KARDS 军械库 —— 基础层：重置、排版、氛围、焦点、降级动效
   ============================================================ */

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.65;
  font-feature-settings: "kern";
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------- 氛围层：径向渐变网格 + 颗粒 ---------- */
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(70rem 45rem at 8% -12%, rgba(224, 161, 58, 0.10), transparent 62%),
    radial-gradient(55rem 40rem at 96% 4%, rgba(90, 120, 70, 0.14), transparent 58%),
    radial-gradient(60rem 50rem at 50% 110%, rgba(60, 80, 45, 0.12), transparent 60%);
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.045;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%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");
}

/* 细网格线：军用坐标感 */
.grid-lines {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    linear-gradient(to right, rgba(233,228,212,.022) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(233,228,212,.022) 1px, transparent 1px);
  background-size: 88px 88px;
}

/* ---------- 排版 ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0;
}

h1 { font-size: clamp(30px, 4.4vw, 54px); }
h2 { font-size: clamp(22px, 2.6vw, 32px); }
h3 { font-size: clamp(17px, 1.6vw, 21px); }

p { margin: 0 0 var(--space-4); }

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}
a:hover { color: var(--color-accent-hot); }

code, kbd, .mono, .num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* 章节标签：档案编号风格 */
.tag {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-accent);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.tag::before {
  content: "";
  width: 18px;
  height: 1px;
  background: var(--color-accent);
}

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

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

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--color-bg-deep); }
::-webkit-scrollbar-thumb {
  background: var(--color-surface-3);
  border: 2px solid var(--color-bg-deep);
  border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover { background: var(--color-raised); }

/* ---------- 入场序列（错峰 3-6 组） ---------- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
}
.reveal.in {
  opacity: 1;
  transform: none;
  transition:
    opacity var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out);
}
.reveal.d1 { transition-delay: 70ms; }
.reveal.d2 { transition-delay: 140ms; }
.reveal.d3 { transition-delay: 210ms; }
.reveal.d4 { transition-delay: 280ms; }
.reveal.d5 { transition-delay: 350ms; }

/* ---------- 降级动效 ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- 工具类 ---------- */
.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;
}
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.grow { flex: 1 1 auto; min-width: 0; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }