/* ============================================================
   Méga-menu proLogistik
   ============================================================ */
.m-megamenu {
	background-color: var(--wp--preset--color--border-light);
	width: 100vw;
	max-width: unset;
	padding: 0;
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
}

.m-megamenu__bar {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 3rem;
	margin: 0 auto;
	padding: 0;
	list-style: none;
	width: 100%;
	max-width: var(--wp--style--global--wide-size);
	position: relative;
}

.m-megamenu__item {
	position: relative;
}

/* L'item dont le panneau contient un encart "featured" laisse la barre
   servir de référent, pour que le panneau s'étende sur toute sa largeur. */
.m-megamenu__item:has(.m-megamenu__featured) {
	position: static;
}

.m-megamenu__toplink[href="#"] {
	pointer-events: none;
	cursor: default;
}

.m-megamenu__toplink::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	top: 0;
	height: 100px;
}

.m-megamenu__toplink[href="#"]::after {
	pointer-events: auto;
}

.m-megamenu__toplink {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 1rem 0;
	font-size: 0.95rem;
	font-weight: var(--wp--custom--font-weight--semi-bold);
	color: var(--wp--preset--color--primary-darken);
	text-decoration: none;
	border-bottom: 2px solid transparent;
	transition: color 0.2s ease, border-color 0.2s ease;
	position: relative;
}

.m-megamenu__toplink-icon {
	display: inline-flex;
	flex: 0 0 auto;
}

.m-megamenu__toplink-icon img {
	width: 1.1rem;
	height: 1.1rem;
	object-fit: contain;
}

.m-megamenu__item--has-panel:hover>.m-megamenu__toplink,
.m-megamenu__item.is-open>.m-megamenu__toplink,
.m-megamenu__toplink:hover {
	color: var(--wp--preset--color--primary);
	border-bottom-color: var(--wp--preset--color--secondary);
}

.m-megamenu__caret {
	width: 0;
	height: 0;
	border-left: 4px solid transparent;
	border-right: 4px solid transparent;
	border-top: 5px solid currentColor;
	transition: transform 0.2s ease;
}

.m-megamenu__item.is-open .m-megamenu__caret {
	transform: rotate(180deg);
}

/* Entrée de menu "recherche" : on masque le libellé, on garde l'icône */
.m-megamenu__item.menu-search .m-megamenu__toplink {
	font-size: 0;
	/* masque le texte */
}

.m-megamenu__item.menu-search .m-megamenu__toplink:hover {
	border-bottom: unset;
}

.m-megamenu__item.menu-search .m-megamenu__toplink-icon img {
	width: 1.3rem;
	height: 1.3rem;
}



/* ── Panneau ───────────────────────────────────────────────── */
.m-megamenu__panel {
	position: absolute;
	top: 100%;
	left: 0;
	transform: translateY(8px);
	z-index: 200;
	width: max-content;
	background: var(--wp--preset--color--base);
	border-radius: var(--wp--custom--radius--base);
	border-bottom: 4px solid var(--wp--preset--color--secondary);
	box-shadow: 0 18px 40px rgb(16 24 40 / 14%);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

/* Panneau riche (avec encart "featured") : pleine largeur du conteneur,
   calé sur le bord gauche de la barre. */
.m-megamenu__panel:has(.m-megamenu__featured) {
	left: 0;
	right: 0;
	width: 100%;
}


.m-megamenu__item--has-panel:hover>.m-megamenu__panel,
.m-megamenu__item.is-open>.m-megamenu__panel {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

.m-megamenu__panel-inner {
	padding: 2rem;
}

/* Liste de 1er niveau du panneau : devient un conteneur flex
   (encart + grille côte à côte, OU grille simple sur 2 colonnes). */
.m-megamenu__list {
	display: flex;
	gap: 1.5rem 2rem;
	margin: 0;
	padding: 0;
	list-style: none;
	align-items: flex-start;
}

.m-megamenu__list {
	display: grid;
	grid-template-columns: 1fr;
	gap: 2.5rem;
}

.m-megamenu__list:has(> li:nth-child(4)) {
	grid-template-columns: repeat(2, 1fr);
	gap: 3rem;
}

.m-megamenu__list:has(>.m-megamenu__featured) {
	display: flex;
}

/* Cas "grille simple" (entrées de niveau 1 sans encart) :
   chaque entrée occupe ~1/2 largeur. */
.m-megamenu__list>.m-megamenu__entry {
	flex: 1 1 calc(50% - 2rem);
	min-width: 240px;
}

/* Encart (à gauche) */
.m-megamenu__featured {
	flex: 0 0 30%;
	order: -1;
	list-style: none;
}

.m-megamenu__featured-link {
	display: flex;
	gap: var(--wp--custom--gap--sm);
	height: 100%;
	padding: 1.5rem;
	background: var(--wp--preset--color--primary-accent);
	border-radius: var(--wp--custom--radius--base);
	text-decoration: none;
}

.m-megamenu__featured-icon {
	display: flex;
	justify-content: center;
	align-items: center;
	width: 44px;
	height: 44px;
	background: var(--wp--preset--color--base);
	border-radius: var(--wp--custom--radius--sm);
}

.m-megamenu__featured-icon img {
	width: 24px;
	height: auto;
	object-fit: contain;
}

.m-megamenu__featured-title {
	display: block;
	font-weight: var(--wp--custom--font-weight--semi-bold);
	color: var(--wp--preset--color--primary-darken);
}

.m-megamenu__featured-intro {
	display: block;
	font-weight: var(--wp--custom--font-weight--bold);
	font-size: 0.9rem;
	margin-bottom: 0.5rem;
	color: var(--wp--preset--color--main);
}


.m-megamenu__featured-desc {
	font-weight: var(--wp--custom--font-weight--regular);
	font-size: 0.9rem;
	color: var(--wp--preset--color--main);
}


/* Porte-grille (enfants d'un encart) : prend le reste de la largeur,
   et affiche ses entrées en 2 colonnes. */
.m-megamenu__gridholder {
	flex: 1 1 60%;
	list-style: none;
}

.m-megamenu__list--sub {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 1.25rem 2rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Entrée de grille */
.m-megamenu__entry {
	list-style: none;
}

.m-megamenu__entry-link {
	display: flex;
	gap: 0.85rem;
	align-items: flex-start;
	text-decoration: none;


	@media(width < 1200px) {
		align-items: center;
	}
}

.m-megamenu__entry-icon {
	flex: 0 0 auto;
	width: 44px;
	height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: var(--wp--preset--color--primary-accent);
	border-radius: var(--wp--custom--radius--sm);
}

.m-megamenu__entry-icon img {
	width: 24px;
	height: auto;
	object-fit: contain;
}

.m-megamenu__entry-title {
	display: block;
	font-weight: var(--wp--custom--font-weight--semi-bold);
	color: var(--wp--preset--color--primary-darken);
}

.m-megamenu__entry-desc {
	font-weight: var(--wp--custom--font-weight--regular);
	font-size: 0.9rem;
	margin-bottom: 0.5rem;
	color: var(--wp--preset--color--main);
}

.m-megamenu__entry-intro {
	display: block;
	font-weight: var(--wp--custom--font-weight--bold);
	font-size: 0.9rem;
	color: var(--wp--preset--color--main);
}

.m-megamenu__entry-link:hover .m-megamenu__entry-title {
	color: var(--wp--preset--color--primary);
}

/* ── Responsive ────────────────────────────────────────────── */
/* ── Wrap + burger (mobile) ───────────────────────────────── */
.m-megamenu-wrap {
	display: contents;
}

.m-megamenu__burger {
	display: none;
	width: 40px;
	height: 40px;
	flex: 0 0 50px;
	margin-left: auto;
	padding: 0;
	border: none;
	border-radius: var(--wp--custom--radius--sm);
	background-color: var(--wp--preset--color--primary);
	cursor: pointer;
	position: relative;
	z-index: 210;
}

.m-megamenu__burger-box {
	display: block;
	width: 25px;
	height: 18px;
	position: relative;
	margin: 0 auto;
}

.m-megamenu__burger-inner,
.m-megamenu__burger-inner::before,
.m-megamenu__burger-inner::after {
	content: "";
	display: block;
	position: absolute;
	left: 0;
	width: 25px;
	height: 2px;
	border-radius: var(--wp--custom--radius--sm);
	background-color: var(--wp--preset--color--base);
	transition: transform 0.2s ease, top 0.2s ease, opacity 0.2s ease;
}

.m-megamenu__burger-inner {
	top: 50%;
	margin-top: -1px;
}

.m-megamenu__burger-inner::before {
	top: -8px;
}

.m-megamenu__burger-inner::after {
	top: 8px;
}

/* Burger animé en croix quand ouvert */
.m-megamenu__burger.is-active .m-megamenu__burger-inner {
	transform: rotate(45deg);
	margin-top: -1px;
}

.m-megamenu__burger.is-active .m-megamenu__burger-inner::before {
	top: 0;
	opacity: 0;
}

.m-megamenu__burger.is-active .m-megamenu__burger-inner::after {
	top: 0;
	transform: rotate(-90deg);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (width < 1400px) {

	.m-megamenu-wrap {
		display: flex;
	}

	.site-header>.wp-block-group {
		display: flex;
		justify-content: space-between;
	}

	/* Boutons du header : masqués en mobile quand le menu est fermé */
	.site-header .wp-block-buttons {
		display: none;
	}

	div:has(.wp-block-site-logo, .m-megamenu-wrap) {
		margin: 0 !important;
	}

	/* Masque le contact flottant quand le menu mobile est ouvert */
	body.m-megamenu-open .floating-contact {
		display: none;
	}

	/* Boutons réaffichés en bas de l'overlay quand le menu est ouvert */
	body.m-megamenu-open .site-header .wp-block-buttons {
		display: flex;
		flex-direction: column;
		align-items: stretch;
		gap: var(--wp--custom--gap--sm);
		position: fixed;
		left: 0;
		bottom: 0;
		width: 100%;
		padding: 1.5rem;
		background-color: var(--wp--preset--color--base);
		z-index: 210;
	}

	body.m-megamenu-open .site-header .wp-block-button {
		width: 100%;
	}

	body.m-megamenu-open .site-header .wp-block-button__link {
		width: 100%;
		text-align: center;
		justify-content: center;
	}

	/* Quand un sous-menu est déplié, on masque les boutons pour libérer la place au profit des sous-onglets. */
	body.m-megamenu-open .site-header:has(.m-megamenu__item.is-open) .wp-block-buttons {
		display: none;
	}

	.site-header .wp-block-group:has(> .m-megamenu-wrap) {
		align-items: center;
		justify-content: end;
		border-top: none;
		padding-top: 0;
		padding-bottom: 0;
	}

	/* Le burger apparaît */
	.m-megamenu__burger {
		display: block;
	}

	/* La barre devient un panneau plein écran masqué au-dessus du viewport */
	.m-megamenu {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100dvh;
		max-width: none;
		transform: translateY(-100%);
		transition: var(--wp--custom--transition--base);
		background-color: var(--wp--preset--color--base);
		overflow-y: auto;
		padding: 100px 0 30px;
		z-index: 200;
	}

	.m-megamenu.is-open {
		transform: translateY(0);
	}

	.m-megamenu__bar {
		flex-direction: column;
		align-items: stretch;
		gap: 0;
		width: 100%;
		margin: 0;
	}

	.m-megamenu__item {
		border-bottom: 1px solid var(--wp--preset--color--border-light);
	}

	.m-megamenu__toplink {
		padding: 1rem 1.5rem;
		font-size: 1.05rem;
		justify-content: space-between;
		width: 100%;
	}

	.m-megamenu__toplink[href="#"] {
		pointer-events: auto;
	}

	.m-megamenu__toplink::after {
		display: none;
	}

	/* Le caret pivote pour indiquer accordéon */
	.m-megamenu__item.is-open>.m-megamenu__toplink .m-megamenu__caret {
		transform: rotate(180deg);
	}

	/* Les panneaux : repliés par défaut, dépliés via .is-open (accordéon) */
	.m-megamenu__panel {
		position: static;
		transform: none;
		width: 100%;
		max-width: none;
		opacity: 1;
		visibility: visible;
		pointer-events: auto;
		box-shadow: none;
		border-bottom: none;
		border-radius: 0;
		background: var(--wp--preset--color--primary-accent);
		display: none;
	}

	.m-megamenu__item.is-open>.m-megamenu__panel {
		display: block;
	}

	/* On annule le survol desktop : en mobile seul .is-open ouvre */
	.m-megamenu__item--has-panel:hover>.m-megamenu__panel {
		opacity: 1;
		visibility: visible;
	}

	.m-megamenu__panel-inner {
		padding: 1rem 1.5rem;
	}

	.m-megamenu__list,
	.m-megamenu__list:has(> li:nth-child(4)),
	.m-megamenu__list:has(> .m-megamenu__featured) {
		display: flex;
		flex-direction: column;
		gap: 1rem;
	}

	.m-megamenu__list--sub {
		grid-template-columns: 1fr;
		gap: 1rem;
	}

	.m-megamenu__featured,
	.m-megamenu__gridholder,
	.m-megamenu__list>.m-megamenu__entry {
		flex-basis: auto;
		min-width: 0;
	}

	/* La recherche : on réaffiche le libellé en mobile */
	.m-megamenu__item.menu-search .m-megamenu__toplink {
		font-size: 1.05rem;
		display: flex;
		flex-direction: row-reverse;
	}
}

@media (width < 767px) {
	.wp-block-site-logo img {
		max-width: 240px;
	}
}


/* Empêche le scroll de page quand le menu mobile est ouvert */
body.m-megamenu-open {
	overflow: hidden;
}