/**
 * Compatibilité des blocs Gutenberg créés sous WordPress 5.0 (fin 2018).
 *
 * WordPress 7 met en forme différemment l'ancien balisage de ces blocs (gap des layouts flex,
 * marges en em, cover sans conteneur interne...). Cette feuille reprend les règles de
 * wp-includes/css/dist/block-library/style.css de WordPress 5.0, avec les mêmes sélecteurs,
 * et elle est chargée juste AVANT la feuille du thème : comme en 5.0, le thème garde la main.
 *
 * Seul l'ancien balisage est ciblé ; un bloc recréé dans l'éditeur actuel n'est pas concerné.
 */

/* ---------- Colonnes (classe historique has-N-columns) ---------- */
.wp-block-columns:where([class*="-columns"]) {
	display: flex;
	flex-wrap: wrap;
}
:where(.wp-block-columns[class*="-columns"]) > .wp-block-column {
	flex: 1;
	margin-bottom: 1em;
	flex-basis: 100%;
	min-width: 0;
	word-break: break-word;
	overflow-wrap: break-word;
}
@media (min-width: 600px) {
	:where(.wp-block-columns[class*="-columns"]) > .wp-block-column {
		flex-basis: 50%;
		flex-grow: 0;
	}
	:where(.wp-block-columns[class*="-columns"]) > .wp-block-column:nth-child(odd) {
		margin-right: 32px;
	}
	:where(.wp-block-columns[class*="-columns"]) > .wp-block-column:nth-child(even),
	:where(.wp-block-columns[class*="-columns"]) > .wp-block-column:not(:first-child) {
		margin-left: 32px;
	}
	:where(.wp-block-columns[class*="-columns"]) > .wp-block-column:not(:last-child) {
		margin-right: 32px;
	}
}
@media (min-width: 782px) {
	.wp-block-columns:where([class*="-columns"]) {
		flex-wrap: nowrap;
	}
}
/* WordPress 7 impose un gap, une marge basse et un flex-basis via des classes de layout. */
body .wp-block-columns.is-layout-flex[class*="has-"][class*="-columns"] {
	gap: 0;
}
body .wp-block-columns.is-layout-flex[class*="has-"][class*="-columns"] > .wp-block-column {
	margin-bottom: 1em;
}
.wp-block-columns:where([class*="-columns"]) {
	margin-bottom: 0;
}
@media (min-width: 782px) {
	body .wp-block-columns.is-layout-flex[class*="has-"][class*="-columns"] > .wp-block-column {
		flex-basis: 50%;
		flex-grow: 0;
	}
}

/* ---------- Bouton seul (hors conteneur wp-block-buttons) ---------- */
.wp-block-button {
	color: #fff;
	margin-bottom: 1.5em;
}
.wp-block-button.aligncenter {
	text-align: center;
}
.wp-block-button.alignright {
	text-align: right;
}
.wp-block-button__link {
	border-radius: 28px;
	display: inline-block;
	font-size: 18px;
	margin: 0;
	padding: 12px 24px;
	text-align: center;
}
.is-style-squared .wp-block-button__link {
	border-radius: 0;
}

/* ---------- Galerie (ancien balisage ul > li.blocks-gallery-item) ---------- */
.wp-block-gallery:not(.has-nested-images):where(ul) {
	margin: 0 0 1.5em;
	display: flex;
	flex-wrap: wrap;
	list-style-type: none;
	padding: 0;
}
body ul.wp-block-gallery.is-layout-flex {
	gap: 0;
	align-items: stretch;
}
.wp-block-gallery:not(.has-nested-images) .blocks-gallery-item {
	margin: 0 16px 16px 0;
	display: flex;
	flex-grow: 1;
	flex-direction: column;
	justify-content: center;
	position: relative;
	width: calc((100% - 16px) / 2);
}
.wp-block-gallery:not(.has-nested-images) .blocks-gallery-item figure {
	margin: 0;
	height: 100%;
}
.wp-block-gallery:not(.has-nested-images) .blocks-gallery-item img {
	display: block;
	max-width: 100%;
	height: auto;
	width: 100%;
}
.wp-block-gallery:not(.has-nested-images) .blocks-gallery-item figcaption {
	position: absolute;
	bottom: 0;
	width: 100%;
	max-height: 100%;
	overflow: auto;
	padding: 40px 10px 5px;
	color: #fff;
	text-align: center;
	font-size: 13px;
	background: linear-gradient(0deg, rgba(0, 0, 0, 0.7) 0, rgba(0, 0, 0, 0.3) 60%, transparent);
}
.wp-block-gallery.is-cropped:not(.has-nested-images) .blocks-gallery-item a,
.wp-block-gallery.is-cropped:not(.has-nested-images) .blocks-gallery-item img {
	width: 100%;
}
.wp-block-gallery:not(.has-nested-images) .blocks-gallery-item figure {
	display: flex;
	align-items: flex-end;
	justify-content: flex-start;
}
.wp-block-gallery.is-cropped:not(.has-nested-images) .blocks-gallery-item a,
.wp-block-gallery.is-cropped:not(.has-nested-images) .blocks-gallery-item img {
	height: 100%;
	flex: 1;
	object-fit: cover;
}
.wp-block-gallery:not(.has-nested-images) .blocks-gallery-item:nth-of-type(even) {
	margin-right: 0;
}
.wp-block-gallery.columns-1:not(.has-nested-images) .blocks-gallery-item {
	width: 100%;
	margin-right: 0;
}
@media (min-width: 600px) {
	.wp-block-gallery.columns-3:not(.has-nested-images) .blocks-gallery-item { width: calc((100% - 16px * 2) / 3); margin-right: 16px; }
	.wp-block-gallery.columns-4:not(.has-nested-images) .blocks-gallery-item { width: calc((100% - 16px * 3) / 4); margin-right: 16px; }
	.wp-block-gallery.columns-5:not(.has-nested-images) .blocks-gallery-item { width: calc((100% - 16px * 4) / 5); margin-right: 16px; }
	.wp-block-gallery.columns-6:not(.has-nested-images) .blocks-gallery-item { width: calc((100% - 16px * 5) / 6); margin-right: 16px; }
	.wp-block-gallery.columns-1:not(.has-nested-images) .blocks-gallery-item:nth-of-type(1n),
	.wp-block-gallery.columns-2:not(.has-nested-images) .blocks-gallery-item:nth-of-type(2n),
	.wp-block-gallery.columns-3:not(.has-nested-images) .blocks-gallery-item:nth-of-type(3n),
	.wp-block-gallery.columns-4:not(.has-nested-images) .blocks-gallery-item:nth-of-type(4n),
	.wp-block-gallery.columns-5:not(.has-nested-images) .blocks-gallery-item:nth-of-type(5n),
	.wp-block-gallery.columns-6:not(.has-nested-images) .blocks-gallery-item:nth-of-type(6n) {
		margin-right: 0;
	}
}
.wp-block-gallery:not(.has-nested-images) .blocks-gallery-item:last-child {
	margin-right: 0;
}

/* ---------- Cover (ancien balisage, texte directement dans le bloc) ---------- */
.wp-block-cover:where(:not(:has(> .wp-block-cover__inner-container))) {
	position: relative;
	background-color: #000;
	background-size: cover;
	background-position: center center;
	min-height: 430px;
	width: 100%;
	margin: 0 0 1.5em 0;
	padding: 0;
	color: inherit;
	display: flex;
	justify-content: center;
	align-items: center;
	overflow: hidden;
}
.wp-block-cover.has-parallax:where(:not(:has(> .wp-block-cover__inner-container))) {
	background-attachment: fixed;
}
.wp-block-cover.has-background-dim:where(:not(:has(> .wp-block-cover__inner-container)))::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	bottom: 0;
	right: 0;
	background-color: inherit;
	opacity: 0.5;
	z-index: 1;
}
.wp-block-cover:where(:not(:has(> .wp-block-cover__inner-container)))::after {
	display: block;
	content: "";
	font-size: 0;
	min-height: inherit;
}
.wp-block-cover .wp-block-cover-text {
	color: #fff;
	font-size: 2em;
	line-height: 1.25;
	z-index: 1;
	margin-bottom: 0;
	max-width: 610px;
	padding: 14px;
	text-align: center;
}
.wp-block-cover .wp-block-cover-text a,
.wp-block-cover .wp-block-cover-text a:hover,
.wp-block-cover .wp-block-cover-text a:focus,
.wp-block-cover .wp-block-cover-text a:active {
	color: #fff;
}

/* ---------- Image ---------- */
/* WordPress 7 passe le lien autour de l'image en inline-block (inline en 5.0). */
.wp-block-image > a,
.wp-block-image > figure > a {
	display: inline;
}
.wp-block-image {
	max-width: 100%;
	margin-bottom: 1em;
	margin-left: 0;
	margin-right: 0;
}
/* WordPress 7 aligne les images en bas de ligne (vertical-align: bottom), ce qui retire
 * l'espace sous l'image présent en 5.0. */
.wp-block-image img {
	vertical-align: baseline;
}
.wp-block-image.aligncenter {
	text-align: center;
}
.wp-block-image .alignleft,
.wp-block-image .alignright,
.wp-block-image .aligncenter,
.wp-block-image.is-resized {
	display: table;
	margin-left: 0;
	margin-right: 0;
}
.wp-block-image .alignleft > figcaption,
.wp-block-image .alignright > figcaption,
.wp-block-image .aligncenter > figcaption,
.wp-block-image.is-resized > figcaption {
	display: table-caption;
	caption-side: bottom;
}
.wp-block-image .aligncenter {
	margin-left: auto;
	margin-right: auto;
}
/* WordPress 7 ajoute les attributs width/height aux images : dans un figure en display: table,
 * l'image déborderait de sa colonne. Sans redimensionnement manuel, elle reste adaptative. */
.wp-block-image .aligncenter:not(.is-resized) img {
	width: auto;
}
/* Le script wideImages() du thème lit cet attribut width et l'impose au figure (largeur et
 * marge négative) : il ne faisait rien en 5.0, où ces images n'avaient pas l'attribut. */
.wp-block-image .aligncenter:not(.is-resized) {
	width: auto !important;
	margin-left: auto !important;
}
.wp-block-image figcaption {
	margin-top: 0.5em;
	margin-bottom: 1em;
	color: #555d66;
	text-align: center;
	font-size: 13px;
}

/* ---------- Paragraphe avec couleur de fond ---------- */
p.has-background {
	padding: 20px 30px;
}

/* ---------- Taille « small » ----------
 * WordPress 7 impose 13px (!important) via ses styles globaux ; en 5.0 cette classe n'avait
 * aucun style et le texte gardait la taille du thème. */
body {
	--wp--preset--font-size--small: 16px;
}

/* ---------- Bloc fichier ---------- */
.wp-block-file:not(.wp-element-button) {
	margin-bottom: 1.5em;
	font-size: inherit;
}
.wp-block-file .wp-block-file__button {
	display: inline;
	background: #32373c;
	border-radius: 2em;
	color: #fff;
	font-size: 13px;
	padding: 0.5em 1em;
}
.wp-block-file a.wp-block-file__button:hover,
.wp-block-file a.wp-block-file__button:visited,
.wp-block-file a.wp-block-file__button:focus,
.wp-block-file a.wp-block-file__button:active {
	box-shadow: none;
	color: #fff;
	opacity: 0.85;
	text-decoration: none;
}

/* ---------- Tableau rayé ---------- */
.wp-block-table.is-style-stripes tbody tr:nth-child(odd) {
	background-color: #f3f4f5;
}
