/*
 * core/post-content — la lecture d'un article.
 * Chargé par wp_enqueue_block_style() seulement si le bloc est sur la page.
 * Règle : aucune valeur littérale de couleur, de taille ni de famille ; des tokens.
 *
 * Ces règles visent aussi le HTML BRUT : beaucoup d'articles n'ont pas été
 * écrits en blocs (contenus importés, publiés par une API, repris d'un ancien
 * thème). Un `<h2>` nu doit se lire aussi bien qu'un `core/heading`. D'où des
 * sélecteurs sur les éléments, sous `.wp-block-post-content`, et jamais sur les
 * classes de blocs seules.
 *
 * Le socle pose la LISIBILITÉ : corps, interligne, rythme vertical, listes,
 * figures. L'ornement des titres appartient à la variation de style (voir
 * styles/arcade.json → core/post-content → css) : un filet néon n'a rien à faire
 * dans un guide éditorial en serif.
 */

/*
 * La colonne de lecture d'un article est un peu plus large que celle d'une page :
 * au corps lg, 46rem ne donnait que 52 caractères par ligne — une lecture hachée,
 * et des marges latérales qui paraissaient vides. 50rem en donne une soixantaine.
 * On surcharge la variable du cœur sur tout le <main> de l'article, pour que
 * l'en-tête, le texte et le bas d'article restent alignés sur le même bord.
 */
.single main:has(.wp-block-post-content) {
	--wp--style--global--content-size: 50rem;
}

/* Le corps : un cran au-dessus du texte courant, et de l'air entre les lignes. */
.wp-block-post-content {
	font-size: var(--wp--preset--font-size--lg);
	line-height: 1.75;
}

/*
 * Le rythme vertical : un paragraphe est séparé du suivant par une vraie ligne
 * blanche, et un intertitre respire deux fois plus avant qu'après — il appartient
 * à ce qui le suit, pas à ce qui le précède.
 */
.wp-block-post-content > :where(p, ul, ol, blockquote, figure, table, .wp-block-image) {
	margin-block-start: var(--wp--preset--spacing--40);
	margin-block-end: 0;
}

.wp-block-post-content > :where(h2, h3) {
	text-align: start;
}

.wp-block-post-content > h2 {
	margin-block-start: var(--wp--preset--spacing--60);
	margin-block-end: 0;
}

.wp-block-post-content > h3 {
	margin-block-start: var(--wp--preset--spacing--50);
	margin-block-end: 0;
}

.wp-block-post-content > :where(h2, h3) + * {
	margin-block-start: var(--wp--preset--spacing--30);
}

/*
 * L'attaque : le premier paragraphe, un cran plus grand et à pleine couleur.
 * Il tient lieu de chapô quand l'article n'en a pas de saisi — le gabarit ne
 * répète alors plus le début du texte au-dessus de lui (voir inc/single.php).
 */
.wp-block-post-content > p:first-child {
	font-size: var(--wp--preset--font-size--xl);
	line-height: 1.55;
	color: var(--wp--preset--color--contrast);
}

/* Le gras : surligné plutôt qu'alourdi, à la couleur primaire de l'ambiance. */
.wp-block-post-content :where(p, li) strong {
	background-image: linear-gradient(
		transparent 62%,
		color-mix(in srgb, var(--wp--preset--color--primary) 32%, transparent) 62%
	);
	color: var(--wp--preset--color--contrast);
}

/* Les liens du texte : soulignés, décalés, épaissis au survol. */
.wp-block-post-content :where(p, li) a {
	text-underline-offset: 0.2em;
	text-decoration-thickness: 0.08em;
}

.wp-block-post-content :where(p, li) a:hover {
	text-decoration-thickness: 0.16em;
}

/* Listes à puces : des puces pleines, à la couleur primaire. */
.wp-block-post-content > ul,
.wp-block-post-content > .gaia-en-bref > ul {
	padding-inline-start: var(--wp--preset--spacing--50);
	margin-inline-start: var(--wp--preset--spacing--20);
}

.wp-block-post-content > ul > li::marker,
.wp-block-post-content > .gaia-en-bref > ul > li::marker {
	color: var(--wp--preset--color--primary);
}

/* Listes numérotées : le numéro dans une pastille. */
.wp-block-post-content > ol,
.wp-block-post-content > .gaia-en-bref > ol {
	list-style: none;
	padding-inline-start: 0;
	counter-reset: gaia-liste;
}

.wp-block-post-content > ol > li,
.wp-block-post-content > .gaia-en-bref > ol > li {
	position: relative;
	padding-inline-start: calc(var(--wp--preset--spacing--40) + var(--wp--preset--spacing--20));
	counter-increment: gaia-liste;
}

.wp-block-post-content > ol > li::before,
.wp-block-post-content > .gaia-en-bref > ol > li::before {
	content: counter(gaia-liste);
	position: absolute;
	inset-inline-start: 0;
	top: 0.4rem;
	display: grid;
	place-items: center;
	width: 1.6em;
	height: 1.6em;
	border-radius: var(--wp--custom--radius--pill);
	background-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--base);
	font-size: var(--wp--preset--font-size--xs);
	font-weight: 700;
	line-height: 1;
}

.wp-block-post-content > :where(ul, ol) > li + li,
.wp-block-post-content > .gaia-en-bref > :where(ul, ol) > li + li {
	margin-block-start: var(--wp--preset--spacing--20);
}

/* Figures : l'image déborde un peu de la colonne de lecture, arrondie, légendée. */
.wp-block-post-content > figure,
.wp-block-post-content > .wp-block-image {
	margin-block: var(--wp--preset--spacing--50);
}

.wp-block-post-content figure img {
	display: block;
	width: 100%;
	height: auto;
	border-radius: var(--wp--custom--radius--lg);
}

.wp-block-post-content figcaption {
	margin-block-start: var(--wp--preset--spacing--20);
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--sm);
	line-height: 1.5;
	text-align: center;
}

/*
 * « En bref » : la synthèse qui clôt la plupart des articles, dans un encadré.
 * La classe est posée par le contenu (un <div class="gaia-en-bref"> autour du
 * titre et de sa liste) : le style ne devine rien, il habille ce qu'on lui
 * désigne.
 */
.wp-block-post-content > .gaia-en-bref {
	margin-block-start: var(--wp--preset--spacing--60);
	padding: var(--wp--preset--spacing--50);
	border: var(--wp--custom--rule--hairline) solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--lg);
	background-color: var(--wp--preset--color--surface);
}

.wp-block-post-content > .gaia-en-bref > :first-child {
	margin-block-start: 0;
}

.wp-block-post-content > .gaia-en-bref > * + * {
	margin-block-start: var(--wp--preset--spacing--30);
}

/*
 * Tableaux : alignés à gauche sur la colonne de lecture, pleine largeur.
 * Un tableau de deux colonnes se centrait dans la colonne et flottait au milieu
 * du texte (revue mes-jeux-videos, retour #1).
 */
.wp-block-post-content table {
	width: 100%;
	margin-inline: 0;
}

.wp-block-post-content :where(th, td) {
	text-align: start;
}

/* Sommaire (Table of Contents Plus) : la largeur du contenu, sur deux colonnes. */
.wp-block-post-content #toc_container {
	display: block;
	width: 100%;
	box-sizing: border-box;
	margin-block: var(--wp--preset--spacing--50);
	padding: var(--wp--preset--spacing--40);
	border: var(--wp--custom--rule--hairline) solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--lg);
	background-color: var(--wp--preset--color--surface);
}

.wp-block-post-content #toc_container .toc_list {
	column-count: 2;
	column-gap: var(--wp--preset--spacing--50);
	margin: 0;
	padding: 0;
	list-style: none;
}

.wp-block-post-content #toc_container .toc_list li {
	break-inside: avoid;
}

.wp-block-post-content #toc_container .toc_list ul {
	padding-inline-start: var(--wp--preset--spacing--30);
	list-style: none;
}

@media (max-width: 40rem) {

	.wp-block-post-content #toc_container .toc_list {
		column-count: 1;
	}
}

/*
 * Bas d'article : « À lire aussi », « Dans ce dossier », « Pour aller plus loin »
 * ne font plus trois encarts empilés mais un seul bloc à trois colonnes
 * (regroupés par gaia_regrouper_liens() dans inc/single.php).
 */
.wp-block-post-content > .gaia-related {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
	gap: var(--wp--preset--spacing--40);
	margin-block-start: var(--wp--preset--spacing--60);
	padding: var(--wp--preset--spacing--40);
	border: var(--wp--custom--rule--hairline) solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--lg);
	background-color: var(--wp--preset--color--surface);
}

.wp-block-post-content > .gaia-related > section > h2 {
	margin-block: 0 var(--wp--preset--spacing--30);
	font-size: var(--wp--preset--font-size--lg);
}

.wp-block-post-content > .gaia-related ul {
	margin: 0;
	padding-inline-start: var(--wp--preset--spacing--40);
	font-size: var(--wp--preset--font-size--base);
}
