/* TradeTally shared foundations: fonts, colour tokens, controls.
   Design 2A tokens: near-black text (#191919), warm off-white bg (#F7F5F0),
   white surface (#FFFFFF), workwear yellow CTA (#FFC83D), secondary text (#66645F),
   subtle borders (#DEDBD4). */

/* Design 2A Fonts */
@font-face {
  font-family: "Barlow Condensed";
  src: url("/fonts/barlow-condensed-600.woff2?v=215a93c6") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("/fonts/barlow-condensed-700.woff2?v=3787a5a4") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Condensed";
  src: url("/fonts/barlow-condensed-800.woff2?v=2515494e") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Sans 3";
  src: url("/fonts/source-sans-3-var.woff2?v=19143dca") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

/* Fallback/Legacy fonts */
@font-face { font-family: "Archivo"; src: url("/fonts/archivo-var.woff2?v=8f704806") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/fonts/plex-400.woff2?v=3b646991") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/fonts/plex-500.woff2?v=0717336f") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/fonts/plex-600.woff2?v=8960851d") format("woff2"); font-weight: 600 700; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/fonts/plex-mono-500.woff2?v=756026ff") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  /* Design 2A Tokens */
  --text: #191919;
  --bg: #F7F5F0;
  --surface: #FFFFFF;
  --cta: #FFC83D;
  --cta-hover: #EBB22A;
  --secondary: #66645F;
  --border: #DEDBD4;
  --border-subtle: #EBE8E1;

  /* Aliases / mappings for app compatibility */
  --ink: #191919;
  --ink-2: #66645F;
  --ink-3: #8C887E;
  --surface-2: #F0EDE5;
  --line: #DEDBD4;
  --line-2: #EBE8E1;
  --brand: #FFC83D;
  --brand-ink: #191919;
  --brand-soft: #FFF3D1;
  --primary: #191919;
  --primary-ink: #FFFFFF;
  --primary-hover: #333333;

  /* Status colours */
  --green: #1D7A4B;
  --green-soft: #E2F1E8;
  --amber: #8A5A00;
  --amber-soft: #FBEFD2;
  --red: #B3261E;
  --red-soft: #F8E2E0;
  --blue: #2B5BA8;
  --blue-soft: #E4ECF8;

  /* Spacing Scale (4px / 8px baseline) */
  --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-24: 96px;
  --space-32: 128px;

  /* Container Widths */
  --container-max: 1376px;
  --container-wide: 1200px;
  --container-narrow: 960px;
  --container-text: 720px;
  --gutter: max(24px, calc((100% - var(--container-max)) / 2));

  /* Focus & Indicators */
  --focus-ring-color: #191919;
  --focus-ring-width: 3px;
  --focus-ring-offset: 2px;
  --focus-ring: 0 0 0 var(--focus-ring-width) var(--focus-ring-color);

  --radius-sm: 2px;
  --radius: 4px;
  --radius-lg: 8px;
  --shadow-sm: 0 1px 2px rgba(25, 25, 25, .05);
  --shadow: 0 1px 0 rgba(25, 25, 25, .04), 0 2px 8px rgba(25, 25, 25, .06);
  --shadow-lg: 0 12px 32px rgba(25, 25, 25, .14);

  --font-display: "Barlow Condensed", "Archivo", "Arial Narrow", sans-serif;
  --font-body: "Source Sans 3", "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --logo-ink: #191919;
  --logo-ruler: #66645F;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --text: #ECEDEE;
    --bg: #111315;
    --surface: #1A1D20;
    --surface-2: #202327;
    --cta: #FFC83D;
    --cta-hover: #F2B500;
    --secondary: #B9BDC2;
    --border: #2E3236;
    --border-subtle: #25292D;

    --ink: #ECEDEE;
    --ink-2: #B9BDC2;
    --ink-3: #8A8F95;
    --line: #2E3236;
    --line-2: #25292D;
    --brand: #FFC83D;
    --brand-ink: #111315;
    --brand-soft: #3A3112;
    --primary: #ECEDEE;
    --primary-ink: #111315;
    --primary-hover: #FFFFFF;

    --green: #5BC48E;
    --green-soft: #173325;
    --amber: #E8B24D;
    --amber-soft: #3A2E14;
    --red: #F07A70;
    --red-soft: #3D1C1A;
    --blue: #8DB0EC;
    --blue-soft: #1C2A40;
    --shadow: 0 1px 0 rgba(0,0,0,.3);
    --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
    --focus-ring-color: #FFC83D;
    --logo-ink: #ECE9E2;
    --logo-ruler: #9DA9B8;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --text: #ECEDEE;
  --bg: #111315;
  --surface: #1A1D20;
  --surface-2: #202327;
  --cta: #FFC83D;
  --cta-hover: #F2B500;
  --secondary: #B9BDC2;
  --border: #2E3236;
  --border-subtle: #25292D;

  --ink: #ECEDEE;
  --ink-2: #B9BDC2;
  --ink-3: #8A8F95;
  --line: #2E3236;
  --line-2: #25292D;
  --brand: #FFC83D;
  --brand-ink: #111315;
  --brand-soft: #3A3112;
  --primary: #ECEDEE;
  --primary-ink: #111315;
  --primary-hover: #FFFFFF;

  --green: #5BC48E;
  --green-soft: #173325;
  --amber: #E8B24D;
  --amber-soft: #3A2E14;
  --red: #F07A70;
  --red-soft: #3D1C1A;
  --blue: #8DB0EC;
  --blue-soft: #1C2A40;
  --shadow: 0 1px 0 rgba(0,0,0,.3);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
  --focus-ring-color: #FFC83D;
  --logo-ink: #ECE9E2;
  --logo-ruler: #9DA9B8;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.55 var(--font-body); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.1; margin: 0; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
a { color: inherit; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; max-width: 100%; }
:focus-visible { outline: 3px solid var(--focus-ring-color, var(--cta)); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--primary); color: var(--primary-ink); padding: 8px 14px; border-radius: var(--radius); font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 10px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--ink-3); }
.pos { color: var(--green); }
.neg { color: var(--red); }

/* Logo: the TradeTally ruler-and-arrow mark (sprite in /img/logo.svg), coloured by --logo-ink / --logo-ruler */
.logo { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; letter-spacing: -.02em; }
.logo__mark { width: 34px; height: 34px; flex: none; stroke: none; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; font-size: .92rem; line-height: 1.2; text-decoration: none; white-space: nowrap; transition: background-color .12s, border-color .12s; }
.btn:hover { border-color: var(--ink-3); }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.btn--primary, .btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn--primary:hover, .btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--yellow, .btn--cta, .btn-cta { background: var(--cta); border-color: var(--cta); color: #191919; font-weight: 700; }
.btn--yellow:hover, .btn--cta:hover, .btn-cta:hover { background: var(--cta-hover); border-color: var(--cta-hover); }
.btn--secondary, .btn-secondary, .btn--outline { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn--secondary:hover, .btn-secondary:hover, .btn--outline:hover { background: var(--surface); border-color: var(--ink); }
.btn--link, .btn-link, .text-link { background: transparent; border: none; padding: 0; color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.btn--link:hover, .btn-link:hover, .text-link:hover { color: var(--ink-2); }
.btn--brand { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn--brand:hover { background: var(--cta-hover); border-color: var(--cta-hover); }
.btn--ok { background: var(--green); border-color: var(--green); color: #fff; }
.btn--danger { color: var(--red); }
.btn--ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn--sm { padding: 6px 10px; font-size: .82rem; }
.btn--lg { padding: 13px 22px; font-size: 1rem; }
.btn--block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

/* Form fields */
.field { display: grid; gap: 5px; align-content: start; font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.field small { font-weight: 400; color: var(--ink-3); }
.input, .field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea {
  width: 100%; min-width: 0; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); font-size: .95rem; font-weight: 400;
}
.field textarea { min-height: 80px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--brand-soft); }
.field input:disabled, .field select:disabled, .input:disabled { background: var(--surface-2); color: var(--ink-2); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; font-weight: 500; color: var(--ink); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--ink); flex: none; }
.check small { display: block; font-weight: 400; color: var(--ink-3); }

/* Status tags: square-ish, not pills */
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px; border-radius: 4px; font-size: .74rem; font-weight: 600; white-space: nowrap; background: var(--line-2); color: var(--ink-2); }
.tag--green { background: var(--green-soft); color: var(--green); }
.tag--amber { background: var(--amber-soft); color: var(--amber); }
.tag--red { background: var(--red-soft); color: var(--red); }
.tag--blue { background: var(--blue-soft); color: var(--blue); }
.tag--brand { background: var(--brand); color: var(--brand-ink); }

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

/* Cookie banner (consent.js), shown on the site and in the app */
.site-cookie-settings { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; }
.cookie-banner { position: fixed; inset: auto 0 0; z-index: 70; background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -6px 24px rgba(0, 0, 0, .08); }
.cookie-banner__inner { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; box-sizing: border-box; max-width: 1200px; margin-inline: auto; padding: 16px 24px; }
.cookie-banner__text { flex: 1 1 320px; margin: 0; font-size: .95rem; line-height: 1.4; color: var(--ink-2); }
.cookie-banner__text strong { display: block; color: var(--ink); }
.cookie-banner__text a { color: var(--ink); }
.cookie-banner__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cookie-banner__btn { min-height: 44px; padding: 8px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.cookie-banner__btn:hover { background: var(--surface-2); }
.cookie-banner__btn--primary { border-color: var(--primary); background: var(--primary); color: var(--primary-ink); }
.cookie-banner__btn--primary:hover { background: var(--primary-hover); }
@media (max-width: 480px) { .cookie-banner__actions { width: 100%; flex-wrap: nowrap; } .cookie-banner__btn { flex: 1; white-space: nowrap; } }
