/* Computer Modern Unicode — full family.
   All faces self-hosted in /static/fonts/ under their canonical filenames.

   Each face is registered as its own font-family so the browser cannot
   substitute or synthesise a variant. Use the CSS variables defined below
   (--serif-i, --serif-b, --serif-bi) to select a face explicitly, and pair
   them with font-style: normal; font-weight: normal so no synthesis occurs.

   License: SIL OFL — Computer Modern Unicode by Andrey V. Panov,
   based on Knuth's Computer Modern. */

/* --- CMU Serif Roman ----------------------------------------------------- */
@font-face {
  font-family: 'CMU Serif';
  src: url('/static/fonts/CMUSerif-Roman.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}

/* --- CMU Serif Italic ---------------------------------------------------- */
@font-face {
  font-family: 'CMU Serif Italic';
  src: url('/static/fonts/CMUSerif-Italic.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}

/* --- CMU Serif Bold ------------------------------------------------------ */
@font-face {
  font-family: 'CMU Serif Bold';
  src: url('/static/fonts/CMUSerif-Bold.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}

/* --- CMU Serif Bold Italic ----------------------------------------------- */
@font-face {
  font-family: 'CMU Serif Bold Italic';
  src: url('/static/fonts/CMUSerif-BoldItalic.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}

/* --- CMU Serif Slanted (oblique, not used by default) -------------------- */
@font-face {
  font-family: 'CMU Serif Slanted';
  src: url('/static/fonts/CMUSerif-RomanSlanted.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'CMU Serif Bold Slanted';
  src: url('/static/fonts/CMUSerif-BoldSlanted.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}

/* --- CMU Serif Upright Italic (cursive forms, upright stance) ------------ */
@font-face {
  font-family: 'CMU Serif Upright Italic';
  src: url('/static/fonts/CMUSerif-UprightItalic.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}

/* --- CMU Sans Serif (display sans) --------------------------------------- */
@font-face {
  font-family: 'CMU Sans Serif';
  src: url('/static/fonts/CMUSansSerif.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'CMU Sans Serif';
  src: url('/static/fonts/CMUSansSerif-Bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'CMU Sans Serif';
  src: url('/static/fonts/CMUSansSerif-Oblique.woff2') format('woff2');
  font-weight: 400; font-style: oblique; font-display: swap;
}
@font-face {
  font-family: 'CMU Sans Serif';
  src: url('/static/fonts/CMUSansSerif-BoldOblique.woff2') format('woff2');
  font-weight: 700; font-style: oblique; font-display: swap;
}
@font-face {
  font-family: 'CMU Sans Serif Condensed';
  src: url('/static/fonts/CMUSansSerif-DemiCondensed.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}

/* --- CMU Typewriter (monospace) ------------------------------------------ */
@font-face {
  font-family: 'CMU Typewriter';
  src: url('/static/fonts/CMUTypewriter-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'CMU Typewriter';
  src: url('/static/fonts/CMUTypewriter-Italic.woff2') format('woff2');
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'CMU Typewriter';
  src: url('/static/fonts/CMUTypewriter-Bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'CMU Typewriter';
  src: url('/static/fonts/CMUTypewriter-BoldItalic.woff2') format('woff2');
  font-weight: 700; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'CMU Typewriter';
  src: url('/static/fonts/CMUTypewriter-Light.woff2') format('woff2');
  font-weight: 300; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'CMU Typewriter';
  src: url('/static/fonts/CMUTypewriter-LightOblique.woff2') format('woff2');
  font-weight: 300; font-style: oblique; font-display: swap;
}
@font-face {
  font-family: 'CMU Typewriter Variable';
  src: url('/static/fonts/CMUTypewriterVariable.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'CMU Typewriter Variable';
  src: url('/static/fonts/CMUTypewriterVariable-Italic.woff2') format('woff2');
  font-weight: 400; font-style: italic; font-display: swap;
}

/* --- CMU Bright (display semi-sans) -------------------------------------- */
@font-face {
  font-family: 'CMU Bright';
  src: url('/static/fonts/CMUBright-Roman.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'CMU Bright';
  src: url('/static/fonts/CMUBright-Oblique.woff2') format('woff2');
  font-weight: 400; font-style: oblique; font-display: swap;
}
@font-face {
  font-family: 'CMU Bright';
  src: url('/static/fonts/CMUBright-SemiBold.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'CMU Bright';
  src: url('/static/fonts/CMUBright-SemiBoldOblique.woff2') format('woff2');
  font-weight: 600; font-style: oblique; font-display: swap;
}

/* --- CMU Concrete (slab) ------------------------------------------------- */
@font-face {
  font-family: 'CMU Concrete';
  src: url('/static/fonts/CMUConcrete-Roman.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'CMU Concrete';
  src: url('/static/fonts/CMUConcrete-Italic.woff2') format('woff2');
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'CMU Concrete';
  src: url('/static/fonts/CMUConcrete-Bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'CMU Concrete';
  src: url('/static/fonts/CMUConcrete-BoldItalic.woff2') format('woff2');
  font-weight: 700; font-style: italic; font-display: swap;
}

/* --- CMU Classical Serif (italic only) ----------------------------------- */
@font-face {
  font-family: 'CMU Classical Serif';
  src: url('/static/fonts/CMUClassicalSerif-Italic.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}

/* --- Font stacks --------------------------------------------------------- */

:root {
  /* Roman body face. */
  --serif:    'CMU Serif', 'Latin Modern Roman', Cambria, 'Times New Roman', serif;
  /* Explicit variant faces — use these directly instead of font-style/weight. */
  --serif-i:  'CMU Serif Italic', 'Latin Modern Roman', Cambria, serif;
  --serif-b:  'CMU Serif Bold', 'Latin Modern Roman', Cambria, serif;
  --serif-bi: 'CMU Serif Bold Italic', 'Latin Modern Roman', Cambria, serif;
  /* Other CMU families. */
  --sans:      'CMU Sans Serif', system-ui, sans-serif;
  --sans-cond: 'CMU Sans Serif Condensed', 'CMU Sans Serif', sans-serif;
  --mono:      'CMU Typewriter', 'CMU Typewriter Variable', Menlo, Consolas, monospace;
  --bright:    'CMU Bright', 'CMU Sans Serif', sans-serif;
  --concrete:  'CMU Concrete', 'CMU Serif', serif;
  --classical: 'CMU Classical Serif', 'CMU Serif Italic', serif;
  /* Small caps use Roman; bold small-caps use Bold Roman. */
  --caps:      'CMU Serif', 'Latin Modern Roman', Cambria, serif;
  --caps-b:    'CMU Serif Bold', 'Latin Modern Roman', Cambria, serif;
}

html { font-family: var(--serif); }

/* Explicit face assignment. font-style and font-weight are reset to their
   normal values so the browser never attempts synthesis on top of the face. */
em, i, .cursiva, address {
  font-family: var(--serif-i); font-style: normal;
}
strong, b {
  font-family: var(--serif-b); font-weight: normal;
}
em strong, strong em, em b, b em {
  font-family: var(--serif-bi); font-style: normal; font-weight: normal;
}
code, pre, kbd, samp, tt {
  font-family: var(--mono);
}

body {
  font-size: 1.0625rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--serif-b);
  font-weight: normal;
  line-height: 1.2;
  margin: 1.4em 0 0.4em;
}
h1 { font-size: 2.0rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }

p { margin: 0 0 1em; text-indent: 0; }
.prose p + p { text-indent: 1.5em; }
.prose p:first-of-type { text-indent: 0; }

/* Opt-in font helpers. */
.cmu-serif          { font-family: var(--serif); }
.cmu-sans           { font-family: var(--sans); }
.cmu-sans-cond      { font-family: var(--sans-cond); }
.cmu-mono           { font-family: var(--mono); }
.cmu-bright         { font-family: var(--bright); }
.cmu-concrete       { font-family: var(--concrete); }
.cmu-classical      { font-family: var(--classical); font-style: normal; }
.cmu-slanted        { font-family: 'CMU Serif Slanted'; font-style: normal; }
.cmu-upright-italic { font-family: 'CMU Serif Upright Italic'; font-style: normal; }

/* Foreign-script tagging. */
/* ---------------------------------------------------------------------------
   Multi-script typography (Phase 4).

   Each family below is self-hosted so the site never depends on Google
   Fonts or any third-party CDN at runtime.  Files land in
   /static/fonts/ via `scripts/fetch_fonts.sh` (which downloads them
   from stable mirrors on first use).  Licences: all OFL / SIL Open Font
   Licence — free for personal and commercial use.
   --------------------------------------------------------------------------- */

/* Polytonic Greek in Teubner style — GFS Didot Classic (Greek Font Society) */
@font-face {
  font-family: 'GFS Didot';
  src: url('/static/fonts/GFSDidot.woff2')  format('woff2'),
       url('/static/fonts/GFSDidot.otf')    format('opentype');
  font-weight: 400; font-style: normal; font-display: swap;
  unicode-range: U+0370-03FF, U+1F00-1FFF, U+0300-036F; /* Greek + polytonic */
}
@font-face {
  font-family: 'GFS Didot';
  src: url('/static/fonts/GFSDidotItalic.woff2') format('woff2'),
       url('/static/fonts/GFSDidotItalic.otf')   format('opentype');
  font-weight: 400; font-style: italic; font-display: swap;
  unicode-range: U+0370-03FF, U+1F00-1FFF, U+0300-036F;
}
@font-face {
  font-family: 'GFS Didot';
  src: url('/static/fonts/GFSDidotBold.woff2') format('woff2'),
       url('/static/fonts/GFSDidotBold.otf')   format('opentype');
  font-weight: 700; font-style: normal; font-display: swap;
  unicode-range: U+0370-03FF, U+1F00-1FFF, U+0300-036F;
}

/* Biblical Hebrew — SBL Hebrew (Society of Biblical Literature) */
@font-face {
  font-family: 'SBL Hebrew';
  src: url('/static/fonts/SBL_Hbrw.woff2') format('woff2'),
       url('/static/fonts/SBL_Hbrw.ttf')   format('truetype');
  font-weight: 400; font-style: normal; font-display: swap;
  unicode-range: U+0590-05FF, U+FB1D-FB4F; /* Hebrew + presentation forms */
}

/* Classical Arabic — Amiri (aliftype), designed for poetry / Naskh */
@font-face {
  font-family: 'Amiri';
  src: url('/static/fonts/Amiri-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: 'Amiri';
  src: url('/static/fonts/Amiri-Italic.woff2') format('woff2');
  font-weight: 400; font-style: italic; font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: 'Amiri';
  src: url('/static/fonts/Amiri-Bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}

/* Sumerian cuneiform — Noto Sans Cuneiform (Google Noto) */
@font-face {
  font-family: 'Noto Sans Cuneiform';
  src: url('/static/fonts/NotoSansCuneiform-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
  unicode-range: U+12000-123FF, U+12400-1247F, U+12480-1254F; /* Sumero-Akkadian */
}

/* Language classes — the `.greek` / `.hebrew` / `.arabic` / `.cuneiform`
   classes emitted by the markup parser now activate the matching family,
   set the proper text direction, and keep a Latin fallback so any
   surrounding punctuation still renders in CMU Serif. */
.greek {
  font-family: 'GFS Didot', var(--serif);
  font-feature-settings: 'kern', 'liga';
}
.hebrew {
  font-family: 'SBL Hebrew', 'Ezra SIL', var(--serif);
  direction: rtl; unicode-bidi: isolate;
  font-feature-settings: 'kern', 'liga', 'ccmp', 'mark';
}
.arabic {
  font-family: 'Amiri', 'Scheherazade New', var(--serif);
  direction: rtl; unicode-bidi: isolate;
  font-feature-settings: 'kern', 'liga', 'calt';
}
.cuneiform {
  font-family: 'Noto Sans Cuneiform', var(--serif);
  font-feature-settings: 'kern';
}
/* Also key off the standard HTML lang attribute so any raw text with a
   proper lang="…" gets the right family even without the manual class. */
:lang(el),  :lang(grc)              { font-family: 'GFS Didot', var(--serif); }
:lang(he),  :lang(hbo)              { font-family: 'SBL Hebrew', var(--serif); direction: rtl; unicode-bidi: isolate; }
:lang(ar)                           { font-family: 'Amiri', var(--serif); direction: rtl; unicode-bidi: isolate; }
:lang(sux)                          { font-family: 'Noto Sans Cuneiform', var(--serif); }
