/* =====================================================================
   Browns Digital — Design Tokens (CSS Custom Properties)
   Shared across all surfaces: Studio, Staff, Help, Marketing
===================================================================== */

:root {
  /* ---- Font ---- */
  --font-sans: "BD Sans", ui-sans-serif, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "BD Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* ---- Type Scale ---- */
  --text-2xs: 11px; --lh-2xs: 16px;
  --text-xs: 12px; --lh-xs: 16px;
  --text-sm: 13px; --lh-sm: 20px;   /* app base */
  --text-md: 14px; --lh-md: 20px;
  --text-base: 16px; --lh-base: 24px; /* marketing base */
  --text-lg: 20px; --lh-lg: 28px;
  --text-xl: 24px; --lh-xl: 32px;
  --text-2xl: 32px; --lh-2xl: 38px;
  --text-3xl: 40px; --lh-3xl: 44px;
  --text-4xl: 48px; --lh-4xl: 52px;
  --text-5xl: 60px; --lh-5xl: 64px;
  --text-6xl: 72px; --lh-6xl: 76px;

  /* ---- Font Weights (ONLY these three) ---- */
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;

  /* ---- Letter Spacing ---- */
  --tracking-tight: -0.025em;   /* headings >= 20px */
  --tracking-tighter: -0.035em; /* display >= 48px */

  /* ---- Spacing (4pt grid) ---- */
  --space-0: 0;
  --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;
  --space-16: 64px;
  --space-20: 80px;
  --space-28: 112px;
  --space-32: 128px;

  /* ---- Border Radius ---- */
  --radius-xs: 6px;     /* kbd, badges, tags */
  --radius-sm: 7px;     /* buttons, inputs, nav items, chips, segmented controls */
  --radius-md: 12px;    /* cards, menus, popovers, search field, nav pill, toolbar */
  --radius-lg: 20px;    /* app content panel, stat cards, large sections */
  --radius-full: 9999px;/* avatars, status dots, toggles ONLY */

  /* ---- Motion: Easings ---- */
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);   /* hovers/colour */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);  /* reveals, menus, accordions, nav morph */
  --ease-shell: cubic-bezier(0.22, 1, 0.36, 1);    /* layout: sidebar collapse, panel resize */
  --ease-exit: cubic-bezier(0.4, 0, 1, 1);         /* dismiss */

  /* ---- Motion: Durations ---- */
  --dur-instant: 100ms;
  --dur-fast: 150ms;
  --dur-base: 200ms;
  --dur-layout: 280ms;
  --dur-reveal: 400ms;
  --dur-shell: 500ms;

  /* ---- Z-index Layers ---- */
  --z-header: 50;
  --z-dropdown: 60;
  --z-nav: 70;
  --z-overlay: 80;
  --z-modal: 90;
  --z-toast: 100;

  /* ---- Layout ---- */
  --sidebar-w: 256px;
  --sidebar-w-collapsed: 64px;
  --header-h: 48px;
  --shell-inset: 8px;
  --container-marketing: 1152px;
  --container-nav: 896px;
  --container-prose: 672px;
  --container-app-form: 720px;
  --gutter: clamp(16px, 4vw, 32px);
  --section-y: clamp(80px, 10vw, 128px);

  /* ---- Brand (Browns Digital blue) ---- */
  --brand: #355cff;
  --brand-hover: #4a6fff;
  --brand-pressed: #2a4ae0;
  --brand-contrast: #ffffff;
  --brand-soft: rgba(53, 92, 255, 0.12);
  --ring: rgba(53, 92, 255, 0.55);
}

/* ========================================================================
   LIGHT THEME (default for marketing/help; optional in apps)
======================================================================== */
:root,
:root[data-theme="light"],
.theme-light {
  color-scheme: light;

  /* Backgrounds */
  --bg: #fafafa;             /* page */
  --bg-app: #f5f5f5;         /* app body behind panels */
  --surface: #ffffff;        /* content panel, cards */
  --surface-2: #ffffff;      /* stat cards, header controls */
  --surface-raised: #ffffff; /* menus, popovers, toolbar, modal */

  /* Fills */
  --fill: #f5f5f5;           /* secondary buttons, hover rows, inputs */
  --fill-hover: #ebebeb;     /* active nav item, pressed */
  --fill-strong: #e5e5e5;    /* selected chip */

  /* Borders */
  --border: #e5e5e5;         /* default 1px border */
  --border-strong: #d4d4d4;  /* controls */
  --border-card: #e5e5e5;    /* stat card outline */

  /* Text */
  --text: #111111;           /* primary text */
  --text-strong: #0a0a0a;    /* headings */
  --text-muted: #525252;     /* secondary */
  --text-subtle: #737373;    /* tertiary, placeholders */
  --text-label: rgba(82, 82, 82, 0.7); /* sidebar section labels */

  /* Semantic Colors */
  --success: #16a34a;
  --success-text: #15803d;
  --success-soft: rgba(22, 163, 74, 0.1);
  --warning: #d97706;
  --warning-text: #b45309;
  --warning-soft: rgba(217, 119, 6, 0.1);
  --danger: #dc2626;
  --danger-text: #b91c1c;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --info: var(--brand);

  /* Overlays & Effects */
  --overlay: rgba(0, 0, 0, 0.4);
  --shadow-float: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.06);

  /* Glass (for floating layers only) */
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(0, 0, 0, 0.08);
  --glass-blur: blur(12px);
}

/* ========================================================================
   DARK THEME (opt-in only via explicit user choice)
   Meridian-inspired: neutral greys, no blue tint
======================================================================== */
:root[data-theme="dark"],
.theme-dark {
  color-scheme: dark;

  /* Backgrounds */
  --bg: #0a0a0a;             /* page */
  --bg-app: #111111;         /* app body behind panels */
  --surface: #0f0f0f;        /* content panel, cards */
  --surface-2: #121212;      /* stat cards, header controls */
  --surface-raised: #1a1a1a; /* menus, popovers, toolbar, modal */

  /* Fills */
  --fill: #1f1f1f;           /* secondary buttons, hover rows, inputs */
  --fill-hover: #2a2a2a;     /* active nav item, pressed */
  --fill-strong: #393939;    /* selected chip */

  /* Borders */
  --border: #2e2e2e;         /* default 1px border */
  --border-strong: #3d3d3d;  /* controls */
  --border-card: #454545;    /* stat card outline (Meridian uses #515151) */

  /* Text */
  --text: #f5f5f5;           /* primary text */
  --text-strong: #ffffff;    /* headings */
  --text-muted: #a3a3a3;     /* secondary */
  --text-subtle: #737373;    /* tertiary, placeholders */
  --text-label: rgba(163, 163, 163, 0.55); /* sidebar section labels */

  /* Semantic Colors */
  --success: #22c55e;
  --success-text: rgba(167, 243, 208, 0.95);
  --success-soft: rgba(34, 197, 94, 0.1);
  --warning: #f59e0b;
  --warning-text: rgba(254, 243, 199, 0.95);
  --warning-soft: rgba(245, 158, 11, 0.1);
  --danger: #ef4444;
  --danger-text: rgba(254, 202, 202, 0.95);
  --danger-soft: rgba(239, 68, 68, 0.1);
  --info: var(--brand);

  /* Overlays & Effects */
  --overlay: rgba(0, 0, 0, 0.6);
  --shadow-float: 0 10px 15px -3px rgba(0, 0, 0, 0.35), 0 4px 6px -4px rgba(0, 0, 0, 0.35);

  /* Glass (for floating layers only) */
  --glass-bg: rgba(28, 28, 28, 0.9);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-blur: blur(12px);
}

/* ========================================================================
   Reduced Motion
======================================================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ========================================================================
   Base Styles
======================================================================== */
html {
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  background: var(--bg);
  color: var(--text);
}

body.app {
  font-size: var(--text-sm);
  line-height: var(--lh-sm);
  background: var(--bg-app);
}

body.site {
  font-size: var(--text-base);
  line-height: var(--lh-base);
}

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  color: var(--text-strong);
}

.num {
  font-variant-numeric: tabular-nums;
}

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: inherit;
}

::selection {
  background: var(--brand-soft);
}
