/* tokens.css — one design system for moltrust.ch (ops INV-5, criterion 2)
 *
 * Status: in use from ops INV-5 (03.12.2026). Every page in scope links this
 * file before its own styles (scripts/inv5_design_rollout.py); a change here
 * needs a ?v bump on all linking pages (assets are cached as immutable).
 *
 * House colours: orange, grey, black, white; navy #0F172A for the logo and
 * code panels. No green, no amber, no red, no blue. Status colours are built
 * from orange, grey and navy only and always carry a text label or symbol, so
 * they never depend on colour alone.
 *
 * Base: the home page palette (ops INV-3 mockup, 24.11.2026; orange contrast
 * fixed in INV-6). Ground truth reused from INV-6:
 *   #E85D26 accent (fills, borders, large text) — 3.49:1 on white
 *   #BD4414 small orange text on white — 5.25:1
 *   #111111 text on orange fill — 5.42:1
 *   #F8A97D dark-mode text on tinted badges
 * Every text/background pair is listed with its ratio in
 * docs/evidence/inv5/contrast.md (generated from this file).
 *
 * Theme: dark mode is [data-theme="dark"] on <html>, set before first paint by
 * the THEME-INIT-V1 snippet from localStorage key "mt-theme" and toggled by
 * /assets/js/theme.js. This file holds no script.
 *
 * Naming: --mt-* only. The pages' old variables (--navy, --slate-*, --white,
 * --orange, --h-* ...) were replaced by these in the rollout; the mapping is
 * LEGACY in scripts/inv5_design_rollout.py.
 */

:root {
  /* surfaces */
  --mt-bg: #FFFFFF;            /* page */
  --mt-surface: #F6F6F5;       /* soft section, hero */
  --mt-surface-2: #EFEFED;     /* chips, table stripes, inline code */
  --mt-line: #E5E5E3;          /* hairlines, card borders */
  --mt-line-strong: #CFCFCC;   /* ghost buttons, dividers (decorative: the label identifies the control) */
  --mt-input-border: #888885;  /* form fields, checkboxes: 3:1 non-text contrast */

  /* text */
  --mt-text: #111111;          /* headings, body */
  --mt-text-2: #333333;        /* nav links, strong secondary */
  --mt-text-3: #444444;        /* lead and card copy */
  --mt-text-muted: #555555;    /* captions, labels, footer */
  --mt-on-text: #FFFFFF;       /* text on a --mt-text fill (selected tab, step dot) */

  /* orange */
  --mt-accent: #E85D26;        /* fills, borders, focus ring, large text only */
  --mt-accent-text: #BD4414;   /* small orange text and links on light surfaces */
  --mt-accent-strong: #9A3412; /* link hover, text on tint */
  --mt-accent-tint: #FEF0EA;   /* tinted badge / callout background */
  --mt-on-tint: #BD4414;       /* text on --mt-accent-tint */
  --mt-on-accent: #111111;     /* text on an orange fill */
  --mt-accent-hover: #F07A45;  /* hover of an orange fill (text stays --mt-on-accent) */

  /* navy and inverse */
  --mt-navy: #0F172A;          /* logo wordmark, success fill */
  --mt-band-bg: #111111;       /* dark bands/boxes in light mode (pricing "How credits work", developers .section-navy); navy stays for logo and code panels only */
  --mt-inverse-bg: #111111;    /* closing band, primary dark button */
  --mt-on-inverse: #FFFFFF;
  --mt-inverse-muted: #D4D4D2; /* secondary text on --mt-inverse-bg / --mt-navy */
  --mt-inverse-accent: #F4A27A;/* links on --mt-inverse-bg / --mt-navy */

  /* code panels: navy in both modes (assets/css/code-theme.css) */
  --mt-code-bg: #1E293B;
  --mt-code-fg: #E2E8F0;
  --mt-code-comment: #94A3B8;
  --mt-code-keyword: #F8A97D;  /* keys, keywords */
  --mt-code-string: #FDBA74;   /* strings */
  --mt-code-number: #FFFFFF;   /* numbers, literals (bold) */
  --mt-code-inline-bg: var(--mt-surface-2);
  --mt-code-inline-fg: var(--mt-accent-strong);

  /* status — orange / grey / navy only; always with a label */
  --mt-ok-bg: #0F172A;        --mt-ok-fg: #FFFFFF;     --mt-ok-text: #0F172A;   /* adherent, success, within */
  --mt-ok-tint: #E7E9EE;      --mt-ok-border: #0F172A;
  --mt-warn-bg: #FEF0EA;      --mt-warn-fg: #9A3412;   --mt-warn-text: #9A3412; /* review, warning, pending */
  --mt-warn-tint: #FEF0EA;    --mt-warn-border: #E85D26;
  --mt-bad-bg: #E85D26;       --mt-bad-fg: #111111;    --mt-bad-text: #BD4414;  /* breached, error, outside */
  --mt-bad-tint: #FEF0EA;     --mt-bad-border: #BD4414;
  --mt-info-bg: #EFEFED;      --mt-info-fg: #444444;   --mt-info-text: #444444; /* neutral, info, n/a */
  --mt-info-border: #CFCFCC;

  /* type */
  --mt-font-sans: 'DM Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mt-font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --mt-text-xs: 0.75rem;   /* 12px labels, badges */
  --mt-text-sm: 0.875rem;  /* 14px captions, footer */
  --mt-text-md: 1rem;      /* 16px body */
  --mt-text-lg: 1.125rem;  /* 18px lead */
  --mt-text-xl: 1.25rem;   /* 20px card title */
  --mt-text-2xl: clamp(1.75rem, 4.2vw, 2.25rem);  /* h2 */
  --mt-text-3xl: clamp(2.125rem, 6.4vw, 3.5rem);  /* h1 */
  --mt-leading: 1.55;
  --mt-leading-tight: 1.15;

  /* spacing (4px grid) */
  --mt-space-1: 4px;  --mt-space-2: 8px;  --mt-space-3: 12px; --mt-space-4: 16px;
  --mt-space-5: 24px; --mt-space-6: 32px; --mt-space-7: 48px; --mt-space-8: 64px;
  --mt-space-9: 80px;
  --mt-gutter: 24px;           /* page side padding; 16px under 640px */
  --mt-content: 1200px;        /* max content width */

  /* radii and shadows */
  --mt-radius-sm: 6px;  --mt-radius: 10px;  --mt-radius-lg: 14px;  --mt-radius-pill: 999px;
  --mt-shadow-sm: 0 1px 2px rgba(17, 17, 17, 0.05);
  --mt-shadow-md: 0 4px 16px rgba(17, 17, 17, 0.07);

  /* nav */
  --mt-nav-h: 60px;
  --mt-nav-bg: rgba(255, 255, 255, 0.92);
  --mt-focus: 3px solid var(--mt-accent);
}

/* Dark mode, and the inside of a dark band in either mode (.mt-inverse):
   the same values, so text and status colours inside a band read as in dark
   mode. The band background itself is --mt-band-bg, set outside this block. */
[data-theme="dark"],
.mt-inverse {
  --mt-bg: #141414;
  --mt-surface: #1C1C1C;
  --mt-surface-2: #262626;
  --mt-line: #2E2E2E;
  --mt-line-strong: #4A4A48;
  --mt-input-border: #737370;

  --mt-text: #F5F5F4;
  --mt-text-2: #E0E0DE;
  --mt-text-3: #CFCFCC;
  --mt-text-muted: #A8A8A5;
  --mt-on-text: #111111;

  --mt-accent: #E85D26;
  --mt-accent-text: #E85D26;   /* on --mt-bg / --mt-surface; large text only on --mt-surface-2 */
  --mt-accent-strong: #F8A97D;
  --mt-accent-tint: #3A2218;
  --mt-on-tint: #F8A97D;
  --mt-on-accent: #111111;

  --mt-navy: #0F172A;
  --mt-inverse-bg: #262626;
  --mt-on-inverse: #FFFFFF;
  --mt-inverse-muted: #D4D4D2;
  --mt-inverse-accent: #F4A27A;

  --mt-code-inline-bg: #262626;
  --mt-code-inline-fg: #F8A97D;

  --mt-ok-bg: #CBD5E1;        --mt-ok-fg: #0F172A;     --mt-ok-text: #CBD5E1;
  --mt-ok-tint: #1E2533;      --mt-ok-border: #CBD5E1;
  --mt-warn-bg: #3A2218;      --mt-warn-fg: #F8A97D;   --mt-warn-text: #F8A97D;
  --mt-warn-tint: #3A2218;    --mt-warn-border: #E85D26;
  --mt-bad-bg: #E85D26;       --mt-bad-fg: #111111;    --mt-bad-text: #F07A45;
  --mt-bad-tint: #3A2218;     --mt-bad-border: #E85D26;
  --mt-info-bg: #262626;      --mt-info-fg: #CFCFCC;   --mt-info-text: #CFCFCC;
  --mt-info-border: #4A4A48;

  --mt-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --mt-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --mt-nav-bg: rgba(20, 20, 20, 0.92);
  color-scheme: dark;
}

/* bands: near-black in light mode, neutral grey in dark mode */
[data-theme="dark"] { --mt-band-bg: #1C1C1C; }

@media (max-width: 640px) {
  :root { --mt-gutter: 16px; }
}

/* ── primitives ─────────────────────────────────────────────────────
   Opt-in classes. A page keeps its own class names; the rollout points their
   colours, radii and fonts at the tokens above. New markup uses these. */

.mt-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--mt-space-2);
  min-height: 48px; padding: 12px 24px; border-radius: var(--mt-radius);
  border: 1px solid transparent; font: 600 var(--mt-text-md)/1.2 var(--mt-font-sans);
  text-decoration: none; cursor: pointer;
}
.mt-btn:focus-visible { outline: var(--mt-focus); outline-offset: 2px; }
.mt-btn--primary { background: var(--mt-accent); color: var(--mt-on-accent); }
.mt-btn--primary:hover { box-shadow: inset 0 0 0 2px var(--mt-text); color: var(--mt-on-accent); }
.mt-btn--dark { background: var(--mt-inverse-bg); color: var(--mt-on-inverse); }
.mt-btn--dark:hover { background: var(--mt-text-2); color: var(--mt-on-inverse); }
.mt-btn--ghost { background: var(--mt-bg); color: var(--mt-text); border-color: var(--mt-line-strong); }
.mt-btn--ghost:hover { border-color: var(--mt-text); color: var(--mt-text); }
.mt-btn--sm { min-height: 36px; padding: 6px 14px; font-size: var(--mt-text-sm); border-radius: var(--mt-radius-sm); }

.mt-card {
  background: var(--mt-bg); border: 1px solid var(--mt-line); border-radius: var(--mt-radius-lg);
  padding: var(--mt-space-6); display: flex; flex-direction: column; gap: var(--mt-space-3);
}
.mt-card--soft { background: var(--mt-surface); border-color: transparent; }
a.mt-card { color: var(--mt-text); text-decoration: none; }
a.mt-card:hover { border-color: var(--mt-line-strong); }

.mt-label {  /* small uppercase section label */
  font: 600 var(--mt-text-xs)/1.3 var(--mt-font-mono); letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--mt-accent-text);
}

.mt-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border-radius: var(--mt-radius-pill); border: 1px solid transparent;
  font: 600 var(--mt-text-xs)/1.3 var(--mt-font-sans); letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--mt-info-bg); color: var(--mt-info-fg);
}
.mt-badge--ok   { background: var(--mt-ok-bg);   color: var(--mt-ok-fg); }
.mt-badge--warn { background: var(--mt-warn-bg); color: var(--mt-warn-fg); border-color: var(--mt-warn-border); border-style: dashed; }
.mt-badge--bad  { background: var(--mt-bad-bg);  color: var(--mt-bad-fg); }
.mt-badge--accent { background: var(--mt-accent-tint); color: var(--mt-on-tint); }
/* symbol before the label, so status never rests on colour alone */
.mt-badge--ok::before   { content: "\2713"; }
.mt-badge--warn::before { content: "\25CB"; }
.mt-badge--bad::before  { content: "\2715"; }

.mt-code {
  background: var(--mt-code-bg); color: var(--mt-code-fg); border-radius: var(--mt-radius);
  padding: var(--mt-space-4) var(--mt-space-5); font: 400 var(--mt-text-sm)/1.6 var(--mt-font-mono);
  overflow-x: auto;
}
:where(p, li, td) > code {
  font-family: var(--mt-font-mono); font-size: 0.85em; padding: 0.1em 0.4em;
  border-radius: 4px; background: var(--mt-code-inline-bg); color: var(--mt-code-inline-fg);
}

/* ── narrow-screen guards ───────────────────────────────────────────
   At 390px wide tables and long code lines pushed about, molcheck, pricing
   and developers wider than the screen (measured before INV-5). A wide
   table scrolls inside itself; long code wraps or scrolls in its panel. */
@media (max-width: 640px) {
  table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  pre { max-width: 100%; overflow-x: auto; }
  code { overflow-wrap: anywhere; }
  img, svg, video, iframe { max-width: 100%; }
}
