/* =========================================
   GLIMWORK Design Tokens — 唯一令牌来源
   =========================================
   所有设计令牌在此文件统一定义。
   styles.css 和 admin.html 只消费令牌，不定义令牌。
   ========================================= */
:root {
  /* ========================================
     1. 色系基础 (ink + warm dark + atmospheric pastels)
     ======================================== */
  --ink: #292524;
  --ink-deep: #0d1117;
  --ink-active: #0d1117;
  --ink-mid: #1c1917;            /* 补充: 介于 ink 和 ink-deep 之间 */

  --body: #4e4e4e;
  --body-strong: #292524;
  --muted: #777169;
  --muted-soft: #a8a29e;

  /* ========================================
     2. 文字颜色 (4 档层级)
     ======================================== */
  --text: #e7e5e4;               /* 主文字色 — 暖白 */
  --text-2: #a8a29e;             /* 次文字色 — 暖灰 */
  --text-3: #777169;             /* 三级文字色 — 深暖灰 */
  --text-4: #a8a29e;             /* 四级文字色 — 浅暖灰 */

  --color-white: #ffffff;
  --color-text-primary: #fafaf9;
  --color-text-secondary: #a8a29e;       /* = var(--text-2) */
  --color-text-tertiary: #777169;        /* = var(--text-3) — 修正: 原 #57606a GitHub 色 */
  --color-border-subtle: #292524;        /* = var(--hairline) — 修正: 原 #30363d GitHub 色 */

  /* ========================================
     3. Canvas (暖深色, 电影质感)
     ======================================== */
  --canvas: #0d1117;
  --canvas-soft: #1c1917;
  --canvas-deep: #050403;
  --surface-card: #1c1917;
  --surface-strong: #292524;
  --surface-elevated: #1c1917;

  /* 兼容别名 */
  --canvas-bg: #0d1117;
  --canvas-surface: #1c1917;
  --canvas-border: #292524;

  /* ========================================
     4. Hairlines (边框/分割线)
     ======================================== */
  --hairline: #292524;
  --hairline-soft: #1c1917;
  --hairline-strong: #44403c;

  /* ========================================
     5. 主色 — 暖沙/香槟 (warm sand)
     ======================================== */
  --accent: #e8c4a0;
  --accent-rgb: 232, 196, 160;
  --accent-dim: rgba(232, 196, 160, 0.12);
  --accent-hover: #f0d4b0;
  --accent-3: #10b981;            /* 补充: 完成状态色 */

  /* 向后兼容: grad-* 统一指向同一主色 */
  --grad-mint: var(--accent);
  --grad-peach: var(--accent);
  --grad-lavender: var(--accent);
  --grad-sky: var(--accent);
  --grad-rose: var(--accent);

  /* ========================================
     6. 语义色
     ======================================== */
  --error: #dc2626;
  --success: #16a34a;
  --warning: #f59e0b;

  /* ========================================
     7. 向后兼容别名 (避免改 200+ 个 var(--orange-*))
     ======================================== */
  --orange: #e8c4a0;
  --orange-50: #161b22;
  --orange-100: #292524;
  --orange-200: #44403c;
  --orange-300: #78716c;
  --orange-400: rgba(232, 196, 160, 0.5);
  --orange-500: #e8c4a0;
  --orange-600: #f0d4b0;
  --orange-700: #f8e0c4;

  --yellow-50: #1c1917;
  --yellow-100: #292524;
  --yellow-200: #44403c;
  --yellow-300: #78716c;
  --yellow-400: #a8a29e;
  --yellow-500: #d6d3d1;
  --yellow-600: #e7e5e4;
  --yellow-700: #f5f5f5;

  --gray-50: #1c1917;
  --gray-100: #292524;
  --gray-200: #44403c;
  --gray-300: #78716c;
  --gray-400: #a8a29e;
  --gray-500: #d6d3d1;
  --gray-600: #e7e5e4;
  --gray-700: #f5f5f5;
  --gray-800: #fafafa;
  --gray-900: #ffffff;

  --green: #16a34a;
  --red: #dc2626;
  --blue: #a8c8e8;
  --purple: #c8b8e0;
  --blue-50: #1c1917;
  --blue-100: #292524;

  /* ========================================
     8. Type Scale (1.25 ratio, 16px base)
     ======================================== */
  --text-xs: 0.64rem;    /* 10px - captions */
  --text-sm: 0.8rem;     /* 13px - secondary */
  --text-base: 1rem;     /* 16px - body */
  --text-lg: 1.25rem;    /* 20px - lead */
  --text-xl: 1.563rem;   /* 25px - h4 */
  --text-2xl: 1.953rem;  /* 31px - h3 */
  --text-3xl: 2.441rem;  /* 39px - h2 */
  --text-4xl: 3.052rem;  /* 49px - h1 */
  --text-5xl: 3.815rem;  /* 61px - hero */

  /* 字体系统 */
  --font-system: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', 'Noto Sans SC', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;

  /* GEN3 字号梯度 (24/20/16/14/12 px) */
  --t-h1: 24px;
  --t-h2: 20px;
  --t-h3: 16px;
  --t-body: 14px;
  --t-caption: 12px;

  /* ========================================
     9. Spacing Scale (8px base)
     ======================================== */
  --space-0: 0;
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.25rem;  /* 20px */
  --space-6: 1.5rem;   /* 24px */
  --space-8: 2rem;     /* 32px */
  --space-10: 2.5rem;  /* 40px */
  --space-12: 3rem;    /* 48px */
  --space-16: 4rem;    /* 64px */
  --space-20: 5rem;    /* 80px */
  --space-24: 6rem;    /* 96px */

  /* ========================================
     10. Surface Layering (Dark Mode)
     ======================================== */
  --surface-0: var(--ink);              /* page */
  --surface-1: var(--canvas-soft);      /* card */
  --surface-2: var(--ink-mid);          /* raised */
  --surface-3: var(--surface-elevated); /* popover/modal */

  /* ========================================
     11. Color Roles (5 functional)
     ======================================== */
  --color-primary: var(--accent);           /* brand */
  --color-neutral: var(--text);             /* text + bg */
  --color-accent: var(--accent);            /* secondary */
  --color-semantic-success: var(--success);
  --color-semantic-warning: var(--warning);
  --color-semantic-error: var(--error);

  /* ========================================
     12. Radius (6 标准档 + 1 微元素档)
     ======================================== */
  --radius-xs: 3px;     /* 微元素: badge, tag, scrollbar thumb */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius: 10px;       /* 中间档 */
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;

  /* ========================================
     13. Motion (统一: communicate, not decorate)
     ======================================== */
  --motion-hover: 150ms ease-out;       /* 统一为 150ms (原 styles.css 为 200ms) */
  --motion-enter: 200ms ease-out;
  --motion-modal-open: 250ms ease-out;
  --motion-modal-close: 200ms ease-in;
  --motion-page: 300ms ease-in-out;
  --motion-stagger: 60ms;
  --motion-spin: 600ms linear infinite;

  /* ========================================
     14. Focus (WCAG 2.4.7)
     ======================================== */
  --focus-ring: 2px solid var(--accent);
  --focus-offset: 2px;

  /* ========================================
     15. Z-Index Scale
     ======================================== */
  --z-base: 1;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal: 1000;
  --z-toast: 2000;
  --z-tooltip: 3000;

  /* ========================================
     16. 渐变令牌
     ======================================== */
  --gradient-magic: linear-gradient(135deg, #a855f7, #6366f1); /* AI 魔法按钮专用 */
}

/* === Focus states (WCAG 2.4.7) === */
:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}
:focus:not(:focus-visible) {
  outline: none;
}

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
