/*
  NPILayer design tokens.
  Source of truth: /DESIGN.md section 4, 5, 7, 8, 33.
  Do not fork these values per-page -- add a new token instead.
*/

:root {
  /* Typography */
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  /* Surfaces */
  --color-bg: #f7f9fc;
  --color-surface: #ffffff;
  --color-surface-subtle: #f8fafc;

  /* Text */
  --color-text: #0b1739;
  --color-text-secondary: #526078;
  --color-text-muted: #64748b;
  --color-text-on-primary: #ffffff;
  --color-text-on-code: #e2e8f0;

  /* Borders */
  --color-border: #e2e8f0;
  --color-border-strong: #cbd5e1;

  /* Primary accent -- use intentionally, not decoratively */
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-subtle: #eff6ff;

  /* Primary gradient -- reserved for the single primary CTA per view.
     Never apply to secondary/tertiary buttons, badges, or icons. */
  --gradient-primary: linear-gradient(to right, #2563eb 0%, #4338ca 100%);
  --gradient-primary-hover: linear-gradient(to right, #1d4ed8 0%, #3730a3 100%);

  /* Status */
  --color-success: #15803d;
  --color-success-subtle: #f0fdf4;
  --color-warning: #b45309;
  --color-warning-subtle: #fffbeb;
  --color-danger: #b91c1c;
  --color-danger-subtle: #fef2f2;

  /* Code / technical values */
  --color-code-bg: #0f172a;
  --color-code-text: #e2e8f0;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 999px;

  /* Shadow -- reserve for floating elements only (menus, modals) */
  --shadow-sm: 0 1px 2px rgba(11, 23, 57, 0.06);
  --shadow-md: 0 4px 16px rgba(11, 23, 57, 0.08);

  /* Spacing scale (8px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;
  --space-30: 120px;

  /* Layout */
  --container-max: 1200px;
  --container-padding: var(--space-4);
  --content-max: 720px;
  --sidebar-width: 240px;

  /* Motion */
  --transition-fast: 120ms ease;
  --transition-base: 180ms ease;

  /* Z-index scale */
  --z-dropdown: 10;
  --z-sticky: 20;
  --z-overlay: 30;
  --z-modal: 50;
}

/* Dark mode tokens — applied when OS prefers dark OR user toggled dark.
   Light override (:root[data-theme="light"]) restores light values even
   when the OS is in dark mode. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg:             #0d1117;
    --color-surface:        #161b22;
    --color-surface-subtle: #1c2128;

    --color-text:           #e6edf3;
    --color-text-secondary: #8d96a0;
    --color-text-muted:     #6e7681;
    --color-text-on-code:   #e2e8f0;

    --color-border:         #30363d;
    --color-border-strong:  #484f58;

    --color-primary:        #4d9fef;
    --color-primary-hover:  #79b8f7;
    --color-primary-subtle: #0d2540;

    --gradient-primary:       linear-gradient(to right, #4d9fef 0%, #6e5ee0 100%);
    --gradient-primary-hover: linear-gradient(to right, #79b8f7 0%, #8b78f0 100%);

    --color-success:        #3fb950;
    --color-success-subtle: #0a2210;
    --color-warning:        #d29922;
    --color-warning-subtle: #2d1f00;
    --color-danger:         #f85149;
    --color-danger-subtle:  #2d0f0e;

    --color-code-bg:        #010409;
    --color-code-text:      #c9d1d9;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  }
}

/* Manual dark override — wins over OS light preference */
:root[data-theme="dark"] {
  --color-bg:             #0d1117;
  --color-surface:        #161b22;
  --color-surface-subtle: #1c2128;

  --color-text:           #e6edf3;
  --color-text-secondary: #8d96a0;
  --color-text-muted:     #6e7681;
  --color-text-on-code:   #e2e8f0;

  --color-border:         #30363d;
  --color-border-strong:  #484f58;

  --color-primary:        #4d9fef;
  --color-primary-hover:  #79b8f7;
  --color-primary-subtle: #0d2540;

  --gradient-primary:       linear-gradient(to right, #4d9fef 0%, #6e5ee0 100%);
  --gradient-primary-hover: linear-gradient(to right, #79b8f7 0%, #8b78f0 100%);

  --color-success:        #3fb950;
  --color-success-subtle: #0a2210;
  --color-warning:        #d29922;
  --color-warning-subtle: #2d1f00;
  --color-danger:         #f85149;
  --color-danger-subtle:  #2d0f0e;

  --color-code-bg:        #010409;
  --color-code-text:      #c9d1d9;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --transition-fast: 0ms;
    --transition-base: 0ms;
  }
}
