/* ==========================================================================
   Self-hosted fonts — kurzweg.digital
   --------------------------------------------------------------------------
   This file lives in assets/font/, so all url() paths are bare filenames.
   Include with:  <link rel="stylesheet" href="assets/font/fonts.css">

   FAMILIES
     Midiet Sans    — proprietary, shipped with the site (4 faces + 1 serif).
     Literata       — variable, SIL Open Font License 1.1. See OFL.txt in this
                      directory; that file MUST ship with the font (licence
                      condition). Source: github.com/google/fonts/ofl/literata
                      Subset to Latin-1 + typographic punctuation, axes
                      restricted to opsz 10-32 / wght 300-700.

   PRELOAD (put in <head>, before this stylesheet — HTML is owned elsewhere):
     <link rel="preload" href="assets/font/Literata-Variable.woff2"
           as="font" type="font/woff2" crossorigin>
     <link rel="preload" href="assets/font/Midiet_Sans_Light.woff2"
           as="font" type="font/woff2" crossorigin>
   ========================================================================== */


/* ==========================================================================
   1. Midiet Sans
   --------------------------------------------------------------------------
   Only four real faces exist. Their true OS/2 usWeightClass values are:
     Midiet_Sans_Light         300  upright
     Midiet_Sans_Bold          700  upright
     Midiet_Sans_Italic_Light  300  italic
     Midiet_Sans_Italic_Medium 500  italic
   Each face is declared over a weight *range* so intermediate CSS weights
   snap to the nearest real design instead of being synthesised by the
   browser. These ranges match the site's existing style.css exactly.

   The .otf is kept as a second src purely as a safety net for pre-2016
   browsers; any engine that understands woff2 never requests it.
   ========================================================================== */

@font-face {
    font-family: 'Midiet Sans';
    src: url('Midiet_Sans_Light.woff2') format('woff2'),
         url('Midiet_Sans_Light.otf') format('opentype');
    font-weight: 300 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Midiet Sans';
    src: url('Midiet_Sans_Bold.woff2') format('woff2'),
         url('Midiet_Sans_Bold.otf') format('opentype');
    font-weight: 600 800;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Midiet Sans';
    src: url('Midiet_Sans_Italic_Light.woff2') format('woff2'),
         url('Midiet_Sans_Italic_Light.otf') format('opentype');
    font-weight: 300 450;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: 'Midiet Sans';
    src: url('Midiet_Sans_Italic_Medium.woff2') format('woff2'),
         url('Midiet_Sans_Italic_Medium.otf') format('opentype');
    font-weight: 450 700;
    font-style: italic;
    font-display: swap;
}


/* ==========================================================================
   2. Midiet Serif — single face (Italic Light, usWeightClass 300)
   --------------------------------------------------------------------------
   Declared for completeness because the file ships in this directory. An
   unused @font-face costs nothing: browsers only fetch a face that some
   element actually matches.
   ========================================================================== */

@font-face {
    font-family: 'Midiet Serif';
    src: url('Midiet_Serif_Italic_Light.woff2') format('woff2'),
         url('Midiet_Serif_Italic_Light.otf') format('opentype');
    font-weight: 300 500;
    font-style: italic;
    font-display: swap;
}


/* ==========================================================================
   3. Literata Variable (SIL OFL 1.1 — see OFL.txt)
   --------------------------------------------------------------------------
   Two axes survive subsetting:
     opsz  10 - 32  (default 12)  — optical size
     wght 300 - 700 (default 400) — weight
   No .ttf fallback src here on purpose: the unsubset upstream TTF is ~955 KB
   against an 82 KB woff2, so shipping it as a fallback would be a liability,
   and every browser that lacks woff2 also lacks variable-font support.
   ========================================================================== */

@font-face {
    font-family: 'Literata';
    src: url('Literata-Variable.woff2') format('woff2-variations'),
         url('Literata-Variable.woff2') format('woff2');
    font-weight: 300 700;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
                   U+02DA, U+02DC, U+2013-2014, U+2018-201A, U+201C-201E,
                   U+2020-2022, U+2026, U+2030, U+2039-203A, U+2044, U+20AC,
                   U+2122, U+2212, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Literata';
    src: url('Literata-Italic-Variable.woff2') format('woff2-variations'),
         url('Literata-Italic-Variable.woff2') format('woff2');
    font-weight: 300 700;
    font-style: italic;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
                   U+02DA, U+02DC, U+2013-2014, U+2018-201A, U+201C-201E,
                   U+2020-2022, U+2026, U+2030, U+2039-203A, U+2044, U+20AC,
                   U+2122, U+2212, U+FEFF, U+FFFD;
}


/* ==========================================================================
   4. Metrics-matched fallbacks for Literata
   --------------------------------------------------------------------------
   font-display: swap means the fallback paints first and Literata replaces it
   on load. Without correction that swap reflows every line. These two faces
   re-describe a locally installed serif so it occupies the *exact* same
   vertical and horizontal space as Literata, making the swap invisible.

   Literata's own metrics (constant across the whole design space — its MVAR
   table varies only cpht/xhgt/stro, never hasc/hdsc/hlgp):
       unitsPerEm 1000, ascender 1177, descender -308, lineGap 0
       hhea == OS/2 sTypo == OS/2 usWin, and USE_TYPO_METRICS (fsSelection
       bit 7) is set, so every platform agrees on those numbers.

   size-adjust is the ratio of average lowercase advance width (a-z plus
   space, weighted by English letter frequency — the capsize/fontaine
   method), each normalised to its own em:

     Literata          483.5773 / 1000 = 0.48357728 em
     Georgia           912.3301 / 2048 = 0.44547368 em
     Times New Roman   829.1386 / 2048 = 0.40485282 em

   GEORGIA
     size-adjust       0.48357728 / 0.44547368 = 1.08553502  -> 108.55%
     ascent-override   (1177/1000) / 1.08553502 = 1.084258   -> 108.43%
     descent-override  ( 308/1000) / 1.08553502 = 0.283731   ->  28.37%
     line-gap-override (   0/1000) / 1.08553502 = 0          ->      0%

   TIMES NEW ROMAN
     size-adjust       0.48357728 / 0.40485282 = 1.19445205  -> 119.45%
     ascent-override   (1177/1000) / 1.19445205 = 0.985389   ->  98.54%
     descent-override  ( 308/1000) / 1.19445205 = 0.257859   ->  25.79%
     line-gap-override (   0/1000) / 1.19445205 = 0          ->      0%

   The overrides are divided by size-adjust because they are resolved against
   the *scaled* em. Verification, line box at font-size:16px —
     Literata  16 x (1177 + 308 + 0) / 1000                        = 23.7600px
     Georgia   16 x 1.085535 x (1.084258 + 0.283731 + 0)           = 23.7600px
     Times     16 x 1.194452 x (0.985389 + 0.257859 + 0)           = 23.7600px

   Two separate families are required because each carries different numbers.
   List them in order: if Georgia is absent the family simply fails to load
   and the Times-tuned family takes over.
   ========================================================================== */

@font-face {
    font-family: 'Literata Fallback Georgia';
    src: local('Georgia'), local('Georgia Regular');
    size-adjust: 108.55%;
    ascent-override: 108.43%;
    descent-override: 28.37%;
    line-gap-override: 0%;
}

@font-face {
    font-family: 'Literata Fallback Times';
    src: local('Times New Roman'), local('TimesNewRomanPSMT'), local('Times');
    size-adjust: 119.45%;
    ascent-override: 98.54%;
    descent-override: 25.79%;
    line-gap-override: 0%;
}


/* ==========================================================================
   5. Stack + optical sizing
   --------------------------------------------------------------------------
   NOTE: font-optical-sizing is a *property*, not an @font-face descriptor —
   it cannot live in a @font-face block. It defaults to `auto`, but is set
   explicitly here so the opsz axis is never left to a UA default, and so the
   intent is legible to the next person reading this file.
   ========================================================================== */

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

.font-serif {
    font-family: var(--font-serif);
    font-optical-sizing: auto;
}
