/* ==========================================================================
   Literata — body serif (pair A)
   Variable WOFF2 (opsz + wght axes), latin + latin-ext × normal + italic.
   Owns its own metric-matched fallback and FOUT override.

   OpenType feature audit (fontkit, against literata-latin-opsz-normal.woff2):
     GSUB:  ccmp dnom frac liga locl numr pnum rvrn tnum
     GPOS:  kern mark
   MISSING that the project's CSS references: calt clig onum lnum smcp c2sc
   dlig ordn sups subs ss01 swsh salt. These look like Google-Fonts-style
   subsetter dropouts. Practical fallout:
     - smcp / c2sc: browsers synthesize small-caps (visibly cruder).
     - onum: figures render in the font's default (lining for this subset),
             so the "old-style figures" demo shows lining figures.
     - sups / subs: browsers synthesize via baseline-shift + size (acceptable).
     - calt / dlig / ss01 / swsh: no effect; the CSS is a no-op.
   If the demo's veracity matters, re-subset from the full Literata source
   (Google Fonts ships a feature-rich variable file; pyftsubset with
   --layout-features='*' preserves OT tables).
   ========================================================================== */

/* Metric overrides pinned to Literata's own hhea (ascent 1177, descent 308,
   line-gap 0 — measured by fontaine from the woff2). Without these, browsers
   fall back to whichever OS/2 metric they prefer; Safari in particular tends
   to use the Win metrics (often > 1.6em strut), which forces each line-box
   to grow past the `line-height: 1.6` we set — visible as the baseline grid
   drifting downward through every paragraph at wide viewports. Pinning the
   ascent/descent/line-gap forces every browser to give Literata the same
   1.485em strut, well under our 1.6em line-height, so the line-height wins
   and lines advance by exactly --baseline. */
@font-face {
    font-family: Literata;
    font-style: normal;
    font-weight: 200 900;
    font-display: swap;
    src: url('fonts/literata-latin-opsz-normal.woff2') format('woff2-variations');
    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;
    ascent-override: 117.7%;
    descent-override: 30.8%;
    line-gap-override: 0%;
}

@font-face {
    font-family: Literata;
    font-style: normal;
    font-weight: 200 900;
    font-display: optional; /* English content rarely needs latin-ext; don't block first paint on it. */
    src: url('fonts/literata-latin-ext-opsz-normal.woff2') format('woff2-variations');
    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;
    ascent-override: 117.7%;
    descent-override: 30.8%;
    line-gap-override: 0%;
}

@font-face {
    font-family: Literata;
    font-style: italic;
    font-weight: 200 900;

    /* `fallback` instead of `swap` for italic: short block period, then a
     permanent fallback render if the italic file arrives late. Italic body
     content (<em>, <cite>) is common above-the-fold, so a CLS-style swap-
     in mid-read is worse than living with the metric-matched fallback for
     the whole pageload when the network is bad. */
    font-display: fallback;
    src: url('fonts/literata-latin-opsz-italic.woff2') format('woff2-variations');
    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;
    ascent-override: 117.7%;
    descent-override: 30.8%;
    line-gap-override: 0%;
}

@font-face {
    font-family: Literata;
    font-style: italic;
    font-weight: 200 900;
    font-display: optional; /* See latin-ext normal above — same rationale. */
    src: url('fonts/literata-latin-ext-opsz-italic.woff2') format('woff2-variations');
    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;
    ascent-override: 117.7%;
    descent-override: 30.8%;
    line-gap-override: 0%;
}

/* Metric-matched Georgia fallback — values measured by fontaine from
   Literata's own hhea table (ascent 1177, descent -308, UPM 1000) and
   Georgia's system-font table. Regenerate with `npm run metrics` in scripts/. */
@font-face {
    font-family: 'Literata Fallback';
    src: local('Georgia');
    size-adjust: 107.8957%;
    ascent-override: 109.0868%;
    descent-override: 28.5461%;
    line-gap-override: 0%;
}

:root {
    --font-body: 'Literata', 'Literata Fallback', 'Times New Roman', serif;

    /* Cap-to-baseline ratio for Literata, measured under text-box-trim.
     The ratio is size-dependent because `font-optical-sizing: auto` picks
     a taller-cap variant at display sizes:
       text  (~28px h3 size): 0.700
       display (~38px h2 size): 0.726
     Two tokens so the slot math in crafted-typography.css can target each
     tier exactly. Falls back to a shared --cap-height for any consumer
     that hasn't been migrated to the split. */
    --cap-height: 0.7; /* legacy single-token fallback */
    --cap-height-text: 0.7;
    --cap-height-display: 0.726;
}

/* FOUT simulation: when the body has .simulate-fout, drop Literata out of
   the stack so text renders in the metric-matched Georgia fallback. The
   button removes the class after ~3s — the moment it lifts is exactly the
   visual swap a first-time visitor experiences. */
.simulate-fout {
    --font-body: 'Literata Fallback', 'Times New Roman', serif;
}
