/* shared/styles/variables.css — design tokens as CSS custom properties (doc 10 §12) [GLB-5]
 *
 * NO styling framework (no Bootstrap/Tailwind). All tokens are CSS custom properties so components
 * reference `var(--…)` and theming is a later drop-in. A [data-theme="dark"] block overrides the
 * palette (theming is a later feature; the foundation supports it). RTL is handled by dir="rtl" on
 * <html> + CSS logical properties in components — NOT per-component branching (doc 14).
 *
 * Import order (§12): variables.css -> base.css -> component <style> blocks.
 */

:root {
  /* ---- Color: brand / semantic ---- */
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-contrast: #ffffff;
  --color-success: #16a34a;
  --color-warning: #d97706;
  --color-danger: #dc2626;
  --color-info: #0891b2;

  /* Semantic surfaces + text (light theme defaults) */
  --color-bg: #ffffff;
  --color-bg-subtle: #f8fafc;
  --color-bg-muted: #f1f5f9;
  --color-surface: #ffffff;
  --color-surface-raised: #ffffff;
  --color-overlay: rgba(15, 23, 42, 0.45);
  --color-text: #0f172a;
  --color-text-muted: #475569;
  --color-text-subtle: #94a3b8;
  --color-text-inverse: #f8fafc;
  --color-border: #e2e8f0;
  --color-border-strong: #cbd5e1;
  --color-focus-ring: #2563eb;

  /* Impersonation banner (§4.2) */
  --color-impersonation-bg: #f59e0b;
  --color-impersonation-text: #1c1917;

  /* ---- Neutral scale ---- */
  --neutral-50: #f8fafc;
  --neutral-100: #f1f5f9;
  --neutral-200: #e2e8f0;
  --neutral-300: #cbd5e1;
  --neutral-400: #94a3b8;
  --neutral-500: #64748b;
  --neutral-600: #475569;
  --neutral-700: #334155;
  --neutral-800: #1e293b;
  --neutral-900: #0f172a;

  /* ---- Typography scale ---- */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.375rem;
  --font-size-2xl: 1.75rem;
  --font-size-3xl: 2.25rem;
  --line-height-tight: 1.25;
  --line-height-base: 1.5;
  --line-height-relaxed: 1.7;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* ---- Spacing scale (4px base) ---- */
  --space-0: 0;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-8: 3rem;
  --space-10: 4rem;

  /* ---- Radius ---- */
  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* ---- Shadows ---- */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 2px 8px rgba(15, 23, 42, 0.10);
  --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.14);
  --shadow-xl: 0 16px 48px rgba(15, 23, 42, 0.20);

  /* ---- Z-index layers ---- */
  --z-base: 0;
  --z-sticky: 100;
  --z-nav: 200;
  --z-dropdown: 800;
  --z-overlay: 900;
  --z-modal: 1000;
  --z-toast: 1100;
  --z-tooltip: 1200;

  /* ---- Transitions ---- */
  --transition-fast: 120ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 320ms ease;

  /* ---- Layout sizes (§12) ---- */
  --nav-height: 56px;
  --status-height: 28px;
  --sidebar-width: 240px;
  --sidebar-width-collapsed: 56px;
  --content-max-width: 1400px;
}

/* Dark theme overrides — theming is a later feature; the foundation supports it (§12). */
:root[data-theme="dark"] {
  --color-bg: #0f172a;
  --color-bg-subtle: #111c33;
  --color-bg-muted: #1e293b;
  --color-surface: #111c33;
  --color-surface-raised: #1e293b;
  --color-overlay: rgba(0, 0, 0, 0.6);
  --color-text: #e2e8f0;
  --color-text-muted: #94a3b8;
  --color-text-subtle: #64748b;
  --color-text-inverse: #0f172a;
  --color-border: #1e293b;
  --color-border-strong: #334155;
  --color-primary: #3b82f6;
  --color-primary-hover: #60a5fa;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.7);
}

/* Respect OS preference too (still overridable by an explicit data-theme). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #0f172a;
    --color-bg-subtle: #111c33;
    --color-bg-muted: #1e293b;
    --color-surface: #111c33;
    --color-surface-raised: #1e293b;
    --color-overlay: rgba(0, 0, 0, 0.6);
    --color-text: #e2e8f0;
    --color-text-muted: #94a3b8;
    --color-text-subtle: #64748b;
    --color-text-inverse: #0f172a;
    --color-border: #1e293b;
    --color-border-strong: #334155;
    --color-primary: #3b82f6;
    --color-primary-hover: #60a5fa;
  }
}

/* shared/styles/base.css — small targeted reset (doc 10 §12) [GLB-5]
 *
 * Imported AFTER variables.css. A minimal reset (box-sizing, margins, body defaults, list/link/
 * button/table resets, :focus-visible outline, subtle scrollbar, .scroll-locked, .sr-only). RTL is
 * handled by dir="rtl" on <html> + CSS logical properties in components — no reset branching.
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd {
  margin: 0;
}

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
}
button:disabled {
  cursor: not-allowed;
}

input, select, textarea {
  font: inherit;
  color: inherit;
}

img, svg, video, canvas {
  display: block;
  max-width: 100%;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
}

/* Visible keyboard focus only (mouse clicks don't ring). */
:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}
:focus:not(:focus-visible) {
  outline: none;
}

/* Body-scroll lock (Modal counter, §8). */
.scroll-locked {
  overflow: hidden !important;
}

/* Screen-reader-only utility (skip links, aria-live regions). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.sr-only-focusable:focus,
.sr-only-focusable:focus-visible {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* Subtle scrollbar (progressive; ignored where unsupported). */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--neutral-300) transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-thumb {
  background-color: var(--neutral-300);
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-track {
  background: transparent;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
