/* ============================================================================
   两站统一设计宪法  design-tokens.css  v1 (2026-11-17)
   ----------------------------------------------------------------------------
   定位：启明(qimenseek) 与 境明(qimenai) 全站唯一设计事实源。
   所有页面只引用这份 token + 组件类，禁止在页面内联里再写魔法色/字号/圆角/间距。
   现有 ds.css 的"变量重映射"是过渡补丁，被本文件取代（同作用域下本文件更靠后即生效）。

   设计原则（玄学/命理站：克制、高贵、有节奏）：
     1. 单一色板——收敛现有 site.css / index.html / ds.css 三套互打架的变量为一份。
     2. 字阶 4 级——标题 1/标题 2/正文/辅助，杜绝 13/15/17 种字号并存。
     3. 间距 8pt 节奏——4/8/12/16/24/32/48/64，section 垂直呼吸统一。
     4. 圆角 2 级——卡片 12 / 控件 8（全圆角胶囊仅用于主 CTA，收敛 7~9 种圆角）。
     5. 组件类——.btn / .card / .section / .grid / .nav 统一，页面挂类名不内联。
   ============================================================================ */

/* ============================ 1. 暗色主题（默认） ============================ */
:root,
html[data-ds-theme="dark"],
html[data-theme="dark"] {
  /* 色板 —— 玄学深蓝 + 鎏金（收敛自启明 index.html 深色 :root） */
  --bg:            #0f1419;   /* 页面底 */
  --bg-elev:       #161d27;   /* 区块/卡底（原 --bg-secondary #1a2332，压一档更沉） */
  --bg-card:       #1c2534;   /* 卡片（原 #212b3c，统一到此） */
  --modal-bg:      #1a1f35;   /* 模态弹层固定深底（不随主题变，承载亮字） */
  --bg-card-hover: #242f40;
  --surface-2:     #242f40;

  --text:          #f0f2f5;   /* 主文字（近白，保证对比） */
  --text-2:        #b0bccd;   /* 次级文字 */
  --text-3:        #8fa0b5;   /* 提示/弱化（7.4:1 已修） */

  --gold:          #d4a853;   /* 主强调（鎏金） */
  --gold-strong:   #f0d48a;   /* 强调高亮 */
  --gold-dim:      rgba(212,168,83,.15);
  --gold-line:     rgba(212,168,83,.32);

  /* 功能色（奇门九星/五行语义，dim 版做底） */
  --red:    #e06a5f;  --red-dim:    rgba(224,106,95,.14);
  --teal:   #4a9e9e;  --teal-dim:   rgba(74,158,158,.14);
  --purple: #9a7bd4;  --purple-dim: rgba(154,123,212,.14);
  --green:  #5aa96f;  --green-dim:  rgba(90,169,111,.14);
  --blue:   #5a82c0;  --blue-dim:   rgba(90,130,192,.14);
  --gray:   #6b7280;  --gray-dim:   rgba(107,114,128,.14);

  --line:        rgba(212,168,83,.18);   /* 默认描边 */
  --line-soft:   rgba(255,255,255,.06);
  --shadow:      0 8px 30px rgba(0,0,0,.32);
  --shadow-soft: 0 4px 14px rgba(0,0,0,.22);

  /* 兼容旧变量名（页面仍 var(--bg-primary) 等也能解析到同一份值） */
  --bg-primary:  var(--bg);
  --bg-secondary: var(--bg-elev);
  --text-primary: var(--text);
  --text-secondary: var(--text-2);
  --text-muted:   var(--text-3);
  --border:       var(--line);
  --border-soft:  var(--line-soft);
}

/* ============================ 2. 浅色主题 ============================ */
html[data-ds-theme="light"],
html[data-theme="light"] {
  --bg:            #faf8f3;
  --bg-elev:       #f4f0e6;
  --bg-card:       #ffffff;
  --modal-bg:      #1a1f35;   /* 模态弹层固定深底（不随主题变，承载亮字） */
  --bg-card-hover: #f5f1e8;
  --surface-2:     #f4f0e6;

  --text:          #1f2430;
  --text-2:        #4b5568;
  --text-3:        #5f6b80;

  --gold:          #8a6a20;   /* 浅底金色加深（4.7:1 已修） */
  --gold-strong:   #6d5318;
  --gold-dim:      rgba(138,106,32,.12);
  --gold-line:     rgba(138,106,32,.30);

  --red:    #b03a3a;  --red-dim:    rgba(176,58,58,.10);
  --teal:   #2e7d7d;  --teal-dim:   rgba(46,125,125,.10);
  --purple: #6b4fa3;  --purple-dim: rgba(107,79,163,.10);
  --green:  #3f7d52;  --green-dim:  rgba(63,125,82,.10);
  --blue:   #3a5a8f;  --blue-dim:   rgba(58,90,143,.10);
  --gray:   #5f6b80;  --gray-dim:   rgba(95,107,128,.10);

  --line:        rgba(138,106,32,.22);
  --line-soft:   rgba(0,0,0,.07);
  --shadow:      0 10px 30px rgba(31,36,48,.10);
  --shadow-soft: 0 4px 14px rgba(31,36,48,.08);

  --bg-primary:  var(--bg);
  --bg-secondary: var(--bg-elev);
  --text-primary: var(--text);
  --text-secondary: var(--text-2);
  --text-muted:   var(--text-3);
  --border:       var(--line);
  --border-soft:  var(--line-soft);
}

/* ============================ 3. 字阶层级（type scale） ============================
   4 级主 + 2 级辅助，全站点只用这些。禁止 9/11.5/13.6/15.2/21.6 等奇数。 */
:root {
  --fs-hero:    40px;  /* H1 主标题 */
  --fs-h1:      32px;  /* 页级标题 */
  --fs-h2:      24px;  /* 区块标题 */
  --fs-h3:      18px;  /* 卡片/小节标题 */
  --fs-body:    16px;  /* 正文 */
  --fs-small:   14px;  /* 辅助正文 */
  --fs-caption: 13px;  /* 提示/标注 */
  --fs-scale-factor: 1.25;

  --fw-regular: 400;
  --fw-medium:  500;
  --fw-semibold:600;
  --fw-bold:    700;

  --lh-tight: 1.25;   /* 标题 */
  --lh-body:  1.6;    /* 正文 */
  --lh-loose: 1.75;

  /* 字号变量（页面统一引用，禁写裸 px） */
  --fs-1: var(--fs-hero);
  --fs-2: var(--fs-h1);
  --fs-3: var(--fs-h2);
  --fs-4: var(--fs-h3);
  --fs-5: var(--fs-body);
  --fs-6: var(--fs-small);
  --fs-7: var(--fs-caption);
}

/* ============================ 4. 间距节奏（8pt） ============================
   只允许这 8 档，section 之间用 48/64。 */
:root {
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;
  --section-gap: 64px;   /* 桌面 section 垂直呼吸 */
  --section-gap-m: 48px; /* 移动 */

  /* 圆角（仅 2 级 + 胶囊） */
  --r-card: 12px;
  --r-control: 8px;
  --r-pill: 999px;
  --r-max: 20px;

  /* 容器宽度 */
  --maxw: 1100px;     /* 内容主容器 */
  --maxw-narrow: 720px; /* 单列正文（博客/报告） */
  --gutter: 24px;     /* 容器两侧留白 */
}

/* ============================ 5. 基础重置 ============================ */
html[data-ds] * { box-sizing: border-box; }
html[data-ds] {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC",
               "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
}
body { margin: 0; background: var(--bg); color: var(--text); }

/* 字阶工具类：页面标题/正文挂这些类，不再写裸字号 */
html[data-ds] .t-hero { font-size: var(--fs-1); line-height: var(--lh-tight); font-weight: var(--fw-bold); }
html[data-ds] .t-h1   { font-size: var(--fs-2); line-height: var(--lh-tight); font-weight: var(--fw-bold); }
html[data-ds] .t-h2   { font-size: var(--fs-3); line-height: var(--lh-tight); font-weight: var(--fw-bold); }
html[data-ds] .t-h3   { font-size: var(--fs-4); line-height: var(--lh-tight); font-weight: var(--fw-semibold); }
html[data-ds] .t-body { font-size: var(--fs-5); line-height: var(--lh-body); }
html[data-ds] .t-small{ font-size: var(--fs-6); line-height: var(--lh-body); color: var(--text-2); }
html[data-ds] .t-cap  { font-size: var(--fs-7); line-height: 1.4; color: var(--text-3); }

/* ============================ 6. 通用组件类 ============================ */
/* —— 按钮（统一 3 种，替代首页 6 种分裂按钮）—— */
html[data-ds] .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: var(--fs-5); font-weight: var(--fw-semibold);
  border-radius: var(--r-control); padding: 12px 24px;
  cursor: pointer; text-decoration: none; line-height: 1;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease, border-color .16s ease;
  border: 1px solid transparent;
}
html[data-ds] .btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-strong));
  color: #1a1a1a; box-shadow: 0 4px 14px var(--gold-dim);
}
html[data-ds] .btn-primary:hover { box-shadow: 0 6px 20px var(--gold-dim); }
html[data-ds] .btn-ghost {
  background: transparent; color: var(--text-2); border-color: var(--line);
}
html[data-ds] .btn-ghost:hover { color: var(--gold); border-color: var(--gold-line); background: var(--gold-dim); }
html[data-ds] .btn-sm { padding: 8px 16px; font-size: var(--fs-6); }
html[data-ds] .btn-pill { border-radius: var(--r-pill); }

/* —— 卡片（统一 1 种，替代各页自造）—— */
html[data-ds] .card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: var(--sp-5);
  box-shadow: var(--shadow-soft);
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
html[data-ds] .card-hover:hover {
  background: var(--bg-card-hover);
  border-color: var(--gold-line);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
html[data-ds] .card h3 { font-size: var(--fs-4); font-weight: var(--fw-semibold);
                          color: var(--text); margin: 0 0 var(--sp-3); }
html[data-ds] .card p  { font-size: var(--fs-5); color: var(--text-2);
                          line-height: var(--lh-body); margin: 0 0 var(--sp-2); }
html[data-ds] .card .card-cta { display: inline-block; margin-top: var(--sp-3);
                                font-size: var(--fs-6); font-weight: var(--fw-semibold);
                                color: var(--gold); }

/* —— 区块（统一垂直节奏）—— */
html[data-ds] .section {
  max-width: var(--maxw); margin: 0 auto;
  padding: 0 var(--gutter);
}
html[data-ds] .section + .section { margin-top: var(--section-gap); }
html[data-ds] .section-head { text-align: center; margin-bottom: var(--sp-6); }
html[data-ds] .section-head h2 { font-size: var(--fs-3); font-weight: var(--fw-bold);
                                  color: var(--text); margin: 0 0 var(--sp-2); }
html[data-ds] .section-head p  { font-size: var(--fs-5); color: var(--text-2); margin: 0; }

/* —— 栅格 —— */
html[data-ds] .grid { display: grid; gap: var(--sp-5); }
html[data-ds] .grid-2 { grid-template-columns: repeat(2, 1fr); }
html[data-ds] .grid-3 { grid-template-columns: repeat(3, 1fr); }
html[data-ds] .grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
  html[data-ds] .grid-3, html[data-ds] .grid-4 { grid-template-columns: repeat(2, 1fr); }
  html[data-ds] .section + .section { margin-top: var(--section-gap-m); }
}
@media (max-width: 600px) {
  html[data-ds] .grid-2, html[data-ds] .grid-3, html[data-ds] .grid-4 { grid-template-columns: 1fr; }
  html[data-ds] .t-hero, html[data-ds] .t-h1 { font-size: 28px; }
  html[data-ds] .t-h2 { font-size: 20px; }
}

/* ============================ 7. 文本角色类（替代内联色） ============================ */
html[data-ds] .c-gold   { color: var(--gold); }
html[data-ds] .c-red    { color: var(--red); }
html[data-ds] .c-green  { color: var(--green); }
html[data-ds] .c-muted  { color: var(--text-2); }
html[data-ds] .c-3      { color: var(--text-3); }
html[data-ds] .bg-gold-dim { background: var(--gold-dim); }
html[data-ds] .b-line   { border: 1px solid var(--line); }
html[data-ds] .b-card   { border: 1px solid var(--line); border-radius: var(--r-card); }
