/*
 * 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;
  /* Super green: Scaling Up's stretch level. A teal-leaning green so it reads as
     "beyond green" next to --rag-green-500, always paired with a ★ and a label. */
  --rag-super-500:  #0d9488;
  --rag-super-100:  #ccfbf1;

  --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:        #5b6577;   /* a11y: darker than slate-500 so it passes 4.5:1 on --bg-muted and --accent-50/100 */
  --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;
  /* Primary used as TEXT (links, accent labels). Light: violet-600, 5.7:1 on white. */
  --primary-text:     var(--accent-600);

  /* Form-control borders (WCAG 1.4.11 non-text contrast >= 3:1 against the surface). */
  --border-input:     #8a94a6;
  --avatar-fg:        var(--accent-700);   /* 6.0:1 on --avatar-bg */
  --avatar-bg:        var(--accent-100);

  /* RAG hues used as TEXT. The -500 fills are too light for text on white
     (green 2.5:1, amber 2.2:1), so text and thin strokes use these (>= 4.5:1). */
  --rag-green-text:   #047857;
  --rag-amber-text:   #b45309;
  --rag-red-text:     #b91c1c;
  --rag-super-text:   #0f766e;
  --danger-solid:     #b91c1c;   /* filled danger buttons: white text 6.5:1 (--danger is 3.8:1) */
}

/* 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:        #8b93a3;   /* a11y: was #6b7280 (3.7:1 on --bg-elevated); now 5.8:1 */
  --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;
  --primary-text:     var(--accent-400);   /* violet-600 is 3.2:1 on dark; lilac is 6.6:1 */
  --border-input:     #71717a;
  --avatar-fg:        var(--accent-100);   /* 8.6:1 on violet-900 */
  --avatar-bg:        var(--accent-900);

  --rag-green-500:  #34d399;
  --rag-amber-500:  #fbbf24;
  --rag-red-500:    #f87171;
  --rag-super-500:  #2dd4bf;
  --rag-green-100:  rgba(52, 211, 153, 0.14);
  --rag-amber-100:  rgba(251, 191, 36, 0.14);
  --rag-red-100:    rgba(248, 113, 113, 0.14);
  --rag-super-100:  rgba(45, 212, 191, 0.16);
  --rag-green-text: #34d399;
  --rag-amber-text: #fbbf24;
  --rag-red-text:   #f87171;
  --rag-super-text: #2dd4bf;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-fast: 0ms;
    --duration-normal: 0ms;
    --duration-slow: 0ms;
  }
  /* Belt and braces for page-level style attributes and <style> blocks that
     hard-code durations rather than using the tokens. */
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Visually hidden but available to screen readers. */
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* 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);
}

/* Links without their own colour (legal pages, help text) — the UA default blue fails on dark. */
:where(main, article) a:not([class]) { color: var(--primary-text); }

/* 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; }

/* Touch and phone-width screens: shell controls are at least 40px tall to tap (QA v27). */
@media (pointer: coarse), (max-width: 800px) {
  .lc-trial-cta, .lc-help-link { min-height: 40px; min-width: 40px; }
}

/* Inline links in running text are underlined so they don't rely on colour (WCAG 1.4.1). */
main p a:not([class]), main li a:not([class]), article a:not([class]) { text-decoration: underline; text-underline-offset: 2px; }

/* Reflow (WCAG 1.4.10): no page-level horizontal scroll at 320px CSS width. */
img, svg, video, canvas { max-width: 100%; }
pre, code { overflow-wrap: anywhere; }

/* Topbar breadcrumb (shell/layout.js): never cut mid-word at phone width (QA v26: "· Ho").
   The current page truncates with an ellipsis; under 480px "Home" and the separator go
   (the logo and menu still lead home) and the company switcher shrinks first. */
.lc-crumbs { min-width: 0; }
.lc-crumbs > li { white-space: nowrap; flex-shrink: 0; }
.lc-crumbs > li[aria-current] { overflow: hidden; text-overflow: ellipsis; min-width: 0; flex-shrink: 1; }
@media (max-width: 480px) {
  .lc-crumbs > li.lc-crumb-home, .lc-crumbs > li.lc-crumb-sep { display: none; }
  .lc-crumbs > li.lc-crumb-switch { min-width: 0 !important; flex: 0 1 auto; max-width: 55vw !important; }
}

/* Ended subscription → view only (app/lib/read-only.js sets <html data-read-only>).
   Hide the obvious "create" controls; the API refuses the writes anyway (402).
   New pages can opt in with data-write on any edit control. */
html[data-read-only] [data-write],
html[data-read-only] #add-rock, html[data-read-only] #add-rock-empty,
html[data-read-only] #add-kpi, html[data-read-only] #add-kpi-empty,
html[data-read-only] #add-thrust, html[data-read-only] #add-move,
html[data-read-only] #add-doc, html[data-read-only] #new-scorecard,
html[data-read-only] #add-outcome, html[data-read-only] #add-competency,
html[data-read-only] #add-candidate,
/* A role that can look but not change (the coach on /cash, viewers on hiring, …): the page
   marks its main element; its edit controls carry data-write. */
[data-cash-view-only] [data-write], [data-role-view-only] [data-write] { display: none !important; }
