/* Callably design tokens: the single source of truth for every raw design value.
 *
 * Change a value here and it changes everywhere (app, sign-in, public pages). Nothing else in the codebase should spell
 * out a colour, radius, shadow, font size or duration; components read these tokens with var(--ds-*).
 * Guide: docs/design-system/README.md. Live reference: /design-system (not available in production).
 *
 * Load order: after style.css / shared.css, before everything else that uses the tokens (the legacy stylesheets read
 * their old variable names from legacy-app.css, which maps them onto the tokens below).
 *
 * Light is the default; dark values live under :root[data-theme="dark"] (set by the theme switcher in header.php).
 * Near-black colours must stay inside the dark block (scripts/check-no-pure-black.php enforces it).
 */

:root {
    color-scheme: light;

    /* ── Colour: brand ──────────────────────────────────────────────────────────────────────────────────────────
       primary         accent for links, active states, icons, focus; also text on a primary-tinted surface
       primary-solid   fill behind white text (buttons, active pills); 5.5:1 against --ds-on-primary
       Change the whole brand colour by editing these (and the dark block below). */
    --ds-primary: #4f46e5;
    --ds-primary-hover: #4338ca;
    --ds-primary-solid: #4f46e5;
    --ds-primary-solid-hover: #4338ca;
    --ds-primary-solid-active: #3730a3;
    --ds-on-primary: #ffffff;
    --ds-primary-ink: #3730a3;
    --ds-primary-soft: #eef2ff;
    --ds-primary-soft-border: #c7d2fe;
    --ds-primary-subtle: rgba(79, 70, 229, 0.08);
    --ds-primary-tint: rgba(79, 70, 229, 0.13);
    --ds-primary-accent: #6366f1;       /* second stop in brand gradients */
    --ds-primary-on-dark: #a5b4fc;      /* brand colour for text and icons on the dark slate sections of the public site */
    --ds-success-on-dark: #34d399;      /* success green for figures and icons on dark gradient panels */
    --ds-info-on-dark: #93c5fd;         /* light blue for links and icons on dark panels */
    --ds-logo-cyan: #4ecbf5;            /* handset gradient from the Callably brand mark */
    --ds-logo-blue: #1a55db;

    /* ── Colour: surfaces and text ───────────────────────────────────────────────────────────────────────────── */
    --ds-background: #ffffff;           /* page canvas */
    --ds-background-subtle: #f8fafc;    /* app shell, zebra rows, inset panels */
    --ds-background-muted: #f1f5f9;     /* hover fills, chips, tracks */
    --ds-surface: #ffffff;              /* cards, dialogs, inputs, menus */
    --ds-surface-hover: rgba(71, 85, 105, 0.055);
    --ds-text: #475569;                 /* body and headings */
    --ds-muted: #64748b;                /* secondary text (4.8:1 on white) */
    --ds-subtle: #94a3b8;               /* placeholders and decorative text only; never essential copy */
    --ds-text-inverse: #ffffff;
    --ds-display-ink: #3730a3;          /* public marketing headlines: rich indigo, never black or near-black */
    --ds-border: #d7dee8;               /* default card and divider border */
    --ds-border-control: #8b98ab;       /* input, select, checkbox outline: 3:1 against the surface (WCAG 1.4.11) */
    --ds-border-subtle: rgba(71, 85, 105, 0.11);   /* dividers */
    --ds-border-strong: rgba(71, 85, 105, 0.20);   /* hovered controls */
    --ds-overlay: rgba(71, 85, 105, 0.50);         /* behind dialogs */

    /* ── Colour: status (text colours pass 4.5:1 on --ds-surface in their theme) ─────────────────────────────── */
    --ds-success: #047857;
    --ds-success-strong: #065f46;
    --ds-success-subtle: rgba(4, 120, 87, 0.12);
    --ds-warning: #b45309;
    --ds-warning-strong: #92400e;
    --ds-warning-subtle: rgba(180, 83, 9, 0.12);
    --ds-error: #be123c;
    --ds-error-strong: #9f1239;
    --ds-error-subtle: rgba(190, 18, 60, 0.11);
    --ds-info: #1d4ed8;
    --ds-info-strong: #1e40af;
    --ds-info-subtle: rgba(29, 78, 216, 0.10);
    --ds-assistant-blue: #38bdf8;
    --ds-assistant-cyan: #67e8f9;
    --ds-assistant-violet: #8b7cf6;
    --ds-on-status: #ffffff;            /* text on a solid success / warning / error fill */

    /* ── Colour: neutral ramp (legacy gray-* scale; inverts in dark) ───────────────────────────────────────────── */
    /* Data visualisation: categorical series for charts and chips (status colours keep their meaning). */
    --ds-chart-1: #6366f1;
    --ds-chart-2: #0ea5e9;
    --ds-chart-3: #f59e0b;
    --ds-chart-4: #8b5cf6;
    --ds-chart-5: #ec4899;
    --ds-chart-6: #64748b;

    --ds-gray-50: #f8fafc;
    --ds-gray-100: #f8fafc;
    --ds-gray-200: #e2e8f0;
    --ds-gray-300: #e2e8f0;
    --ds-gray-400: #94a3b8;
    --ds-gray-500: #64748b;
    --ds-gray-600: #64748b;
    --ds-gray-700: #475569;
    --ds-gray-800: #475569;
    --ds-gray-900: #475569;

    /* ── Typography ─────────────────────────────────────────────────────────────────────────────────────────────── */
    --ds-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --ds-font-accent: 'Instrument Serif', Georgia, 'Times New Roman', serif;   /* italic accent words in public marketing headlines */
    --ds-font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
    --ds-text-2xs: 0.75rem;     /* 12px  badge counters, micro labels (never below 12px) */
    --ds-text-xs: 0.75rem;      /* 12px  table headers, captions */
    --ds-text-sm: 0.8125rem;    /* 13px  secondary text, controls */
    --ds-text-base: 0.875rem;   /* 14px  body (dense data UI) */
    --ds-text-md: 0.9375rem;    /* 15px  comfortable reading */
    --ds-text-lg: 1rem;         /* 16px  emphasised body, dialog titles */
    --ds-text-xl: 1.125rem;     /* 18px  card titles */
    --ds-text-2xl: 1.25rem;     /* 20px  section headings, page title on mobile */
    --ds-text-page-title: 1.375rem; /* 22px  app page title (H1); 20px on phones */
    --ds-text-3xl: 1.5rem;      /* 24px  large titles */
    --ds-text-4xl: 2rem;        /* 32px  stat numbers */
    --ds-text-5xl: 2.5rem;      /* 40px  marketing headlines */
    --ds-weight-normal: 400;
    --ds-weight-medium: 500;
    --ds-weight-semibold: 600;
    --ds-weight-bold: 700;
    --ds-weight-extrabold: 800;
    --ds-leading-none: 1;
    --ds-leading-tight: 1.25;
    --ds-leading-snug: 1.375;
    --ds-leading-normal: 1.5;
    --ds-leading-relaxed: 1.75;
    --ds-tracking-tight: -0.025em;
    --ds-tracking-snug: -0.015em;
    --ds-tracking-normal: 0;
    --ds-tracking-wide: 0.025em;
    --ds-tracking-wider: 0.05em;

    /* ── Spacing (4px base) ─────────────────────────────────────────────────────────────────────────────────── */
    --ds-space-0: 0;
    --ds-space-0-5: 0.125rem;
    --ds-space-1: 0.25rem;
    --ds-space-1-5: 0.375rem;
    --ds-space-2: 0.5rem;
    --ds-space-2-5: 0.625rem;
    --ds-space-3: 0.75rem;
    --ds-space-4: 1rem;
    --ds-space-5: 1.25rem;
    --ds-space-6: 1.5rem;
    --ds-space-8: 2rem;
    --ds-space-10: 2.5rem;
    --ds-space-12: 3rem;
    --ds-space-16: 4rem;

    /* ── Sizing ─────────────────────────────────────────────────────────────────────────────────────────────── */
    --ds-control-xs: 1.5rem;        /* 24px  compact table actions */
    --ds-control-sm: 1.75rem;       /* 28px */
    --ds-control-md: 2rem;          /* 32px  default button */
    --ds-control-lg: 2.5rem;        /* 40px  large button, buttons on phones */
    --ds-input-height: 2.25rem;     /* 36px  text inputs and selects */
    --ds-touch-target: 2.75rem;     /* 44px  minimum tap area for checkboxes and icon buttons on touch screens */
    --ds-icon-sm: 0.875rem;
    --ds-icon-md: 1rem;
    --ds-icon-lg: 1.25rem;
    --ds-field-number: 10rem;     /* bounded numeric settings */
    --ds-form-compact: 32rem;     /* short configuration forms */
    --ds-text-measure: 70ch;      /* readable explanatory copy */
    --ds-container-narrow: 40rem;   /* forms, auth, long-form text */
    --ds-container: 72rem;          /* default content width */
    --ds-container-wide: 90rem;     /* tables and boards */
    --ds-sidebar-width: 220px;
    --ds-topbar-height: 50px;

    /* ── Borders and radii ──────────────────────────────────────────────────────────────────────────────────── */
    --ds-border-width: 1px;
    --ds-border-width-strong: 2px;
    --ds-border-width-accent: 3px;  /* left bar on alerts and toasts, spinner ring */
    --ds-radius-xs: 0.25rem;
    --ds-radius-sm: 0.375rem;
    --ds-radius-md: 0.5rem;
    --ds-radius-lg: 0.75rem;
    --ds-radius-xl: 1rem;
    --ds-radius-2xl: 1.5rem;
    --ds-radius-full: 9999px;
    /* Formerly the 3px "classic" square corners. The whole app now uses the landing page's rounded corners: the
       universal classic-corner rules were removed from style.css and shared.css, and legacy-app.css maps the old
       --radius-* names onto the real scale. Kept as an alias for any older rule that still reads it. */
    --ds-radius-classic: var(--ds-radius-md);

    /* ── Elevation ──────────────────────────────────────────────────────────────────────────────────────────── */
    --ds-shadow-xs: 0 1px 2px rgba(71, 85, 105, 0.06);
    --ds-shadow-sm: 0 2px 8px rgba(71, 85, 105, 0.08);
    --ds-shadow-md: 0 6px 20px rgba(71, 85, 105, 0.10);
    --ds-shadow-lg: 0 12px 34px rgba(71, 85, 105, 0.14);
    --ds-shadow-xl: 0 16px 52px rgba(71, 85, 105, 0.15);
    --ds-shadow-dropdown: 0 14px 36px rgba(71, 85, 105, 0.16);
    --ds-shadow-input: 0 1px 3px rgba(71, 85, 105, 0.08), inset 0 1px 2px rgba(71, 85, 105, 0.04);
    --ds-shadow-panel: -4px 0 24px rgba(71, 85, 105, 0.12);
    --ds-focus-ring: 0 0 0 3px rgba(79, 70, 229, 0.25);
    --ds-focus-ring-error: 0 0 0 3px var(--ds-error-subtle);
    --ds-focus-outline: 2px solid var(--ds-primary);
    --ds-focus-offset: 2px;

    /* ── Motion (everything collapses to ~0 under prefers-reduced-motion, see base.css) ─────────────────────────── */
    --ds-duration-fast: 120ms;
    --ds-duration-base: 200ms;
    --ds-duration-slow: 320ms;
    --ds-duration-reduced: 0.01ms;  /* what every duration shrinks to under prefers-reduced-motion */
    --ds-duration-spin: 800ms;      /* one turn of a spinner */
    --ds-duration-shimmer: 1400ms;  /* skeleton shimmer sweep */
    --ds-duration-loading: 2200ms;  /* branded logo fill, hold and drain */
    --ds-duration-popup: 400ms;
    --ds-ease: cubic-bezier(0.25, 0.1, 0.25, 1);
    --ds-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ds-ease-popup: cubic-bezier(0.4, 0, 0.2, 1);
    --icon-popup-motion-duration: var(--ds-duration-popup);
    --icon-popup-motion: var(--ds-duration-popup) var(--ds-ease-popup);
    --ds-transition-fast: var(--ds-duration-fast) var(--ds-ease);
    --ds-transition-base: var(--ds-duration-base) var(--ds-ease);
    --ds-transition-slow: var(--ds-duration-slow) var(--ds-ease);

    /* ── Layering ───────────────────────────────────────────────────────────────────────────────────────────── */
    --ds-z-base: 0;
    --ds-z-dropdown: 100;
    --ds-z-sticky: 200;
    --ds-z-overlay: 900;
    --ds-z-modal: 1000;
    --ds-z-toast: 1100;
    --ds-z-skip-link: 10000;

    /* ── Breakpoints ────────────────────────────────────────────────────────────────────────────────────────────
       CSS cannot read custom properties inside @media, so these are the documented values to type in a query.
       New CSS uses only these: mobile (max-width: 600px) · tablet (max-width: 900px) · wide (min-width: 1280px).
       Older stylesheets still contain other widths (480, 640, 700, 768, 1024 ...); scripts/check-design-system.php
       lets that number shrink but never grow, and keeps the design-system files strictly on this scale. */
    --ds-bp-mobile: 600px;
    --ds-bp-tablet: 900px;
    --ds-bp-wide: 1280px;
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --ds-primary: #a5b4fc;
    --ds-primary-hover: #c7d2fe;
    --ds-primary-solid: #4f46e5;
    --ds-primary-solid-hover: #4338ca;
    --ds-primary-solid-active: #3730a3;
    --ds-primary-ink: #c7d2fe;
    --ds-primary-soft: rgba(165, 180, 252, 0.10);
    --ds-primary-soft-border: rgba(165, 180, 252, 0.35);
    --ds-primary-subtle: rgba(165, 180, 252, 0.10);
    --ds-primary-tint: rgba(165, 180, 252, 0.18);
    --ds-primary-accent: #818cf8;

    --ds-background: #0f172a;
    --ds-background-subtle: #0b1120;
    --ds-background-muted: #1e293b;
    --ds-surface: #111827;
    --ds-surface-hover: rgba(148, 163, 184, 0.10);
    --ds-text: #f8fafc;
    --ds-display-ink: #e0e7ff;
    --ds-muted: #cbd5e1;
    --ds-subtle: #94a3b8;
    --ds-border: #334155;
    --ds-border-control: #64748b;
    --ds-border-subtle: rgba(148, 163, 184, 0.20);
    --ds-border-strong: rgba(148, 163, 184, 0.34);
    --ds-overlay: rgba(2, 6, 23, 0.72);

    --ds-success: #34d399;
    --ds-success-strong: #6ee7b7;
    --ds-success-subtle: rgba(52, 211, 153, 0.15);
    --ds-warning: #fbbf24;
    --ds-warning-strong: #fcd34d;
    --ds-warning-subtle: rgba(251, 191, 36, 0.16);
    --ds-error: #fb7185;
    --ds-error-strong: #fda4af;
    --ds-error-subtle: rgba(251, 113, 133, 0.16);
    --ds-info: #93c5fd;
    --ds-info-strong: #bfdbfe;
    --ds-info-subtle: rgba(147, 197, 253, 0.16);
    --ds-assistant-blue: #38bdf8;
    --ds-assistant-cyan: #67e8f9;
    --ds-assistant-violet: #8b7cf6;
    --ds-on-status: #0f172a;

    --ds-gray-50: #111827;
    --ds-gray-100: #172033;
    --ds-gray-200: #1e293b;
    --ds-gray-300: #334155;
    --ds-gray-400: #94a3b8;
    --ds-gray-500: #cbd5e1;
    --ds-gray-600: #cbd5e1;
    --ds-gray-700: #e2e8f0;
    --ds-gray-800: #f1f5f9;
    --ds-gray-900: #f8fafc;

    --ds-shadow-xs: 0 1px 3px rgba(2, 6, 23, 0.30);
    --ds-shadow-sm: 0 4px 12px rgba(2, 6, 23, 0.34);
    --ds-shadow-md: 0 8px 24px rgba(2, 6, 23, 0.40);
    --ds-shadow-lg: 0 16px 40px rgba(2, 6, 23, 0.48);
    --ds-shadow-xl: 0 20px 52px rgba(2, 6, 23, 0.52);
    --ds-shadow-dropdown: 0 18px 44px rgba(2, 6, 23, 0.56);
    --ds-shadow-input: inset 0 0 0 1px rgba(148, 163, 184, 0.10);
    --ds-shadow-panel: -4px 0 24px rgba(2, 6, 23, 0.40);
    --ds-focus-ring: 0 0 0 3px rgba(165, 180, 252, 0.30);
}
