/*
 * Sikai — the typefaces, self-hosted.
 *
 * Not loaded from Google Fonts, even though that is what the design project
 * does. spec/requests/learn/theme_spec.rb asserts that a student page
 * requests nothing from an external host, and it is right to: a child on
 * 2G in a load-shedding hour cannot afford a DNS lookup, a TLS handshake
 * and a render-blocking round trip to fonts.googleapis.com before any text
 * appears -- and if that host is slow or blocked, the page is blank rather
 * than merely unstyled.
 *
 * THREE FAMILIES, AND EACH SURFACE USES EXACTLY ONE OF THEM:
 *
 *   Manrope  -- /teach, /school, /sa, /admin, /parents
 *   Dosis    -- every screen a child sees, /join included
 *   Baloo 2  -- the signed-out public pages, / and /for-parents
 *
 * A fourth, IBM Plex Mono, is GONE -- files, faces and token. It used to set
 * every figure and micro-label on all three surfaces beside the family that
 * set the words, so each screen carried two faces. What it bought was
 * columns of numbers that line up, which is a real thing to lose: a
 * monospace does that by construction. Manrope's surfaces get it back from
 * `font-variant-numeric: tabular-nums` (Manrope ships `tnum` -- see the
 * rules at the foot of parents.css, staff.css and admin.css). Dosis does
 * NOT ship tnum and cannot, so the children's screens size or centre their
 * number boxes instead; --s-font in student.css spells out the trap.
 *
 * Read that before adding a monospace back.
 *
 * Manrope ships as one variable file covering 500-800, so the four weights
 * the design uses cost one request rather than four; Dosis does the same for
 * 400-800, and Baloo 2 for 400-800. No surface asks for a weight outside the
 * range its own face declares -- a face declared 500-800 under a stylesheet
 * asking for 400 does not fail loudly, it synthesises.
 *
 * Baloo 2 is declared TWICE, in two subsets, and the split is the whole
 * point of it:
 *
 *   - Devanagari (113 KB), scoped by unicode-range to the Devanagari block.
 *     A browser DOES NOT FETCH a face whose unicode-range no character on
 *     the page falls into, so while the interface is English-only this costs
 *     a child nothing -- and the day the language phase lands, Nepali
 *     arrives with no further change here. That conditional fetch is the
 *     whole reason a file this size is acceptable beside the Latin faces,
 *     of which no single page loads more than one.
 *
 *   - Latin (32 KB), fetched unconditionally, because the public landing
 *     pages are set ENTIRELY in it -- headlines, body, labels and figures,
 *     one family and no other (see the type note in landing.css). It is the
 *     SAME family the Devanagari half carries, so the day / and
 *     /for-parents are translated the Nepali is the same typeface as the
 *     English rather than a fallback that happens to have the glyphs.
 *
 *     This makes the public pages CHEAPER, not dearer: they used to pull
 *     Manrope plus two IBM Plex Mono weights and now pull this one file
 *     instead. No student screen loads it at all -- Dosis covers the same
 *     range and wins the stack there (spec/requests/learn/theme_spec.rb).
 *
 * The two are declared Devanagari-first, and under DIFFERENT family names --
 * see the long note above the Latin one, which is the only thing keeping its
 * 32 KB off a child's connection. spec/assets/font_delivery_spec.rb asserts
 * on each by its range rather than by which comes first, so the order is
 * documentation rather than load-bearing.
 *
 * All three families are SIL Open Font License 1.1. Files fetched from Google
 * Fonts' own CDN (fonts.gstatic.com), unmodified.
 *
 * @font-face is deliberately unscoped -- unlike every other rule in this
 * directory, it declares a family rather than styling an element, so it
 * cannot leak into the admin the way a bare `.card` would.
 */

@font-face {
  font-family: "Dosis";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/assets/dosis-latin-variable-5fd173f3.woff2") format("woff2");
  /* Google's own `latin` subset range, copied unmodified from the CSS that
     serves this exact file. */
  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: "Baloo 2";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/assets/baloo2-devanagari-variable-fefb18e8.woff2") format("woff2");
  /* Google's own `devanagari` subset range, copied unmodified. This is the
     line that keeps the file off a child's connection until there is Nepali
     on the screen to need it -- narrowing or dropping it would start sending
     113 KB to every child for text that does not exist yet. U+200C-200D are
     the zero-width joiners Devanagari conjuncts depend on; without them
     आधा-अक्षर break. */
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+20F0,
                 U+25CC, U+A830-A839, U+A8E0-A8FF, U+11B00-11B09;
}

/* "Baloo 2 Latin", NOT "Baloo 2", and the different family name is the whole
   point of this block rather than a naming preference.
 *
 * Declared as "Baloo 2" it was a second face of the SAME family as the
 * Devanagari one above, covering U+0000-00FF and U+2000-206F. The children's
 * stack is `Dosis, "Baloo 2", ui-sans-serif` -- Baloo 2 is there so Nepali
 * has a chosen face -- so naming this file "Baloo 2" silently added it to
 * every child's font stack for Latin as well.
 *
 * That is not theoretical and it is not free. A `unicode-range` says which
 * codepoints a face is FOR, not which glyphs its file actually contains, and
 * U+2192 (the rightwards arrow "→", used on the continue card, the PIN-slip
 * link and half the student buttons) is inside the range every one of these
 * faces declares and inside none of their files. So the browser tried Dosis,
 * found no glyph, and went to the next family declaring that range -- and
 * downloaded 32 KB of Baloo 2 to look for an arrow that is not in there
 * either, before falling through to a system face to actually draw it.
 * 32 KB, on a low-end Android on 3G, for nothing.
 *
 * Under its own family name it can only be reached by a stack that asks for
 * it by that name, which is landing.css and nothing else. The children's
 * "Baloo 2" now resolves to the Devanagari face alone, whose range excludes
 * Latin, so the arrow falls straight to the system font with no request --
 * which is exactly what happened before this file existed.
 *
 * spec/assets/font_delivery_spec.rb fails if any two faces sharing a family
 * name ever declare overlapping ranges again. */
@font-face {
  font-family: "Baloo 2 Latin";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/assets/baloo2-latin-variable-e3251557.woff2") format("woff2");
  /* Google's own `latin` subset range, copied unmodified from the CSS that
     serves this exact file. Unlike the Devanagari half above, this one is
     meant to load: it is the landing pages' only face. */
  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: "Manrope";
  font-style: normal;
  font-weight: 500 800;
  font-display: swap;
  src: url("/assets/manrope-latin-variable-822bc47d.woff2") format("woff2");
  /* Latin, punctuation and the Devanagari-adjacent marks the interface needs
     for names. A pack's own Nepali content is not covered and is not meant to
     be -- see the ROADMAP's language phase. */
  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;
}

