/* ============================================================================
   Aurenza — Design Tokens (single source of truth for landing + console)
   Load this FIRST in both contexts. All surfaces, type, motion, spacing here.
   ============================================================================ */

:root {
  /* ===== Color: Light (default) ===== */
  --paper: #faf5ea;
  --paper-2: #f3ede2;
  --paper-3: #e8e0d1;
  --ink: #14120e;
  --ink-2: #2a2822;
  --muted: #6b655a;
  --faint: #9b9486;
  --cream: #fdfbf6;
  --card: #ffffff;
  --rule: #e5ddd0;
  --rule-2: #ddd5c4;

  /* Semantic accents (single accent family) */
  --accent: #0a7a34;       /* primary green - trust, growth, freshness (darker for contrast) */
  --accent-2: #0f9d46;     /* hover/active */
  --accent-3: #085e28;     /* pressed */
  --accent-soft: rgba(15, 157, 70, 0.1);
  --accent-line: rgba(15, 157, 70, 0.3);
  --warn: #d4a01e;         /* amber for cautions */
  --warn-soft: rgba(212, 160, 30, 0.12);
  --warn-line: rgba(212, 160, 30, 0.35);
  --bad: #d94a4a;          /* red for errors/losses */
  --bad-soft: rgba(217, 74, 74, 0.12);
  --bad-line: rgba(217, 74, 74, 0.35);
  --base: #5a7f9e;         /* neutral blue for baseline */

  /* ===== Color: Dark (media query + class override) ===== */
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --paper: #0e131c;
      --paper-2: #121926;
      --paper-3: #17202e;
      --ink: #e9eef6;
      --ink-2: #cdd9e8;
      --muted: #9bacc2;
      --faint: #6d7f95;
      --cream: #fdfbf6;
      --card: #121926;
      --rule: #1d2735;
      --rule-2: #283444;
      --accent: #2fbf7f;
      --accent-2: #5ee0a8;
      --accent-3: #1ea05f;
      --accent-soft: rgba(47, 191, 127, 0.12);
      --accent-line: rgba(47, 191, 127, 0.38);
      --warn: #e2a53a;
      --warn-soft: rgba(226, 165, 58, 0.12);
      --warn-line: rgba(226, 165, 58, 0.32);
      --bad: #e5717a;
      --bad-soft: rgba(229, 113, 122, 0.13);
      --bad-line: rgba(229, 113, 122, 0.4);
      --base: #8aa0b8;
    }
  }
  [data-theme="dark"] {
    --paper: #0e131c;
    --paper-2: #121926;
    --paper-3: #17202e;
    --ink: #e9eef6;
    --ink-2: #cdd9e8;
    --muted: #9bacc2;
    --faint: #6d7f95;
    --cream: #fdfbf6;
    --card: #121926;
    --rule: #1d2735;
    --rule-2: #283444;
    --accent: #2fbf7f;
    --accent-2: #5ee0a8;
    --accent-3: #1ea05f;
    --accent-soft: rgba(47, 191, 127, 0.12);
    --accent-line: rgba(47, 191, 127, 0.38);
    --warn: #e2a53a;
    --warn-soft: rgba(226, 165, 58, 0.12);
    --warn-line: rgba(226, 165, 58, 0.32);
    --bad: #e5717a;
    --bad-soft: rgba(217, 74, 74, 0.12);
    --bad-line: rgba(217, 74, 74, 0.4);
    --base: #8aa0b8;
  }
  [data-theme="light"] {
    --paper: #faf5ea;
    --paper-2: #f3ede2;
    --paper-3: #e8e0d1;
    --ink: #14120e;
    --ink-2: #2a2822;
    --muted: #6b655a;
    --faint: #9b9486;
    --cream: #fdfbf6;
    --card: #ffffff;
    --rule: #e5ddd0;
    --rule-2: #ddd5c4;
    --accent: #0f9d46;
    --accent-2: #2ec86e;
    --accent-3: #0a7a34;
    --accent-soft: rgba(15, 157, 70, 0.1);
    --accent-line: rgba(15, 157, 70, 0.3);
    --warn: #d4a01e;
    --warn-soft: rgba(212, 160, 30, 0.12);
    --warn-line: rgba(212, 160, 30, 0.35);
    --bad: #d94a4a;
    --bad-soft: rgba(217, 74, 74, 0.12);
    --bad-line: rgba(217, 74, 74, 0.35);
    --base: #5a7f9e;
  }

  /* ===== Typography ===== */
  /* Geist (display/sans) + Geist Mono - loaded via preconnect + font-face below */
  --display: "Geist Display", "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Type scale */
  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-lg: 17px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 30px;
  --text-4xl: 38px;
  --text-5xl: 48px;
  --text-6xl: 64px;

  --leading-tight: 1.05;
  --leading-snug: 1.2;
  --leading-normal: 1.55;
  --leading-relaxed: 1.7;

  /* Font variation settings for Geist Display */
  --display-opsz-lg: 90;
  --display-opsz-md: 60;
  --display-soft: 20;

  /* ===== Geometry ===== */
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 999px;

  --maxw: 1120px;
  --maxw-narrow: 720px;

  /* ===== Spacing ===== */
  --sp1: 4px;
  --sp2: 8px;
  --sp3: 12px;
  --sp4: 16px;
  --sp5: 24px;
  --sp6: 32px;
  --sp7: 48px;
  --sp8: 64px;
  --sp9: 96px;

  /* ===== Motion ===== */
  --dur-1: 120ms;
  --dur-2: 200ms;
  --dur-3: 350ms;
  --dur-4: 500ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);

  /* ===== Shadows ===== */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 8px -4px rgba(0, 0, 0, 0.08);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 12px 28px -12px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.08), 0 24px 48px -24px rgba(0, 0, 0, 0.16);

  /* Dark mode shadows (override in dark) */
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 8px -4px rgba(0, 0, 0, 0.5);
      --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 14px 34px -16px rgba(0, 0, 0, 0.65);
      --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.5), 0 24px 48px -24px rgba(0, 0, 0, 0.7);
    }
  }
  [data-theme="dark"] {
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 8px -4px rgba(0, 0, 0, 0.5);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 14px 34px -16px rgba(0, 0, 0, 0.65);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.5), 0 24px 48px -24px rgba(0, 0, 0, 0.7);
  }
  [data-theme="light"] {
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 8px -4px rgba(0, 0, 0, 0.08);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 12px 28px -12px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.08), 0 24px 48px -24px rgba(0, 0, 0, 0.16);
  }

  /* ===== Z-index scale ===== */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal: 300;
  --z-toast: 400;
  --z-tooltip: 500;
}

/* ===== Font faces (Geist + Geist Mono) — self-hosted via CDN fallback ===== */
@font-face {
  font-family: "Geist";
  font-weight: 100 900;
  font-display: swap;
  font-style: normal;
  src: url("https://cdn.jsdelivr.net/npm/geist@1.4.2/fonts/Geist/Geist-Variable.woff2") format("woff2-variations"),
       url("https://cdn.jsdelivr.net/npm/geist@1.4.2/fonts/Geist/Geist-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Geist Display";
  font-weight: 100 900;
  font-display: swap;
  font-style: normal;
  src: url("https://cdn.jsdelivr.net/npm/geist@1.4.2/fonts/GeistDisplay/GeistDisplay-Variable.woff2") format("woff2-variations"),
       url("https://cdn.jsdelivr.net/npm/geist@1.4.2/fonts/GeistDisplay/GeistDisplay-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Geist Mono";
  font-weight: 100 700;
  font-display: swap;
  font-style: normal;
  src: url("https://cdn.jsdelivr.net/npm/geist@1.4.2/fonts/GeistMono/GeistMono-Variable.woff2") format("woff2-variations"),
       url("https://cdn.jsdelivr.net/npm/geist@1.4.2/fonts/GeistMono/GeistMono-Regular.woff2") format("woff2");
}

/* ===== Global reset ===== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  line-height: var(--leading-tight);
  letter-spacing: -0.015em;
  font-family: var(--display);
  font-variation-settings: 'opsz' var(--display-opsz-lg), 'SOFT' var(--display-soft);
  font-weight: 650;
}

h1 { font-size: var(--text-5xl); }
h2 { font-size: var(--text-4xl); font-variation-settings: 'opsz' var(--display-opsz-md), 'SOFT' var(--display-soft); }
h3 { font-size: var(--text-2xl); }

p { margin: 0 0 var(--sp4); max-width: 70ch; }

a { color: var(--accent); text-decoration: none; transition: color var(--dur-1) var(--ease); }
a:hover { color: var(--accent-2); text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; border-radius: 2px; }

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
}

img { max-width: 100%; height: auto; display: block; }

/* ===== Focus visible ===== */
:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
  border-radius: 2px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 1000;
  background: var(--accent);
  color: var(--cream);
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 0 0 var(--r) 0;
  text-decoration: none;
}
.skip-link:focus { left: 0; }

/* ===== Selection ===== */
::selection { background: var(--accent-soft); color: var(--accent-3); }

/* ===== Scrollbar (subtle) ===== */
* { scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--rule-2); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ===== Reveal animation (CSS-driven, respects reduced-motion) ===== */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity var(--dur-4) var(--ease-out), transform var(--dur-4) var(--ease-out);
}
.reveal.is-in {
  opacity: 1;
  transform: none;
}

/* Stagger delays for grids */
.reveal-stagger-1 { transition-delay: 60ms; }
.reveal-stagger-2 { transition-delay: 120ms; }
.reveal-stagger-3 { transition-delay: 180ms; }
.reveal-stagger-4 { transition-delay: 240ms; }
.reveal-stagger-5 { transition-delay: 300ms; }
.reveal-stagger-6 { transition-delay: 360ms; }

/* ===== Shared button system ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp2);
  padding: 12px 20px;
  font-family: var(--sans);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.btn-primary {
  color: var(--cream);
  background: var(--accent);
  border-color: var(--accent);
}
.btn-primary:hover { color: var(--cream); background: var(--accent-2); border-color: var(--accent-2); }
.btn-primary:focus-visible { outline-color: var(--accent-2); }

.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--paper-2); }

.btn-lg { padding: 16px 28px; font-size: var(--text-base); }
.btn-sm { padding: 8px 14px; font-size: var(--text-xs); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ===== Card base ===== */
.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

/* ===== Form inputs ===== */
.input, select.input {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--sans);
  font-size: var(--text-base);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.input::placeholder { color: var(--faint); }
.input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input[aria-invalid="true"] { border-color: var(--bad); }

.label {
  display: block;
  font-family: var(--mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--sp2);
}

/* ===== Badge/Chip ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp1);
  padding: 4px 10px;
  font-family: var(--mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: var(--r-full);
  white-space: nowrap;
}
.badge-success { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line); }
.badge-warn { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-line); }
.badge-error { background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad-line); }
.badge-neutral { background: var(--paper-2); color: var(--muted); border: 1px solid var(--rule); }

/* ===== Table base ===== */
.table-wrap { overflow-x: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--rule); }
th { color: var(--faint); font-weight: 700; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
td { vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
tbody tr { transition: background var(--dur-1) var(--ease); }
tbody tr:hover { background: var(--paper-2); }
tbody tr:last-child td { border-bottom: 0; }

@media (max-width: 720px) {
  table.responsive thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr { border: 1px solid var(--rule); border-radius: var(--r); margin-bottom: var(--sp2); padding: var(--sp2); background: var(--card); }
  table.responsive td { display: flex; justify-content: space-between; gap: var(--sp3); border-bottom: 1px dashed var(--rule); padding: 8px 4px; white-space: normal; text-align: right; }
  table.responsive td:last-child { border-bottom: 0; }
  table.responsive td::before { content: attr(data-label); text-align: left; color: var(--faint); text-transform: uppercase; font-size: 10px; letter-spacing: 0.05em; font-weight: 700; flex: none; }
}