/*
 * serras — self-hosted brand fonts (SIL OFL 1.1, all free / Preserve-bundleable)
 *
 * Hand-authored (NOT baker-emitted): this bake CODIFIES the client's verified
 * `serras.css` @font-face set verbatim. The canonical shipped set is 5 FAMILIES
 * (by @font-face, NOT by folder contents — the source assets/fonts/ dir is a
 * 23-file experiments folder; only these 5 are wired):
 *   · Fraunces      — display/serif  → --serras-font-display  (4-axis FULL file)
 *   · Instrument Sans — body/UI/sans → --serras-font-body     (Inter = opt-in swap)
 *   · JetBrains Mono — mono/numeric  → --serras-font-mono      (roman-only, tnum)
 *   · Saira         — WORDMARK ONLY  → .serras-wordmark        (no type-ramp slot)
 *   · Inter         — OPT-IN sans display swap → html[data-display="sans"]
 *
 * Import once at the app root, AFTER the theme tokens (so the family names the
 * generated --serras-font-* stacks reference are resolvable):
 *   import '@tarva/ui/themes/serras/tokens.css';
 *   import '@tarva/ui/themes/serras/fonts.css';
 *
 * ── THE FRAUNCES FILE TRAP (verified, load-bearing) ──────────────────────────
 * The TAMED display recipe REQUIRES the 4-axis `-full-` file below (opsz/wght/
 * SOFT/WONK). Only it exposes the WONK axis, so `'WONK' 0` can turn OFF the
 * swashy f/j/g ball-terminal alternates the client REJECTED. The retired 2-axis
 * `-var-` file baked WONK ON and made `'WONK' 0` a SILENT NO-OP — do NOT swap it.
 */

/* ── Fraunces — display/serif · 4-axis FULL (opsz 9–144, wght 100–900, SOFT 0–100, WONK 0–1) ── */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('./fonts/Fraunces-latin-var-full-roman.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces';
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url('./fonts/Fraunces-latin-var-full-italic.woff2') format('woff2');
}

/* ── Instrument Sans — body/UI/sans (variable 400–700) ── */
@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('./fonts/InstrumentSans-latin-var-roman.woff2') format('woff2');
}
@font-face {
  font-family: 'Instrument Sans';
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url('./fonts/InstrumentSans-latin-var-italic.woff2') format('woff2');
}

/* ── JetBrains Mono — mono/numeric (variable 400–700, roman-only, tabular-nums) ── */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('./fonts/JetBrainsMono-latin-var-roman.woff2') format('woff2');
}

/* ── Saira — WORDMARK ONLY (variable wght 100–900, wdth 50–125). Not in the type ramp. ── */
@font-face {
  font-family: 'Saira';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('./fonts/Saira-latin-var.woff2') format('woff2');
}

/* ── Inter — OPT-IN sans display swap (variable opsz 14–32, wght 100–900) ── */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('./fonts/Inter-latin-var-roman.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url('./fonts/Inter-latin-var-italic.woff2') format('woff2');
}

/*
 * ── TAMED Fraunces display recipe (client FINAL DECISION 2026-07-02) ──────────
 * Pin the optical size low and force WONK 0 / SOFT 0 so the ball-terminal f/j/g
 * swashes shrink to upright, instrument-grade forms. `font-optical-sizing:none`
 * keeps opsz PINNED (it does NOT track rendered size). H1 opsz 60, H2 opsz 48,
 * wght 600. Scoped to the Serras color-scheme so it never leaks to other themes.
 * Consumers apply .serras-h1 / .serras-h2 / .serras-display to display headings.
 */
:where([data-color-scheme='serras'], .serras) {
  --serras-fraunces-tamed: 'opsz' 48, 'wght' 600, 'SOFT' 0, 'WONK' 0;
}
.serras-display,
.serras-h2 {
  font-family: var(--serras-font-display);
  font-optical-sizing: none;
  font-variation-settings: var(--serras-fraunces-tamed);
  letter-spacing: -0.010em;
}
.serras-h1 {
  font-family: var(--serras-font-display);
  font-optical-sizing: none;
  font-variation-settings: 'opsz' 60, 'wght' 600, 'SOFT' 0, 'WONK' 0;
  letter-spacing: -0.014em;
}

/*
 * ── Wordmark — the SERRAS lockup in live system type (Saira caps) ─────────────
 * wght 560 / wdth 88, +0.14em tracking, ALL-WHITE on dark (text.hi). Client
 * decision 2026-07-02: NO amber final S — "SERRAS all white on dark." Do NOT set
 * the wordmark in Fraunces; do NOT color the final S. (For most surfaces prefer
 * the SVG wordmark in ./assets/logos/.)
 */
.serras-wordmark {
  font-family: 'Saira', 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 560;
  font-variation-settings: 'wght' 560, 'wdth' 88;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  line-height: 1;
  color: var(--fg-strong, var(--fg-primary));
}

/*
 * ── Inter opt-in display swap (client "clean Apple-system"/SF Pro request) ─────
 * ADDITIVE, NON-DEFAULT. Activates ONLY under a scoped ancestor; the default
 * Fraunces system is untouched. Fallback leads to -apple-system so real SF Pro
 * renders on Apple hardware if Inter is unavailable. Config A = statement roles
 * only (.serras-h1/.serras-h2). See analysis/typography.md "Sans display option".
 */
:where([data-color-scheme='serras'], .serras) {
  --serras-font-display-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
[data-color-scheme='serras'][data-display='sans'] .serras-h1,
[data-color-scheme='serras'][data-display='sans'] .serras-h2,
.serras-display-sans .serras-h1,
.serras-display-sans .serras-h2 {
  font-family: var(--serras-font-display-sans);
  font-optical-sizing: auto;
  font-variation-settings: 'opsz' 32;
  font-weight: 600;
}
