/* ==========================================================================
   PIANOMODE SELF-HOSTED FONTS
   --------------------------------------------------------------------------
   Mobile and Safari font fix. This file replaces the remote Google Fonts
   dependency. The three UI families are now served locally as variable woff2,
   so iOS Lockdown Mode, Safari content blockers, privacy DNS, and flaky mobile
   networks can no longer leave the page stuck on a degraded fallback font.

   Families:
     Fraunces        editorial display titles (opsz 9..144, wght 100..900,
                     normal and italic)
     Montserrat      body and UI (wght 100..900)
     JetBrains Mono  eyebrows, meta, monospaced labels (wght 100..800)

   Source: fontsource variable packages (SIL Open Font License 1.1).
   See README.md in this folder for exact versions and how to update.

   The fallback faces at the bottom (size-adjust plus the metric overrides)
   are measured from the real font files, so the brief swap from the system
   fallback to the loaded font causes no visible shift (near zero CLS). They
   only change loading behavior, never the visual design.

   Project rule: no em dashes, no en dashes, no spaced hyphen separators.
   ========================================================================== */

/* Google standard subsets. The browser downloads only the range a page uses.
   The "latin" range already covers French (accents, the oe ligature U+0152-0153,
   and the guillemets in U+00AB and U+00BB), so most pages fetch only latin. */

/* ----------------------------------------------------------- MONTSERRAT */
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('montserrat-latin-wght-normal.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+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('montserrat-latin-ext-wght-normal.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;
}

/* ------------------------------------------------------------- FRAUNCES */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('fraunces-latin-opsz-normal.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+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('fraunces-latin-ext-opsz-normal.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: 'Fraunces';
  font-style: italic;
  font-display: swap;
  font-weight: 100 900;
  src: url('fraunces-latin-opsz-italic.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+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

/* --------------------------------------------------------- JETBRAINS MONO */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url('jetbrains-mono-latin-wght-normal.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+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url('jetbrains-mono-latin-ext-wght-normal.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;
}

/* ============================================================================
   METRIC MATCHED FALLBACK FACES
   Measured from the real woff2 files with fontTools. While the variable font
   streams in (now near instant because it is local), the system fallback is
   scaled to occupy the exact same space, so no text reflow is visible.
   local() resolves only where the system font exists (Arial and Georgia ship
   on Windows, macOS, and iOS, which is where the swap is visible). On systems
   without them the face is simply skipped and the next stack entry is used.
   ============================================================================ */
@font-face {
  font-family: 'Montserrat Fallback';
  src: local('Arial');
  size-adjust: 141.37%;
  ascent-override: 68.47%;
  descent-override: 17.76%;
  line-gap-override: 0%;
}
@font-face {
  font-family: 'Fraunces Fallback';
  src: local('Georgia');
  size-adjust: 117.21%;
  ascent-override: 83.44%;
  descent-override: 21.76%;
  line-gap-override: 0%;
}
@font-face {
  font-family: 'JetBrains Mono Fallback';
  src: local('Consolas'), local('Menlo');
  size-adjust: 136.38%;
  ascent-override: 74.79%;
  descent-override: 22.00%;
  line-gap-override: 0%;
}

/* ============================================================================
   FONT TOKEN WIRING
   This only inserts the metric matched fallback into each font stack. The
   primary families and the visual design are unchanged. Loaded after
   design-system.css (declared as a dependency), so this :root wins the cascade.
   ============================================================================ */
:root {
  --pm-font:         'Montserrat', 'Montserrat Fallback', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --pm-font-display: 'Fraunces', 'Fraunces Fallback', 'Times New Roman', Georgia, 'Cormorant Garamond', serif;
  --pm-font-mono:    'JetBrains Mono', 'JetBrains Mono Fallback', ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}
