/* ============================================================================
   Tree.AI Design System · tokens.css
   v1.1 · 2026-11-23 · 树语智能（补齐线上高频间距/字号阶梯）
   ----------------------------------------------------------------------------
   三层令牌架构：
     1) Primitive（原料层）  --ds-green-600     只允许在本文件内被引用
     2) Semantic（语义层）   --ds-color-accent  组件与页面唯一可直接消费的一层
     3) Component（组件层）  --ds-btn-primary-bg 组件内部使用，便于局部微调
   规则：组件里出现十六进制颜色，视为缺陷（见 README「设计 QA 清单」）。
   ========================================================================== */

/* ---------- 字体：Space Grotesk（拉丁/数字，自托管 OFL，变量字重 300–700） ---------- */
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url(assets/space-grotesk-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ============================================================================
   1. PRIMITIVE · 原料层
   ========================================================================== */
:root {
  /* 主色 · 树语绿（品牌识别色，界面主色） */
  --ds-green-50:  #f7faf0;
  --ds-green-100: #eff4e4;
  --ds-green-200: #dfead0;
  --ds-green-300: #c6daae;
  --ds-green-400: #9bc178;
  --ds-green-500: #6aa24d;
  --ds-green-600: #2f7d3a;   /* Brand Green */
  --ds-green-700: #276633;
  --ds-green-800: #1f5129;
  --ds-green-900: #173d20;
  --ds-green-950: #0f2614;

  /* 强调色 · 嫩芽青柠（只用于单一转化点与需要被看见的瞬间） */
  --ds-lime-300: #dcf27a;
  --ds-lime-400: #cfea52;
  --ds-lime-500: #c0e937;    /* Brand Lime */
  --ds-lime-600: #a8cf22;

  /* 中性 · 带绿倾向的暖灰（不用纯灰，避免与纸感底色脱节） */
  --ds-warm-0:   #ffffff;
  --ds-warm-25:  #fbfdf5;
  --ds-warm-50:  #f7faf0;
  --ds-warm-100: #eff4e4;
  --ds-warm-200: #e4ecd4;
  --ds-warm-300: #cdd5c3;
  --ds-warm-400: #b2b8a8;
  --ds-warm-500: #8f9784;
  --ds-warm-600: #6b7460;
  --ds-warm-700: #4d5546;
  --ds-warm-800: #2c322a;
  --ds-warm-900: #1f241c;    /* Ink */
  --ds-warm-950: #14170f;

  /* 语义辅色 · 金（会员/价值）、紫（AI/新事物，兼作旧版标志色） */
  --ds-gold-100:   #f5eed2;
  --ds-gold-500:   #c79a34;
  --ds-gold-600:   #8a6410;
  --ds-gold-700:   #6d4e0b;
  --ds-violet-100: #efe9ff;
  --ds-violet-500: #7a58d8;
  --ds-violet-600: #6b48cf;
  --ds-violet-700: #5636b3;

  /* 状态 · 成功 / 危险 */
  --ds-green-ok-50:  #e6f4ec;
  --ds-green-ok-600: #147a4a;
  --ds-green-ok-400: #4cc58c;
  --ds-red-50:       #fbeae8;
  --ds-red-500:      #e06555;
  --ds-red-600:      #c0392b;
  --ds-red-700:      #9c2a1f;
}

/* ============================================================================
   2. SEMANTIC · 语义层（浅色为默认值）
   ========================================================================== */
:root,
[data-ds-theme="light"] {
  color-scheme: light;

  /* 背景与表面 */
  --ds-color-bg:            var(--ds-green-50);
  --ds-color-bg-subtle:     var(--ds-green-100);
  --ds-color-bg-muted:      var(--ds-warm-200);
  --ds-color-surface:       var(--ds-warm-0);
  --ds-color-surface-sunken: var(--ds-warm-25);
  --ds-color-surface-raised: var(--ds-warm-0);
  --ds-color-field:         var(--ds-warm-0);
  --ds-color-overlay:       rgba(12, 14, 10, .38);

  /* 文字 */
  --ds-color-text:           var(--ds-warm-900);
  --ds-color-text-secondary: var(--ds-warm-700);
  --ds-color-text-muted:     var(--ds-warm-600);
  --ds-color-text-inverted:  var(--ds-green-50);

  /* 描边 */
  --ds-color-border:        rgba(63, 90, 40, .13);
  --ds-color-border-strong: rgba(63, 90, 40, .24);

  /* 品牌 */
  --ds-color-accent:        var(--ds-green-600);
  --ds-color-accent-hover:  var(--ds-green-700);
  --ds-color-accent-soft:   #e8f3d6;
  --ds-color-on-accent:     #ffffff;
  --ds-color-highlight:     var(--ds-lime-500);
  --ds-color-on-highlight:  #1d2117;
  --ds-color-highlight-glow: rgba(150, 190, 40, .55);

  /* 状态 */
  --ds-color-success:      var(--ds-green-ok-600);
  --ds-color-success-soft: var(--ds-green-ok-50);
  --ds-color-warning:      var(--ds-gold-600);
  --ds-color-warning-soft: var(--ds-gold-100);
  --ds-color-danger:       var(--ds-red-600);
  --ds-color-danger-soft:  var(--ds-red-50);
  --ds-color-info:         var(--ds-violet-600);
  --ds-color-info-soft:    var(--ds-violet-100);

  /* 交互 */
  --ds-color-focus:      var(--ds-green-600);
  --ds-color-focus-ring: rgba(47, 125, 58, .20);
  --ds-color-selection:  rgba(192, 233, 55, .55);
}

/* ---------- 深色主题：站点用 html.dark，设计系统用 [data-ds-theme="dark"] ---------- */
html.dark,
[data-ds-theme="dark"] {
  color-scheme: dark;

  --ds-color-bg:            #191c17;
  --ds-color-bg-subtle:     #1f231b;
  --ds-color-bg-muted:      #272c24;
  --ds-color-surface:       #23271f;
  --ds-color-surface-sunken: #1b1e18;
  --ds-color-surface-raised: #272c24;
  --ds-color-field:         #1b1e18;
  --ds-color-overlay:       rgba(0, 0, 0, .62);

  --ds-color-text:           #ecefe6;
  --ds-color-text-secondary: #b2b8a8;
  --ds-color-text-muted:     #8f9784;
  --ds-color-text-inverted:  #191c17;

  --ds-color-border:        rgba(255, 255, 255, .075);
  --ds-color-border-strong: rgba(255, 255, 255, .14);

  --ds-color-accent:        #7cc65a;
  --ds-color-accent-hover:  #93d472;
  --ds-color-accent-soft:   #16240f;
  --ds-color-on-accent:     #0f1510;
  --ds-color-highlight:     var(--ds-lime-500);
  --ds-color-on-highlight:  #0f1510;
  --ds-color-highlight-glow: rgba(120, 160, 30, .40);

  --ds-color-success:      #4cc58c;
  --ds-color-success-soft: #0f2319;
  --ds-color-warning:      #e3b257;
  --ds-color-warning-soft: #2a2410;
  --ds-color-danger:       #e06555;
  --ds-color-danger-soft:  #2a1512;
  --ds-color-info:         #b497ef;
  --ds-color-info-soft:    #26203a;

  --ds-color-focus:      #7cc65a;
  --ds-color-focus-ring: rgba(124, 198, 90, .26);
  --ds-color-selection:  rgba(192, 233, 55, .30);
}

/* ============================================================================
   3. 排版
   ========================================================================== */
:root {
  --ds-font-sans: "Space Grotesk", "PingFang SC", "Noto Sans SC", "Microsoft YaHei",
                  -apple-system, BlinkMacSystemFont, sans-serif;
  --ds-font-serif: "Noto Serif SC", "Songti SC", "SimSun", Georgia, serif;
  --ds-font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* v1.1 正式阶梯：命名即像素值。新增界面只用这一组。 */
  --ds-text-10: 10px;   /* 极小角标 */
  --ds-text-11: 11px;   /* 元信息 */
  --ds-text-12: 12px;   /* 辅助说明、表格 */
  --ds-text-13: 13px;   /* 导航、次级正文（线上主用字号） */
  --ds-text-14: 14px;   /* 按钮、表单 */
  --ds-text-15: 15px;   /* 正文基准 */
  --ds-text-16: 16px;
  --ds-text-17: 17px;   /* 导语 */
  --ds-text-18: 18px;
  --ds-text-20: 20px;   /* 小标题 */
  --ds-text-22: 22px;   /* 卡片组标题 */
  --ds-text-24: 24px;
  --ds-text-28: 28px;
  --ds-text-32: 32px;
  --ds-text-40: 40px;
  --ds-text-3xl:  clamp(24px, 3vw, 36px);
  --ds-text-4xl:  clamp(32px, 4.6vw, 56px);
  --ds-text-5xl:  clamp(40px, 6vw, 76px);

  /* 存量别名（deprecated）：v1.0 遗留，仅用于存量组件，新增界面不得使用。 */
  --ds-text-code: 10.5px;   /* 键位、版本号（等宽） */
  --ds-text-2xs:  11.5px;   /* → --ds-text-11 */
  --ds-text-xs:   12.5px;   /* → --ds-text-12 */
  --ds-text-sm:   13.5px;   /* → --ds-text-13 */
  --ds-text-base: 15px;     /* → --ds-text-15 */
  --ds-text-md:   16px;     /* → --ds-text-16 */
  --ds-text-lg:   17px;     /* → --ds-text-17 */
  --ds-text-xl:   20px;     /* → --ds-text-20 */
  --ds-text-2xl:  22px;     /* → --ds-text-22 */

  --ds-leading-none:    1;
  --ds-leading-tight:   1.08;
  --ds-leading-snug:    1.25;
  --ds-leading-normal:  1.5;
  --ds-leading-relaxed: 1.65;
  --ds-leading-loose:   1.75;

  --ds-tracking-display: -.035em;
  --ds-tracking-heading: -.025em;
  --ds-tracking-normal:  0;
  --ds-tracking-label:   .04em;
  --ds-tracking-caps:    .12em;

  --ds-weight-regular:  400;
  --ds-weight-medium:   500;
  --ds-weight-semibold: 600;
  --ds-weight-bold:     700;
}

/* ============================================================================
   4. 间距（v1.1：4px 基准 + 2px 半档；命名即像素值）
   线上高频的 6/10/14/18/22/26/28/30px 已纳入正式阶梯，避免“为了合规而改版”。
   1px 属于描边宽度，用 --ds-hairline，不占间距令牌。
   ========================================================================== */
:root {
  --ds-hairline: 1px;
  --ds-space-0:  0px;
  --ds-space-2:  2px;
  --ds-space-4:  4px;
  --ds-space-6:  6px;
  --ds-space-8:  8px;
  --ds-space-10: 10px;
  --ds-space-12: 12px;
  --ds-space-14: 14px;
  --ds-space-16: 16px;
  --ds-space-18: 18px;
  --ds-space-20: 20px;
  --ds-space-22: 22px;
  --ds-space-24: 24px;
  --ds-space-26: 26px;
  --ds-space-28: 28px;
  --ds-space-30: 30px;
  --ds-space-32: 32px;
  --ds-space-40: 40px;
  --ds-space-48: 48px;
  --ds-space-56: 56px;
  --ds-space-72: 72px;
  --ds-space-96: 96px;
}

/* ============================================================================
   5. 圆角与阴影
   ========================================================================== */
:root {
  --ds-radius-xs:  5px;    /* 徽标、小标签 */
  --ds-radius-sm:  8px;    /* 侧栏项、图标按钮 */
  --ds-radius-md:  11px;   /* 按钮、输入框 */
  --ds-radius-lg:  14px;   /* 图片、小卡片 */
  --ds-radius-xl:  20px;   /* 卡片 */
  --ds-radius-2xl: 24px;   /* 面板、弹窗、表单容器 */
  --ds-radius-pill: 999px;

  --ds-shadow-hairline: inset 0 0 0 1px var(--ds-color-border);
  --ds-shadow-1: 0 1px 2px rgba(12, 12, 14, .05);
  --ds-shadow-2: 0 2px 6px rgba(12, 12, 14, .05), 0 12px 28px -16px rgba(12, 12, 14, .18);
  --ds-shadow-3: 0 2px 6px rgba(12, 12, 14, .05), 0 30px 70px -24px rgba(12, 12, 14, .30);
  --ds-shadow-focus: 0 0 0 3px var(--ds-color-focus-ring);
}
html.dark,
[data-ds-theme="dark"] {
  --ds-shadow-1: 0 1px 2px rgba(0, 0, 0, .40);
  --ds-shadow-2: 0 2px 6px rgba(0, 0, 0, .40), 0 14px 30px -16px rgba(0, 0, 0, .70);
  --ds-shadow-3: 0 2px 6px rgba(0, 0, 0, .40), 0 30px 70px -24px rgba(0, 0, 0, .90);
}

/* ============================================================================
   6. 动效
   ========================================================================== */
:root {
  --ds-duration-instant: 80ms;
  --ds-duration-fast:    120ms;
  --ds-duration-base:    200ms;
  --ds-duration-slow:    320ms;
  --ds-duration-enter:   600ms;

  --ds-ease-standard: cubic-bezier(.2, .8, .2, 1);
  --ds-ease-out:      cubic-bezier(.2, .7, .2, 1);
  --ds-ease-in-out:   ease-in-out;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --ds-duration-instant: 1ms;
    --ds-duration-fast:    1ms;
    --ds-duration-base:    1ms;
    --ds-duration-slow:    1ms;
    --ds-duration-enter:   1ms;
  }
}

/* ============================================================================
   7. 布局与层级
   ========================================================================== */
:root {
  --ds-container:        1180px;
  --ds-container-narrow: 760px;
  --ds-container-prose:  680px;
  --ds-sidebar-w:        248px;
  --ds-topbar-h:         52px;
  --ds-tap-min:          44px;

  --ds-z-base:     1;
  --ds-z-sticky:   40;
  --ds-z-header:   50;
  --ds-z-overlay:  55;
  --ds-z-drawer:   60;
  --ds-z-dropdown: 120;
  --ds-z-modal:    170;
  --ds-z-toast:    200;
}

/* 断点（供实现参考，CSS 变量不能用于媒体查询）：
   480  小屏手机       单列、隐藏次级信息
   640  手机横向       卡片单列、弹窗变底部抽屉
   760  平板竖屏       底栏出现、页脚两列
   920  平板横屏       侧栏变抽屉
   1051 桌面           正文双栏 / 阅读目录
   1180 大桌面         版心封顶
*/

/* ============================================================================
   8. COMPONENT · 组件层
   ========================================================================== */
:root {
  --ds-btn-height-sm: 36px;
  --ds-btn-height:    44px;
  --ds-btn-height-lg: 50px;
  --ds-btn-px:        18px;
  --ds-btn-radius:    var(--ds-radius-md);

  --ds-input-height: 44px;
  --ds-input-radius: var(--ds-radius-md);

  --ds-card-bg:     var(--ds-color-surface);
  --ds-card-radius: var(--ds-radius-xl);
  --ds-card-border: var(--ds-color-border);
}
