/**
 * EatMeals Design Tokens — "The Modern Larder"
 * ==============================================
 * 
 * Single source of truth for all design decisions.
 * 
 * Design Direction:
 * - Concept: "Your Freezer, Curated" — premium, restrained, editorial
 * - Primary orange used sparingly like Hermès orange (luxury restraint)
 * - NOT cold/industrial — warm, alive, "suspended freshness"
 * 
 * Usage Rules:
 * - Use --color-primary ONLY on: CTAs, price points, badges, key accents
 * - Use --color-primary-dim for subtle backgrounds (hover states, selection)
 * - Use warm neutrals (cream, warm surfaces) over pure white
 * - Typography: Serif for headlines (editorial), Sans for body, Mono for data
 * 
 * @version 1.0.0
 * @date 2026-02-01
 */

:root {
  /* ============================================
   * COLOR TOKENS
   * ============================================ */

  /* Primary Brand Orange — Use with restraint
   * Like Hermès orange: CTAs, prices, badges only
   * -------------------------------------------- */
  --color-primary: #ff7300;
  --color-primary-hover: #e66800;
  --color-primary-active: #cc5c00;
  --color-primary-dim: rgba(255, 115, 0, 0.15);
  --color-primary-glow: rgba(255, 115, 0, 0.4);
  --color-primary-subtle: rgba(255, 115, 0, 0.08);

  /* Warm Neutral Scale — The soul of "Modern Larder"
   * These replace cold grays throughout the site
   * ------------------------------------------------- */
  --color-surface-pure: #ffffff;
  --color-surface-cream: #faf8f5;
  --color-surface-warm: #f5f0e8;
  --color-surface-muted: #ebe5db;
  --color-surface-dark: #1a1612;
  --color-surface-darker: #0f0d0a;

  /* Text Colors — Warm-tinted, not pure black
   * ----------------------------------------- */
  --color-text-primary: #1a1612;
  --color-text-secondary: #4a453d;
  --color-text-tertiary: #7a746a;
  --color-text-muted: #a69f94;
  --color-text-inverse: #faf8f5;

  /* Accent Colors — Supporting the palette
   * -------------------------------------- */
  --color-sage: #7a9a7a;
  --color-sage-dim: rgba(122, 154, 122, 0.15);
  --color-copper: #b87333;
  --color-copper-dim: rgba(184, 115, 51, 0.15);

  /* Semantic Colors — Status and feedback
   * ------------------------------------- */
  --color-success: #2d8a4e;
  --color-success-dim: rgba(45, 138, 78, 0.12);
  --color-warning: #c9860a;
  --color-warning-dim: rgba(201, 134, 10, 0.12);
  --color-error: #c53030;
  --color-error-dim: rgba(197, 48, 48, 0.12);
  --color-info: #3182ce;
  --color-info-dim: rgba(49, 130, 206, 0.12);

  /* Border Colors — Subtle, warm-tinted
   * ----------------------------------- */
  --color-border: rgba(26, 22, 18, 0.1);
  --color-border-strong: rgba(26, 22, 18, 0.2);
  --color-border-focus: var(--color-primary);

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

  /* Font Families
   * Heading: Serif for editorial feel (Playfair Display)
   * Body: Sans for readability (Inter)
   * Mono: For data, prices, nutrition (JetBrains Mono)
   * ---------------------------------------------------- */
  --font-heading: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  /* Fluid Type Scale — Responsive typography
   * Uses clamp() for smooth scaling between breakpoints
   * Min: 375px viewport | Max: 1440px viewport
   * --------------------------------------------------- */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);       /* 12-14px */
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);          /* 14-16px */
  --text-base: clamp(1rem, 0.9rem + 0.5vw, 1.125rem);         /* 16-18px */
  --text-lg: clamp(1.125rem, 1rem + 0.6vw, 1.25rem);          /* 18-20px */
  --text-xl: clamp(1.25rem, 1.1rem + 0.75vw, 1.5rem);         /* 20-24px */
  --text-2xl: clamp(1.5rem, 1.2rem + 1.5vw, 2rem);            /* 24-32px */
  --text-3xl: clamp(1.875rem, 1.4rem + 2.4vw, 2.5rem);        /* 30-40px */
  --text-4xl: clamp(2.25rem, 1.6rem + 3.2vw, 3.5rem);         /* 36-56px */
  --text-5xl: clamp(3rem, 2rem + 5vw, 5rem);                  /* 48-80px */

  /* Line Heights — Tailored per use case
   * ------------------------------------ */
  --leading-none: 1;
  --leading-tight: 1.15;
  --leading-snug: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.65;
  --leading-loose: 1.8;

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

  /* Font Weights
   * ------------ */
  --weight-normal: 400;
  --weight-regular: 400;  /* Alias for --weight-normal */
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --weight-extrabold: 800;

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

  /* 4px Base Unit System
   * All spacing derived from multiples of 4px
   * ------------------------------------------ */
  --space-0: 0;
  --space-px: 1px;
  --space-0-5: 2px;    /* 0.5 × 4 */
  --space-1: 4px;      /* 1 × 4 */
  --space-1-5: 6px;    /* 1.5 × 4 */
  --space-2: 8px;      /* 2 × 4 */
  --space-2-5: 10px;   /* 2.5 × 4 */
  --space-3: 12px;     /* 3 × 4 */
  --space-3-5: 14px;   /* 3.5 × 4 */
  --space-4: 16px;     /* 4 × 4 */
  --space-5: 20px;     /* 5 × 4 */
  --space-6: 24px;     /* 6 × 4 */
  --space-7: 28px;     /* 7 × 4 */
  --space-8: 32px;     /* 8 × 4 */
  --space-9: 36px;     /* 9 × 4 */
  --space-10: 40px;    /* 10 × 4 */
  --space-11: 44px;    /* 11 × 4 */
  --space-12: 48px;    /* 12 × 4 */
  --space-14: 56px;    /* 14 × 4 */
  --space-16: 64px;    /* 16 × 4 */
  --space-20: 80px;    /* 20 × 4 */
  --space-24: 96px;    /* 24 × 4 */
  --space-28: 112px;   /* 28 × 4 */
  --space-32: 128px;   /* 32 × 4 */

  /* Section Spacing — For major layout blocks
   * ----------------------------------------- */
  --section-sm: clamp(48px, 8vw, 80px);
  --section-md: clamp(64px, 10vw, 120px);
  --section-lg: clamp(80px, 12vw, 160px);

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

  --radius-none: 0;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-3xl: 32px;
  --radius-full: 9999px;

  /* ============================================
   * SHADOW TOKENS — Warm-tinted, not cold gray
   * ============================================ */

  /* Warm shadows use rgba(26, 22, 18, x) instead of black */
  --shadow-xs: 0 1px 2px rgba(26, 22, 18, 0.05);
  --shadow-sm: 0 2px 4px rgba(26, 22, 18, 0.06),
               0 1px 2px rgba(26, 22, 18, 0.04);
  --shadow-md: 0 4px 8px rgba(26, 22, 18, 0.08),
               0 2px 4px rgba(26, 22, 18, 0.04);
  --shadow-lg: 0 8px 16px rgba(26, 22, 18, 0.1),
               0 4px 8px rgba(26, 22, 18, 0.05);
  --shadow-xl: 0 16px 32px rgba(26, 22, 18, 0.12),
               0 8px 16px rgba(26, 22, 18, 0.06);
  --shadow-2xl: 0 24px 48px rgba(26, 22, 18, 0.15),
                0 12px 24px rgba(26, 22, 18, 0.08);

  /* Glow shadows — For hover states on primary buttons */
  --shadow-glow-sm: 0 4px 12px rgba(255, 115, 0, 0.2);
  --shadow-glow-md: 0 8px 24px rgba(255, 115, 0, 0.25);
  --shadow-glow-lg: 0 12px 36px rgba(255, 115, 0, 0.3);

  /* Inset shadows — For pressed states */
  --shadow-inset: inset 0 2px 4px rgba(26, 22, 18, 0.1);

  /* ============================================
   * TRANSITION & ANIMATION TOKENS
   * ============================================ */

  /* Timing Functions — Named for purpose
   * ------------------------------------ */
  --ease-default: cubic-bezier(0.4, 0, 0.2, 1);          /* General use */
  --ease-in: cubic-bezier(0.4, 0, 1, 1);                 /* Enter screen */
  --ease-out: cubic-bezier(0, 0, 0.2, 1);                /* Exit screen */
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);           /* Symmetric */
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);      /* Playful pop */
  --ease-smooth: cubic-bezier(0.22, 1, 0.36, 1);         /* Elegant glide */
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Slight overshoot */

  /* Durations — Use multiples
   * ------------------------- */
  --duration-instant: 75ms;
  --duration-fast: 150ms;
  --duration-normal: 200ms;
  --duration-slow: 300ms;
  --duration-slower: 400ms;
  --duration-slowest: 500ms;

  /* Combined Transitions — Ready-to-use
   * ----------------------------------- */
  --transition-fast: var(--duration-fast) var(--ease-default);
  --transition-normal: var(--duration-normal) var(--ease-default);
  --transition-slow: var(--duration-slow) var(--ease-smooth);
  --transition-bounce: var(--duration-normal) var(--ease-bounce);

  /* ============================================
   * Z-INDEX SCALE — Layering system
   * ============================================ */

  --z-below: -1;
  --z-base: 0;
  --z-raised: 10;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-header: 250;   /* Fixed header, above sticky */
  --z-overlay: 300;
  --z-modal: 400;
  --z-popover: 500;
  --z-tooltip: 600;
  --z-toast: 700;
  --z-max: 9999;

  /* ============================================
   * BREAKPOINT TOKENS (for reference)
   * ============================================ */

  /* Note: CSS custom properties can't be used in @media queries.
   * These are documented here for reference; use the values directly.
   * 
   * --breakpoint-sm: 640px;   // Small phones in landscape
   * --breakpoint-md: 768px;   // Tablets portrait
   * --breakpoint-lg: 1024px;  // Tablets landscape, small laptops
   * --breakpoint-xl: 1280px;  // Laptops
   * --breakpoint-2xl: 1536px; // Large desktops
   */

  /* Container Max-Widths */
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1280px;
  --container-2xl: 1440px;
  --container-max: 1280px;  /* Default max-width for page content */
  --container-prose: 65ch;  /* Optimal reading width */

  /* ============================================
   * COMPONENT-SPECIFIC TOKENS
   * ============================================ */

  /* Button Heights */
  --btn-height-sm: 32px;
  --btn-height-md: 40px;
  --btn-height-lg: 48px;
  --btn-height-xl: 56px;

  /* Card */
  --card-padding: var(--space-6);
  --card-radius: var(--radius-xl);
  --card-shadow: var(--shadow-sm);
  --card-shadow-hover: var(--shadow-lg);

  /* Input */
  --input-height: 44px;
  --input-padding-x: var(--space-4);
  --input-radius: var(--radius-md);
  --input-border-width: 1px;
  --input-border: var(--input-border-width) solid var(--color-border);
  --input-focus-ring: 0 0 0 3px var(--color-primary-dim);

  /* Header/Navbar */
  --header-height: 72px;
  --header-height-mobile: 64px;

  /* ============================================
   * GLASSMORPHISM TOKENS (Apple Vision Pro style)
   * ============================================ */

  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-bg-dark: rgba(26, 22, 18, 0.7);
  --glass-blur: 16px;
  --glass-border: 1px solid rgba(255, 255, 255, 0.2);
  --glass-shadow: 0 8px 32px rgba(26, 22, 18, 0.1);
}

/* ============================================
 * DARK MODE TOKENS (optional, for future use)
 * ============================================ */

@media (prefers-color-scheme: dark) {
  :root.dark-mode {
    --color-surface-pure: #1a1612;
    --color-surface-cream: #242019;
    --color-surface-warm: #2d2821;
    --color-surface-muted: #3a342b;
    --color-surface-dark: #faf8f5;
    
    --color-text-primary: #faf8f5;
    --color-text-secondary: #c9c3b8;
    --color-text-tertiary: #9a9489;
    --color-text-muted: #6b665c;
    --color-text-inverse: #1a1612;
    
    --color-border: rgba(250, 248, 245, 0.1);
    --color-border-strong: rgba(250, 248, 245, 0.2);
    
    --glass-bg: rgba(26, 22, 18, 0.8);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
  }
}

/* ============================================
 * REDUCED MOTION — Accessibility
 * ============================================ */

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-instant: 0ms;
    --duration-fast: 0ms;
    --duration-normal: 0ms;
    --duration-slow: 0ms;
    --duration-slower: 0ms;
    --duration-slowest: 0ms;
  }
}
