/* Magazines pour Elementor — styles front */

.mge {
	--mge-meta-width: 190px;
	--mge-cover-width: 260px;
	--mge-gap: 28px;
	display: grid;
	grid-template-columns: var(--mge-meta-width) var(--mge-cover-width) minmax(0, 1fr);
	gap: var(--mge-gap);
	align-items: start;
}

/* --- Colonne de gauche ---------------------------------------------- */

.mge__meta {
	display: flex;
	flex-direction: column;
	height: 100%;
}

.mge__title {
	margin: 0;
	color: #111;
	font-size: 22px;
	font-weight: 700;
	line-height: 1.2;
	text-transform: uppercase;
	text-wrap: balance;
}

.mge__issue {
	margin: 10px 0 0;
	color: #8a8a8a;
	font-size: 16px;
}

.mge__buttons {
	display: flex;
	flex-direction: column;
	gap: 12px;
	margin-top: auto;
	padding-top: 28px;
}

.mge__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 12px 20px;
	border: 2px solid #ffc800;
	border-radius: 3px;
	background-color: transparent;
	color: #111;
	font-size: 15px;
	font-weight: 600;
	text-align: center;
	text-decoration: none;
	transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}

.mge__button--primary {
	background-color: #ffc800;
}

/* Bouton « Trouver un point de vente » : texte et icône alignés. */
.mge__button--stores {
	--mge-stores-icon: 18px;
	gap: 8px;
	color: #111;
}

/* Le bouton est rendu en premier : l'ordre flex le replace si besoin. */
.mge__buttons {
	display: flex;
}

.mge__button--stores-before {
	order: -1;
}

.mge__button--stores-after {
	order: 1;
}

.mge__button--link {
	padding-inline: 0;
	border-color: transparent;
	background-color: transparent;
}

.mge__button-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--mge-stores-icon);
	height: var(--mge-stores-icon);
	flex: 0 0 auto;
}

.mge__button-icon svg,
.mge__button-icon img {
	width: 100%;
	height: 100%;
	fill: currentColor;
}

.mge__button-icon i {
	font-size: var(--mge-stores-icon);
	line-height: 1;
}

.mge__button--disabled {
	border-color: #d5d5d5;
	color: #8a8a8a;
	cursor: not-allowed;
}

.mge__button:focus-visible,
.mge__link:focus-visible,
.mge__cover:focus-visible {
	outline: 2px solid #111;
	outline-offset: 3px;
}

/* --- Couvertures ------------------------------------------------------ */

.mge__cover {
	position: relative;
	display: block;
	line-height: 0;
}

/* Voile de couleur : au-dessus de l'image, sous les textes. */
.mge__veil {
	position: absolute;
	inset: 0;
	z-index: 1;
	background-color: transparent;
	pointer-events: none;
}


.mge__cover img {
	display: block;
	width: 100%;
	height: auto;
	transition: transform 220ms ease;
}

.mge__item:hover .mge__cover img,
.mge__featured:hover .mge__cover img {
	transform: translateY(-4px);
}

/* --- Colonne de droite ------------------------------------------------ */

.mge__list {
	display: flex;
	flex-direction: column;
	gap: calc(var(--mge-gap) * 0.75);
	min-width: 0;
}

.mge__list-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 16px;
}

.mge__grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: var(--mge-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

.mge__item {
	display: flex;
	flex-direction: column;
	gap: 14px;
	margin: 0;
}

/* La légende reste alignée en bas même si les couvertures ont des hauteurs différentes. */
.mge__item .mge__cover {
	margin-bottom: auto;
}

.mge__link {
	display: inline-flex;
	align-items: center;
	gap: 0.5em;
	color: #111;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 1px;
	text-decoration: none;
	text-transform: uppercase;
}

.mge__link--disabled {
	color: #8a8a8a;
}

.mge__arrow {
	transition: transform 180ms ease;
}

.mge__link:hover .mge__arrow,
.mge__link:focus-visible .mge__arrow {
	transform: translateX(4px);
}

.mge-empty {
	padding: 24px;
	border: 1px dashed #c3c4c7;
	color: #50575e;
	text-align: center;
}

.mge .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* --- Responsive -------------------------------------------------------- */

@media (max-width: 1024px) {
	.mge {
		grid-template-columns: var(--mge-meta-width) minmax(0, 1fr);
	}

	/* La grille passe sous le duo texte + couverture. */
	.mge__list {
		grid-column: 1 / -1;
	}

	.mge__featured .mge__cover img {
		max-width: var(--mge-cover-width);
	}
}

/* Tablettes comprises : même comportement qu'en mobile. */
@media (max-width: 1024px) {
	.mge {
		grid-template-columns: minmax(0, 1fr);
	}

	.mge__featured {
		justify-self: center;
		width: 100%;
		max-width: var(--mge-cover-width);
	}

	.mge__list-head {
		flex-direction: column;
		align-items: flex-start;
		gap: 8px;
	}

	/* --- Maquette mobile : titre, couverture, puis boutons -------------- */

	/* display:contents sort les enfants de .mge__meta pour les ordonner
	   individuellement dans la grille parente. */
	.mge--m-stack .mge__meta {
		display: contents;
	}

	.mge--m-stack .mge__title {
		order: 1;
		text-align: center;
	}

	.mge--m-stack .mge__issue {
		order: 2;
		text-align: center;
	}

	.mge--m-stack .mge__featured {
		order: 3;
	}

	.mge--m-stack .mge__buttons {
		order: 4;
		flex-direction: row;
		flex-wrap: wrap;
		justify-content: center;
		margin-top: 0;
		padding-top: 0;
	}

	.mge--m-stack .mge__button {
		flex: 0 1 auto;
	}

	.mge--m-stack .mge__list {
		order: 5;
		align-items: center;
	}

	/* Même principe pour l'en-tête : « Voir plus » passe sous la grille. */
	.mge--m-stack .mge__list-head {
		display: contents;
	}

	.mge--m-stack .mge__grid {
		order: 2;
		width: 100%;
	}

	.mge--m-stack .mge__link--more {
		order: 3;
	}

	.mge--m-no-issue .mge__issue {
		display: none;
	}

	/* --- Carrousel horizontal ------------------------------------------ */

	/* La zone de défilement ne doit jamais dépasser son parent :
	   sans largeur explicite, elle se dimensionne sur son contenu. */
	/* Spécificité renforcée et !important : certains thèmes remettent
	   overflow: visible sur les listes, ce qui casse le défilement et fait
	   déborder les cartes hors de l'écran. */
	.mge.mge--m-carousel .mge__grid {
		display: flex !important;
		overflow-x: auto !important;
	}

	.mge--m-carousel .mge__grid {
		display: flex;
		width: 100%;
		max-width: 100%;
		min-width: 0;
		gap: 10px;
		overflow-x: auto;
		padding-bottom: 4px;
		scroll-snap-type: x mandatory;
		/* Sans ce retrait, les cartes des extrémités ne peuvent pas
		   se centrer : la dernière reste coincée au bord. */
		scroll-padding-inline: calc((100% - var(--mge-card-width, 62%)) / 2);
		scrollbar-width: none;
		-webkit-overflow-scrolling: touch;
		overscroll-behavior-x: contain;
	}

	.mge--m-carousel .mge__grid::-webkit-scrollbar {
		display: none;
	}

	/* Filet de sécurité : même si un parent est trop large, le débordement
	   est coupé ici et n'élargit pas le document. */
	.mge--m-carousel .mge__list {
		overflow-x: clip;
	}

	/* Largeur posée sur l'élément plutôt que sur flex-basis : un pourcentage
	   de flex-basis se résout parfois sur une largeur parente indéterminée,
	   et la carte déborde alors au lieu de défiler. */
	.mge--m-carousel .mge__item {
		flex: 0 0 auto;
		width: var(--mge-card-width, 62%);
		max-width: 100%;
		scroll-snap-align: center;
	}

	/* Dernier rempart : rien de ce bloc ne peut élargir le document. */
	.mge--m-carousel {
		overflow-x: clip;
	}

	/* Libellés masqués visuellement, toujours accessibles au clavier
	   et aux lecteurs d'écran. */
	.mge--m-no-labels .mge__item .mge__link {
		position: absolute;
		width: 1px;
		height: 1px;
		margin: -1px;
		padding: 0;
		overflow: hidden;
		clip: rect(0 0 0 0);
		clip-path: inset(50%);
		white-space: nowrap;
	}

	.mge--m-no-labels .mge__item .mge__link:focus-visible {
		position: static;
		width: auto;
		height: auto;
		margin: 0;
		clip: auto;
		clip-path: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mge__cover img,
	.mge__arrow,
	.mge__button {
		transition: none;
	}
}

/* Un widget Elementor est un élément flex : sans min-width, il s'élargit à la
   taille de son contenu, et une zone à défilement horizontal fait alors
   déborder toute la page. */
.elementor-widget-mge_magazines {
	min-width: 0;
	max-width: 100%;
}

.mge,
.mge__list,
.mge__grid {
	max-width: 100%;
	min-width: 0;
}
