/**
 * StayNomad self-hosted webfonts.
 *
 * Self-hosted rather than Google-CDN linked: removes a third-party connection
 * on the critical path, avoids the privacy/consent question in the EU, and
 * lets the hero headline preload (see staynomad_preload_fonts()).
 *
 * font-display: swap keeps text visible during load. The fallback stacks in
 * tokens.css are metric-adjusted below so the swap does not reflow the page.
 *
 * Place the .woff2 files in assets/fonts/. Filenames are contractual —
 * functions.php preloads the two 400-weight faces by exact name.
 *
 * @see docs/DESIGN-SYSTEM.md
 */

/* --- Cormorant Garamond — display / editorial ------------------------ */

@font-face {
  font-family: 'Cormorant Garamond';
  src: url('../fonts/cormorant-garamond-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F,
    U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}

@font-face {
  font-family: 'Cormorant Garamond';
  src: url('../fonts/cormorant-garamond-400-italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'Cormorant Garamond';
  src: url('../fonts/cormorant-garamond-600.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* --- DM Sans — body / UI --------------------------------------------- */

@font-face {
  font-family: 'DM Sans';
  src: url('../fonts/dm-sans-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F,
    U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}

@font-face {
  font-family: 'DM Sans';
  src: url('../fonts/dm-sans-500.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'DM Sans';
  src: url('../fonts/dm-sans-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/**
 * Metric-adjusted fallbacks.
 *
 * Without these, the swap from Georgia to Cormorant visibly jumps the hero
 * headline — Cormorant is a notably narrow, small-x-height face. These
 * descriptors squeeze the fallback to match, so the swap is near-invisible
 * and cumulative layout shift stays at zero.
 */

@font-face {
  font-family: 'Cormorant Fallback';
  src: local('Georgia'), local('Times New Roman');
  size-adjust: 88%;
  ascent-override: 95%;
  descent-override: 26%;
  line-gap-override: 0%;
}

@font-face {
  font-family: 'DM Sans Fallback';
  src: local('Segoe UI'), local('Helvetica Neue'), local('Arial');
  size-adjust: 97%;
  ascent-override: 100%;
  descent-override: 24%;
  line-gap-override: 0%;
}

/**
 * Insert the adjusted fallbacks ahead of the generic stacks defined in
 * tokens.css. Redefining the token here keeps tokens.css authoritative for
 * the families themselves while fonts.css owns loading concerns.
 */
:root {
  --sn-font-display: 'Cormorant Garamond', 'Cormorant Fallback', 'Iowan Old Style',
    Georgia, serif;
  --sn-font-body: 'DM Sans', 'DM Sans Fallback', -apple-system,
    BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
