/* ==========================================================================
   OpenParticle — Design Tokens
   单一事实来源：DESIGN.md §2 / §3 / §4 / §7
   浅色为默认，[data-theme="dark"] 覆盖。
   ========================================================================== */

:root {
    color-scheme: light;

    /* ---- Color: surfaces ---- */
    --color-canvas:        #FAFAFA;
    --color-surface:       #FFFFFF;
    --color-surface-2:     #F4F5F6;
    --color-surface-3:     #EDEEF0;

    /* ---- Color: text ---- */
    --color-text:          #0D0E10;
    --color-text-2:        #4B5058;
    --color-text-3:        #6B7280;   /* AA: 4.83:1 on #FFF */
    --color-text-4:        #AEB4BC;   /* 仅禁用态，AA 豁免 */

    /* ---- Color: borders ---- */
    --color-border:        #E2E4E8;
    --color-border-subtle: #EDEEF0;
    --color-border-strong: #C9CDD3;

    /* ---- Color: accent (唯一彩色) ---- */
    --color-accent:        #0F766E;   /* AA: 5.51:1 on #FFF */
    --color-accent-hover:  #115E59;
    --color-accent-bg:     #E6F5F3;
    --color-on-accent:     #FFFFFF;   /* accent 实底上的文字色 */

    /* ---- Color: status ---- */
    --color-success:       #15803D;
    --color-warning:       #B45309;
    --color-error:         #B91C1C;
    --color-info:          #1D4ED8;
    --color-backdrop:      rgba(13, 14, 16, 0.45);
    --color-success-bg:    #ECFDF3;
    --color-warning-bg:    #FFFBEB;
    --color-error-bg:      #FEF2F2;
    --color-info-bg:       #EFF6FF;

    /* ---- Typography ---- */
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
                 "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, SFMono-Regular,
                 Menlo, Consolas, "Liberation Mono", monospace;

    --text-display: clamp(1.75rem, 3vw, 2.5rem);
    --text-h1:      1.75rem;
    --text-h2:      1.375rem;
    --text-h3:      1.0625rem;
    --text-body-lg: 1rem;
    --text-body:    0.9375rem;
    --text-body-sm: 0.8125rem;
    --text-label:   0.75rem;
    --text-caption: 0.6875rem;
    --text-overline: 0.625rem;
    --text-mono:    0.8125rem;

    --leading-display: 1.1;
    --leading-h1:      1.2;
    --leading-h2:      1.3;
    --leading-h3:      1.35;
    --leading-body:    1.6;
    --leading-tight:   1.45;

    --tracking-display: -0.02em;
    --tracking-h1:      -0.015em;
    --tracking-h2:      -0.01em;
    --tracking-none:    0;
    --tracking-label:   0.01em;
    --tracking-caption: 0.02em;
    --tracking-overline: 0.08em;

    /* ---- Spacing (4px base) ---- */
    --space-1:  4px;
    --space-2:  8px;
    --space-3:  12px;
    --space-4:  16px;
    --space-5:  20px;
    --space-6:  24px;
    --space-8:  32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;

    /* ---- Radius ---- */
    --radius-badge:   4px;
    --radius-control: 6px;
    --radius-card:    8px;
    --radius-panel:   12px;

    /* ---- Layout ---- */
    --layout-max:  1280px;
    --layout-wide: 1440px;
    --nav-height:  56px;
    --nav-height-mobile: 52px;

    /* ---- Depth: overlays only ---- */
    --shadow-overlay: 0 8px 24px rgba(13, 14, 16, 0.10), 0 0 0 1px var(--color-border);
    --shadow-overlay-strong: 0 16px 40px rgba(13, 14, 16, 0.14), 0 0 0 1px var(--color-border);

    /* ---- Motion ---- */
    --dur-micro:    120ms;
    --dur-standard: 160ms;
    --dur-emphasis: 320ms;
    --ease-micro:    ease-out;
    --ease-standard: cubic-bezier(0.2, 0, 0, 1);
    --ease-emphasis: cubic-bezier(0.16, 1, 0.3, 1);

    /* ---- Focus ---- */
    --focus-ring: 2px solid var(--color-accent);
    --focus-offset: 2px;

    /* ---- Z-index scale ---- */
    --z-nav:     50;
    --z-overlay: 60;
    --z-modal:   70;
    --z-toast:   80;
}

/* ==========================================================================
   Dark theme — 表面亮度递进，不用阴影表达层级
   ========================================================================== */
[data-theme="dark"] {
    color-scheme: dark;

    --color-canvas:        #08090A;
    --color-surface:       #0F1011;
    --color-surface-2:     #141516;
    --color-surface-3:     #1B1C1E;

    --color-text:          #F7F8F8;
    --color-text-2:        #D0D6E0;
    --color-text-3:        #8A8F98;
    --color-text-4:        #62666D;

    --color-border:        rgba(255, 255, 255, 0.08);
    --color-border-subtle: rgba(255, 255, 255, 0.05);
    --color-border-strong: #34343A;

    --color-accent:        #2DD4BF;
    --color-accent-hover:  #5EEAD4;
    --color-accent-bg:     rgba(45, 212, 191, 0.10);
    --color-on-accent:     #08090A;   /* 亮青底上用深字，避免 1.86:1 */

    --color-success:       #4ADE80;
    --color-warning:       #FBBF24;
    --color-error:         #F87171;
    --color-info:          #60A5FA;
    --color-backdrop:      rgba(0, 0, 0, 0.62);
    --color-success-bg:    rgba(74, 222, 128, 0.10);
    --color-warning-bg:    rgba(251, 191, 36, 0.10);
    --color-error-bg:      rgba(248, 113, 113, 0.10);
    --color-info-bg:       rgba(96, 165, 250, 0.10);

    --shadow-overlay: 0 12px 32px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.10);
    --shadow-overlay-strong: 0 18px 48px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.12);
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    :root {
        --dur-micro:    0.01ms;
        --dur-standard: 0.01ms;
        --dur-emphasis: 0.01ms;
    }
}
