/**
 * RUNEKT Design Tokens
 * Design system foundation with CSS custom properties
 * Version: 1.0.0
 */

:root {
  /* ============================================================================
     Colors - Light Mode
     ============================================================================ */

  /* Neutral Backgrounds */
  --rk-bg: #ffffff;
  --rk-bg-2: #f8fafc;
  --rk-bg-3: #f1f5f9;
  --rk-bg-4: #e2e8f0;

  /* Text Colors */
  --rk-text: #0f172a;
  --rk-text-2: #64748b;
  --rk-text-3: #94a3b8;

  /* Border Colors */
  --rk-border: #e2e8f0;
  --rk-border-strong: #cbd5e1;

  /* Semantic Colors */
  --rk-primary: #2563eb;
  --rk-primary-hover: #1d4ed8;
  --rk-success: #16a34a;
  --rk-warning: #d97706;
  --rk-danger: #dc2626;
  --rk-info: #0891b2;

  /* ============================================================================
     Typography
     ============================================================================ */

  /* Font Families */
  --rk-font-ko: -apple-system, "Apple SD Gothic Neo", "Pretendard Variable", Pretendard, system-ui, sans-serif;
  --rk-font-zh-cn: -apple-system, "PingFang SC", "Noto Sans SC", "Hiragino Sans GB", system-ui, sans-serif;
  --rk-font-en: -apple-system, Inter, system-ui, sans-serif;
  --rk-font-mono: "JetBrains Mono", "D2Coding", ui-monospace, "Cascadia Mono", "SF Mono", monospace;

  /* Active font (set by i18n) */
  --rk-font-active: var(--rk-font-ko);

  /* Font Sizes (rem-based for accessibility) */
  --rk-font-size-xs: 0.75rem;    /* 12px */
  --rk-font-size-sm: 0.8125rem;  /* 13px */
  --rk-font-size-base: 0.875rem; /* 14px */
  --rk-font-size-md: 1rem;       /* 16px */
  --rk-font-size-lg: 1.125rem;   /* 18px */
  --rk-font-size-xl: 1.5rem;     /* 24px */
  --rk-font-size-2xl: 1.875rem;  /* 30px */

  /* Font Weights */
  --rk-font-weight-normal: 400;
  --rk-font-weight-medium: 500;
  --rk-font-weight-semibold: 600;
  --rk-font-weight-bold: 700;

  /* Line Heights */
  --rk-line-height-tight: 1.25;
  --rk-line-height-normal: 1.5;
  --rk-line-height-relaxed: 1.7;

  /* CJK line-height tokens (SPEC §7.5.5) */
  --rk-line-height-cjk: 1.7;
  --rk-line-height-latin: 1.5;

  /* ============================================================================
     Spacing (rem-based scale)
     ============================================================================ */

  --rk-space-1: 0.25rem;  /* 4px */
  --rk-space-2: 0.5rem;   /* 8px */
  --rk-space-3: 0.75rem;  /* 12px */
  --rk-space-4: 1rem;     /* 16px */
  --rk-space-5: 1.25rem;  /* 20px */
  --rk-space-6: 1.5rem;   /* 24px */
  --rk-space-8: 2rem;     /* 32px */
  --rk-space-10: 2.5rem;  /* 40px */
  --rk-space-12: 3rem;    /* 48px */

  /* ============================================================================
     Border Radius
     ============================================================================ */

  --rk-radius-sm: 0.375rem; /* 6px */
  --rk-radius: 0.5rem;      /* 8px */
  --rk-radius-md: 0.625rem; /* 10px */
  --rk-radius-lg: 0.75rem;  /* 12px */
  --rk-radius-xl: 1rem;     /* 16px */
  --rk-radius-full: 9999px;

  /* ============================================================================
     Shadows
     ============================================================================ */

  --rk-shadow-1: 0 1px 2px rgba(15, 23, 42, 0.04);
  --rk-shadow-2: 0 2px 8px rgba(15, 23, 42, 0.06);
  --rk-shadow-3: 0 4px 12px rgba(15, 23, 42, 0.08);
  --rk-shadow-4: 0 8px 24px rgba(15, 23, 42, 0.12);

  /* ============================================================================
     Breakpoints (read-only reference for JS matchMedia)
     ============================================================================ */

  --bp-xs: 360px;
  --bp-sm: 390px;
  --bp-md: 430px;
  --bp-tablet: 768px;
  --bp-desktop: 1024px;
  --bp-wide: 1440px;

  /* ============================================================================
     Provider Colors (brand colors for LLM providers)
     ============================================================================ */

  --color-provider-openai: #10a37f;
  --color-provider-anthropic: #d97757;
  --color-provider-google: #4285f4;
  --color-provider-deepseek: #4d6ef5;
  --color-provider-alibaba: #ff6a00;
  --color-provider-kimi: #00c4cc;
  --color-provider-minimax: #7c3aed;
  --color-provider-bytedance: #fe2c55;
  --color-provider-unknown: #94a3b8;

  /* ============================================================================
     Transitions
     ============================================================================ */

  --rk-transition-fast: 150ms ease;
  --rk-transition: 200ms ease;
  --rk-transition-slow: 300ms ease;

  /* ============================================================================
     Focus Ring (WCAG 2.1 AA compliant)
     ============================================================================ */

  --rk-focus-ring: 0 0 0 2px var(--rk-primary);
  --rk-focus-ring-offset: 0 0 0 2px white, 0 0 0 4px var(--rk-primary);

  /* ============================================================================
     Touch Target (mobile accessibility)
     ============================================================================ */

  --rk-touch-min: 44px;
  --rk-touch-gap: 8px;

  /* ============================================================================
     Layout Dimensions
     ============================================================================ */

  --rk-sidebar-width: 260px;
  --rk-right-panel-width: 320px;
  --rk-admin-sidebar-width: 232px;
  --rk-topbar-height: 48px;
  --rk-admin-topbar-height: 56px;

  /* ============================================================================
     Table Row Heights
     ============================================================================ */

  --rk-row-height: 40px;
  --rk-admin-row-height: 36px;

  /* ============================================================================
     Z-Index Scale
     ============================================================================ */

  --rk-z-base: 0;
  --rk-z-dropdown: 1000;
  --rk-z-sticky: 1100;
  --rk-z-modal: 1200;
  --rk-z-tooltip: 1300;
  --rk-z-toast: 11000;

  /* ============================================================================
     Canvas Skeleton Loading Tokens (REQ-U1-SKELETON-005, SPEC-025-CANVAS-001)
     ============================================================================ */

  --rk-color-bg-skeleton: #e8edf3;
  --rk-color-bg-skeleton-shimmer: rgba(255, 255, 255, 0.7);
}

/* ============================================================================
   Dark Mode Tokens
   ============================================================================ */

[data-theme="dark"] {
  /* Neutral Backgrounds */
  --rk-bg: #0f172a;
  --rk-bg-2: #1e293b;
  --rk-bg-3: #334155;
  --rk-bg-4: #475569;

  /* Text Colors */
  --rk-text: #e2e8f0;
  --rk-text-2: #94a3b8;
  --rk-text-3: #64748b;

  /* Border Colors */
  --rk-border: #334155;
  --rk-border-strong: #475569;

  /* Focus Ring (dark mode optimized) */
  --rk-focus-ring-offset: 0 0 0 2px #0f172a, 0 0 0 4px var(--rk-primary);

  /* Shadows (dark mode optimized) */
  --rk-shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --rk-shadow-2: 0 2px 8px rgba(0, 0, 0, 0.4);
  --rk-shadow-3: 0 4px 12px rgba(0, 0, 0, 0.5);
  --rk-shadow-4: 0 8px 24px rgba(0, 0, 0, 0.6);

  /* Canvas Skeleton Tokens - Dark Mode */
  --rk-color-bg-skeleton: #2a3444;
  --rk-color-bg-skeleton-shimmer: rgba(255, 255, 255, 0.08);
}

/* ============================================================================
   System Theme (auto-detect from OS preference)
   ============================================================================ */

[data-theme="system"] {
  /* Inherits from :root by default
     JavaScript will update to light/dark based on prefers-color-scheme */
}

/* ============================================================================
   Locale line-height tokens
   Keep these as opt-in tokens. Do not apply line-height globally by :lang(),
   otherwise switching locale visibly changes spacing across shared layouts.
   ============================================================================ */

:root {
  line-height: var(--rk-line-height-latin);
}
