/* Menu commun à Apparence et au panneau de l'éditeur. */
.mz-content-library__filter {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.5rem;
	padding: 0.75rem;
	font-weight: 500;
}
.mz-content-library__filter select {
	width: 100%;
	max-width: 20rem;
	min-height: 2.125rem;
}
.mz-content-library__filter select:focus-visible {
	outline: 2px solid var(--wp-admin-theme-color);
	outline-offset: 2px;
}

/* 01 — Grille.
 * Auto-remplie et extensible : un modèle de plus s'ajoute sans réglage. */
.mz-content-library__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
	gap: 16px;
	padding: 12px;
}

.mz-content-library-screen {
	--mz-content-library-success: var(--wp--preset--color--success, #43705a);
	/* Survol et focus des cartes : bleu primaire A5 ; le vert reste réservé
	 * au bouton « Aperçu ». */
	--mz-content-library-accent: var(--wp--preset--color--primary, #2f4a7e);
	max-width: none;
}

.mz-content-library-screen .mz-content-library__grid {
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), min(100%, 280px)));
	gap: 20px;
	align-items: start;
	padding: 0;
	margin-top: 20px;
}

/* 02 — Carte. */
.mz-content-library__card {
	position: relative;
	min-width: 0;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	border: 1px solid #dcdcde;
	border-radius: 12px;
	background: #fff;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
	transition: border-color 160ms ease, box-shadow 160ms ease,
		transform 160ms ease;
}

/* Zone du titre compacte, sans fond coloré au survol ni au focus. */
.mz-content-library__card-body {
	padding: 8px 12px;
}

.mz-content-library__card-body h2,
.mz-content-library__card-body h3 {
	margin: 0;
	font-size: 13px;
	line-height: 1.3;
}

.mz-content-library-screen .mz-content-library__card-body h2 {
	font-size: 12px;
	font-weight: 500;
	text-align: center;
}

/* Survol de la carte : contour bleu et ombre neutre, sans déplacement ni
 * ouverture. */
@media (hover: hover) {
	.mz-content-library-screen .mz-content-library__card:hover {
		border-color: var(--mz-content-library-accent);
		box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
	}
}

/* 03 — Vignette compacte : début du document à la hauteur réelle du
 * modèle, mise à l'échelle et bornée par le script entre une bande
 * lisible et le format 3:2. La forme 3:2 sert seulement d'attente avant
 * la mesure ; la suite de la page se consulte dans la vue complète. */
.mz-content-library__frame {
	position: relative;
	display: block;
	border-bottom: 1px solid #dcdcde;
}

.mz-content-library__stage {
	position: relative;
	overflow: hidden;
	aspect-ratio: 3 / 2;
	background: #f6f7f7;
}

.mz-content-library__stage-frame {
	position: absolute;
	top: 0;
	left: 0;
	transform-origin: top left;
	border: 0;
	background: #fff;
	pointer-events: none;
}

.mz-content-library__modal-frame,
.mz-content-library__stage-frame {
	color-scheme: light;
}

/* 04 — Bouton « Aperçu » : seule commande d'ouverture, centrée sur la
 * vignette. Visible au survol et au focus ; toujours visible sans survol. */
.mz-content-library__preview-button {
	position: absolute;
	top: 50%;
	left: 50%;
	z-index: 2;
	padding: 4px 12px;
	border: 0;
	border-radius: 999px;
	background: var(--mz-content-library-success);
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
	color: #fff;
	font-size: 12px;
	font-weight: 600;
	line-height: 1.4;
	white-space: nowrap;
	cursor: pointer;
	opacity: 0;
	transform: translate(-50%, -50%);
	transition: opacity 160ms ease;
}

.mz-content-library__card:hover .mz-content-library__preview-button,
.mz-content-library__card:focus-within .mz-content-library__preview-button {
	opacity: 1;
}

.mz-content-library__preview-button:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 2px;
	box-shadow: 0 0 0 5px var(--mz-content-library-success);
}

@media (hover: none) {
	.mz-content-library__preview-button {
		opacity: 1;
	}
}

.mz-content-library-screen .mz-content-library__card:focus-within {
	border-color: var(--mz-content-library-accent);
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
}

/* 05 — Insertion réservée à l'éditeur ; aucune création dans l'aperçu. */
.mz-content-library__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 12px;
}

/* 06 — Vue complète : barre d'action stable, puis document réel défilant. */
.mz-content-library__modal.components-modal__frame {
	width: 100%;
	height: 100%;
	margin: 0;
}

.mz-content-library__modal .components-modal__content {
	display: flex;
	height: 100%;
	min-height: 0;
	flex-direction: column;
	padding-bottom: 0;
}

/* Le nom du dialogue reste disponible aux lecteurs d'écran. */
.mz-content-library__modal .components-modal__header-heading {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

.mz-content-library__modal-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	flex-shrink: 0;
	padding-bottom: 12px;
	border-bottom: 1px solid #dcdcde;
}

.mz-content-library__modal-widths {
	display: flex;
	gap: 4px;
}

.mz-content-library__modal-widths .components-button {
	min-width: 40px;
	min-height: 40px;
	justify-content: center;
}

.mz-content-library__modal-viewport {
	display: flex;
	height: 100%;
	min-height: 0;
	flex: 1;
	justify-content: center;
	overflow: auto;
	padding: 24px;
	background: #f0f0f1;
}

.mz-content-library__modal-frame {
	flex-shrink: 0;
	height: 100%;
	min-height: 0;
	border: 1px solid #dcdcde;
	background: #fff;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

/* 07 — Repli public du modèle, hors administration.
 * Le serveur marque uniquement un carrousel activé ; navigation.js reprend
 * ensuite le contrat existant. Sans script, le contenu reste lisible en
 * séquence grâce à la feuille noscript du thème. */
body.mz-content-model-preview {
	min-width: 0;
	margin: 0;
	background: var(--mz-background, #fff);
}

.mz-content-model-preview__canvas {
	width: 100%;
	max-width: none;
	margin: 0;
	overflow: hidden;
}

.mz-hero[data-mz-slider-prepared="true"]:not([data-mz-slider-ready="true"])
	> .mz-hero__track {
	display: grid;
}

.mz-hero[data-mz-slider-prepared="true"]:not([data-mz-slider-ready="true"])
	> .mz-hero__track > .mz-hero__slide:not(.is-active) {
	visibility: hidden;
	opacity: 0;
	pointer-events: none;
}

/* 08 — Réponsif. */
@media (max-width: 48rem) {
	.mz-content-library__modal-bar {
		flex-direction: column;
		align-items: stretch;
	}

	.mz-content-library__modal-widths {
		justify-content: center;
	}

	.mz-content-library__modal-viewport {
		padding: 12px;
	}

	.mz-content-library__modal-frame {
		min-height: 24rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mz-content-library__card,
	.mz-content-library__preview-button {
		transition: none;
	}
}
