/*
  JARVIS Design System — tokens. (Phase 10a, Radical Modernization;
  revised after first review of the Home implementation.)

  Palette direction (explicit, from the user's visual revision request):
  a light/white foundation, powerful deep blues as the primary structural
  color, and ONE restrained accent — kiwi green, chosen over the prior
  purple specifically because purple/violet is the default "AI product"
  color (this app's own prior palette included) and the brief asks for
  JARVIS to avoid reading as "overly AI-looking." Blue carries primary
  actions, navigation and structure; green is held back for AI-
  intelligence moments (Ask JARVIS, Intelligence insights) and success
  states — two colors with distinct jobs, not two competing primaries.

  This is the canonical source for the --db-* custom properties that
  have been independently copy-pasted (byte-identical where present)
  into dashboard.css, meetings-redesign.css, projects-tasks-redesign.css,
  settings-redesign.css, reports-redesign.css, nexus-redesign.css,
  documents-redesign.css, integration-flow.css and onboarding.css across
  Phases 2-9. Those files are untouched and keep working as-is — this is
  additive, not a migration. New/rebuilt pages load this instead.

  Beyond --db-*, this adds what those 9 files never had: a neutral color
  scale, a typography scale, a spacing scale, an elevation scale, motion
  tokens, and a real z-index scale — the last one specifically because
  every prior phase fought ad-hoc z-index collisions one at a time
  (documents-redesign.css and integration-flow.css both needed a
  one-off `.gl-picker { z-index: 10001 }` patch just to clear their own
  page's modal). A named scale stops that pattern from recurring.
*/

:root {
  /* ============ Neutral scale ============
     Blue-leaning grays (not pure neutral) so the "powerful blue"
     identity carries through even into body text and borders, not just
     accent moments. */
  --n-0: #ffffff;
  --n-50: #f7f9fc;
  --n-100: #eff3f8;
  --n-150: #e6ecf3;
  --n-200: #dce3ed;
  --n-300: #c2ccdb;
  --n-400: #94a1b8;
  --n-500: #5d6b85;
  --n-600: #42506b;
  --n-700: #2b3850;
  --n-800: #182238;
  --n-900: #0b1626;

  /* ============ Brand ============ */
  --brand-primary: #1e3a8a;
  --brand-primary-hover: #15306f;
  --brand-primary-active: #0f2456;
  --brand-accent: #65a30d;
  --brand-accent-bright: #84cc16;
  --brand-accent-hover: #528208;

  /* ============ Semantic surfaces (the --db-* API every prior
     redesign already depends on — kept as the primary names) ============ */
  --db-bg: var(--n-50);
  --db-surface: var(--n-0);
  --db-surface-hover: var(--n-100);
  --db-surface-sunken: var(--n-100);
  --db-border: var(--n-200);
  --db-border-strong: var(--n-300);
  --db-text: var(--n-900);
  --db-text-muted: var(--n-500);
  --db-text-faint: var(--n-400);

  --db-primary: var(--brand-primary);
  --db-primary-hover: var(--brand-primary-hover);
  --db-primary-active: var(--brand-primary-active);
  --db-primary-soft: #eaf0fb;
  --db-accent: var(--brand-accent);
  --db-accent-bright: var(--brand-accent-bright);
  --db-accent-hover: var(--brand-accent-hover);
  --db-accent-soft: #f2f9e6;

  --db-danger: #dc2626;
  --db-danger-hover: #c01f1f;
  --db-danger-soft: #fcebeb;
  --db-warning: #d97706;
  --db-warning-hover: #b76405;
  --db-warning-soft: #fdf1e1;
  --db-success: var(--brand-accent);
  --db-success-hover: var(--brand-accent-hover);
  --db-success-soft: var(--db-accent-soft);
  --db-info: #2563a8;
  --db-info-soft: #e9f1fb;

  /* ============ Radius (standardized on the value 8 of 9 prior
     files already used; onboarding.css's 14/9 was the one outlier) ============ */
  --db-radius-sm: 8px;
  --db-radius: 12px;
  --db-radius-lg: 16px;
  --db-radius-full: 999px;

  /* ============ Elevation ============ */
  --shadow-sm: 0 1px 2px rgba(20, 20, 30, 0.04);
  --shadow-md: 0 1px 2px rgba(20, 20, 30, 0.04), 0 8px 24px -12px rgba(20, 20, 30, 0.10);
  --shadow-lg: 0 4px 12px rgba(20, 20, 30, 0.06), 0 20px 48px -16px rgba(20, 20, 30, 0.18);
  --db-shadow: var(--shadow-md); /* alias kept for drop-in parity with existing --db-shadow usage */

  /* ============ Spacing (4px base) ============ */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* ============ Fonts ============
     Libre Caslon Condensed is the primary DISPLAY face — reserved for
     the two most prominent typographic tiers (page title, section
     title) so it reads as a deliberate identity choice, not a global
     typeface swap. Everything else (card titles, body, metadata,
     labels, every interactive control) stays in the system sans stack
     for density and legibility at small sizes, where a condensed serif
     stops working. */
  --font-display: "Libre Caslon Condensed", Georgia, "Times New Roman", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* ============ Typography scale ============
     Each level bundles size/weight/line-height/letter-spacing so a
     component picks one token set, not four separate properties. */
  --text-page-title-size: 32px;
  --text-page-title-weight: 400;
  --text-page-title-line: 1.15;

  --text-section-title-size: 19px;
  --text-section-title-weight: 400;
  --text-section-title-line: 1.25;

  --text-card-title-size: 14px;
  --text-card-title-weight: 650;
  --text-card-title-line: 1.35;

  --text-body-size: 13.5px;
  --text-body-weight: 450;
  --text-body-line: 1.55;

  --text-metadata-size: 12px;
  --text-metadata-weight: 500;
  --text-metadata-line: 1.4;

  --text-label-size: 11px;
  --text-label-weight: 700;
  --text-label-line: 1.3;
  --text-label-tracking: 0.04em;

  /* ============ Motion ============ */
  --duration-fast: 120ms;
  --duration-base: 180ms;
  --duration-slow: 280ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* ============ Z-index scale ============
     Named layers instead of ad-hoc 9999/10000/10001 patches. Floor is
     1001: the shared .sp-top-bar (styles.css, loaded on every page) is
     hardcoded to z-index:1000, so anything meant to sit above the chrome
     — which is everything below — has to clear that first. Confirmed
     the hard way: a drawer at 900 put its own close button underneath
     the top bar's notification icon, unclickable. */
  --z-dropdown: 1010;
  --z-sticky: 1020;
  --z-overlay: 1100;
  --z-drawer: 1150;
  --z-modal: 1200;
  --z-popover: 1250;
  --z-toast: 1300;
}

/* ============ Typography utility classes ============ */

.text-page-title {
  font-family: var(--font-display);
  font-size: var(--text-page-title-size);
  font-weight: var(--text-page-title-weight);
  line-height: var(--text-page-title-line);
  color: var(--db-text);
  margin: 0;
}

.text-section-title {
  font-family: var(--font-display);
  font-size: var(--text-section-title-size);
  font-weight: var(--text-section-title-weight);
  line-height: var(--text-section-title-line);
  color: var(--db-text);
  margin: 0;
}

.text-card-title {
  font-family: var(--font-body);
  font-size: var(--text-card-title-size);
  font-weight: var(--text-card-title-weight);
  line-height: var(--text-card-title-line);
  color: var(--db-text);
  margin: 0;
}

.text-body {
  font-family: var(--font-body);
  font-size: var(--text-body-size);
  font-weight: var(--text-body-weight);
  line-height: var(--text-body-line);
  color: var(--db-text);
}

.text-metadata {
  font-family: var(--font-body);
  font-size: var(--text-metadata-size);
  font-weight: var(--text-metadata-weight);
  line-height: var(--text-metadata-line);
  color: var(--db-text-muted);
}

.text-label {
  font-family: var(--font-body);
  font-size: var(--text-label-size);
  font-weight: var(--text-label-weight);
  line-height: var(--text-label-line);
  letter-spacing: var(--text-label-tracking);
  text-transform: uppercase;
  color: var(--db-text-faint);
}

/* ============ Accessibility preferences (Settings › Accessibility) ============
   Classes on <html>, set on every page by jarvis-components.js. */

/* Font size: the whole interface scales together (text set in px included) */
html.a11y-zoomed body { zoom: var(--a11y-zoom, 1); }

/* High contrast: darker text and borders, stronger brand color */
html.a11y-contrast {
  --db-text: #000;
  --db-text-muted: #1f2937;
  --db-text-faint: #374151;
  --db-border: #6b7280;
  --db-border-strong: #374151;
  --db-bg: #fff;
  --db-primary: #102a6b;
  --db-primary-soft: #dbe6fb;
}
html.a11y-contrast main a:not(.jbtn):not([class*="btn"]) { text-decoration: underline; }
html.a11y-contrast ::placeholder { color: #4b5563; opacity: 1; }

/* Reduce motion: no animations, transitions or smooth scrolling */
html.a11y-reduce-motion *,
html.a11y-reduce-motion *::before,
html.a11y-reduce-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

/* Keyboard navigation indicators: a clear ring on whatever has keyboard focus */
html.a11y-focus :focus-visible {
  outline: 3px solid var(--db-accent, #65a30d) !important;
  outline-offset: 2px !important;
  border-radius: 4px;
}

/* Screen reader support: a skip link, full (not cut-off) text, underlined links */
.a11y-skip {
  position: absolute;
  left: 8px;
  top: -48px;
  z-index: 10000;
  padding: 8px 14px;
  border-radius: 6px;
  background: var(--db-primary);
  color: #fff;
  font-weight: 600;
}
.a11y-skip:focus { top: 8px; }
html.a11y-reader [class*="title"],
html.a11y-reader [class*="name"] { text-overflow: clip; white-space: normal; }
html.a11y-reader main a:not(.jbtn):not([class*="btn"]) { text-decoration: underline; }

/* Compact mode (Settings › Appearance): tighter spacing everywhere the tokens are used */
html.compact-mode {
  --space-2: 6px;
  --space-3: 9px;
  --space-4: 12px;
  --space-5: 15px;
  --space-6: 18px;
  --space-8: 24px;
  --space-10: 30px;
  --space-12: 36px;
}
html.compact-mode .jcard-body,
html.compact-mode .setting-item { padding-top: 8px; padding-bottom: 8px; }
