/* ============================================================
   THE BRAND TYPEFACES, SERVED FROM THIS SERVER
   ============================================================
   Syne for display, DM Sans for text.

   Not a new choice. questionnaire/assets/q.css has used exactly this pair
   since September, pulled from Google Fonts by a <link> in
   questionnaire/index.php. The rest of the site stayed on 'Segoe UI', which
   is not a typeface the site owns: it is whatever the visitor's computer
   happens to have, so the pages looked like Windows on Windows, like macOS on
   a Mac, and like nothing in particular on a phone. This finishes the
   decision that was already made rather than making a second one.

   Self-hosted, and that is the point as much as the faces are.

     - No third party is asked for anything. fonts.googleapis.com is a
       stylesheet request and fonts.gstatic.com is a font request, both to a
       server this site does not control, both carrying the visitor's IP and
       the page they are on.
     - Browsers stopped sharing a cross-site font cache years ago, so the
       old argument that "everyone already has it" is no longer true. The
       first visit paid for a DNS lookup, a TCP connection and a TLS
       handshake to a new host before the font could even be requested.
     - These files sit on the same connection as everything else, which on
       this host is worth more than usual: the TLS handshake to
       merikagency.com is eight seconds, measured, so one fewer host to
       greet is one fewer eight-second greeting.

   Variable fonts, one file per family.

   DM Sans carries weights 100 to 1000 and Syne 400 to 800 in a single file
   each, so every weight the site uses costs nothing beyond the first. Six
   static cuts would have been six downloads.

   Both are SIL Open Font License 1.1. The licence requires the text to
   travel with the files, so it does: assets/fonts/OFL-DMSans.txt and
   assets/fonts/OFL-Syne.txt.

   WHAT GETS DOWNLOADED, AND WHEN

   A browser fetches a @font-face only when text on the page actually matches
   it. That is what the unicode-range and font-style splits below are for:

     dmsans-latin.woff2            61 KB   every page
     syne-latin.woff2              34 KB   every page
     dmsans-latin-ext.woff2        31 KB   only if an accented character appears
     dmsans-italic-latin.woff2     74 KB   only if something is in italics
     dmsans-italic-latin-ext.woff2 40 KB   both of the above at once
     syne-latin-ext.woff2          14 KB   only if a heading has an accent

   So an ordinary English page pays 95 KB, once, and never again: these are
   fingerprint-free filenames under a long cache, and they are the only two
   files that load on a normal visit.
   ============================================================ */

/* font-display: swap, deliberately.

   The alternatives are worse here. The default, 'auto', behaves like 'block'
   in every browser that matters: the text is INVISIBLE for up to three
   seconds while the font loads, and on a host whose handshake alone is eight
   seconds that is a blank page with a working connection behind it. 'swap'
   draws the fallback immediately and replaces it when the real face arrives.

   The cost of swap is a reflow when the swap happens. It is paid once per
   visitor, on the first page only, and the fallbacks below are chosen to keep
   it small. */

/* ── DM Sans, upright ───────────────────────────────────────────────────── */
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 100 1000;
  font-display: swap;
  src: url('../fonts/dmsans-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: 'DM Sans';
  font-style: normal;
  font-weight: 100 1000;
  font-display: swap;
  src: url('../fonts/dmsans-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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ── DM Sans, italic ────────────────────────────────────────────────────── */
/* A real italic rather than letting the browser lean the upright over. A
   synthesised oblique is a shear transform: the curves keep their upright
   shape and the result looks like a mistake at display sizes. Nothing is
   downloaded unless the page has italic text on it. */
@font-face {
  font-family: 'DM Sans';
  font-style: italic;
  font-weight: 100 1000;
  font-display: swap;
  src: url('../fonts/dmsans-italic-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: 'DM Sans';
  font-style: italic;
  font-weight: 100 1000;
  font-display: swap;
  src: url('../fonts/dmsans-italic-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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ── Syne, display only ─────────────────────────────────────────────────── */
/* Headings, labels and the brand lockup. Syne is wide and high-contrast,
   which is what makes it work as a display face and what makes it a poor one
   for paragraphs, so it is never set as the body family. */
@font-face {
  font-family: 'Syne';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../fonts/syne-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: 'Syne';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../fonts/syne-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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ── The two names the rest of the site asks for ────────────────────────── */
/*
   Every stylesheet already reads var(--font-body) and var(--font-display).
   Both were 'Segoe UI', system-ui, sans-serif, which is why the site had no
   typography of its own: the display face and the body face were the same
   face at two weights.

   The same pair is now written into style.css, app.css and auth.css, which is
   where a reader looking for the site's fonts would go first. These copies
   are for the handful of pages that load this file and none of those three:
   account.php, ticket.php, 404.php, maintenance.php, suspended_notice.php,
   unsubscribe.php and the questionnaire, each of which carries its own
   stylesheet in the page.

   No !important. All four definitions are identical, so whichever one wins is
   the right answer, and the day somebody wants a different face on one page
   they can set it in that page's own stylesheet and have it work.

   The fallback behind each is the OLD value, on purpose. Those are the
   metrics the layout was built against, so during the swap, and permanently
   on a browser that cannot load a woff2, the page looks like it did before
   rather than dropping to Times New Roman.

   The admin panel is deliberately left out. admin/css/admin-style.css still
   says 'Segoe UI' and no admin page loads this file: an internal tool is
   better off with the font that is already on the machine than with 95 KB it
   has to wait for.
*/
:root {
  --font-display: 'Syne', 'Segoe UI', system-ui, sans-serif;
  --font-body:    'DM Sans', 'Segoe UI', system-ui, sans-serif;
}

/* Keep the real shapes.

   DM Sans ships proper small-caps-free figures and a single-storey 'a' that
   both depend on the font's own kerning and ligature tables. Some resets in
   this project turn ligatures off wholesale to stop 'fi' breaking in a
   monospace block; this puts them back for text, and leaves code alone. */
body {
  font-feature-settings: 'kern' 1, 'liga' 1;
  text-rendering: optimizeLegibility;
}
code, pre, kbd, samp, .mono, .code, [class*="codemirror"] {
  font-feature-settings: normal;
  text-rendering: auto;
}
