/* Design tokens — locked dark palette (the AI theme since Nov 2026).
 * Major Third typography scale, 4px spacing grid, WCAG AA
 * on dark surfaces. The dashboard is intentionally always-dark; we
 * don't honour prefers-color-scheme.
 */

:root {
  /* Always dark: native controls (date and number fields, scrollbars,
     selects) draw in their dark style to match. */
  color-scheme: dark;
  /* Typography — Major Third ratio 1.25 */
  --font-family-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-family-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  --font-size-xs:   0.75rem;
  --font-size-sm:   0.8rem;
  --font-size-base: 1rem;
  --font-size-md:   1.25rem;
  --font-size-lg:   1.563rem;
  --font-size-xl:   1.953rem;
  --font-size-2xl:  2.441rem;
  --font-size-3xl:  3.052rem;

  --font-weight-regular: 400;
  --font-weight-medium:  500;
  --font-weight-semi:    600;
  --font-weight-bold:    700;

  --line-height-tight: 1.2;
  --line-height-body:  1.55;
  --line-height-loose: 1.8;

  /* Spacing — 4px grid */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  24px;
  --space-6:  32px;
  --space-7:  48px;
  --space-8:  64px;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  /* Surfaces — locked dark: a deep navy, near black, with a cyan cast
   * in the borders (the AI theme, lib/goals/theme-ai.css). Opaque, so
   * menus, dialogs and sticky bars still hide what is behind them; the
   * glass panels lay their own translucent fill over these. */
  --surface-bg:     #050b17;
  --surface-card:   #0b1628;
  --surface-muted:  #112038;
  --surface-elev:   #182b4a;
  --surface-border: #1f3a5c;
  --surface-border-light: #2d5378;

  /* Text */
  --text-primary:   #e2e8f0;
  --text-secondary: #cbd5e1;
  --text-muted:     #9aa8c2;

  /* Accent + semantic palette
   * Accent is the dashboard's primary colour: cyan, the AI theme's glow
   * (theme-ai.css). The solid accent is a deep cyan so white text on
   * it reads at 5.4:1 (white on accent-dim: 7.3:1); accent-light is the
   * bright cyan for text, fills and dots on the dark surfaces. */
  /* The accent's glow colour as r, g, b, for rgba(var(--ai-rgb), a):
   * the AI theme's tints follow the accent picked in Settings. */
  --ai-rgb: 34, 211, 238;
  /* The glow's brightest part (orb ticks, the brand mark's core). */
  --ai-light-rgb: 103, 232, 249;
  --color-accent:        #0e7490;
  --color-accent-light:  #67e8f9;
  --color-accent-dim:    #155e75;
  --color-accent-bg:     rgba(var(--ai-rgb), 0.13);
  --color-accent-border: rgba(var(--ai-rgb), 0.40);
  /* Accent text on an accent tint over a muted surface: 10:1 or more,
     for 12px labels, badges and Add buttons. */
  --color-accent-text:   #a5f3fc;

  --color-blue:        #38bdf8;
  --color-blue-bg:     rgba(56,189,248,0.12);
  --color-blue-border: rgba(56,189,248,0.30);
  /* Blue and green text on their own tints over a tinted row. */
  --color-blue-text:   #7dd3fc;

  --color-green:        #34d399;
  --color-green-bg:     rgba(52,211,153,0.12);
  --color-green-border: rgba(52,211,153,0.30);
  --color-green-text:   #6ee7b7;

  --color-amber:        #fbbf24;
  --color-amber-bg:     rgba(251,191,36,0.12);
  --color-amber-border: rgba(251,191,36,0.30);

  --color-red:        #f87171;
  --color-red-bg:     rgba(248,113,113,0.12);
  --color-red-border: rgba(248,113,113,0.30);
  /* Red text on a red tint or a muted surface (an overdue row's 10%
     tint, its badge's further 12%, --surface-muted): --color-red is
     3.8-4.5:1 there, this is 5.4:1 or more. */
  --color-red-text:   #fca5a5;

  --color-pink:        #f472b6;
  --color-pink-bg:     rgba(244,114,182,0.12);
  --color-pink-border: rgba(244,114,182,0.30);

  --color-purple:      #a78bfa;
  --color-purple-bg:   rgba(167,139,250,0.12);
  --color-purple-border: rgba(167,139,250,0.30);

  --color-gold:        #fbbf24;
  --color-gold-bg:     rgba(251,191,36,0.15);
  --color-gold-border: rgba(251,191,36,0.40);

  /* Platform-level aliases mapped to the locked palette. */
  --color-success:        var(--color-green);
  --color-success-bg:     var(--color-green-bg);
  --color-success-border: var(--color-green-border);

  --color-warn:        var(--color-amber);
  --color-warn-bg:     var(--color-amber-bg);
  --color-warn-border: var(--color-amber-border);

  --color-danger:        var(--color-red);
  --color-danger-bg:     var(--color-red-bg);
  --color-danger-border: var(--color-red-border);

  --color-info:        var(--color-blue);
  --color-info-bg:     var(--color-blue-bg);
  --color-info-border: var(--color-blue-border);

  --focus-ring: 0 0 0 3px rgba(var(--ai-rgb), 0.60);

  /* The AI theme (lib/goals/theme-ai.css, shared with the Assistant):
   * a cyan glow on glass panels over a faint grid (the Assistant page,
   * styles.css, uses these too). Text in cyan uses
   * --ai-cyan-text (7:1 or more on every surface above). */
  --ai-cyan:         #22d3ee;
  --ai-cyan-soft:    rgba(var(--ai-rgb), 0.14);
  --ai-cyan-text:    #a5f3fc;
  --ai-glow:         rgba(var(--ai-rgb), 0.45);   /* a colour: halos, gradients */
  --ai-glow-shadow:  0 0 0 1px rgba(var(--ai-rgb), 0.10), 0 0 18px -4px rgba(var(--ai-rgb), 0.35);
  --ai-glow-shadow-strong: 0 0 0 1px rgba(var(--ai-rgb), 0.35), 0 0 24px -2px rgba(var(--ai-rgb), 0.55);
  --ai-glass:        rgba(11, 22, 40, 0.78);
  --ai-glass-raised: rgba(17, 32, 56, 0.82);
  --ai-glass-border: rgba(var(--ai-rgb), 0.22);
  --ai-grid:         rgba(var(--ai-rgb), 0.045);
  --ai-core-dark:    #04101c;

  --shadow-xs: 0 1px 1px rgba(0, 0, 0, 0.30);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.40), 0 1px 2px rgba(0, 0, 0, 0.30);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.45), 0 2px 4px -2px rgba(0, 0, 0, 0.30);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.50), 0 4px 6px -4px rgba(0, 0, 0, 0.30);

  --motion-fast:   120ms cubic-bezier(0.2, 0.8, 0.2, 1);
  --motion-base:   200ms cubic-bezier(0.2, 0.8, 0.2, 1);
  --motion-slow:   320ms cubic-bezier(0.2, 0.8, 0.2, 1);

  --bp-sm: 640px;
  --bp-md: 768px;
  --bp-lg: 1024px;

  --touch-target: 44px;
}

/* The accent picked in Settings (cfg:accent, lib/goals/look.js), on
 * <html data-accent>. Cyan, the default, has no attribute. Each keeps
 * the cyan's contrast: white on the solid accent 5:1 or more, the
 * light accent 7.5:1 or more on every surface, and --ai-rgb (the
 * focus ring and outlines at 60%) 3:1 or more, so it is a light shade
 * (tests/unit/look.test.js checks all three). */
:root[data-accent="blue"] {
  --ai-rgb: 147, 197, 253; --ai-light-rgb: 191, 219, 254;
  --color-accent: #1d4ed8; --color-accent-light: #93c5fd; --color-accent-dim: #1e3a8a; --color-accent-text: #bfdbfe;
  --ai-cyan: #60a5fa; --ai-cyan-text: #bfdbfe;
}
:root[data-accent="green"] {
  --ai-rgb: 52, 211, 153; --ai-light-rgb: 110, 231, 183;
  --color-accent: #047857; --color-accent-light: #6ee7b7; --color-accent-dim: #065f46; --color-accent-text: #a7f3d0;
  --ai-cyan: #34d399; --ai-cyan-text: #a7f3d0;
}
:root[data-accent="purple"] {
  --ai-rgb: 196, 181, 253; --ai-light-rgb: 221, 214, 254;
  --color-accent: #6d28d9; --color-accent-light: #c4b5fd; --color-accent-dim: #5b21b6; --color-accent-text: #ddd6fe;
  --ai-cyan: #a78bfa; --ai-cyan-text: #ddd6fe;
}
:root[data-accent="pink"] {
  --ai-rgb: 249, 168, 212; --ai-light-rgb: 251, 207, 232;
  --color-accent: #be185d; --color-accent-light: #f9a8d4; --color-accent-dim: #9d174d; --color-accent-text: #fbcfe8;
  --ai-cyan: #f472b6; --ai-cyan-text: #fbcfe8;
}
:root[data-accent="amber"] {
  --ai-rgb: 251, 191, 36; --ai-light-rgb: 252, 211, 77;
  --color-accent: #b45309; --color-accent-light: #fcd34d; --color-accent-dim: #92400e; --color-accent-text: #fde68a;
  --ai-cyan: #fbbf24; --ai-cyan-text: #fde68a;
}

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

html {
  font-family: var(--font-family-sans);
  font-size: 100%; /* follows the browser's text-size setting */
  color: var(--text-primary);
  background: var(--surface-bg);
  line-height: var(--line-height-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* Every field's placeholder: the browser's grey is meant for light
   fields. --text-muted is 4.9:1 on --surface-muted, 5.8:1 on the card.
   Firefox also dims it with opacity. */
::placeholder { color: var(--text-muted); opacity: 1; }
body { margin: 0; background: var(--surface-bg); color: var(--text-primary); }
*, *::before, *::after { box-sizing: border-box; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
