/**
 * Guanyiai Design System - Variables
 * Chinese Antique Market - Design Tokens
 * Version: 2.0
 * Date: 2026-05-30
 */

/* ============================================
   CSS CUSTOM PROPERTIES - LIGHT MODE (Default)
   ============================================ */

:root {
  /* ------------------------------------------
     Color Palette - Primary: Deep Ink Blue (墨色)
     ------------------------------------------ */
  --color-primary-50: #f0f4f8;
  --color-primary-100: #d9e2ec;
  --color-primary-200: #bcccdc;
  --color-primary-300: #9fb3c8;
  --color-primary-400: #829ab1;
  --color-primary-500: #627d98;
  --color-primary-600: #486581;
  --color-primary-700: #334e68;
  --color-primary-800: #243b53;
  --color-primary-900: #102a43;

  /* ------------------------------------------
     Color Palette - Secondary: Antique Gold (古金)
     ------------------------------------------ */
  --color-secondary-50: #fefcf3;
  --color-secondary-100: #fdf6e3;
  --color-secondary-200: #f9e8b9;
  --color-secondary-300: #f4d88a;
  --color-secondary-400: #e8c44e;
  --color-secondary-500: #d4a832;
  --color-secondary-600: #b8912a;
  --color-secondary-700: #8c6d1f;
  --color-secondary-800: #604a15;
  --color-secondary-900: #3d2f0e;

  /* ------------------------------------------
     Color Palette - Accent: Jade Green (翡翠)
     ------------------------------------------ */
  --color-accent-50: #e6f7f1;
  --color-accent-100: #b3e8d4;
  --color-accent-200: #80d9b7;
  --color-accent-300: #4dca9a;
  --color-accent-400: #26bd84;
  --color-accent-500: #1a9e6b;
  --color-accent-600: #147d55;
  --color-accent-700: #0f5c3f;
  --color-accent-800: #0a3b29;
  --color-accent-900: #051a13;

  /* ------------------------------------------
     Color Palette - Neutral: Warm Gray (暖灰)
     ------------------------------------------ */
  --color-neutral-50: #fafaf9;
  --color-neutral-100: #f5f4f2;
  --color-neutral-200: #ebe9e5;
  --color-neutral-300: #d6d3cd;
  --color-neutral-400: #a8a29e;
  --color-neutral-500: #78716c;
  --color-neutral-600: #57534e;
  --color-neutral-700: #44403c;
  --color-neutral-800: #292524;
  --color-neutral-900: #1c1917;

  /* ------------------------------------------
     Color Palette - Vermilion: Cinnabar Red (朱砂)
     ------------------------------------------ */
  --color-vermilion-50: #fef2f2;
  --color-vermilion-100: #fee2e2;
  --color-vermilion-200: #fecaca;
  --color-vermilion-300: #fca5a5;
  --color-vermilion-400: #f87171;
  --color-vermilion-500: #ef4444;
  --color-vermilion-600: #dc2626;
  --color-vermilion-700: #b91c1c;

  /* ------------------------------------------
     Color Palette - Indigo: Traditional Dye (靛蓝)
     ------------------------------------------ */
  --color-indigo-50: #eef2ff;
  --color-indigo-100: #e0e7ff;
  --color-indigo-200: #c7d2fe;
  --color-indigo-300: #a5b4fc;
  --color-indigo-400: #818cf8;
  --color-indigo-500: #6366f1;
  --color-indigo-600: #4f46e5;
  --color-indigo-700: #4338ca;

  /* ------------------------------------------
     Semantic Colors
     ------------------------------------------ */
  --color-success: #16a34a;
  --color-success-light: #dcfce7;
  --color-success-dark: #15803d;
  --color-warning: #d97706;
  --color-warning-light: #fef3c7;
  --color-warning-dark: #b45309;
  --color-error: #dc2626;
  --color-error-light: #fee2e2;
  --color-error-dark: #b91c1c;
  --color-info: #2563eb;
  --color-info-light: #dbeafe;
  --color-info-dark: #1d4ed8;

  /* ------------------------------------------
     Background & Surface
     ------------------------------------------ */
  --color-bg-primary: #faf9f7;
  --color-bg-secondary: #f5f3f0;
  --color-bg-tertiary: #ebe8e3;
  --color-bg-inverse: #1c1917;
  --color-surface: #ffffff;
  --color-surface-elevated: #ffffff;
  --color-surface-overlay: rgba(255, 255, 255, 0.95);
  --color-surface-sunken: #f5f3f0;

  /* ------------------------------------------
     Text Colors
     ------------------------------------------ */
  --color-text-primary: #1c1917;
  --color-text-secondary: #57534e;
  --color-text-tertiary: #78716c;
  --color-text-muted: #a8a29e;
  --color-text-inverse: #fafaf9;
  --color-text-link: #486581;
  --color-text-link-hover: #334e68;
  --color-text-link-active: #243b53;

  /* ------------------------------------------
     Border Colors
     ------------------------------------------ */
  --color-border: #d6d3cd;
  --color-border-subtle: #ebe8e3;
  --color-border-strong: #a8a29e;
  --color-border-focus: var(--color-primary-400);
  --color-border-error: var(--color-error);
  --color-border-success: var(--color-success);

  /* ============================================
     TYPOGRAPHY
     ============================================ */

  /* Font Families */
  --font-serif: 'Noto Serif SC', 'Source Han Serif SC', 'STSong', 'SimSun', serif;
  --font-sans: 'Noto Sans SC', 'Source Han Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
  --font-display: 'ZCOOL XiaoWei', 'Ma Shan Zheng', var(--font-serif);

  /* Font Sizes - Fluid Typography Scale */
  --text-2xs: clamp(0.625rem, 0.6rem + 0.125vw, 0.6875rem);
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.8125rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.375vw, 0.9375rem);
  --text-base: clamp(1rem, 0.9rem + 0.5vw, 1.0625rem);
  --text-lg: clamp(1.125rem, 1rem + 0.625vw, 1.25rem);
  --text-xl: clamp(1.25rem, 1.1rem + 0.75vw, 1.5rem);
  --text-2xl: clamp(1.5rem, 1.3rem + 1vw, 1.875rem);
  --text-3xl: clamp(1.875rem, 1.5rem + 1.875vw, 2.5rem);
  --text-4xl: clamp(2.25rem, 1.8rem + 2.25vw, 3rem);
  --text-5xl: clamp(3rem, 2.4rem + 3vw, 3.75rem);

  /* Font Weights */
  --font-weight-light: 300;
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Line Heights */
  --leading-none: 1;
  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  --leading-loose: 2;

  /* Letter Spacing */
  --tracking-tighter: -0.05em;
  --tracking-tight: -0.025em;
  --tracking-normal: 0em;
  --tracking-wide: 0.025em;
  --tracking-wider: 0.05em;
  --tracking-widest: 0.1em;

  /* Typography Presets */
  --text-display: var(--text-4xl) / var(--leading-tight) var(--font-display);
  --text-h1: var(--text-3xl) / var(--leading-tight) var(--font-serif);
  --text-h2: var(--text-2xl) / var(--leading-snug) var(--font-serif);
  --text-h3: var(--text-xl) / var(--leading-snug) var(--font-sans);
  --text-body-lg: var(--text-lg) / var(--leading-normal) var(--font-sans);
  --text-body: var(--text-base) / var(--leading-normal) var(--font-sans);
  --text-body-sm: var(--text-sm) / var(--leading-normal) var(--font-sans);
  --text-caption: var(--text-xs) / var(--leading-normal) var(--font-sans);
  --text-overline: var(--text-2xs) / var(--leading-normal) var(--font-sans);

  /* ============================================
     SPACING
     ============================================ */

  /* Base Spacing Scale (4px increments) */
  --space-0: 0;
  --space-px: 1px;
  --space-0-5: 0.125rem;  /* 2px */
  --space-1: 0.25rem;     /* 4px */
  --space-1-5: 0.375rem;  /* 6px */
  --space-2: 0.5rem;      /* 8px */
  --space-2-5: 0.625rem;  /* 10px */
  --space-3: 0.75rem;     /* 12px */
  --space-3-5: 0.875rem;  /* 14px */
  --space-4: 1rem;        /* 16px */
  --space-5: 1.25rem;     /* 20px */
  --space-6: 1.5rem;      /* 24px */
  --space-7: 1.75rem;     /* 28px */
  --space-8: 2rem;        /* 32px */
  --space-9: 2.25rem;     /* 36px */
  --space-10: 2.5rem;     /* 40px */
  --space-12: 3rem;       /* 48px */
  --space-14: 3.5rem;     /* 56px */
  --space-16: 4rem;       /* 64px */
  --space-20: 5rem;       /* 80px */
  --space-24: 6rem;       /* 96px */
  --space-28: 7rem;       /* 112px */
  --space-32: 8rem;       /* 128px */

  /* Container Widths */
  --container-xs: 480px;
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1280px;
  --container-2xl: 1440px;

  /* Component Spacing Tokens */
  --component-padding-xs: var(--space-2);
  --component-padding-sm: var(--space-3);
  --component-padding-md: var(--space-4);
  --component-padding-lg: var(--space-6);
  --component-padding-xl: var(--space-8);

  /* Section Spacing */
  --section-gap: var(--space-16);
  --section-gap-lg: var(--space-24);

  /* Layout Spacing */
  --page-padding: var(--space-6);
  --page-padding-lg: var(--space-8);
  --page-max-width: var(--container-lg);

  /* Grid Gaps */
  --grid-gap-xs: var(--space-2);
  --grid-gap-sm: var(--space-3);
  --grid-gap-md: var(--space-4);
  --grid-gap-lg: var(--space-6);
  --grid-gap-xl: var(--space-8);

  /* Card Spacing */
  --card-padding: var(--space-5);
  --card-gap: var(--space-4);

  /* Navigation Spacing */
  --nav-height: 4rem;
  --nav-padding: var(--space-4);
  --nav-gap: var(--space-2);

  /* Footer Spacing */
  --footer-padding: var(--space-12) 0;
  --footer-padding-lg: var(--space-16) 0;
  --footer-gap: var(--space-10);

  /* ============================================
     BORDER RADIUS
     ============================================ */

  --radius-none: 0;
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-3xl: 2rem;
  --radius-full: 9999px;

  /* Component Radius Tokens */
  --radius-button: var(--radius-lg);
  --radius-card: var(--radius-xl);
  --radius-input: var(--radius-lg);
  --radius-avatar: var(--radius-full);
  --radius-badge: var(--radius-full);
  --radius-modal: var(--radius-2xl);
  --radius-nav: var(--radius-xl);
  --radius-dropdown: var(--radius-xl);
  --radius-toast: var(--radius-lg);

  /* ============================================
     SHADOWS
     ============================================ */

  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05), 0 1px 3px 0 rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);

  /* Colored Shadows */
  --shadow-primary-sm: 0 4px 14px 0 rgb(72 101 129 / 0.2);
  --shadow-primary-md: 0 6px 20px 0 rgb(72 101 129 / 0.25);
  --shadow-primary-lg: 0 8px 28px 0 rgb(72 101 129 / 0.3);
  --shadow-secondary-sm: 0 4px 14px 0 rgb(212 168 50 / 0.2);
  --shadow-secondary-md: 0 6px 20px 0 rgb(212 168 50 / 0.25);
  --shadow-secondary-lg: 0 8px 28px 0 rgb(212 168 50 / 0.3);
  --shadow-accent-sm: 0 4px 14px 0 rgb(26 158 107 / 0.2);
  --shadow-accent-md: 0 6px 20px 0 rgb(26 158 107 / 0.25);
  --shadow-accent-lg: 0 8px 28px 0 rgb(26 158 107 / 0.3);

  /* Inner Shadow */
  --shadow-inner: inset 0 2px 4px 0 rgb(0 0 0 / 0.06);
  --shadow-inner-lg: inset 0 4px 8px 0 rgb(0 0 0 / 0.1);

  /* Glow Effects */
  --shadow-glow-primary: 0 0 20px rgb(72 101 129 / 0.4);
  --shadow-glow-secondary: 0 0 20px rgb(212 168 50 / 0.4);
  --shadow-glow-accent: 0 0 20px rgb(26 158 107 / 0.4);

  /* Navigation Shadow */
  --shadow-nav: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px 0 rgb(0 0 0 / 0.06);
  --shadow-nav-scrolled: 0 4px 12px 0 rgb(0 0 0 / 0.1), 0 2px 4px 0 rgb(0 0 0 / 0.06);

  /* Dropdown Shadow */
  --shadow-dropdown: 0 10px 25px -5px rgb(0 0 0 / 0.15), 0 4px 10px -4px rgb(0 0 0 / 0.1);

  /* Modal Shadow */
  --shadow-modal: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  --shadow-modal-backdrop: 0 0 0 100vmax rgb(0 0 0 / 0.5);

  /* ============================================
     TRANSITIONS & ANIMATIONS
     ============================================ */

  /* Duration Scale */
  --duration-instant: 0ms;
  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;
  --duration-slower: 700ms;

  /* Easing Curves */
  --ease-default: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-linear: linear;
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --ease-expo-out: cubic-bezier(0.19, 1, 0.22, 1);

  /* Transition Presets */
  --transition-colors: color var(--duration-fast) var(--ease-default),
                       background-color var(--duration-fast) var(--ease-default),
                       border-color var(--duration-fast) var(--ease-default);
  --transition-shadow: box-shadow var(--duration-normal) var(--ease-default);
  --transition-transform: transform var(--duration-normal) var(--ease-default);
  --transition-opacity: opacity var(--duration-normal) var(--ease-default);
  --transition-all: all var(--duration-normal) var(--ease-default);
  --transition-spring: transform var(--duration-slow) var(--ease-spring);

  /* Animation Presets */
  --animate-fade-in: fadeIn var(--duration-normal) var(--ease-out) forwards;
  --animate-fade-in-up: fadeInUp var(--duration-slow) var(--ease-out) forwards;
  --animate-fade-in-down: fadeInDown var(--duration-slow) var(--ease-out) forwards;
  --animate-slide-in-left: slideInLeft var(--duration-slow) var(--ease-out) forwards;
  --animate-slide-in-right: slideInRight var(--duration-slow) var(--ease-out) forwards;
  --animate-scale-in: scaleIn var(--duration-normal) var(--ease-spring) forwards;
  --animate-bounce-in: bounceIn var(--duration-slower) var(--ease-bounce) forwards;
  --animate-spin: spin 1s linear infinite;
  --animate-pulse: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;

  /* ============================================
     Z-INDEX SCALE
     ============================================ */

  --z-below: -1;
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-nav: 300;
  --z-overlay: 400;
  --z-modal: 500;
  --z-popover: 600;
  --z-toast: 700;
  --z-tooltip: 800;
  --z-max: 9999;

  /* ============================================
     BREAKPOINTS (for reference / JS usage)
     ============================================ */
  /* --bp-xs: 480px;  */
  /* --bp-sm: 640px;  */
  /* --bp-md: 768px;  */
  /* --bp-lg: 1024px; */
  /* --bp-xl: 1280px; */
  /* --bp-2xl: 1440px; */
}

/* ============================================
   DARK MODE
   ============================================ */

[data-theme="dark"] {
  /* Background & Surface */
  --color-bg-primary: #0f0e0d;
  --color-bg-secondary: #1a1816;
  --color-bg-tertiary: #252220;
  --color-bg-inverse: #faf9f7;
  --color-surface: #1a1816;
  --color-surface-elevated: #252220;
  --color-surface-overlay: rgba(26, 24, 22, 0.95);
  --color-surface-sunken: #0f0e0d;

  /* Text */
  --color-text-primary: #f5f4f2;
  --color-text-secondary: #a8a29e;
  --color-text-tertiary: #78716c;
  --color-text-muted: #57534e;
  --color-text-inverse: #1c1917;
  --color-text-link: #80d9b7;
  --color-text-link-hover: #b3e8d4;
  --color-text-link-active: #4dca9a;

  /* Border */
  --color-border: #44403c;
  --color-border-subtle: #292524;
  --color-border-strong: #57534e;

  /* Adjusted Palette for Dark Mode */
  --color-primary-400: #9fb3c8;
  --color-primary-500: #829ab1;
  --color-primary-600: #627d98;

  --color-secondary-400: #f4d88a;
  --color-secondary-500: #e8c44e;
  --color-secondary-600: #d4a832;

  --color-accent-400: #4dca9a;
  --color-accent-500: #26bd84;
  --color-accent-600: #1a9e6b;

  /* Semantic Colors - Dark Mode */
  --color-success-light: #14532d;
  --color-warning-light: #713f12;
  --color-error-light: #7f1d1d;
  --color-info-light: #1e3a5f;

  /* Dark Mode Shadows */
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.4);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.5);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.6);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.7);
  --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.8);
  --shadow-inner: inset 0 2px 4px 0 rgb(0 0 0 / 0.2);
  --shadow-nav: 0 1px 3px 0 rgb(0 0 0 / 0.3);
  --shadow-nav-scrolled: 0 4px 12px 0 rgb(0 0 0 / 0.4);
  --shadow-dropdown: 0 10px 25px -5px rgb(0 0 0 / 0.4);
  --shadow-modal-backdrop: 0 0 0 100vmax rgb(0 0 0 / 0.7);
}

/* ============================================
   AUTO DARK MODE (system preference)
   ============================================ */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* Background & Surface */
    --color-bg-primary: #0f0e0d;
    --color-bg-secondary: #1a1816;
    --color-bg-tertiary: #252220;
    --color-bg-inverse: #faf9f7;
    --color-surface: #1a1816;
    --color-surface-elevated: #252220;
    --color-surface-overlay: rgba(26, 24, 22, 0.95);
    --color-surface-sunken: #0f0e0d;

    /* Text */
    --color-text-primary: #f5f4f2;
    --color-text-secondary: #a8a29e;
    --color-text-tertiary: #78716c;
    --color-text-muted: #57534e;
    --color-text-inverse: #1c1917;
    --color-text-link: #80d9b7;
    --color-text-link-hover: #b3e8d4;
    --color-text-link-active: #4dca9a;

    /* Border */
    --color-border: #44403c;
    --color-border-subtle: #292524;
    --color-border-strong: #57534e;

    /* Adjusted Palette */
    --color-primary-400: #9fb3c8;
    --color-primary-500: #829ab1;
    --color-primary-600: #627d98;
    --color-secondary-400: #f4d88a;
    --color-secondary-500: #e8c44e;
    --color-secondary-600: #d4a832;
    --color-accent-400: #4dca9a;
    --color-accent-500: #26bd84;
    --color-accent-600: #1a9e6b;

    /* Semantic Colors */
    --color-success-light: #14532d;
    --color-warning-light: #713f12;
    --color-error-light: #7f1d1d;
    --color-info-light: #1e3a5f;

    /* Shadows */
    --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.4);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.5);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.6);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.7);
    --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.8);
    --shadow-inner: inset 0 2px 4px 0 rgb(0 0 0 / 0.2);
    --shadow-nav: 0 1px 3px 0 rgb(0 0 0 / 0.3);
    --shadow-nav-scrolled: 0 4px 12px 0 rgb(0 0 0 / 0.4);
    --shadow-dropdown: 0 10px 25px -5px rgb(0 0 0 / 0.4);
    --shadow-modal-backdrop: 0 0 0 100vmax rgb(0 0 0 / 0.7);
  }
}

/* ============================================
   HIGH CONTRAST MODE
   ============================================ */

@media (prefers-contrast: high) {
  :root {
    --color-border: #000000;
    --color-border-subtle: #333333;
    --color-border-strong: #000000;
    --shadow-xs: none;
    --shadow-sm: none;
  }
}
