/*
 * Mur des modèles — charte 2026.
 *
 * Grille CSS de tuiles carrées : la maçonnerie JavaScript posait les images à
 * leur ratio natif, ce qui donnait des colonnes de hauteurs inégales et un saut
 * de mise en page à chaque image chargée. Ici la place de chaque tuile est
 * connue avant le premier octet d'image.
 */

.mh-wall {
	background: var(--mh-bg);
	padding: 28px 0 64px;
}

.mh-wall .mh-crumb {
	margin-bottom: 18px;
}

/* --------------------------------------------------------------- En-tête */

.mh-wall-head {
	max-width: 760px;
	margin: 0 0 26px;
}

.mh-wall-head h1 {
	font-family: var(--mh-display);
	font-size: clamp(30px, 4.4vw, 46px);
	line-height: 1.08;
	letter-spacing: -0.015em;
	color: var(--mh-ink);
	margin: 6px 0 12px;
}

.mh-wall-lead {
	font-size: 17px;
	line-height: 1.6;
	color: var(--mh-ink-2);
	margin: 0;
}

.mh-wall-intro {
	font-size: 15px;
	line-height: 1.6;
	color: var(--mh-muted);
	margin: 8px 0 0;
}

/* --------------------------------------------------------------- Filtres */

.mh-wall-filters {
	margin: 0 0 24px;
	border-top: 1px solid var(--mh-line);
	border-bottom: 1px solid var(--mh-line);
	padding: 14px 0;
}

.mh-wall-toggle {
	display: none;
}

.mh-wall-pills {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0;
	padding: 0;
}

.mh-wall-pills.mh-plain,
.mh-wall-pills.mh-plain li {
	list-style: none;
}

.mh-wall-pills li {
	margin: 0;
}

.mh-wall .mh-pill {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 7px 13px;
	border: 1px solid var(--mh-line-strong);
	border-radius: 999px;
	background: var(--mh-surface);
	color: var(--mh-ink-2);
	font-size: 14px;
	font-weight: 600;
	line-height: 1;
	text-decoration: none;
	transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.mh-wall .mh-pill:hover,
.mh-wall .mh-pill:focus-visible {
	border-color: var(--mh-ink);
	color: var(--mh-ink);
	background: var(--mh-tint);
}

.mh-wall .mh-pill.is-on {
	background: var(--mh-dark);
	border-color: var(--mh-dark);
	color: #fff;
}

.mh-pill-n {
	font-size: 12px;
	font-weight: 600;
	color: var(--mh-muted);
	font-variant-numeric: tabular-nums;
}

.mh-wall .mh-pill.is-on .mh-pill-n,
.mh-wall .mh-pill:hover .mh-pill-n {
	color: inherit;
	opacity: 0.75;
}

.mh-wall-panel-head {
	display: none;
}

/* ---------------------------------------------------------------- Grille */

.mh-wall-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
	gap: 20px;
}

.mh-wall-tile {
	margin: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
	min-width: 0;
}

.mh-wall-open {
	display: block;
	position: relative;
	aspect-ratio: 1 / 1;
	border: 1px solid var(--mh-line);
	border-radius: var(--mh-r);
	background-color: var(--mh-peg);
	/*
	 * Fond en trame de perles : la grille se lit sur un damier discret plutôt
	 * que sur du blanc, et les modèles à fond clair ne se fondent plus dans la
	 * page.
	 */
	background-image: radial-gradient(var(--mh-peg-dot) 1.1px, transparent 1.2px);
	background-size: 10px 10px;
	overflow: hidden;
	transition: border-color 0.15s ease, transform 0.15s ease;
}

.mh-wall-open:hover,
.mh-wall-open:focus-visible {
	border-color: var(--mh-ink);
	transform: translateY(-2px);
}

.mh-wall-img {
	display: block;
	width: 100%;
	height: 100%;
	/*
	 * contain, jamais cover : une grille de perles recadrée perd des rangées et
	 * devient inutilisable pour qui veut la reproduire.
	 */
	object-fit: contain;
	object-position: center;
}

.mh-wall-cap {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.mh-wall-name {
	font-family: var(--mh-display);
	font-size: 14px;
	font-weight: 600;
	line-height: 1.3;
	color: var(--mh-ink);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.mh-wall-src {
	font-size: 12.5px;
	line-height: 1.35;
	color: var(--mh-muted);
	text-decoration: none;
	display: -webkit-box;
	-webkit-line-clamp: 1;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.mh-wall-src:hover,
.mh-wall-src:focus-visible {
	color: var(--mh-link);
	text-decoration: underline;
}

.mh-wall-empty {
	padding: 40px 0;
	font-size: 16px;
	color: var(--mh-ink-2);
}

/* ------------------------------------------------------------ Publicité */

.mh-wall-ad {
	grid-column: 1 / -1;
	margin: 12px 0;
	min-height: 100px;
	background: var(--mh-tint);
	border-radius: var(--mh-r-sm);
	overflow: hidden;
}

/* ------------------------------------------------------------ Pagination */

.mh-wall-pager {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	margin: 28px 0 0;
	padding-top: 22px;
	border-top: 1px solid var(--mh-line);
}

.mh-wall-pg {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 38px;
	height: 38px;
	padding: 0 11px;
	border: 1px solid var(--mh-line-strong);
	border-radius: var(--mh-r-sm);
	background: var(--mh-surface);
	color: var(--mh-ink-2);
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
	font-variant-numeric: tabular-nums;
}

.mh-wall-pg:hover,
.mh-wall-pg:focus-visible {
	border-color: var(--mh-ink);
	color: var(--mh-ink);
}

.mh-wall-pg.is-on {
	background: var(--mh-dark);
	border-color: var(--mh-dark);
	color: #fff;
}

.mh-wall-gap {
	color: var(--mh-muted);
	padding: 0 2px;
}

/* ------------------------------------------------------------ Autres thèmes */

.mh-wall-more {
	margin: 48px 0 0;
	padding: 24px;
	background: var(--mh-tint);
	border-radius: var(--mh-r);
}

.mh-wall-more h2 {
	font-family: var(--mh-display);
	font-size: 20px;
	line-height: 1.2;
	color: var(--mh-ink);
	margin: 0 0 14px;
}

.mh-wall-more-pills {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.mh-wall-more-link {
	margin: 16px 0 0;
	font-size: 15px;
}

.mh-wall-more-link a {
	color: var(--mh-link);
	font-weight: 600;
}

/* ----------------------------------------------------------- Visionneuse */

.mh-lb {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 16px;
}

.mh-lb.is-open {
	display: flex;
}

.mh-lb-back {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
	padding: 0;
	background: rgba(22, 22, 26, 0.82);
	cursor: zoom-out;
}

.mh-lb-box {
	position: relative;
	display: flex;
	flex-direction: column;
	width: min(940px, 100%);
	max-height: 100%;
	background: var(--mh-surface);
	border-radius: var(--mh-r);
	overflow: hidden;
	box-shadow: 0 24px 60px rgba(22, 22, 26, 0.35);
}

.mh-lb-bar {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 14px;
	border-bottom: 1px solid var(--mh-line);
	background: var(--mh-surface);
}

.mh-lb-title {
	flex: 1 1 auto;
	margin: 0;
	font-family: var(--mh-display);
	font-size: 15px;
	font-weight: 600;
	line-height: 1.3;
	color: var(--mh-ink);
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.mh-lb-acts {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 0 0 auto;
}

.mh-lb-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 36px;
	padding: 0 14px;
	border: 1px solid var(--mh-line-strong);
	border-radius: var(--mh-r-sm);
	background: var(--mh-surface);
	color: var(--mh-ink);
	font-family: var(--mh-text);
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
}

.mh-lb-btn:hover,
.mh-lb-btn:focus-visible {
	border-color: var(--mh-ink);
	background: var(--mh-tint);
}

.mh-lb-btn--go {
	background: var(--mh-red);
	border-color: var(--mh-red);
	color: #fff;
}

.mh-lb-btn--go:hover,
.mh-lb-btn--go:focus-visible {
	background: var(--mh-red-dark);
	border-color: var(--mh-red-dark);
	color: #fff;
}

.mh-lb-btn--x {
	width: 36px;
	padding: 0;
	font-size: 20px;
	line-height: 1;
}

.mh-lb-fig {
	margin: 0;
	flex: 1 1 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 18px;
	background-color: var(--mh-peg);
	background-image: radial-gradient(var(--mh-peg-dot) 1.1px, transparent 1.2px);
	background-size: 12px 12px;
	min-height: 0;
}

.mh-lb-img {
	display: block;
	max-width: 100%;
	max-height: 72vh;
	width: auto;
	height: auto;
	image-rendering: pixelated;
}

body.mh-lb-on {
	overflow: hidden;
}

/* --------------------------------------------------------------- Tablette */

@media (max-width: 1024px) {
	.mh-wall-grid {
		grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
		gap: 16px;
	}
}

/* ----------------------------------------------------------------- Mobile */

@media (max-width: 767px) {
	.mh-wall {
		padding: 20px 0 48px;
	}

	.mh-wall-head {
		margin-bottom: 18px;
	}

	.mh-wall-lead {
		font-size: 16px;
	}

	.mh-wall-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 14px;
	}

	.mh-wall-more {
		padding: 18px;
	}

	/*
	 * Douze pastilles à la file poussaient la première grille sous deux écrans
	 * de haut : sur mobile le choix du thème passe par un bouton et un panneau
	 * plein écran.
	 */
	.mh-wall-filters {
		border: 0;
		padding: 0;
	}

	.mh-wall-toggle {
		display: flex;
		align-items: baseline;
		gap: 8px;
		width: 100%;
		padding: 12px 14px;
		border: 1px solid var(--mh-line-strong);
		border-radius: var(--mh-r-sm);
		background: var(--mh-surface);
		font-family: var(--mh-text);
		font-size: 15px;
		text-align: left;
		cursor: pointer;
	}

	.mh-wall-toggle-label {
		color: var(--mh-muted);
		font-size: 13px;
		text-transform: uppercase;
		letter-spacing: 0.04em;
	}

	.mh-wall-toggle-value {
		color: var(--mh-ink);
		font-weight: 700;
	}

	.mh-wall-toggle::after {
		content: "▾";
		margin-left: auto;
		color: var(--mh-muted);
	}

	.mh-wall-panel {
		position: fixed;
		inset: 0;
		z-index: 99999;
		display: none;
		flex-direction: column;
		background: var(--mh-bg);
		padding: 0 16px 24px;
		overflow-y: auto;
		overscroll-behavior: contain;
	}

	.mh-wall-panel.is-open {
		display: flex;
	}

	.mh-wall-panel-head {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 12px;
		padding: 14px 0;
		margin-bottom: 8px;
		border-bottom: 1px solid var(--mh-line);
		font-family: var(--mh-display);
		font-size: 17px;
		font-weight: 600;
		color: var(--mh-ink);
		position: sticky;
		top: 0;
		background: var(--mh-bg);
	}

	.mh-wall-close {
		width: 38px;
		height: 38px;
		border: 1px solid var(--mh-line-strong);
		border-radius: var(--mh-r-sm);
		background: var(--mh-surface);
		font-size: 22px;
		line-height: 1;
		color: var(--mh-ink);
		cursor: pointer;
	}

	.mh-wall-panel .mh-wall-pills {
		display: block;
	}

	.mh-wall-panel .mh-wall-pills li + li {
		margin-top: 8px;
	}

	.mh-wall-panel .mh-pill {
		display: flex;
		justify-content: space-between;
		width: 100%;
		border-radius: var(--mh-r-sm);
		padding: 13px 14px;
		font-size: 15px;
	}

	.mh-lb {
		padding: 0;
	}

	.mh-lb-box {
		width: 100%;
		height: 100%;
		max-height: 100%;
		border-radius: 0;
	}

	.mh-lb-bar {
		flex-wrap: wrap;
	}

	.mh-lb-title {
		order: 2;
		flex-basis: 100%;
		white-space: normal;
	}

	.mh-lb-acts {
		order: 1;
		width: 100%;
		justify-content: space-between;
	}

	.mh-lb-img {
		max-height: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mh-wall-open,
	.mh-wall-open:hover {
		transition: none;
		transform: none;
	}
}
