/*
 * VELRIX — tonal design tokens.
 * ============================================================================
 *
 * One file that every surface reads from. Loaded in <head> BEFORE any page's
 * own stylesheet, so the legacy names each page already uses (--a, --bg2,
 * --dim, --card …) resolve to this scale instead of their old flat values.
 *
 * ── WHY THIS EXISTS ────────────────────────────────────────────────────────
 * The site shipped four mutually independent token sets, none of them related:
 *
 *   index-inline.css   --bg:#05030a  --a:#8b5cf6
 *   tools.css          --bg:#05030a  --a:#8b5cf6
 *   backend/app.css    --bg:#0B0B0F  --accent:#7C5CFF
 *   partner-form       --bg:#06080E  --accent:#A855F7
 *
 * The symptom the owner reported — "the input fields blend into the
 * background" — is exactly the shape this causes. `backend/app.css` set
 * `input{background:var(--bg)}`, the same colour as the page, over a border at
 * 1.7:1. Nothing was wrong with any one file; there was no system.
 *
 * ── PER-SURFACE ACCENTS, DELIBERATELY (not an oversight) ────────────────────
 * The accents are NOT unified to one hex, and that is a requirement, not a
 * preference. The Android app's `scripts/check-palette.mjs` BANS #8b5cf6 and
 * REQUIRES the light accent to differ from the dark one:
 *
 *     ["#8B5CF6", "old violet accent", "use var(--accent) #7C5CFF"]
 *     check 5: "the light theme's accent is present and distinct from the dark"
 *
 * So each surface ramps from its own hue:
 *
 *     marketing      #8b5cf6   (index-inline.css, tools.css)
 *     backend + app  #7C5CFF   (app.css, app dark)  /  #6A46E8 (app light)
 *     partner-form   #A855F7
 *
 * ── SHAPE OF THE SCALE ─────────────────────────────────────────────────────
 * Five-plus shades per role. Dark ramps from near-black up; light inverts.
 * Every *-strong / border value was picked to clear 3:1 against the surface it
 * borders, and every text value to clear 4.5:1 against the surface it sits on.
 * `scripts/check-contrast.mjs` reads this file and enforces both floors — the
 * numbers here are checked, not asserted in a comment.
 *
 * ── DARK IS LISTED FIRST ───────────────────────────────────────────────────
 * `[data-theme="dark"]` is declared before `[data-theme="light"]`, and the
 * legacy re-point block further down lists dark's already resolved. Specificity
 * is equal, so source order decides ties; dark-first means a page that somehow
 * gets neither attribute still renders the dark scale rather than half of each.
 */

/* ── DARK (the original Velrix look, now the opt-in) ───────────────────────── */
[data-theme="dark"]{
  color-scheme: dark;

  /* backgrounds — 5 steps from the page floor to a raised card */
  --bg:            #0B0B0F;
  --bg-2:          #08080B;
  --surface:       #131318;
  --surface-2:     #1A1A21;
  --surface-3:     #212129;
  --raised:        #1A1A21;

  /* borders — 4 steps. `--border` is the hairline, `--border-strong` is the
     one that must clear 3:1 (it is what an input draws on the page). */
  --border:        #26262E;
  --border-2:      #2E2E38;
  --border-strong: #8E8EA6;

  /* text — 4 steps, all >= 4.5:1 on --bg and --surface */
  --text:          #EDEDF2;
  --text-2:        #C9C9D4;
  --text-muted:    #A7A7B6;
  --text-faint:    #8A8A99;

  /* accent ramp (backend + app dark hue)
     `--accent` must clear 4.5:1 as TEXT on --surface (#131318), which pure
     #7C5CFF does not (4.26:1). Text-on-surface roles use --accent-text, the
     same hue lifted; the raw --accent stays for fills.

     `--accent-contrast` is the LABEL drawn on an --accent fill. White on
     #7C5CFF is 4.35:1 — under AA, and the reason is measurable: #7C5CFF is a
     light-enough violet that white does not clear it. The near-black base
     does (4.60:1). That looks wrong next to every other button on the web and
     is still the accessible choice; the app's check-palette already accepts a
     theme-specific accent-contrast, so this is the same rule, not a new one. */
  --accent:          #7C5CFF;
  --accent-hover:    #9B82FF;
  --accent-quiet:    #1E1A33;
  --accent-contrast: #08080B;
  --accent-text:     #A78BFA;
  --chip-accent:     #B9A8FF;

  /* focus — must clear 3:1 on --bg, --surface AND on an --accent fill, because
     a ring is drawn in all three places and a ring you cannot see on the
     filled "Sign in" button is the exact failure this file exists to stop.
     Verified: #FFFFFF is 19.64:1 on --bg and 4.35:1 on --accent. */
  --focus: #FFFFFF;
  --focus-halo: #0B0B0F;

  /* semantic */
  --positive: #4ADE80;
  --danger:   #F87171;
  --negative: #F87171;
  --warning:  #FBBF24;

  /* legacy names this file re-points, so existing rules keep working */
  --a:     #8b5cf6;
  --a2:    #d946ef;
  --a3:    #6366f1;
  --a-txt: #C4B5FD;
  --bg2:   #08080B;
  --text-sub: #A7A7B6;
  --dim:   #8A8A99;
  --dim-txt: #C9C9D4;
  --muted: #A7A7B6;
  --faint: #8A8A99;
  --card:  rgba(255,255,255,.04);
  --gb:    rgba(255,255,255,.10);
  --on-accent: #FFFFFF;
  --overlay: rgba(0,0,0,.70);
}

/* ── LIGHT (new; matches the app's cream theme) ───────────────────────────── */
[data-theme="light"]{
  color-scheme: light;

  /* backgrounds — cream family, taken from the app's shipped light theme so
     the site and the app read as one product */
  --bg:            #FAF9F7;
  --bg-2:          #FFFFFF;
  --surface:       #FFFFFF;
  --surface-2:     #F4F2EF;
  --surface-3:     #EFEDE9;
  --raised:        #F4F2EF;

  /* borders */
  --border:        #E4E1DB;
  --border-2:      #CFCBC3;
  --border-strong: #6E6A63;

  /* text */
  --text:          #14131A;
  --text-2:        #45444F;
  --text-muted:    #5E5D68;
  --text-faint:    #5E5D68;

  /* accent ramp (app light hue — kept distinct from dark, check-palette #5) */
  --accent:          #6A46E8;
  --accent-hover:    #5A36D8;
  --accent-quiet:    #EFEBFE;
  --accent-contrast: #FFFFFF;
  --accent-text:     #6A46E8;
  --chip-accent:     #5A36D8;

  /* focus — same rule inverted for cream: #0B0B0F is 18.67:1 on --bg and
     3.42:1 on the --accent fill, so one value covers both placements. */
  --focus: #0B0B0F;
  --focus-halo: #FAF9F7;

  /* semantic — the DARK values are invisible on cream, so each has its own */
  /* #10612C, not the obvious #15803D. The admin Approve button paints its
     label in --positive over a 14% --positive tint (22% on hover) sitting on
     --surface-raised, so the token has to clear 4.5:1 against THREE different
     tinted backdrops, not against white. At #15803D the rest state measures
     3.745:1 there - under the floor, and only visible to the panel a11y gate.
     Measured against every state this token is used in:
       rest 14% tint  5.490   hover 22% tint  4.808
       pill 16% tint  5.893   plain on white  7.586
     The darkest of those is 4.808, which leaves real margin rather than the
     4.525 a #11662F would give. Same fix covers s-approved, the toast border,
     idyes and acct-yes, which all read this one token. */
  --positive: #10612C;
  --danger:   #C8322B;
  --negative: #C8322B;
  --warning:  #8A5A00;

  /* legacy re-points for light */
  --a:     #6A46E8;
  --a2:    #9333EA;
  --a3:    #4F46E5;
  --a-txt: #5A36D8;
  --bg2:   #FFFFFF;
  --text-sub: #45444F;
  --dim:   #6A6975;
  --dim-txt: #45444F;
  --muted: #5E5D68;
  --faint: #6A6975;
  --card:  rgba(20,19,26,.035);
  --gb:    rgba(20,19,26,.09);
  --on-accent: #FFFFFF;
  --overlay: rgba(20,19,26,.42);
}

/*
 * ── THE MARKETING ACCENT, SEPARATE ON PURPOSE ────────────────────────────────
 * /index.html, the 10 sibling pages and the tools pages are built on #8b5cf6
 * and read `--a`, not `--accent`. They get their own value in both themes.
 * Keeping this out of the `--accent` slot is what lets the backend keep
 * #7C5CFF and the palette guard stay satisfied.
 */
[data-theme="dark"]{
  --a-marketing:     #8b5cf6;
  --a-marketing-txt: #C4B5FD;   /* lifted: #8b5cf6 is 4.1:1 on --bg, below AA */
}
[data-theme="light"]{
  --a-marketing:     #6A46E8;
  --a-marketing-txt: #5A36D8;
}

/*
 * ── PARTNER-FORM ACCENT ──────────────────────────────────────────────────────
 * partner-form ships its own #A855F7. It keeps it, but lifted to a value that
 * clears AA on its own very dark base (#06080E).
 */
[data-theme="dark"]{
  --accent-partner:     #A855F7;
  --accent-partner-txt: #C99BFB;
}
[data-theme="light"]{
  --accent-partner:     #7E22CE;
  --accent-partner-txt: #7E22CE;
}

/*
 * ── RADII / MOTION / SHADOW (shared across themes) ───────────────────────────
 * Motion lives here so Phase 7 can reference one duration scale, and so the
 * reduced-motion guard is written once rather than per component.
 */
:root{
  --r:      10px;
  --r-card: 12px;
  --r-pill: 999px;

  --dur-fast: 120ms;
  --dur-mid:  180ms;
  --dur-card: 220ms;
  --ease-out: cubic-bezier(.22,.61,.36,1);

  --shadow-card: 0 1px 3px rgba(0,0,0,.24), 0 8px 32px rgba(0,0,0,.28);
}
[data-theme="light"]{
  --shadow-card: 0 1px 2px rgba(20,19,26,.06), 0 1px 3px rgba(20,19,26,.05);
}

/*
 * ── REDUCED MOTION ───────────────────────────────────────────────────────────
 * Anything that animates opts in through the --dur-* scale. Zeroing the scale
 * here disables every consumer at once, with no per-rule media query to forget.
 */
@media (prefers-reduced-motion: reduce){
  :root{
    --dur-fast: 0ms;
    --dur-mid:  0ms;
    --dur-card: 0ms;
  }
}

/* ── TAP TARGETS ON PHONES ───────────────────────────────────────────────────
   2026-10-18 bug hunt, measured at 390px: footer and header links were 14–15px
   tall on every page — under WCAG 2.2's 24px minimum and awkward with a thumb.
   Lives here because tokens.css is the one sheet every page loads (pricing,
   learn and faq never load index-inline.css). The footer links carry inline
   `padding:7px 3px`, so this sets HEIGHT, not padding: min-height plus a
   matching line-height centres the label without fighting the inline style. */
@media (max-width: 768px){
  .fbot a, .flinks a, footer a, nav a, .nav-links a{
    display: inline-block;
    min-height: 32px;
    line-height: 32px;
  }
}
