/* ==========================================================================
   20KM – Header  ·  [km_header]
   Couleurs et polices = globales Elementor (Réglages du site) — seul endroit à toucher.
   Formes : système hex du thème (style.css) — .hex, .hex--sm, .hex-line.
   ========================================================================== */

.kmh {
	/* Couleurs (valeur actuelle en commentaire) */
	--kmh-ink:        var(--e-global-color-e1f2c5f);    /* noir      #000000 */
	--kmh-paper:      var(--e-global-color-81a98aa);    /* blanc     #F2F0EF */
	--kmh-bar-bg:     var(--e-global-color-81a98aa);    /* blanc     #F2F0EF */
	--kmh-accent:     var(--e-global-color-secondary);  /* orange    #FF6600 */
	--kmh-dd-bg:      color-mix(in srgb, var(--e-global-color-e1f2c5f) 80%, transparent); /* noir 80 % */
	--kmh-dd-hover:   var(--e-global-color-30cd4d0);    /* gris clair #E8E5E3 */
	--kmh-dd-sep:     rgb(167 167 167 / .4);            /* neutral-400 @ 40 % — pas de globale */
	--kmh-card-bg:    var(--e-global-color-81a98aa);    /* blanc     #F2F0EF */
	/* CTA « S'inscrire » — barre compacte : comme « Voir plus » (Élite & invitations) */
	--kmh-cta-bg:          var(--e-global-color-secondary);  /* #FF6600 */
	--kmh-cta-text:        var(--e-global-color-e1f2c5f);    /* #000000 */
	--kmh-cta-bg-hover:    var(--e-global-color-87b91f0);    /* #D15400 */
	--kmh-cta-text-hover:  var(--e-global-color-013f9ca);    /* #D9D9D9 */

	/* Polices : familles des typographies globales Label M (Martian Mono) et Body M (Inter) */
	--kmh-font-label: var(--e-global-typography-e045607-font-family), ui-monospace, monospace;
	--kmh-font-body:  var(--e-global-typography-e6e6b86-font-family), system-ui, sans-serif;

	--kmh-list-w:   350px;
	--kmh-aside-w:  274px;   /* 24 gap + 250 carte  → panneau ouvert = 648px */
	--kmh-ease:     cubic-bezier(.2, .7, .2, 1);
	/* Pleine largeur ; marges latérales = celles des conteneurs Elementor
	   (Réglages du site > Mise en page), donc le header suit chaque point de rupture. */
	--kmh-gutter-l: var(--container-default-padding-left, 10px);
	--kmh-gutter-r: var(--container-default-padding-right, 10px);
	--kmh-logo-gap: 40px;   /* espace logo → navigation principale */

	position: relative;
	z-index: 100;
	width: 100%;
	color: var(--kmh-fg);
	/* Seule transition de couleur du header : tout le reste hérite de cette valeur,
	   donc tous les éléments passent du blanc au noir en même temps. */
	transition: color .25s;
}
.kmh--compact,
.kmh--overlay.is-scrolled { --kmh-fg: var(--kmh-ink); }
.kmh--overlay {
	--kmh-fg: var(--kmh-paper);
	/* CTA noir → blanc au survol */
	--kmh-cta-bg:         var(--kmh-ink);
	--kmh-cta-text:       var(--kmh-paper);
	--kmh-cta-bg-hover:   white;
	--kmh-cta-text-hover: var(--kmh-ink);
}

/* --- Sticky : le <header> Elementor qui contient le shortcode ------------ */
.elementor-location-header:has(.kmh) {
	position: sticky;
	top: 0;
	z-index: 100;
}
.admin-bar .elementor-location-header:has(.kmh) { top: var(--wp-admin--admin-bar--height, 32px); }

/* --- Resets (Hello / Elementor stylent button, input, a) ---------------- */
.kmh *, .kmh *::before, .kmh *::after { box-sizing: border-box; }
.kmh ul { list-style: none; margin: 0; padding: 0; }
.kmh p { margin: 0; }
.kmh a, .kmh a:hover, .kmh a:focus { color: inherit; text-decoration: none; }
.kmh button {
	appearance: none; background: none; border: 0; border-radius: 0; box-shadow: none;
	margin: 0; padding: 0; color: inherit; font: inherit; letter-spacing: inherit;
	text-transform: inherit; line-height: inherit; cursor: pointer;
}
/* le Kit Elementor style button:hover → on neutralise avec une spécificité plus haute */
.kmh .kmh__btn,
.kmh .kmh__btn:hover,
.kmh .kmh__btn:focus { background: transparent; color: inherit; border: 0; box-shadow: none; }
.kmh :focus-visible { outline: 1px solid currentColor; outline-offset: 2px; }
.kmh-sr {
	position: absolute !important; width: 1px; height: 1px; overflow: hidden;
	clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* --- Typo Label/M ------------------------------------------------------- */
.kmh .kmh__label {
	font-family: var(--kmh-font-label);
	font-weight: 300;
	font-stretch: 112.5%;          /* SemiExpanded (axe wdth de Martian Mono) */
	font-size: 14px;
	line-height: 16.8px;
	letter-spacing: .2px;
	text-transform: uppercase;
	white-space: nowrap;
}

.kmh__icon { display: block; flex: none; width: 20px; height: 20px; fill: currentColor; }
.kmh__icon--16 { width: 16px; height: 16px; }
.kmh__icon--right { transform: rotate(-90deg); }

/* --- Fond plat, pleine largeur ----------------------------------------- */
.kmh__bg {
	position: absolute;
	inset: 0;
	z-index: -1;
	pointer-events: none;
	background: var(--kmh-bar-bg);
	transition: opacity .25s;
}
.kmh--overlay .kmh__bg            { opacity: 0; }
.kmh--overlay.is-scrolled .kmh__bg { opacity: 1; }

/* --- Barre ------------------------------------------------------------- */
/* Logo + navigation principale ancrés à gauche, outils (FAQ, Shop, recherche…) à droite */
.kmh__bar {
	display: flex;
	align-items: center;
	gap: var(--kmh-logo-gap);
	height: 58px;
	padding: 0 var(--kmh-gutter-r) 0 var(--kmh-gutter-l);
}

.kmh__logo {
	--kmh-logo-w: 90.22px;
	display: block;
	flex: none;
	width: var(--kmh-logo-w);
	height: 32px;
	overflow: hidden;   /* le logo est révélé par la largeur en overlay */
	color: var(--kmh-ink);
}
.kmh__logo svg, .kmh__logo img { display: block; width: var(--kmh-logo-w); height: 100%; max-width: none; }

/* Overlay : en haut de page, logo replié (largeur 0, espace annulé) → la navigation
   part du bord gauche. Au défilement, le logo s'ouvre et pousse la navigation à droite. */
.kmh--overlay .kmh__logo {
	width: 0;
	margin-right: calc(-1 * var(--kmh-logo-gap));
	opacity: 0;
	visibility: hidden;
	transition:
		width .35s var(--kmh-ease),
		margin-right .35s var(--kmh-ease),
		opacity .2s,
		visibility 0s linear .35s;
}
.kmh--overlay.is-scrolled .kmh__logo {
	width: var(--kmh-logo-w);
	margin-right: 0;
	opacity: 1;
	visibility: visible;
	transition:
		width .35s var(--kmh-ease),
		margin-right .35s var(--kmh-ease),
		opacity .25s .1s,
		visibility 0s;
}

.kmh__menu { display: flex; align-items: flex-start; gap: 2px; }
.kmh__item { position: relative; }

.kmh .kmh__trigger,
.kmh .kmh__toplink {
	display: flex;
	align-items: center;
	gap: 8px;
	height: 40px;
	padding: 8px;
	transition: background-color .15s;   /* pas de color : elle suit .kmh, sinon décalage */
}
.kmh .kmh__toplink--sm { height: 30px; }

.kmh .kmh__item.is-open > .kmh__trigger,
.kmh .kmh__item.is-open > .kmh__trigger:hover {
	background: var(--kmh-accent);
	color: var(--kmh-ink);
}

.kmh__tools { display: flex; align-items: center; justify-content: flex-end; gap: 20px; height: 40px; margin-left: auto; }
.kmh__secondary { display: flex; gap: 20px; }

/* --- Recherche : contour = .hex .hex--sm .hex-line du thème -------------
   S'ouvre au survol, reste ouverte tant qu'elle a le focus ou du texte.   */
.kmh .kmh-search {
	display: none;
	align-items: center;
	height: 28px;
	padding: 0 10px;                    /* 6 (biseau) + 4 */
	margin: 0;
	color: inherit;
}
.kmh .kmh-search .kmh-search__field[type="search"] {
	all: unset;
	box-sizing: border-box;
	width: 0;
	min-width: 0;
	visibility: hidden;
	opacity: 0;
	color: inherit;
	font-family: var(--kmh-font-label);
	font-weight: 300;
	font-stretch: 112.5%;
	font-size: 14px;
	line-height: 16.8px;
	letter-spacing: .2px;
	text-transform: uppercase;
	/* refermeture retardée : un léger écart de souris ne la ferme pas */
	transition: width .25s var(--kmh-ease) .3s, opacity .15s .3s, visibility 0s linear .55s;
}
.kmh .kmh-search__field::placeholder { color: inherit; opacity: 1; }
.kmh .kmh-search__field::-webkit-search-cancel-button { display: none; }
.kmh .kmh-search:is(:hover, :focus-within) .kmh-search__field[type="search"],
.kmh .kmh-search .kmh-search__field[type="search"]:not(:placeholder-shown) {
	width: 119px;                       /* 147 − 2×4 − 20 (icône) */
	visibility: visible;
	opacity: 1;
	transition: width .25s var(--kmh-ease), opacity .2s .1s, visibility 0s;
}
.kmh-search__btn { display: flex; }

/* --- CTA (phase inscription) ------------------------------------------- */
.kmh a.kmh-cta,
.kmh a.kmh-cta:hover,
.kmh a.kmh-cta:focus {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 13px 22px;
	background: var(--kmh-cta-bg);
	color: var(--kmh-cta-text);
	transition: background-color .3s, color .3s;
}
.kmh a.kmh-cta:hover,
.kmh a.kmh-cta:focus-visible {
	background: var(--kmh-cta-bg-hover);
	color: var(--kmh-cta-text-hover);
}

/* ==========================================================================
   Dropdown
   ========================================================================== */
.kmh-dd {
	position: absolute;
	top: 100%;
	left: calc(-12px + var(--kmh-shift, 0px));
	z-index: 10;
	visibility: hidden;
	opacity: 0;
	transform: translateY(-4px);
	transition: opacity .18s, transform .18s var(--kmh-ease), visibility 0s linear .18s;
}
.kmh__item.is-open > .kmh-dd {
	visibility: visible;
	opacity: 1;
	transform: none;
	transition-delay: 0s;
}

/* Biseaux : classe .hex (preset 12/12 du thème) sur le panneau */
.kmh-dd__panel {
	display: flex;
	align-items: flex-start;   /* la liste garde sa hauteur naturelle (mesurée par le JS) */
	padding: 12px;
	background: var(--kmh-dd-bg);
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
	color: var(--kmh-paper);
	/* hauteur posée par le JS (liste, ou carte si plus haute) : s'agrandit en douceur au survol */
	overflow: hidden;
	transition: height .28s var(--kmh-ease);
}

.kmh-dd__list { flex: none; width: var(--kmh-list-w); }
.kmh-dd__list > li + li { border-top: 1px solid var(--kmh-dd-sep); }

.kmh .kmh-dd__link {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 8px;
	color: var(--kmh-paper);
	transition: background-color .12s, color .12s;
}
.kmh .kmh-dd__link.is-active {
	background: var(--kmh-dd-hover);
	color: var(--kmh-ink);
}

/* Colonne visuel : s'ouvre vers la droite, puis la carte apparaît */
.kmh-dd__aside {
	flex: none;
	display: flex;
	align-items: flex-start;   /* carte alignée en haut, comme la maquette */
	width: 0;
	overflow: hidden;
	transition: width .28s var(--kmh-ease);
}
.kmh-dd.is-expanded .kmh-dd__aside { width: var(--kmh-aside-w); }

.kmh-dd__stack {
	display: grid;
	flex: none;
	width: 250px;
	margin-left: 24px;
	opacity: 0;
	transition: opacity .12s;
}
.kmh-dd.is-expanded .kmh-dd__stack {
	opacity: 1;
	transition: opacity .2s .18s;
}

.kmh-dd__visual {
	grid-area: 1 / 1;
	align-self: start;
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 12px;
	background: var(--kmh-card-bg);
	color: var(--kmh-ink);
	opacity: 0;
	visibility: hidden;
	transition: opacity .18s, visibility 0s linear .18s;
}
.kmh-dd__visual.is-active {
	opacity: 1;
	visibility: visible;
	transition-delay: 0s;
}
/* la carte est un lien : garder le texte noir malgré le reset .kmh a */
.kmh a.kmh-dd__visual,
.kmh a.kmh-dd__visual:hover,
.kmh a.kmh-dd__visual:focus { color: var(--kmh-ink); text-decoration: none; }

.kmh .kmh-dd__img {
	display: block;
	width: 100%;
	max-width: none;
	height: auto;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	border-radius: 0;
	background: rgb(0 0 0 / .06);
}
.kmh-dd__text {
	font-family: var(--kmh-font-body);
	font-weight: 400;
	font-size: 14px;
	line-height: 16.8px;
	letter-spacing: .2px;
}

@media (prefers-reduced-motion: reduce) {
	.kmh *, .kmh *::before, .kmh *::after { transition-duration: 0s !important; transition-delay: 0s !important; }
}

/* ==========================================================================
   Mobile / tablette — maquette « Home - mobile » : « MENU ≡ » en haut à droite,
   « FERMER × » une fois ouvert (le panneau lui-même n'est pas encore dessiné : repli simple)
   ========================================================================== */
.kmh__burger, .kmh-m { display: none; }

@media (max-width: 1024px) {
	.kmh__nav,
	.kmh__secondary,
	.kmh-search { display: none !important; }
	.kmh__tools { margin-left: auto; }

	/* CTA : centré dans la barre quand le logo est là ; en overlay tout en haut
	   (logo masqué), il glisse au bord gauche. Positionné sur la barre, aligné
	   verticalement sur le bouton menu (40px) via --kmh-pt (marge haute de la barre). */
	.kmh__tools { display: contents; }
	.kmh .kmh__bar { position: relative; --kmh-pt: 9px; }
	.kmh--compact .kmh__bar { height: auto; padding-top: var(--kmh-pt); padding-bottom: var(--kmh-pt); }
	.kmh--overlay .kmh__bar { --kmh-pt: 34px; }
	.kmh--overlay.is-scrolled .kmh__bar { --kmh-pt: 9px; }
	.kmh a.kmh-cta,
	.kmh a.kmh-cta:hover,
	.kmh a.kmh-cta:focus {
		padding: 6px 8px;
		position: absolute;
		top: calc(var(--kmh-pt) + 6px);          /* (40 − 28) / 2 */
		left: 50%;
		transform: translateX(-50%);
		transition: left .35s var(--kmh-ease), transform .35s var(--kmh-ease), top .25s var(--kmh-ease),
			background-color .3s, color .3s;
	}
	.kmh--overlay:not(.is-scrolled) a.kmh-cta {
		left: var(--kmh-gutter-l);
		transform: translateX(0);
	}

	/* Bouton « MENU ≡ » / « FERMER × » : texte Label M + icône 40 × 40, écart 4px */
	.kmh .kmh__burger {
		display: flex;
		align-items: center;
		gap: 4px;
		flex: none;
		height: 40px;
		margin-left: auto;
	}
	.kmh__burger-icon { display: block; flex: none; width: 40px; height: 40px; fill: currentColor; }
	.kmh__burger[aria-expanded="true"] .kmh__when-closed,
	.kmh__burger[aria-expanded="false"] .kmh__when-open { display: none; }

	/* Overlay (home) : bouton à 34px du haut, aligné sur la marge des conteneurs, comme la maquette */
	.kmh--overlay .kmh__bar {
		height: auto;
		align-items: center;   /* logo (32px) et bouton (40px) centrés une fois défilé */
		padding: 34px var(--kmh-gutter-r) 0 var(--kmh-gutter-l);
		transition: padding .25s var(--kmh-ease);
	}
	/* une fois la page défilée : barre normale de 58px avec fond */
	.kmh--overlay.is-scrolled .kmh__bar { padding-top: 9px; padding-bottom: 9px; }

	.kmh-m:not([hidden]) {
		display: block;
		position: absolute;
		top: calc(100% + 4px);
		left: 8px;
		right: 8px;
		padding: 12px;
		background: var(--kmh-dd-bg);
		-webkit-backdrop-filter: blur(10px);
		backdrop-filter: blur(10px);
		color: var(--kmh-paper);
		max-height: calc(100dvh - 80px);
		overflow-y: auto;
	}
	.kmh-m__menu > li + li { border-top: 1px solid var(--kmh-dd-sep); }
	.kmh .kmh-m__row {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 12px 8px;
		cursor: pointer;
		list-style: none;
	}
	.kmh-m__row::-webkit-details-marker { display: none; }
	.kmh-m__row--sub { padding-left: 20px; }
	.kmh-m details[open] > summary .kmh__icon { transform: rotate(180deg); }
	.kmh-m__sub { padding-bottom: 8px; }
}
