/* ABA Easy shared tokens. Spec 6.2. Owned by FOUNDATION: change values here, nowhere else.
   Used by the app and by the restyled landing pages.

   Theme: follows the device (prefers-color-scheme). Force one with <html data-theme="light"> or "dark".
   Any element with data-theme="light" or "dark" re-themes its subtree (used by public/dev/buttons.html).

   Extra tokens beyond the spec table, needed so dark mode keeps contrast:
     --on-primary / --on-danger / --on-gold   text colour on a solid fill
     --primary-text / --danger-text / --select-text   text and icons on the matching tint
   (In light theme these equal the spec's "edge" colours, which the spec also lists as the tint text colour.)

   CSP note: the site allows no inline styles. Set values from JS with el.style.setProperty(), not style="". */

/* ---------- Nunito, self-hosted, variable weight (SIL OFL, see /fonts/OFL-Nunito.txt) ---------- */
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 200 1000;
  font-display: swap;
  src: url("../fonts/nunito-latin-ext-var.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 200 1000;
  font-display: swap;
  src: url("../fonts/nunito-latin-var.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Theme-independent tokens ---------- */
:root {
  --font: "Nunito", ui-rounded, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* shape */
  --bw: 2px;
  --depth: 4px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-full: 999px;

  /* spacing scale: 4, 8, 12, 16, 24, 32, 48 */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;

  /* page */
  --col-app: 480px;
  --col-landing: 600px;
  --gutter: 20px;
  --tap: 48px;
  --tap-gap: 8px;

  /* type scale: size / line height / weight */
  --fs-landing-h1: clamp(30px, 7.6vw, 44px);
  --lh-landing-h1: 1.1;
  --fs-title: 28px;
  --lh-title: 34px;
  --fs-section: 22px;
  --lh-section: 28px;
  --fs-stem: 20px;
  --lh-stem: 28px;
  --fs-gist: 16px;
  --lh-gist: 24px;
  --fs-body: 17px;
  --lh-body: 26px;
  --fs-button: 17px;
  --lh-button: 20px;
  --fs-small: 14px;
  --lh-small: 20px;

  /* motion */
  --t-press: 80ms;
  --t-sheet: 200ms;
  --t-bar: 300ms;
}

/* ---------- Light theme (default) ---------- */
:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #f4f6f8;
  --ink: #1d2a32;
  --ink-2: #55656f;
  --line: #dce2e7;
  --edge: #7c8a94;
  --primary: #0a8567;
  --primary-edge: #06644d;
  --primary-tint: #e2f5ee;
  --primary-text: #06644d;
  --on-primary: #ffffff;
  --danger: #d63a3a;
  --danger-edge: #a32424;
  --danger-tint: #fdeaea;
  --danger-text: #a32424;
  --on-danger: #ffffff;
  --select: #1b6fd8;
  --select-edge: #1454a8;
  --select-tint: #e7f0fd;
  --select-text: #1454a8;
  --gold: #f4a300;
  --gold-edge: #b87900;
  --gold-tint: #fff3d6;
  --gold-ink: #7a5200;
  --on-gold: #1d2a32;
  --locked: #e9edf0;
}

/* ---------- Dark theme: follows the device unless the page forces light ---------- */
/* DARK-BLOCK-START (the two blocks below must stay identical; test/tokens.test.ts checks) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #10191e;
    --surface: #18242b;
    --ink: #eef3f5;
    --ink-2: #a7b4bc;
    --line: #2a3841;
    --edge: #6a7b85;
    --primary: #35c39e;
    --primary-edge: #1f9477;
    --primary-tint: #123329;
    --primary-text: #7be3c4;
    --on-primary: #06241c;
    --danger: #ff8a80;
    --danger-edge: #c85a52;
    --danger-tint: #3a1c1e;
    --danger-text: #ffb4ac;
    --on-danger: #3a0b08;
    --select: #7fb4ff;
    --select-edge: #4a86d6;
    --select-tint: #14263f;
    --select-text: #a9cbff;
    --gold: #ffc247;
    --gold-edge: #c9922a;
    --gold-tint: #3a2f12;
    --gold-ink: #ffd98a;
    --on-gold: #1d2a32;
    --locked: #1f2d35;
  }
}
:root[data-theme="dark"],
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10191e;
  --surface: #18242b;
  --ink: #eef3f5;
  --ink-2: #a7b4bc;
  --line: #2a3841;
  --edge: #6a7b85;
  --primary: #35c39e;
  --primary-edge: #1f9477;
  --primary-tint: #123329;
  --primary-text: #7be3c4;
  --on-primary: #06241c;
  --danger: #ff8a80;
  --danger-edge: #c85a52;
  --danger-tint: #3a1c1e;
  --danger-text: #ffb4ac;
  --on-danger: #3a0b08;
  --select: #7fb4ff;
  --select-edge: #4a86d6;
  --select-tint: #14263f;
  --select-text: #a9cbff;
  --gold: #ffc247;
  --gold-edge: #c9922a;
  --gold-tint: #3a2f12;
  --gold-ink: #ffd98a;
  --on-gold: #1d2a32;
  --locked: #1f2d35;
}
/* DARK-BLOCK-END */

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 500 var(--fs-body) / var(--lh-body) var(--font);
}

/* Type styles. Nothing under 14px. */
.t-landing-h1 { font: 800 var(--fs-landing-h1) / var(--lh-landing-h1) var(--font); }
.t-title      { font: 800 var(--fs-title) / var(--lh-title) var(--font); }
.t-section    { font: 800 var(--fs-section) / var(--lh-section) var(--font); }
.t-stem       { font: 700 var(--fs-stem) / var(--lh-stem) var(--font); }
.t-gist       { font: 600 var(--fs-gist) / var(--lh-gist) var(--font); color: var(--ink-2); }
.t-body       { font: 500 var(--fs-body) / var(--lh-body) var(--font); }
.t-small      { font: 600 var(--fs-small) / var(--lh-small) var(--font); }

/* ---------- Button (spec 6.2) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 24px;
  margin-bottom: var(--depth);
  border: 0;
  border-radius: var(--r-md);
  background: var(--primary);
  color: var(--on-primary);
  font: 800 var(--fs-button) / var(--lh-button) var(--font);
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 var(--depth) 0 var(--primary-edge);
  transition: transform var(--t-press), box-shadow var(--t-press);
  -webkit-tap-highlight-color: transparent;
}
.btn:active {
  transform: translateY(var(--depth));
  box-shadow: none;
}
.btn:focus-visible {
  outline: 3px solid var(--select);
  outline-offset: 3px;
}
/* Disabled and sending look the same: same size, label swapped by JS ("Sending..."), button disabled. */
.btn[disabled],
.btn[aria-busy="true"] {
  background: var(--locked);
  color: var(--ink-2);
  box-shadow: none;
  cursor: default;
  transform: none;
}
.btn-block {
  display: flex;
  width: 100%;
}

/* Secondary: page-colour fill, 2px --edge border, edge in --edge, text --ink. */
.btn-secondary {
  background: var(--bg);
  color: var(--ink);
  border: var(--bw) solid var(--edge);
  box-shadow: 0 var(--depth) 0 var(--edge);
}
.btn-secondary[disabled],
.btn-secondary[aria-busy="true"] {
  background: var(--locked);
  border-color: transparent;
  color: var(--ink-2);
  box-shadow: none;
}

/* Danger: red fill, --danger-edge. */
.btn-danger {
  background: var(--danger);
  color: var(--on-danger);
  box-shadow: 0 var(--depth) 0 var(--danger-edge);
}

/* Text-only link button for low-priority actions. No depth, no margin. */
.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 var(--sp-3);
  margin: 0;
  border: 0;
  background: none;
  color: var(--select);
  font: 800 var(--fs-button) / var(--lh-button) var(--font);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  box-shadow: none;
}
.btn-link:active { transform: none; }
.btn-link:focus-visible {
  outline: 3px solid var(--select);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}
.btn-link[disabled] { color: var(--ink-2); cursor: default; }

@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}
