/**
 * Confort de lecture : réglages du panneau « Affichage », communs à tous les thèmes enfants
 * (voir functions/components/reading-preferences.php).
 * Chaque réglage actif est listé dans l'attribut data-reading de <html>. Les styles des thèmes fixent
 * police et interlignage à de nombreux endroits : les réglages les remplacent donc avec !important,
 * comme le ferait une feuille de style utilisateur (critère RGAA 10.12, WCAG 1.4.12).
 * La barre d'administration WordPress n'est pas concernée.
 */

@font-face {
	font-family: "OpenDyslexic";
	font-style: normal;
	font-weight: 400;
	font-display: swap;
	src: url("../fonts/OpenDyslexic-400-normal.woff2") format("woff2");
}

@font-face {
	font-family: "OpenDyslexic";
	font-style: italic;
	font-weight: 400;
	font-display: swap;
	src: url("../fonts/OpenDyslexic-400-italic.woff2") format("woff2");
}

@font-face {
	font-family: "OpenDyslexic";
	font-style: normal;
	font-weight: 700;
	font-display: swap;
	src: url("../fonts/OpenDyslexic-700-normal.woff2") format("woff2");
}

@font-face {
	font-family: "OpenDyslexic";
	font-style: italic;
	font-weight: 700;
	font-display: swap;
	src: url("../fonts/OpenDyslexic-700-italic.woff2") format("woff2");
}

/* Police adaptée à la dyslexie (le code garde une police à chasse fixe) */
:root[data-reading~="dyslexic-font"] body :not(#wpadminbar, #wpadminbar *, code, kbd, pre, samp) {
	font-family: "OpenDyslexic", sans-serif !important;
}

/* Interlignage augmenté, plus resserré sur les titres pour qu'ils restent lisibles d'un bloc */
:root[data-reading~="line-height"] body :not(#wpadminbar, #wpadminbar *) {
	line-height: 2 !important;
}

:root[data-reading~="line-height"] body :is(h1, h2, h3, h4, h5, h6, h1 *, h2 *, h3 *, h4 *, h5 *, h6 *) {
	line-height: 1.5 !important;
}

/* Lettres et mots espacés (valeurs du critère WCAG 1.4.12) */
:root[data-reading~="spacing"] body :not(#wpadminbar, #wpadminbar *) {
	letter-spacing: 0.12em !important;
	word-spacing: 0.16em !important;
}

/* Texte non justifié : seuls les textes justifiés par les contributeurs sont concernés */
:root[data-reading~="no-justify"] body :is([style*="text-align: justify"], [style*="text-align:justify"], .has-text-align-justify) {
	text-align: start !important;
}

/* Liens soulignés, y compris dans les menus, boutons et cartes */
:root[data-reading~="underline-links"] body a:not(#wpadminbar a) {
	text-decoration-line: underline !important;
	text-decoration-thickness: max(1px, 0.0625em) !important;
	text-underline-offset: 0.15em !important;
}

/* Police adaptée et espacement élargissent les mots : un mot long (nom de la commune en grand titre, adresse e-mail,
   lien) peut alors être coupé plutôt que de faire défiler la page à l'horizontale (critère RGAA 10.11, WCAG 1.4.10) */
:root:is([data-reading~="dyslexic-font"], [data-reading~="spacing"]) body :not(#wpadminbar, #wpadminbar *) {
	overflow-wrap: anywhere;
}

/* Un champ de saisie garde sinon la largeur de ses 20 caractères par défaut, élargis par la police : il prend la
   largeur disponible, à côté de son bouton s'il en a un */
:root:is([data-reading~="dyslexic-font"], [data-reading~="spacing"]) body :is(input:not([type="checkbox"], [type="radio"], [type="submit"], [type="button"], [type="hidden"]), select, textarea):not(#wpadminbar *) {
	width: 100%;
	min-width: 0;
	max-width: 100%;
}

/* Textes gardés sur une ligne par les thèmes (format et poids d'un document, plage horaire, tarif d'une salle) : ils passent à la
   ligne quand la police ou l'espacement les élargissent */
:root:is([data-reading~="dyslexic-font"], [data-reading~="spacing"]) body :is(.publication-file, .horaires-slot, .reservation-tarifs-cartes dd) {
	white-space: normal !important;
}
