﻿/* Novela.Web/wwwroot/css/reading-comfort.css
   ───────────────────────────────────────────────
   Reading comfort: two fonts that are easier to read, and letter / word spacing.
   Kept in its own file rather than in reader.css.

   The fonts are free (SIL Open Font License) and come with Novela, so they work offline.
   Their files are added with LibMan (libman.json) into wwwroot/lib/fonts/:
     Atkinson Hyperlegible — by the Braille Institute: letters that can't be mistaken for each
       other (I l 1, O 0, b d p q), for low vision and dyslexia.
       (Either fontsource's files in atkinson-hyperlegible/files/, or the four .ttf files from
       Google Fonts straight in atkinson-hyperlegible/ — both are looked for.)
     OpenDyslexic — heavier at the bottom of each letter, so letters don't seem to flip or swim.
       (Either its web files in opendyslexic/woff/, or the .otf files from opendyslexic.org
       straight in opendyslexic/ — both are looked for.)
   If Windows already has a font with that name installed, that one is used.
   ─────────────────────────────────────────────── */

@font-face {
    font-family: "Atkinson Hyperlegible";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: local("Atkinson Hyperlegible"), local("AtkinsonHyperlegible-Regular"),
         url("../lib/fonts/atkinson-hyperlegible/files/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"),
         url("../lib/fonts/atkinson-hyperlegible/AtkinsonHyperlegible-Regular.ttf") format("truetype");
}

@font-face {
    font-family: "Atkinson Hyperlegible";
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: local("Atkinson Hyperlegible Italic"), local("AtkinsonHyperlegible-Italic"),
         url("../lib/fonts/atkinson-hyperlegible/files/atkinson-hyperlegible-latin-400-italic.woff2") format("woff2"),
         url("../lib/fonts/atkinson-hyperlegible/AtkinsonHyperlegible-Italic.ttf") format("truetype");
}

@font-face {
    font-family: "Atkinson Hyperlegible";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: local("Atkinson Hyperlegible Bold"), local("AtkinsonHyperlegible-Bold"),
         url("../lib/fonts/atkinson-hyperlegible/files/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2"),
         url("../lib/fonts/atkinson-hyperlegible/AtkinsonHyperlegible-Bold.ttf") format("truetype");
}

@font-face {
    font-family: "Atkinson Hyperlegible";
    font-style: italic;
    font-weight: 700;
    font-display: swap;
    src: local("Atkinson Hyperlegible Bold Italic"), local("AtkinsonHyperlegible-BoldItalic"),
         url("../lib/fonts/atkinson-hyperlegible/files/atkinson-hyperlegible-latin-700-italic.woff2") format("woff2"),
         url("../lib/fonts/atkinson-hyperlegible/AtkinsonHyperlegible-BoldItalic.ttf") format("truetype");
}

@font-face {
    font-family: "OpenDyslexic";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: local("OpenDyslexic"), local("OpenDyslexic-Regular"),
         url("../lib/fonts/opendyslexic/woff/OpenDyslexic-Regular.woff") format("woff"),
         url("../lib/fonts/opendyslexic/OpenDyslexic-Regular.otf") format("opentype");
}

@font-face {
    font-family: "OpenDyslexic";
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: local("OpenDyslexic Italic"), local("OpenDyslexic-Italic"),
         url("../lib/fonts/opendyslexic/woff/OpenDyslexic-Italic.woff") format("woff"),
         url("../lib/fonts/opendyslexic/OpenDyslexic-Italic.otf") format("opentype");
}

@font-face {
    font-family: "OpenDyslexic";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: local("OpenDyslexic Bold"), local("OpenDyslexic-Bold"),
         url("../lib/fonts/opendyslexic/woff/OpenDyslexic-Bold.woff") format("woff"),
         url("../lib/fonts/opendyslexic/OpenDyslexic-Bold.otf") format("opentype");
}

@font-face {
    font-family: "OpenDyslexic";
    font-style: italic;
    font-weight: 700;
    font-display: swap;
    src: local("OpenDyslexic Bold Italic"), local("OpenDyslexic-BoldItalic"),
         url("../lib/fonts/opendyslexic/woff/OpenDyslexic-BoldItalic.woff") format("woff"),
         url("../lib/fonts/opendyslexic/OpenDyslexic-BoldItalic.otf") format("opentype");
}

/* Letter and word spacing (Settings → Beautiful → Letter / Word spacing), for every book.
   Only switched on when one of them is above 0, so a book's own spacing is untouched otherwise. */
body.custom-spacing .chapter-content :is(p, li, blockquote, dd, dt, td, th, figcaption, div, span, a, em, i, b, strong, cite, small) {
    letter-spacing: var(--nv-letters, 0);
    word-spacing: var(--nv-words, 0);
}

/* The two reading-comfort fonts in books shown in their own look too (not just Beautiful):
   reader.js sets body.access-font when Atkinson Hyperlegible or OpenDyslexic is chosen.
   They're for comfort and access, so they work in Novela Free as well as Plus. */
body.access-font .chapter-content:not(.nv-beautiful) :is(p, li, blockquote, dd, dt, td, th, figcaption, div, span, a, em, i, b, strong, cite, small, h1, h2, h3, h4, h5, h6) {
    font-family: var(--nv-font) !important;
}
