/* ============================================================
   CatchLead Design System — tokens (single source of truth)
   Served at /static/ds/tokens.css and loaded by every surface:
   landing + marketing pages, dashboard, admin. The chat widget
   (static/widget.js) mirrors these values inline because it runs
   inside customers' websites.

   Theme: [data-theme="dark|light"] on <html>, set before paint by
   /static/ds/theme.js. Without JS, the OS preference decides.
   ============================================================ */

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

  /* Surfaces */
  --bg: #0b0d12;
  --bg-alt: #0f1117;
  --surface: #14161d;
  --surface-raised: #1b1e27;
  --surface-hover: #20242f;

  /* Borders */
  --border: #262a35;
  --border-strong: #343947;

  /* Text */
  --text: #e7e9ee;
  --text-secondary: #9aa1b2;
  --text-muted: #6f7688;

  /* Brand */
  --accent: #6366f1;
  --accent-hover: #7477f0;
  --accent-text: #8b8ef5; /* accent used as text/links on dark surfaces */
  --accent-soft: rgba(99, 102, 241, 0.14);
  --accent-contrast: #ffffff;

  /* Status */
  --success: #34c98e;
  --success-soft: rgba(52, 201, 142, 0.14);
  --warning: #f5a623;
  --warning-soft: rgba(245, 166, 35, 0.14);
  --danger: #ef5350;
  --danger-soft: rgba(239, 83, 80, 0.14);
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, 0.14);

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.4);
  --overlay: rgba(4, 5, 8, 0.6);

  /* Glass: translucent panels over the ambient glow (see DESIGN.md) */
  --glass: rgba(22, 24, 33, 0.55);
  --glass-strong: rgba(22, 24, 33, 0.78);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.05);
  --ambient-1: color-mix(in srgb, var(--accent) 30%, transparent);
  --ambient-2: color-mix(in srgb, #8b5cf6 22%, transparent);
}

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

  --bg: #fafafa;
  --bg-alt: #f3f4f6;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-hover: #f2f3f5;

  --border: #e5e6eb;
  --border-strong: #d2d4dc;

  --text: #17181c;
  --text-secondary: #5c6270;
  --text-muted: #80869a;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-text: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.09);
  --accent-contrast: #ffffff;

  --success: #0e9f6e;
  --success-soft: rgba(14, 159, 110, 0.1);
  --warning: #c27803;
  --warning-soft: rgba(194, 120, 3, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.09);
  --info: #0284c7;
  --info-soft: rgba(2, 132, 199, 0.09);

  --shadow-sm: 0 1px 2px rgba(23, 24, 28, 0.06);
  --shadow-md: 0 4px 12px rgba(23, 24, 28, 0.08);
  --shadow-lg: 0 16px 40px rgba(23, 24, 28, 0.12);
  --overlay: rgba(23, 24, 28, 0.4);

  --glass: rgba(255, 255, 255, 0.6);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(255, 255, 255, 0.75);
  --glass-highlight: rgba(255, 255, 255, 0.6);
  --ambient-1: color-mix(in srgb, var(--accent) 22%, transparent);
  --ambient-2: color-mix(in srgb, #8b5cf6 18%, transparent);
}

/* No JS: follow the OS. theme.js sets data-theme, which wins. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #fafafa;
    --bg-alt: #f3f4f6;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --surface-hover: #f2f3f5;
    --border: #e5e6eb;
    --border-strong: #d2d4dc;
    --text: #17181c;
    --text-secondary: #5c6270;
    --text-muted: #80869a;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-text: #4f46e5;
    --accent-soft: rgba(79, 70, 229, 0.09);
    --success: #0e9f6e;
    --success-soft: rgba(14, 159, 110, 0.1);
    --warning: #c27803;
    --warning-soft: rgba(194, 120, 3, 0.1);
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.09);
    --info: #0284c7;
    --info-soft: rgba(2, 132, 199, 0.09);
    --shadow-sm: 0 1px 2px rgba(23, 24, 28, 0.06);
    --shadow-md: 0 4px 12px rgba(23, 24, 28, 0.08);
    --shadow-lg: 0 16px 40px rgba(23, 24, 28, 0.12);
    --overlay: rgba(23, 24, 28, 0.4);

  --glass: rgba(255, 255, 255, 0.6);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(255, 255, 255, 0.75);
  --glass-highlight: rgba(255, 255, 255, 0.6);
  --ambient-1: color-mix(in srgb, var(--accent) 22%, transparent);
  --ambient-2: color-mix(in srgb, #8b5cf6 18%, transparent);
  }
}

:root {
  /* Two-stop brand gradient: app icon / favicon artwork only. UI uses flat --accent. */
  --brand-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);

  /* Spacing (4px grid) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 48px;
  --space-10: 64px;
  --space-11: 96px;

  /* Radii */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 999px;

  /* Typography: Inter everywhere */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 15px;
  --text-lg: 18px;
  --text-xl: 22px;
  --text-2xl: 28px;
  --text-3xl: 36px;
  --text-display: clamp(36px, 5.5vw, 60px);
  --leading-tight: 1.15;
  --leading: 1.5;
  --tracking-tight: -0.02em;

  /* Icons (Lucide) */
  --icon-sm: 16px;
  --icon: 20px;
  --icon-lg: 24px;
  --icon-stroke: 1.75;

  /* Motion */
  --glass-blur: blur(18px) saturate(150%);
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --duration: 0.15s;
}

/* Lucide icons inherit the text color and one stroke weight everywhere.
   Icons given an explicit stroke-width attribute (e.g. the logo) keep it. */
svg.lucide {
  flex-shrink: 0;
}
svg.lucide[stroke-width="2"] {
  stroke-width: var(--icon-stroke);
}

/* Show an element in one theme only (e.g. the theme toggle's sun/moon). */
[data-theme="light"] .when-dark,
[data-theme="dark"] .when-light {
  display: none !important;
}

/* Glass panel: translucent, blurred, hairline border. Use on cards and bars
   that sit over the ambient background (body.cl-ambient). */
.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: inset 0 1px 0 var(--glass-highlight), var(--shadow-sm);
}

/* Ambient background that glass panels blur: two soft accent glows, fixed. */
.cl-ambient::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60vw 50vh at 10% 0%, var(--ambient-1), transparent 70%),
    radial-gradient(50vw 50vh at 95% 35%, var(--ambient-2), transparent 70%),
    radial-gradient(60vw 40vh at 40% 100%, var(--ambient-1), transparent 70%),
    var(--bg);
}

/* Faint grid over the ambient glow on public pages: add class "cl-grid" to <body>
   (with cl-ambient). Sits above the glow and below all content. */
.cl-grid::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(to right, var(--border) 1px, transparent 1px),
    linear-gradient(to bottom, var(--border) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse at top, black 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at top, black 20%, transparent 70%);
}
