/**
 * Platform foundation — single source for design tokens and typography.
 * --------------------------------------------------------------
 * Loaded by components/_platform_foundation.html on every interactive page
 * (staff portal, client portal, applications, sign-in flows, public site),
 * so every stylesheet and page <style> block can rely on these tokens.
 *
 * Rules for page and component CSS:
 * - Colours: use the tokens below; never hard-code a hex value that has one.
 * - Corners: var(--lm-radius-sm | -md | -pill). 0 and 50% (circles) are fine.
 * - Elevation: var(--lm-shadow-sm | -md | -lg). Focus rings and inset
 *   shadows stay literal because they carry state, not elevation.
 * - Type: var(--lm-font-sans) / var(--lm-font-mono); weights 400/500/600.
 * Print, PDF and legal documents (contracts, quotation packs, credit report
 * letters, deal sheets) deliberately keep their own embedded styles: PDF
 * renderers cannot fetch web fonts and signed documents must not change.
 * The size scale (--lm-text-*) and shared components live in
 * platform-components.css.
 */

:root {
  /* Brand — values come from the active brand's tokens.css
     (static/brands/<key>/tokens.css); this file holds no brand colours. */
  --navy: rgb(var(--brand-primary-rgb));
  --teal: rgb(var(--brand-accent-rgb));
  --turquoise: var(--brand-highlight);
  --brand-accent: rgb(var(--brand-accent-rgb));
  --silver: #F3F4F6;
  --white: #FFFFFF;

  /* Text and lines */
  --ink: rgba(var(--brand-ink-rgb), 0.92);
  /* 0.68 keeps secondary text above 5.5:1 contrast on white. */
  --muted: rgba(var(--brand-ink-rgb), 0.68);
  --border: rgba(15, 23, 42, 0.10);

  /* Status */
  --status-good: rgba(22, 163, 74, 0.95);
  --status-warn: rgba(180, 83, 9, 0.95);
  --status-danger: rgba(185, 28, 28, 0.95);
  --status-info: rgba(30, 64, 175, 0.95);

  /* Neutral scale (surfaces, borders, secondary text) */
  --lm-slate-50: #f8fafc;
  --lm-slate-100: #f1f5f9;
  --lm-slate-200: #e2e8f0;
  --lm-slate-300: #cbd5e1;
  --lm-slate-400: #94a3b8;
  --lm-slate-500: #64748b;
  --lm-slate-600: #475569;
  --lm-slate-700: #334155;
  --lm-slate-900: #0f172a;
  --lm-gray-900: #111827;
  --lm-ink-soft: #526575;
  --lm-ui-gray-500: #667085;
  --lm-ui-gray-700: #344054;

  /* Brand depth */
  --lm-teal-deep: rgb(var(--brand-accent-deep-rgb));
  --lm-teal-soft: var(--brand-accent-soft);
  --lm-navy-deep: var(--brand-primary-deep);

  /* Status scales (text on tint, fills) */
  --lm-green-50: #ecfdf5;
  --lm-green-600: #16a34a;
  --lm-green-700: #047857;
  --lm-green-800: #166534;
  --lm-amber-50: #fffbeb;
  --lm-amber-500: #f59e0b;
  --lm-amber-600: #d97706;
  --lm-amber-700: #b45309;
  --lm-amber-800: #92400e;
  --lm-red-600: #dc2626;
  --lm-red-700: #b91c1c;
  --lm-red-750: #b42318;
  --lm-red-800: #991b1b;

  /* Corners */
  --lm-radius-sm: 8px;
  --lm-radius-md: 12px;
  --lm-radius-pill: 999px;

  /* Elevation — ink-tinted, soft */
  --lm-shadow-sm: 0 1px 2px rgba(var(--brand-ink-rgb), 0.06), 0 1px 3px rgba(var(--brand-ink-rgb), 0.05);
  --lm-shadow-md: 0 4px 12px rgba(var(--brand-ink-rgb), 0.06), 0 12px 28px rgba(var(--brand-ink-rgb), 0.08);
  --lm-shadow-lg: 0 24px 56px rgba(var(--brand-ink-rgb), 0.18);

  /* Tick mark. Inter has no ✓ glyph, so text ticks fall back to a system
     symbol font; these SVGs match the icon stroke instead. */
  --lm-tick-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
  --lm-tick-on-fill: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");

  /* Typeface */
  --lm-font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --lm-font-mono: ui-monospace, "Cascadia Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* Inline tick in the current text colour: <span class="lm-tick" aria-hidden="true"></span> */
.lm-tick {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  background-color: currentColor;
  -webkit-mask: var(--lm-tick-mask) center / contain no-repeat;
  mask: var(--lm-tick-mask) center / contain no-repeat;
}

/*
 * Bootstrap re-declares its own font variables on :root. The extra type
 * selector keeps ours winning whatever order the stylesheets load in.
 */
html:root {
  --bs-font-sans-serif: var(--lm-font-sans);
  --bs-body-font-family: var(--lm-font-sans);
  --bs-font-monospace: var(--lm-font-mono);
}

html body {
  font-family: var(--lm-font-sans);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/*
 * Weight scale — three weights only:
 *   400 text · 500 labels/controls · 600 headings, key figures, emphasis.
 * Browser/Bootstrap defaults that would produce 700 are pulled to 600 here.
 * Do not use 700+ or 300 in platform CSS.
 */
html b,
html strong,
html th {
  font-weight: 600;
}

html .fw-bold,
html .fw-bolder {
  font-weight: 600 !important;
}

/* Form controls do not inherit the page font by default in every browser. */
:where(button, input, select, textarea, optgroup) {
  font-family: inherit;
}

/*
 * Figures: fixed-width digits so amounts, rates and dates line up in columns
 * and do not jitter when values change. Zero specificity (:where) so a
 * component can opt back into proportional figures if it needs to.
 */
:where(td, th, dd, time, output, input[type="number"]),
:where(.kpi-v, .kpi-value, .metric-v, .text-end, .tabular-nums, .amount, .money, .mono) {
  font-variant-numeric: tabular-nums;
}

/* Real code only. The platform's .mono class means "aligned figures", not a
   monospace face, so it stays in Inter (tabular digits above). */
:where(code, kbd, samp, pre, .font-monospace) {
  font-family: var(--lm-font-mono);
}
