/*
 * trade-tokens.css - shared brand tokens for the Trade Websites family.
 * Source of truth for values: tokens.json (scripts/check-contrast.mjs fails if this file drifts from it).
 * Usage: <link rel="stylesheet" href="trade-tokens.css"> and <html data-site="tps|aialgo|mindset">.
 * No purple/violet anywhere (portfolio rule). Status: proposal, pending Owner Gates G3/G4.
 */

:root {
  /* typography: Inter, scale 14/16/20/24/32/48 */
  --font-sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 20px;
  --text-xl: 24px;
  --text-2xl: 32px;
  --text-3xl: 48px;
  --leading-body: 1.6;
  --leading-heading: 1.2;

  /* spacing: 8px scale (--space-half is the only sub-8 step) */
  --space-half: 4px;
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 48px;
  --space-8: 64px;

  /* radius */
  --radius-md: 12px;
  --radius-lg: 16px;

  /* focus ring: 2px, offset 2px */
  --focus-width: 2px;
  --focus-offset: 2px;

  /* semantic colours (P&L / state only, never decoration) */
  --positive: #22c55e;
  --negative: #ef4444;      /* fills, borders, icons */
  --negative-text: #f87171; /* text: #ef4444 fails 4.5:1 on some surfaces */
  --caution: #f59e0b;
}

html {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  background: var(--bg);
  color: var(--txt);
}
body { margin: 0; background: var(--bg); color: var(--txt); }
.tnum { font-variant-numeric: tabular-nums; }

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: var(--focus-width) solid var(--accent);
  outline-offset: var(--focus-offset);
}

/* ---------- thepayoutstrategy.com (surface = DESIGN.md --card, surface-2 = --card2) ---------- */
[data-site="tps"] {
  --bg: #060b14;
  --surface: #111d30;
  --surface-2: #162035;
  --border: #1e2d45;
  --txt: #f0f4f8;
  --txt-2: #8fa3bc;
  --muted: #7489a3;
  --accent: #10b981;
  --accent-text: #10b981;
  --on-accent: #000000;
}

/* ---------- aialgo.trading ---------- */
[data-site="aialgo"] {
  --bg: #0a0a0a;
  --surface: #171717;
  --surface-2: #262626;
  --border: #262626;
  --txt: #fafafa;
  --txt-2: #9ca3af;
  --muted: #9ca3af;
  --accent: #3b82f6;      /* fills, focus ring, chart series */
  --accent-text: #60a5fa; /* text/links: #3b82f6 is 4.11:1 on surface-2 */
  --on-accent: #000000;
}

/* ---------- tradingmindset.app ---------- */
[data-site="mindset"] {
  --bg: #111827;
  --surface: #1f2937;
  --surface-2: #1f2937;
  --border: #374151;
  --txt: #f9fafb;
  --txt-2: #d1d5db;
  --muted: #d1d5db;
  --accent: #14b8a6;
  --accent-text: #14b8a6;
  --on-accent: #000000;
}

/* Derived, theme-independent */
[data-site] {
  /* WCAG 1.4.11: form-control boundaries need 3:1; muted passes 4.5:1 on every surface */
  --control-border: var(--muted);
}

/* Shared primitives (kept minimal; sites extend) */
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  border: 0;
  border-radius: var(--radius-md);
  padding: var(--space-1) var(--space-3);
  font: 600 var(--text-base)/1.2 var(--font-sans);
  min-height: 44px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}
a { color: var(--accent-text); }
.text-muted { color: var(--muted); }
.pos { color: var(--positive); }
.neg { color: var(--negative-text); }
.caution { color: var(--caution); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/*
 * compliance-footer.css - styles for compliance-footer.html.
 * Requires trade-tokens.css and <html data-site="...">. Colours come only from tokens (no hex literals here).
 */
.compliance-footer {
  background: var(--bg);
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding: var(--space-4) var(--space-2);
  font-size: var(--text-sm);
  line-height: var(--leading-body);
}
.compliance-footer__inner { max-width: 1120px; margin: 0 auto; }
.compliance-footer__text { margin: 0; max-width: 70ch; }
.compliance-footer a { color: var(--accent-text); }

/*
 * Hypothetical-performance block (placeholder slot). Render it IMMEDIATELY ADJACENT to every
 * backtest / simulated / projected figure, not only in the footer (menu M8: a footer alone fails
 * the proximity standard). Wording is NOT supplied here: counsel (G4) must confirm.
 */
.compliance-hypothetical {
  margin: var(--space-1) 0 0;
  padding: var(--space-1) var(--space-2);
  border-left: 3px solid var(--caution);
  background: var(--surface);
  color: var(--txt-2);
  font-size: var(--text-sm);
  line-height: var(--leading-body);
}
.compliance-hypothetical[hidden] { display: none; }

/*
 * site.css - aialgo.trading page styles. Colours ONLY via trade-tokens.css variables
 * (scripts/wave1a/check-hex.mjs fails on any colour literal here).
 * Direction: dark, data-dense research tool; single blue accent; tabular numerals; no urgency patterns.
 */
* { box-sizing: border-box; }
body { min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: var(--space-4) var(--space-2) var(--space-6); }
h1, h2, h3 { line-height: var(--leading-heading); color: var(--txt); margin: var(--space-4) 0 var(--space-2); }
h1 { font-size: var(--text-2xl); margin-top: 0; }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
p, li { max-width: 72ch; }
code, pre, kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: var(--text-sm); }
pre { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-2); overflow-x: auto; }

.site-header { border-bottom: 1px solid var(--border); background: var(--bg); }
.site-header__inner { max-width: 1120px; margin: 0 auto; padding: var(--space-2); display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-3); align-items: center; justify-content: space-between; }
.brand { font-weight: 700; color: var(--txt); text-decoration: none; letter-spacing: 0.01em; }
.site-nav { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.site-nav a { color: var(--txt-2); text-decoration: none; font-size: var(--text-sm); padding: var(--space-half) 0; }
.site-nav a[aria-current="page"], .site-nav a:hover { color: var(--accent-text); }

.lede { color: var(--txt-2); font-size: var(--text-lg); margin: 0 0 var(--space-3); }
.kicker { color: var(--muted); font-size: var(--text-sm); text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 var(--space-1); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--space-2); margin: var(--space-3) 0; }
.card h3 { margin-top: 0; }
.card p { color: var(--txt-2); margin: 0 0 var(--space-2); }
.stance { border-left: 3px solid var(--accent); padding: var(--space-1) var(--space-2); background: var(--surface); color: var(--txt-2); }
.muted { color: var(--muted); font-size: var(--text-sm); }

table { border-collapse: collapse; width: 100%; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: var(--space-1) var(--space-2); border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--txt-2); font-weight: 600; }
td.num, th.num { text-align: right; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }

form.stack { display: grid; gap: var(--space-2); max-width: 520px; }
label { display: grid; gap: var(--space-half); font-size: var(--text-sm); color: var(--txt-2); }
input, select, textarea { font: inherit; color: var(--txt); background: var(--surface-2); border: 1px solid var(--control-border); border-radius: var(--radius-md); padding: var(--space-1) var(--space-2); min-height: 44px; }
textarea { min-height: 160px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: var(--text-sm); }
.check { display: flex; gap: var(--space-1); align-items: flex-start; }
.check input { min-height: auto; margin-top: var(--space-half); }
.btn-primary { cursor: pointer; }
.btn-primary:disabled { opacity: 0.6; cursor: progress; }
.form-status { min-height: 1.6em; font-size: var(--text-sm); color: var(--txt-2); }
.form-status[data-state="error"] { color: var(--negative-text); }
.form-status[data-state="ok"] { color: var(--positive); }

.tool { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: var(--space-3); align-items: start; }
@media (max-width: 860px) { .tool { grid-template-columns: 1fr; } }
.params { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-1); margin: var(--space-2) 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-1) var(--space-2); }
.stat dt { color: var(--muted); font-size: var(--text-sm); }
.stat dd { margin: 0; font-size: var(--text-lg); font-variant-numeric: tabular-nums; }
.chart { width: 100%; height: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }
.chart .series { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .baseline { stroke: var(--border); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 12px; }
figure.perf, section.perf { margin: var(--space-3) 0; }

.article-meta { color: var(--muted); font-size: var(--text-sm); }
.article-list { list-style: none; padding: 0; display: grid; gap: var(--space-2); }
.article-list li { max-width: none; }
.compliance-footer__stance { margin: 0 0 var(--space-1); max-width: 70ch; color: var(--txt-2); }
