/*
 * LikeClockwork Design Tokens
 * Single source of truth for the design system.
 * See CLAUDE OUTPUTS/Likeclockwork/Phase2_Design_Tokens.md for full specification.
 *
 * Theme switching: data-theme attribute on <html> — default 'dark'.
 * Reduced motion: respected via @media (prefers-reduced-motion: reduce).
 */

:root {
  /* Spacing — 4px grid */
  --space-0: 0;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  /* Type */
  --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Geist Mono', 'SF Mono', Menlo, Consolas, monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;
  --text-6xl: 3.75rem;

  --leading-tight: 1.2;
  --leading-snug: 1.4;
  --leading-normal: 1.6;

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  --tracking-tight: -0.02em;
  --tracking-normal: 0;
  --tracking-wider: 0.05em;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-2xl: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 12px 24px rgba(0, 0, 0, 0.12);

  /* Brand accent — violet ramp.
     Derived from the LikeClockwork brand spec; aligned to Tailwind violet/950. */
  --accent-50:  #f5f3ff;   /* surface tint              (violet-50) */
  --accent-100: #ede9fe;   /* surface active            (violet-100) */
  --accent-200: #ddd6fe;   /* border accent / focus     (violet-200) */
  --accent-300: #c4b5fd;   /*                            (violet-300) */
  --accent-400: #a78bfa;   /* accent-light              (violet-400) */
  --accent-500: #8b5cf6;   /*                            (violet-500) */
  --accent-600: #7c3aed;   /* PRIMARY                   (violet-600) */
  --accent-700: #6d28d9;   /* primary-hover             (violet-700) */
  --accent-800: #5b21b6;   /*                            (violet-800) */
  --accent-900: #4c1d95;   /* primary-dark (sidebar)    (violet-900) */
  --accent-950: #2e1065;   /* primary-deepest (hero)    (violet-950) */

  /* RAG (semantic) */
  --rag-green-500:  #10b981;
  --rag-green-100:  #d1fae5;
  --rag-amber-500:  #f59e0b;
  --rag-amber-100:  #fef3c7;
  --rag-red-500:    #ef4444;
  --rag-red-100:    #fee2e2;

  --info:    #7c3aed;
  --success: #10b981;
  --warning: #f59e0b;
  --danger:  #ef4444;
  --neutral: #64748b;

  /* Z-index */
  --z-dropdown: 100;
  --z-sticky:   200;
  --z-overlay:  300;
  --z-modal:    400;
  --z-toast:    500;
  --z-tooltip:  600;

  /* Motion */
  --ease-out:   cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in:    cubic-bezier(0.7, 0, 0.84, 0);
  --ease-inout: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast:    120ms;
  --duration-normal:  200ms;
  --duration-slow:    320ms;

  /* Layout */
  --content-max:    72rem;
  --content-narrow: 48rem;
  --sidebar-w:      240px;
  --sidebar-w-collapsed: 60px;
}

/* Light theme */
:root,
[data-theme="light"] {
  --bg:               #f8fafc;   /* slate-50 — page background per spec */
  --bg-subtle:        #f6f8fb;
  --bg-muted:         #f1f3f7;
  --bg-elevated:      #ffffff;
  --bg-overlay:       rgba(46, 16, 101, 0.45);  /* tinted with violet-950 */

  --fg:               #0f172a;   /* slate-900 — text-primary */
  --fg-muted:         #475569;   /* slate-600 — text-secondary */
  --fg-subtle:        #64748b;   /* slate-500 — neutral */
  --fg-on-accent:     #ffffff;

  --border:           #e2e8f0;   /* slate-200 */
  --border-strong:    #cbd5e1;   /* slate-300 */
  --border-accent:    var(--accent-200);  /* violet-200 — focus ring */

  --surface-tint:     var(--accent-50);   /* violet-50 — selected rows / cards */
  --surface-active:   var(--accent-100);  /* violet-100 — active nav / badges */

  --hover:            rgba(124, 58, 237, 0.06);   /* violet-tinted hover */
  --active:           rgba(124, 58, 237, 0.10);
  --focus-ring:       var(--accent-600);

  --primary:          var(--accent-600);   /* #7c3aed */
  --primary-hover:    var(--accent-700);   /* #6d28d9 */
  --primary-dark:     var(--accent-900);   /* #4c1d95 — sidebar */
  --primary-deepest:  var(--accent-950);   /* #2e1065 — hero */
  --primary-fg:       #ffffff;
}

/* Dark theme — DEFAULT for the app */
[data-theme="dark"] {
  --bg:               #0a0a0a;
  --bg-subtle:        #111114;
  --bg-muted:         #1a1a1f;
  --bg-elevated:      #161619;
  --bg-overlay:       rgba(0, 0, 0, 0.6);

  --fg:               #fafafa;
  --fg-muted:         #b4bccc;
  --fg-subtle:        #6b7280;
  --fg-on-accent:     #ffffff;

  --border:           #27272a;
  --border-strong:    #3f3f46;
  --border-accent:    var(--accent-400);

  --surface-tint:     rgba(124, 58, 237, 0.08);
  --surface-active:   rgba(124, 58, 237, 0.16);

  --hover:            rgba(167, 139, 250, 0.08);
  --active:           rgba(167, 139, 250, 0.14);
  --focus-ring:       var(--accent-400);   /* lilac on dark */

  --primary:          var(--accent-600);   /* keeps brand identity */
  --primary-hover:    var(--accent-500);   /* lifts on dark */
  --primary-dark:     var(--accent-950);   /* deepest sidebar on dark */
  --primary-deepest:  var(--accent-950);
  --primary-fg:       #ffffff;

  --rag-green-500:  #34d399;
  --rag-amber-500:  #fbbf24;
  --rag-red-500:    #f87171;
}

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

/* Base reset */
*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light dark; -webkit-font-smoothing: antialiased; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  background: var(--bg);
  color: var(--fg);
}

/* Focus ring — uniform */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary);
  color: var(--primary-fg);
  padding: var(--space-2) var(--space-4);
  z-index: var(--z-tooltip);
}
.skip-link:focus { top: 0; }
