/* ==========================================================================
   osler-theme — self-hosted webfonts
   --------------------------------------------------------------------------
   Goes at osler/static/theme/fonts.css, loaded from base.html BEFORE
   tokens.css so the faces exist by the time the token stacks name them:

     <link rel="stylesheet" href=".../theme/fonts.css">
     <link rel="stylesheet" href=".../theme/tokens.css">
     <link rel="stylesheet" href=".../theme/components.css">

   ---- no third-party font host, deliberately --------------------------

   Every face is served from this application's own static path. Not a
   preference — three reasons, in order of how much they matter here:

     1. The projector runs in seminar rooms and lecture theatres on hospital
        wifi. A font that arrives late is a slide that reflows in front of a
        room; a font that does not arrive is a fallback nobody chose. The
        artefact ladders and the one-screen presenter constraint were tuned
        against known metrics.
     2. A font request to a third party is a request that carries a referrer
        and an IP from a clinical teaching session to a company that is not
        us. There is no consent story for that and no need for one.
     3. It removes a runtime dependency from a tool whose whole governance
        posture is about knowing where things came from.

   ---- licences ----------------------------------------------------------

   All three are SIL Open Font License 1.1, which permits bundling and
   redistribution with the application:

     IBM Plex Sans, IBM Plex Mono
       Copyright © 2017 IBM Corp., Reserved Font Name "Plex". OFL 1.1.
       Source: github.com/IBM/plex releases.

     Libre Caslon Text
       Copyright © 2012 Pablo Impallari, Rodrigo Fuenzalida,
       Reserved Font Name "Libre Caslon". OFL 1.1.
       Source: github.com/impallari/Libre-Caslon-Text.

   OFL 1.1 requires the licence text to travel with the fonts. Ship
   theme/fonts/OFL-Plex.txt and theme/fonts/OFL-LibreCaslon.txt alongside
   the woff2 files; that is the whole obligation.

   ---- the slashed zero, and why it is a CSS feature and not a build ----

   IBM Plex ships a slashed zero as an OpenType feature, reachable as either
   `zero` or `ss03`. It is NOT the default glyph, which is why --mono-features
   exists and why components.css has to apply it — the token alone does
   nothing.

   The alternative is baking it in with a feature-freezing tool so it needs no
   CSS. Do not: that produces a Modified Version, and OFL 1.1's Reserved Font
   Name clause then forbids shipping it as "IBM Plex Mono". A renamed fork of
   a clinical tool's join-code font is a maintenance liability for no gain.

   VERIFY ON THE ACTUAL FILE before trusting the join code, because a
   subsetted or re-generated woff2 can lose GSUB features:

     from fontTools.ttLib import TTFont
     f = TTFont("IBMPlexMono-Regular.woff2")
     print(sorted({r.FeatureTag for r in f["GSUB"].table.FeatureList.FeatureRecord}))

   `zero` must appear in that list. If it does not, the slashed zero is not
   available and the decision behind --mono-features has to be revisited —
   the fallbacks are `ss03` on the same file, or accepting Plex's plain zero
   and keeping a disambiguated face for join codes only. Say which, rather
   than shipping a feature flag that silently does nothing.

   ---- weights ----------------------------------------------------------

   400 / 500 / 600 only. --weight-medium is 500 and --weight-bold is 600;
   nothing asks for 700 in the sans, and every weight shipped is a file the
   room downloads. Libre Caslon Text has no 500 — it ships 400, 400 italic
   and 700 — so the display face uses 400 for headings and 700 where a
   genuine bold is called for.
   ========================================================================== */

/* ---- display: Libre Caslon Text ---------------------------------------- */
/* local() first throughout: if the machine already has the face, the room
   downloads nothing. */
@font-face {
  font-family: "Libre Caslon Text";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: local("Libre Caslon Text"),
       url("fonts/LibreCaslonText-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Libre Caslon Text";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  /* The login quotation is the only italic in the product. It is one file and
     it is the sentence the whole page is built around. */
  src: local("Libre Caslon Text Italic"),
       url("fonts/LibreCaslonText-Italic.woff2") format("woff2");
}
@font-face {
  font-family: "Libre Caslon Text";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: local("Libre Caslon Text Bold"),
       url("fonts/LibreCaslonText-Bold.woff2") format("woff2");
}

/* ---- UI: IBM Plex Sans -------------------------------------------------- */
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: local("IBM Plex Sans"),
       url("fonts/IBMPlexSans-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: local("IBM Plex Sans Medium"),
       url("fonts/IBMPlexSans-Medium.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: local("IBM Plex Sans SemiBold"),
       url("fonts/IBMPlexSans-SemiBold.woff2") format("woff2");
}

/* ---- machine output: IBM Plex Mono -------------------------------------- */
/* Join codes, timers, counts, measurements. The face whose `zero` feature the
   check above verifies. */
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: local("IBM Plex Mono"),
       url("fonts/IBMPlexMono-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: local("IBM Plex Mono Medium"),
       url("fonts/IBMPlexMono-Medium.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: local("IBM Plex Mono SemiBold"),
       url("fonts/IBMPlexMono-SemiBold.woff2") format("woff2");
}

/* ---- what is NOT declared here ------------------------------------------
   --font-machine. The artefacts' lettering stays on the platform monospace
   stack (ui-monospace / SF Mono / Menlo / Consolas) and the export flavours
   name "DejaVu Sans Mono" explicitly. Shipping a webfont for the ECG headers
   and the analyser printout would make the restyle reach into the frozen
   objects through the back door — and it would mean a slide's artefact could
   render in a different face from the same artefact exported to PNG.

   Nine files, ~9 preloads' worth of bytes if all miss local(). Preload only
   the two the first paint actually needs:

     <link rel="preload" as="font" type="font/woff2" crossorigin
           href=".../theme/fonts/IBMPlexSans-Regular.woff2">
     <link rel="preload" as="font" type="font/woff2" crossorigin
           href=".../theme/fonts/LibreCaslonText-Regular.woff2">
   ========================================================================== */
