/* ==========================================================================
   WORKWAY Design Tokens - CDN Distribution
   "Weniger, aber besser" - Dieter Rams

   Usage: <link rel="stylesheet" href="https://cdn.workway.co/tokens.css">

   This file serves as the canonical source of truth for WORKWAY design tokens.
   All Private/BYOO Workflows should use these tokens for consistency.
   ========================================================================== */

:root {
  /* ==========================================================================
     Background Colors - Pure to near-black
     ========================================================================== */
  --color-bg-pure: #000000;
  --color-bg-elevated: #0a0a0a;
  --color-bg-surface: #111111;
  --color-bg-subtle: #1a1a1a;

  /* ==========================================================================
     Foreground Colors - White with semantic opacity
     ========================================================================== */
  --color-fg-primary: #ffffff;
  --color-fg-secondary: rgba(255, 255, 255, 0.8);
  --color-fg-tertiary: rgba(255, 255, 255, 0.6);
  --color-fg-muted: rgba(255, 255, 255, 0.4);
  --color-fg-subtle: rgba(255, 255, 255, 0.2);

  /* ==========================================================================
     Border Colors - Subtle separation
     ========================================================================== */
  --color-border-default: rgba(255, 255, 255, 0.1);
  --color-border-emphasis: rgba(255, 255, 255, 0.2);
  --color-border-strong: rgba(255, 255, 255, 0.3);

  /* ==========================================================================
     Functional Colors - Muted, purposeful
     ========================================================================== */
  --color-success: #44aa44;
  --color-success-muted: rgba(68, 170, 68, 0.2);
  --color-error: #cc4444;
  --color-error-muted: rgba(204, 68, 68, 0.2);
  --color-warning: #aa8844;
  --color-warning-muted: rgba(170, 136, 68, 0.2);
  --color-info: #4477aa;
  --color-info-muted: rgba(68, 119, 170, 0.2);

  /* ==========================================================================
     Interactive States
     ========================================================================== */
  --color-hover: rgba(255, 255, 255, 0.05);
  --color-active: rgba(255, 255, 255, 0.1);
  --color-focus: rgba(255, 255, 255, 0.2);

  /* ==========================================================================
     Shadow System - Elevation and hierarchy
     ========================================================================== */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -2px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --shadow-glow-sm: 0 0 10px rgba(255, 255, 255, 0.05);
  --shadow-glow-md: 0 0 20px rgba(255, 255, 255, 0.1);

  /* ==========================================================================
     Radius System
     ========================================================================== */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* ==========================================================================
     Animation System - "Good design is unobtrusive"
     ========================================================================== */
  --ease-standard: cubic-bezier(0.4, 0.0, 0.2, 1);
  --duration-hover: 150ms;
  --duration-micro: 200ms;
  --duration-standard: 300ms;
  --duration-complex: 500ms;

  /* ==========================================================================
     Typography System
     ========================================================================== */
  --font-sans: 'Stack Sans Notch', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Monaco, 'Cascadia Code', monospace;

  /* Font weights */
  --font-regular: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  /* Line heights */
  --leading-tightest: 1.05;
  --leading-tighter: 1.15;
  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-body: 1.6;
  --leading-relaxed: 1.625;

  /* Letter spacing */
  --tracking-tighter: -0.025em;
  --tracking-tight: -0.015em;
  --tracking-normal: 0;

  /* Fluid type scale */
  --text-display-xl: clamp(3.5rem, 5vw + 2rem, 7rem);
  --text-display: clamp(2.5rem, 4vw + 1.5rem, 5rem);
  --text-h1: clamp(3.5rem, 9vw, 7rem);
  --text-h2: clamp(2rem, 5vw, 3.5rem);
  --text-h3: clamp(1.25rem, 1.5vw + 0.5rem, 1.75rem);
  --text-h4: clamp(1.125rem, 1vw + 0.5rem, 1.5rem);
  --text-body-lg: 1.125rem;
  --text-body: clamp(1rem, 1.5vw, 1.25rem);
  --text-body-sm: 0.875rem;
  --text-caption: 0.75rem;

  /* ==========================================================================
     Golden Ratio Spacing Scale (phi = 1.618)
     ========================================================================== */
  --space-xs: 0.5rem;      /* 8px */
  --space-sm: 1rem;        /* 16px - base unit */
  --space-md: 1.618rem;    /* ~26px */
  --space-lg: 2.618rem;    /* ~42px */
  --space-xl: 4.236rem;    /* ~68px */
  --space-2xl: 6.854rem;   /* ~110px */

  /* ==========================================================================
     Icon Size Scale - Consistent 16, 20, 24px
     ========================================================================== */
  --icon-sm: 16px;         /* Inline icons, small UI elements */
  --icon-md: 20px;         /* Default icons, buttons, cards */
  --icon-lg: 24px;         /* Header icons, hero elements */

  /* ==========================================================================
     Component Spacing - Buttons, Inputs, Cards
     ========================================================================== */
  --button-padding-x: 1.5rem;     /* Horizontal padding for standard buttons */
  --button-padding-y: 0.75rem;    /* Vertical padding for standard buttons */
  --button-padding-x-sm: 1rem;    /* Horizontal padding for small/ghost buttons */
  --button-padding-y-sm: 0.5rem;  /* Vertical padding for small/ghost buttons */
  --button-min-height: 44px;      /* Touch target minimum (WCAG) */
  --button-min-height-sm: 40px;   /* Smaller button minimum */
  --button-gap: 0.5rem;           /* Gap between button icon and text */
  --input-padding-x: 1rem;        /* Horizontal padding for inputs */
  --input-padding-y: 0.5rem;      /* Vertical padding for inputs */
  --input-icon-offset: 2.5rem;    /* Left padding when input has icon */

  /* ==========================================================================
     Layout Tokens - Max widths, blur, micro-spacing
     ========================================================================== */
  --max-width-content: 80rem;     /* 1280px - Standard page content */
  --max-width-narrow: 56rem;      /* 896px - Content-focused pages (e.g., articles) */
  --blur-glass: 12px;             /* Backdrop blur for glass effects */
  --translate-micro: 2px;         /* Micro-interactions (e.g., card hover) */
  --translate-sm: 10px;           /* Small animations (e.g., fade-in-up) */
  --scrollbar-width: 8px;         /* Scrollbar dimensions */
  --scrollbar-radius: 4px;        /* Scrollbar thumb radius */
  --outline-offset: 2px;          /* Focus outline offset (a11y standard) */
  --radius-none: 0;               /* Explicit zero radius for square corners */

  /* ==========================================================================
     Short Aliases - Backwards compatibility for existing workflows
     Usage: var(--bg-pure) instead of var(--color-bg-pure)
     ========================================================================== */
  --bg-pure: var(--color-bg-pure);
  --bg-elevated: var(--color-bg-elevated);
  --bg-surface: var(--color-bg-surface);
  --bg-subtle: var(--color-bg-subtle);
  --fg-primary: var(--color-fg-primary);
  --fg-secondary: var(--color-fg-secondary);
  --fg-tertiary: var(--color-fg-tertiary);
  --fg-muted: var(--color-fg-muted);
  --fg-subtle: var(--color-fg-subtle);
  --border-default: var(--color-border-default);
  --border-emphasis: var(--color-border-emphasis);
  --border-strong: var(--color-border-strong);
  --success: var(--color-success);
  --success-muted: var(--color-success-muted);
  --error: var(--color-error);
  --error-muted: var(--color-error-muted);
  --warning: var(--color-warning);
  --warning-muted: var(--color-warning-muted);
  --info: var(--color-info);
  --info-muted: var(--color-info-muted);
}

/* ==========================================================================
   Base Styles - Applied automatically
   ========================================================================== */
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: var(--tracking-tight);
  background-color: var(--color-bg-pure);
  color: var(--color-fg-primary);
  line-height: var(--leading-body);
}

/* ==========================================================================
   Heading Styles - Applied automatically
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: var(--font-semibold);
  letter-spacing: var(--tracking-tighter);
}

h1 {
  font-size: var(--text-h1);
  line-height: var(--leading-tightest);
}

h2 {
  font-size: var(--text-h2);
  line-height: var(--leading-tighter);
}

h3 {
  font-size: var(--text-h3);
  line-height: var(--leading-tight);
}

h4 {
  font-size: var(--text-h4);
  line-height: var(--leading-tight);
}

h5, h6 {
  font-size: var(--text-body);
  line-height: var(--leading-snug);
}

/* Focus states for accessibility */
*:focus-visible {
  outline: 2px solid var(--color-border-emphasis);
  outline-offset: 2px;
}

/* Link styles */
a {
  color: inherit;
  text-decoration: none;
  transition: color var(--duration-hover) var(--ease-standard);
}

a:hover {
  opacity: 0.7;
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
