/*
 * Header réseau — modèle gouvernement : logo | barre | nom du site | menu | CTA.
 * Couleurs : presets theme.json uniquement. Seuil menu mobile : 960px.
 * Contrastes (cf. brief graphistes) : texte main/blanc 16,55:1 ; bouton blanc/vert 5,79:1.
 */

.apajh-header__inner {
	gap: var(--wp--preset--spacing--small);
}

/* Bloc marque : logo + barre verticale grise + nom du site. */
.apajh-header__brand {
	flex: 0 1 auto;
	min-width: 0;
	gap: var(--wp--preset--spacing--small);
}

.apajh-header__brand .wp-block-site-logo img {
	width: auto;
	max-width: 120px;
	height: auto;
	max-height: 56px;
}

.apajh-header__site {
	margin: 0;
	max-width: 14rem;
	text-wrap: balance;
}

.apajh-header__site a {
	text-decoration: none;
}

.apajh-header__site a:hover,
.apajh-header__site a:focus-visible {
	text-decoration: underline;
}

/* Barre verticale grise (décorative), uniquement si un logo précède le nom. */
.apajh-header__brand.has-logo .apajh-header__site {
	padding-left: var(--wp--preset--spacing--small);
	border-left: 1px solid color-mix(in srgb, var(--wp--preset--color--border-dark) 55%, transparent);
	min-height: 2.25rem;
	display: flex;
	align-items: center;
}

/* Navigation. */
.apajh-header__nav {
	flex: 1 1 auto;
}

.apajh-header__nav .wp-block-navigation-item__content {
	padding: 0.4rem 0.2rem;
}

.apajh-header__nav .wp-block-navigation-item__content[aria-current="page"] {
	font-weight: 600;
	text-decoration: underline;
	text-decoration-thickness: 2px;
	text-underline-offset: 0.4em;
}

/* CTA : bouton du header (desktop) / entrée du menu (mobile). */
.apajh-header__cta {
	flex: 0 0 auto;
}

.apajh-header .apajh-header__nav .apajh-header__cta-item {
	display: none;
}

/* Bouton « Menu » libellé, comme sur le site du gouvernement. */
.apajh-header .wp-block-navigation__responsive-container-open,
.apajh-header .wp-block-navigation__responsive-container-close {
	align-items: center;
	gap: 0.4rem;
	padding: 0.45rem 0.95rem;
	border: 1px solid var(--wp--preset--color--primary);
	border-radius: 999px;
	color: var(--wp--preset--color--primary);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	line-height: 1.2;
}

.apajh-header .wp-block-navigation__responsive-container-open svg,
.apajh-header .wp-block-navigation__responsive-container-close svg {
	display: none;
}

.apajh-header .wp-block-navigation__responsive-container-open::after {
	content: "Menu";
}

.apajh-header .wp-block-navigation__responsive-container-close::after {
	content: "Fermer";
}

/* Tablette et mobile : menu replié dans le bouton, CTA dans le panneau. */
@media (max-width: 959px) {
	.apajh-header .wp-block-navigation__responsive-container:not(.is-menu-open) {
		display: none;
	}

	.apajh-header .wp-block-navigation__responsive-container-open {
		display: flex;
	}

	.apajh-header__nav {
		flex: 0 0 auto;
		margin-left: auto;
	}

	.apajh-header .apajh-header__cta {
		display: none;
	}

	.apajh-header .apajh-header__nav .apajh-header__cta-item {
		display: block;
		margin-top: var(--wp--preset--spacing--small);
	}

	.apajh-header .wp-block-navigation__responsive-container .apajh-header__cta-item .wp-block-navigation-item__content {
		display: block;
		padding: 0.8rem 1.6rem;
		border-radius: 999px;
		background: var(--wp--preset--color--primary);
		color: var(--wp--preset--color--base);
		font-size: var(--wp--preset--font-size--small);
		font-weight: 600;
		text-align: center;
		text-decoration: none;
	}

	/* Panneau ouvert : liens empilés, séparés par un filet. */
	.apajh-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__container {
		gap: 0;
		align-items: stretch;
		width: 100%;
	}

	.apajh-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item:not(.apajh-header__cta-item) {
		border-bottom: 1px solid var(--wp--preset--color--border-light);
	}

	.apajh-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content {
		display: block;
		padding: 0.9rem 0;
		font-size: var(--wp--preset--font-size--medium);
	}

	.apajh-header__brand .wp-block-site-logo img {
		max-width: 72px;
		max-height: 40px;
	}

	.apajh-header__site {
		max-width: 12rem;
		font-size: var(--wp--preset--font-size--x-small);
	}
}

/*
 * Desktop (≥ 960 px) : grille logo | menu centré | CTA.
 * - Menu court : colonnes symétriques, menu centré sur la page.
 * - Menu long : classe .is-full (posée par header-menu.js), menu centré dans
 *   l'espace restant, entrées excédentaires sous « Plus ».
 * Sans JavaScript, le menu natif garde son retour à la ligne.
 */
@media (min-width: 960px) {
	.apajh-header .apajh-header__inner {
		display: grid;
		grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
		align-items: center;
	}

	.apajh-header .apajh-header__inner.is-full {
		grid-template-columns: auto minmax(0, 1fr) auto;
	}

	.apajh-header .apajh-header__inner.is-measuring {
		display: flex;
	}

	.apajh-header .apajh-header__inner.is-measuring .apajh-header__nav {
		display: none;
	}

	.apajh-header .apajh-header__brand {
		justify-self: start;
	}

	.apajh-header .apajh-header__nav {
		justify-self: center;
		max-width: 100%;
	}

	.apajh-header .apajh-header__cta {
		justify-self: end;
	}

	.apajh-header .apajh-header__nav .wp-block-navigation__container {
		justify-content: center;
	}

	/* Une seule ligne dès que le script est actif. */
	.apajh-header.has-priority-nav .apajh-header__nav .wp-block-navigation__container {
		flex-wrap: nowrap;
	}

	.apajh-header.has-priority-nav .apajh-header__nav .wp-block-page-list {
		display: flex;
		flex-wrap: nowrap;
		justify-content: center;
		gap: inherit;
	}

	.apajh-header.has-priority-nav .apajh-header__nav .wp-block-navigation__container > .wp-block-navigation-item,
	.apajh-header.has-priority-nav .apajh-header__nav .wp-block-page-list > .wp-block-navigation-item {
		flex: none;
		white-space: nowrap;
	}

	/* Entrée « Plus ». */
	.apajh-header__plus {
		position: relative;
	}

	.apajh-header__plus[hidden] {
		display: none;
	}

	.apajh-header__plus-button {
		display: inline-flex;
		align-items: center;
		gap: 0.3rem;
		padding: 0.3rem 0.8rem;
		border: 1px solid var(--wp--preset--color--primary);
		border-radius: 999px;
		background: transparent;
		color: var(--wp--preset--color--primary);
		font: inherit;
		font-weight: 600;
		cursor: pointer;
	}

	.apajh-header__plus-button:hover {
		background: var(--wp--preset--color--primary-accent);
	}

	.apajh-header__plus-button[aria-expanded="true"] .apajh-header__plus-chevron {
		transform: rotate(180deg);
	}

	.apajh-header__plus.is-current .apajh-header__plus-button {
		text-decoration: underline;
		text-decoration-thickness: 2px;
		text-underline-offset: 0.3em;
	}

	.apajh-header__plus-list {
		position: absolute;
		top: calc(100% + 0.5rem);
		right: 0;
		z-index: 100;
		min-width: 15rem;
		margin: 0;
		padding: 0.4rem 0;
		list-style: none;
		background: var(--wp--preset--color--base);
		border: 1px solid var(--wp--preset--color--border-dark);
		border-radius: 12px;
		box-shadow: var(--wp--preset--shadow--medium);
	}

	.apajh-header__plus-list[hidden] {
		display: none;
	}

	.apajh-header__plus-list > .wp-block-navigation-item {
		display: block;
		white-space: normal;
	}

	.apajh-header__plus-list .wp-block-navigation-item__content {
		display: block;
		padding: 0.55rem 1.1rem;
		width: 100%;
		text-align: left;
		color: var(--wp--preset--color--main);
		text-decoration: none;
	}

	.apajh-header__plus-list a.wp-block-navigation-item__content:hover,
	.apajh-header__plus-list a.wp-block-navigation-item__content:focus-visible {
		background: var(--wp--preset--color--tertiary);
		text-decoration: underline;
	}

	/* Entrée à sous-menu déplacée sous « Plus » : dépliée à plat. */
	.apajh-header__plus-list [data-apajh-flat] {
		font-weight: 600;
		pointer-events: none;
		background: transparent;
	}

	.apajh-header__plus-list .wp-block-navigation__submenu-icon {
		display: none;
	}

	.apajh-header__plus-list .wp-block-navigation__submenu-container {
		position: static;
		display: block;
		visibility: visible;
		opacity: 1;
		height: auto;
		width: auto;
		min-width: 0;
		margin: 0;
		padding: 0 0 0.3rem 1rem;
		border: 0;
		background: transparent;
		box-shadow: none;
	}
}

/*
 * « Plus » n'existe que sur desktop. !important : les règles du panneau
 * mobile de WordPress (display:flex sur les entrées) l'emportaient sinon,
 * et le bouton réapparaissait non stylé dans le menu ouvert.
 */
.apajh-header__plus[hidden] {
	display: none !important;
}

@media (max-width: 959px) {
	.apajh-header .apajh-header__plus {
		display: none !important;
	}
}

/* ------------------------------------------------------------------
 * Recherche (10/2026) : loupe dans la colonne de droite (avec le CTA),
 * panneau déplié sous l'en-tête (pousse le contenu, pas de superposition).
 * RGAA : cible 44×44, focus visible, libellé texte masqué visuellement,
 * label visible sur le champ, état ouvert/fermé via aria-expanded (JS).
 * ------------------------------------------------------------------ */
.apajh-header__actions {
	flex: 0 0 auto;
	gap: var(--wp--preset--spacing--small);
}

.apajh-header__recherche {
	display: inline-grid;
	place-items: center;
	flex: none;
	width: 44px;
	height: 44px;
	border: 1px solid var(--wp--preset--color--primary);
	border-radius: 50%;
	color: var(--wp--preset--color--primary);
	background: var(--wp--preset--color--base);
	text-decoration: none;
}

.apajh-header__recherche svg,
.apajh-recherche-panneau__fermer svg {
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
}

.apajh-header__recherche:hover,
.apajh-header__recherche[aria-expanded="true"] {
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--base);
}

.apajh-header__recherche:focus-visible,
.apajh-recherche-panneau__fermer:focus-visible,
.apajh-recherche-panneau__valider:focus-visible,
.apajh-recherche-panneau input[type="search"]:focus-visible {
	outline: 3px solid var(--wp--preset--color--secondary);
	outline-offset: 2px;
}

.apajh-recherche-panneau {
	max-width: var(--wp--style--global--wide-size, 1320px);
	margin: var(--wp--preset--spacing--small) auto 0 !important;
	padding-top: var(--wp--preset--spacing--small);
	border-top: 1px solid var(--wp--preset--color--border-light);
}

.apajh-recherche-panneau[hidden] {
	display: none !important;
}

.apajh-recherche-panneau__label {
	display: block;
	margin-bottom: 0.4rem;
	font-weight: 600;
	font-size: var(--wp--preset--font-size--small);
}

.apajh-recherche-panneau__ligne {
	display: flex;
	gap: 0.5rem;
	align-items: center;
}

.apajh-recherche-panneau input[type="search"] {
	flex: 1 1 auto;
	min-width: 0;
	min-height: 48px;
	padding: 0.5rem 1.1rem;
	border: 1px solid var(--wp--preset--color--border-dark);
	border-radius: 999px;
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--main);
	font-size: var(--wp--preset--font-size--base, 1rem);
}

.apajh-recherche-panneau__valider {
	flex: none;
	min-height: 48px;
	padding: 0.5rem 1.4rem;
	border: 0;
	border-radius: 999px;
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--base);
	font-weight: 700;
	cursor: pointer;
}

.apajh-recherche-panneau__fermer {
	display: inline-grid;
	place-items: center;
	flex: none;
	width: 44px;
	height: 44px;
	border: 1px solid var(--wp--preset--color--border-dark);
	border-radius: 50%;
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--main);
	cursor: pointer;
}

@media (min-width: 960px) {
	.apajh-header .apajh-header__actions {
		justify-self: end;
	}
}

/* Tablette/mobile : loupe juste avant le bouton « Menu », CTA dans le panneau du menu. */
@media (max-width: 959px) {
	.apajh-header .apajh-header__actions {
		order: 2;
		margin-left: auto;
	}

	.apajh-header .apajh-header__nav {
		order: 3;
		margin-left: 0;
	}

	.apajh-recherche-panneau__valider {
		padding-inline: 1rem;
	}
}

@media (max-width: 420px) {
	.apajh-recherche-panneau__ligne {
		flex-wrap: wrap;
	}

	.apajh-recherche-panneau input[type="search"] {
		flex-basis: 100%;
	}

	.apajh-recherche-panneau__valider {
		flex: 1 1 auto;
	}
}
