/* =====================================================================
   fonts.css  —  self-hosted Inter + Fira Code
   ---------------------------------------------------------------------
   Replaces the fonts.googleapis.com <link> that templates/layout.php
   carried. This plugin deliberately does NOT use Lato - Inter for UI,
   Fira Code for code samples - so only the delivery technique is shared
   with bq-pages, not the typeface.

   font-display:block, NOT swap. swap paints a fallback and then exchanges
   it, and the exchange reflows the page. block holds the text unpainted,
   and the metric-matched fallbacks at the bottom mean the geometry is
   already right when the real font lands - so nothing moves either way.

   FIVE FILES, NOT SEVENTEEN. Both families are VARIABLE fonts: Google
   serves one woff2 per subset spanning the whole weight axis, and the
   browser instances 400/500/600/700 out of it. Downloading them "per
   weight" just fetches the same bytes four times under four names - a
   mistake worth naming, because the filenames Google's CSS implies make
   it look like separate faces. Hence one rule per subset with a weight
   RANGE, which is also what lets any intermediate weight work for free.

   Subsets trimmed to latin and latin-ext; Google also offers cyrillic,
   greek and vietnamese, which unicode-range means an English page never
   downloads. Fira Code's symbols2 subset IS kept - it carries the arrows
   and box-drawing glyphs that show up in code samples.
   ===================================================================== */


@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 700;
    font-display: block;
    src: url('../fonts/inter-latin.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;
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 700;
    font-display: block;
    src: url('../fonts/inter-latin-ext.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: 'Fira Code';
    font-style: normal;
    font-weight: 400 600;
    font-display: block;
    src: url('../fonts/fira-code-latin.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;
}

@font-face {
    font-family: 'Fira Code';
    font-style: normal;
    font-weight: 400 600;
    font-display: block;
    src: url('../fonts/fira-code-latin-ext.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: 'Fira Code';
    font-style: normal;
    font-weight: 400 600;
    font-display: block;
    src: url('../fonts/fira-code-symbols2.woff2') format('woff2');
    unicode-range: U+2000-2001, U+2004-2008, U+200A, U+23B8-23BD, U+2500-259F;
}

/* ---------------------------------------------------------------------
   Metric-matched fallbacks — NEVER SEEN, only measured.
   ---------------------------------------------------------------------
   font-display:block stops the wrong typeface being PAINTED; it does not
   stop the page MOVING. During the block period the browser still lays the
   invisible text out in whatever comes next in the stack, then reflows to
   the real metrics when the font lands. These faces make that first,
   invisible layout occupy exactly the space Inter and Fira Code will:
   within 0.009% on advance width and 0px on line box, measured against the
   real faces in the browser.

   local('Arial') / local('Consolas') always resolve to the REGULAR weight
   whatever font-weight the rule declares - the declared weight is an exact
   match so no synthetic bolding happens - so every size-adjust below is
   calibrated against the regular face.

       size-adjust    = real advance width / fallback advance width
       ascent+descent = real line box / size-adjust

   Fira Code is monospace, so its width is identical at every weight; only
   the sans needs per-weight values. Recalibrate the same way if either
   font file is replaced.
   --------------------------------------------------------------------- */

@font-face{font-family:'Inter Fallback';src:local('Arial');font-weight:400;size-adjust:106.930%;ascent-override:90.60%;descent-override:22.56%;line-gap-override:0%;}
@font-face{font-family:'Inter Fallback';src:local('Arial');font-weight:500;size-adjust:108.219%;ascent-override:89.52%;descent-override:22.29%;line-gap-override:0%;}
@font-face{font-family:'Inter Fallback';src:local('Arial');font-weight:600;size-adjust:109.492%;ascent-override:88.48%;descent-override:22.03%;line-gap-override:0%;}
@font-face{font-family:'Inter Fallback';src:local('Arial');font-weight:700;size-adjust:110.770%;ascent-override:87.46%;descent-override:21.77%;line-gap-override:0%;}
@font-face{font-family:'Fira Code Fallback';src:local('Consolas'),local('Menlo'),local('DejaVu Sans Mono');font-weight:400 600;size-adjust:109.129%;ascent-override:96.03%;descent-override:24.01%;line-gap-override:0%;}

/* ---------------------------------------------------------------------
   SECOND TIER: Roboto. Covers Android and Linux, where Arial does not exist.
   ---------------------------------------------------------------------
   src:local('Arial') simply FAILS on those platforms - the @font-face is
   unusable, the browser skips it and drops to whatever comes next, so all
   the calibration above is bypassed and the shift returns. Measured by
   pointing a face at a font name that does not exist: the error went from
   -0.01% / 0px to -4.62% / 5px. Android is not a rounding error in this
   site's traffic, so it gets its own calibrated tier.

   Roboto is Android's system font and ships on most Linux desktops. Values
   derived exactly as the Arial tier's were, against Roboto Regular, and
   verified to within 0.008% width and 0px line box.

   Order in the stack is Arial tier, then Roboto tier: whichever resolves
   first wins, and only one ever will on a given device.
   --------------------------------------------------------------------- */

@font-face{font-family:'Inter Fallback R';src:local('Roboto');font-weight:400;size-adjust:107.015%;ascent-override:90.53%;descent-override:22.54%;line-gap-override:0%;}
@font-face{font-family:'Inter Fallback R';src:local('Roboto');font-weight:500;size-adjust:108.305%;ascent-override:89.45%;descent-override:22.27%;line-gap-override:0%;}
@font-face{font-family:'Inter Fallback R';src:local('Roboto');font-weight:600;size-adjust:109.579%;ascent-override:88.41%;descent-override:22.01%;line-gap-override:0%;}
@font-face{font-family:'Inter Fallback R';src:local('Roboto');font-weight:700;size-adjust:110.858%;ascent-override:87.39%;descent-override:21.76%;line-gap-override:0%;}

/* ---------------------------------------------------------------------
   NOTHING ON THESE PAGES RENDERS IN A FOREIGN FAMILY.
   ---------------------------------------------------------------------
   Two SVG <text> nodes were coming out in Lato: the "60%" badge that
   bq-popups injects site-wide carries a hardcoded
   font-family="'Lato', Arial, sans-serif" presentation attribute. This
   plugin is Inter and Fira Code by design, and Lato is not even loaded
   here, so those two glyphs were rendering in Arial.

   Fixed HERE rather than in bq-popups on purpose: that plugin is on hold
   until the registration fix is confirmed on production, and a page's own
   typography is this stylesheet's business anyway. A CSS declaration beats
   an SVG presentation attribute, so no !important is needed - but it is
   scoped to .bq-api-body so it cannot reach the popup on any other route.
   --------------------------------------------------------------------- */

.bq-api-body svg text { font-family: var(--api-font-sans); }

/* ---------------------------------------------------------------------
   THE LAST TWO PLACES A FOREIGN FONT GOT IN.
   ---------------------------------------------------------------------
   1. FORM CONTROLS DO NOT INHERIT font-family. button, input, select and
      textarea are styled by the browser's own UA stylesheet, which sets a
      system UI font - Arial on Windows - and inheritance does not apply.
      No rule in any stylesheet was setting Arial; the search button simply
      never received Inter. This is the single most common way a site that
      "uses one font" quietly renders two.

   2. BARE <code> AND <pre> fall to the UA monospace default. api-portal.css
      styles code inside specific containers (.api-param-table,
      .bq-viewer-title-block, .bq-table-footer-bar) but not code in running
      prose, so inline code in a paragraph rendered in Courier-ish default
      rather than Fira Code.

   Both scoped to .bq-api-body so they cannot affect any other route.
   --------------------------------------------------------------------- */

.bq-api-body button,
.bq-api-body input,
.bq-api-body select,
.bq-api-body textarea { font-family: inherit; }

.bq-api-body code,
.bq-api-body pre,
.bq-api-body kbd,
.bq-api-body samp { font-family: var(--api-font-mono); }

