/* Contenu de l'article : mise en forme de lecture des blocs WordPress (texte, intertitres,
   images, galeries, citations, listes). Sélecteurs en :where() : les réglages du widget
   et le CSS du site gardent la main. Les couleurs partent du texte : thèmes clairs et sombres. */
.mb-post-content { line-height: 1.75; overflow-wrap: break-word; }
.mb-post-content > :first-child { margin-top: 0; }
.mb-post-content > :last-child { margin-bottom: 0; }
.mb-post-content img { max-width: 100%; height: auto; }

.mb-post-content :where(p, ul, ol, blockquote, pre, table, figure, .wp-block-image) { margin: 0 0 1.4em; }
.mb-post-content :where(h2, h3, h4, h5, h6) { margin: 2em 0 0.6em; line-height: 1.25; text-wrap: balance; }
.mb-post-content :where(h2) { font-size: 1.55em; }
.mb-post-content :where(h3) { font-size: 1.3em; }
.mb-post-content :where(h4) { font-size: 1.12em; }
.mb-post-content :where(h2, h3, h4) + :where(*) { margin-top: 0; }
.mb-post-content :where(a) { color: var(--mb-primary); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
.mb-post-content :where(a:hover) { text-decoration-thickness: 2px; }
.mb-post-content :where(strong, b) { font-weight: 700; }
.mb-post-content :where(ul, ol) { padding-left: 1.4em; }
.mb-post-content :where(li + li) { margin-top: 0.4em; }
.mb-post-content :where(li)::marker { color: var(--mb-primary); }
.mb-post-content :where(hr) { border: 0; border-top: 1px solid color-mix(in srgb, currentColor 18%, transparent); margin: 2.4em 0; }

/* Citation : un trait de la couleur principale */
.mb-post-content :where(blockquote, .wp-block-quote) { border-left: 3px solid var(--mb-primary); padding: 0.2em 0 0.2em 1.2em; font-size: 1.12em; font-style: italic; }
.mb-post-content :where(blockquote) :where(p:last-child) { margin-bottom: 0; }
.mb-post-content :where(blockquote cite) { display: block; margin-top: 0.6em; font-size: 0.85em; font-style: normal; opacity: 0.75; }

/* Images et légendes */
.mb-post-content :where(.wp-block-image img, figure > img) { display: block; border-radius: 14px; }
.mb-post-content :where(figcaption, .wp-element-caption) { margin-top: 0.6em; font-size: 0.85em; text-align: center; opacity: 0.75; }

/* Galerie : grille régulière, photos recadrées au même format, agrandies au clic.
   Sélecteurs volontairement précis : ils doivent passer devant le CSS des blocs de WordPress. */
.mb-post-content .wp-block-gallery.has-nested-images,
.mb-post-content .wp-block-gallery:not(.has-nested-images) {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 12px;
	margin: 2em 0;
	padding: 0;
	list-style: none;
}
/* WordPress donne à chaque photo une largeur en % selon le nombre de colonnes (règles à forte
   priorité) : dans la grille, la case décide. */
.mb-post-content .wp-block-gallery.has-nested-images figure.wp-block-image:not(#individual-image) {
	width: 100% !important;
	margin: 0;
	flex: none;
	position: relative;
}
.mb-post-content .wp-block-gallery figure.wp-block-image img {
	width: 100%;
	height: 100%;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	border-radius: 10px;
	transition: transform 0.35s ease, filter 0.35s ease;
}
.mb-post-content .wp-block-gallery figure.wp-block-image { overflow: hidden; border-radius: 10px; }
/* Une seule photo : en grand, au format d'origine. Deux ou quatre : deux colonnes. */
.mb-post-content .wp-block-gallery:has(> figure:only-child) { grid-template-columns: 1fr; }
.mb-post-content .wp-block-gallery:has(> figure:only-child) figure.wp-block-image img { aspect-ratio: auto; }
.mb-post-content .wp-block-gallery:has(> figure:nth-child(2):last-child),
.mb-post-content .wp-block-gallery:has(> figure:nth-child(4):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mb-post-content .wp-block-gallery figure.wp-block-image figcaption {
	position: absolute; inset: auto 0 0; margin: 0; padding: 24px 10px 8px;
	background: linear-gradient(transparent, rgba(0, 0, 0, 0.6)); color: #fff; font-size: 0.8em; opacity: 1;
}
.mb-post-content .mb-zoomable,
.mb-post-content .wp-block-gallery a { cursor: zoom-in; }
.mb-post-content .wp-block-gallery figure:hover img { transform: scale(1.03); }
.mb-post-content .mb-zoomable:focus-visible { outline: 3px solid var(--mb-primary); outline-offset: -3px; }
@media (max-width: 767px) {
	.mb-post-content .wp-block-gallery.has-nested-images,
	.mb-post-content .wp-block-gallery:not(.has-nested-images) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
	.mb-post-content .wp-block-gallery:has(> figure:only-child) { grid-template-columns: 1fr; }
	/* Nombre impair : la première photo prend toute la largeur, pas de case vide en bas. */
	.mb-post-content .wp-block-gallery:has(> figure:last-child:nth-child(odd)) > figure:first-child { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
	.mb-post-content .wp-block-gallery figure:hover img { transform: none; }
}
