/* ─────────────────────────────────────────────────────────────
   tokens.css —— 设计令牌 · 宣纸底 + 朱砂强调的「自然有机 × 中医本草」
   说明：令牌值已固化，业务样式只可引用不可改写；所有页面共用本文件。
   ───────────────────────────────────────────────────────────── */

/* Fraunces（拉丁展示字，已本地化至 /fonts，零外网请求） */
@font-face {
  font-family: 'Fraunces';
  src: url('/fonts/fraunces-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Fraunces';
  src: url('/fonts/fraunces-latin-600-normal.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Fraunces';
  src: url('/fonts/fraunces-latin-700-normal.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Fraunces';
  src: url('/fonts/fraunces-latin-900-normal.woff2') format('woff2');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* 底色与面 */
  --color-bg: #F6F2E9;
  --color-surface: #FFFDF7;
  --color-surface-2: #EFE8D8;

  /* 文字 */
  --color-ink: #1E2420;
  --color-muted: #6B7166;
  --color-border: rgba(30, 36, 32, .14);

  /* 强调：朱砂 / 青黛 */
  --color-accent: #C0472B;
  --color-accent-ink: #A63A22;
  --color-teal: #2F5D62;

  /* 语义色 */
  --color-ok: #4B7A52;
  --color-warn: #C08A2E;
  --color-danger: #A63A22;

  /* 字体 */
  --font-display: "Fraunces", "Songti SC", "Source Han Serif SC", "Noto Serif SC", SimSun, serif;
  --font-body: "PingFang SC", "Source Han Sans SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;

  /* 动效 */
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --dur-fast: 160ms;
  --dur-base: 320ms;
  --dur-slow: 640ms;

  /* 图表 8 色序列（按序使用，不得乱序） */
  --chart-1: #C0472B;  /* 朱砂 */
  --chart-2: #2F5D62;  /* 青黛 */
  --chart-3: #7A8F5A;  /* 艾草 */
  --chart-4: #C08A2E;  /* 姜黄 */
  --chart-5: #8C5A3C;  /* 赭石 */
  --chart-6: #6B5B8A;  /* 紫草 */
  --chart-7: #9DB5A8;  /* 淡竹 */
  --chart-8: #B0794F;  /* 桂枝 */

  /* 圆角与投影 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-1: 0 1px 2px rgba(30, 36, 32, .06), 0 6px 18px -10px rgba(30, 36, 32, .16);
  --shadow-2: 0 2px 6px rgba(30, 36, 32, .08), 0 18px 40px -24px rgba(30, 36, 32, .28);

  /* 布局 */
  --page-max: 560px;
  --gutter: 16px;
  --hairline: 1px solid var(--color-border);

  /* 氛围层：宣纸噪点 */
  --paper-noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── 全局 reset ── */
*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100%;
  /* 宣纸底：噪点 + 两处低透明径向渐变 */
  background-color: var(--color-bg);
  background-image:
    radial-gradient(1100px 520px at 12% -8%, rgba(122, 143, 90, .16), transparent 62%),
    radial-gradient(880px 460px at 96% 4%, rgba(192, 71, 43, .10), transparent 58%),
    var(--paper-noise);
  background-repeat: no-repeat, no-repeat, repeat;
  background-size: auto, auto, 140px 140px;
  background-attachment: fixed, fixed, fixed;
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* 噪点层单独承载 opacity，避免污染背景色 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: var(--paper-noise);
  background-size: 140px 140px;
  opacity: .04;
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: .01em;
}

p { margin: 0; }

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

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
}

input, textarea, select {
  font-family: inherit;
  font-size: 16px; /* iOS 聚焦不缩放 */
  color: inherit;
}

/* 数字统一等宽，避免跳动 */
.num,
.stat-value,
.kpi-value {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* 键盘可达：统一 focus-visible 描边 */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* 无障碍隐藏但保留给屏幕阅读器 */
.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;
}

/* 入场动效基类：错峰 60-120ms，全部包在 prefers-reduced-motion 降级内 */
.rise {
  opacity: 0;
  transform: translate3d(0, 12px, 0);
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}
.rise.is-in {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .rise {
    opacity: 1;
    transform: none;
  }
}
