/**
 * Recherche dans le catalogue.
 *
 * Bande sous l'en-tête, suggestions, et blocs de la page de résultats.
 * Cible AAA, texte à 16px au minimum, cibles à 48px : le lectorat est âgé.
 */

/* Même papier que l'en-tête : la bande en est le prolongement, pas un
   bandeau posé dessus. Seul le filet du bas la sépare de la page. */
.jmg-recherche {
	background-color: var(--jmg-fond);
	border-block-end: 1px solid var(--jmg-bordure);
	padding-block: var(--jmg-e-3) var(--jmg-e-4);
}

/* Kadence peint son .site-container en fond de page : sans ce retrait, un
   rectangle plus clair se découpe au milieu de la bande. */
.jmg-recherche .site-container {
	background-color: transparent;
}

.jmg-recherche__form {
	margin: 0;
}

.jmg-recherche__label {
	display: block;
	margin-block-end: var(--jmg-e-2);
	font-size: var(--jmg-t-sm);
	font-weight: 600;
	color: var(--jmg-texte);
}

.jmg-recherche__ligne {
	display: flex;
	flex-wrap: wrap;
	gap: var(--jmg-e-3);
	align-items: stretch;
}

.jmg-recherche__champ {
	position: relative;
	flex: 1 1 18rem;
	min-width: 0;
}

.jmg-recherche__saisie {
	width: 100%;
	min-height: var(--jmg-cible);
	padding: 0.7em 1em;
	background-color: var(--jmg-fond-carte);
	color: var(--jmg-texte);
	font-family: var(--jmg-corps);
	font-size: var(--jmg-t-base);
	line-height: 1.3;
	/* Le champ garde une frontière à 3:1 au moins (WCAG 1.4.11). */
	border: 2px solid var(--jmg-bordure-forte);
	border-radius: var(--jmg-rayon);
	-webkit-appearance: none;
	appearance: none;
}

.jmg-recherche__saisie::placeholder {
	color: var(--jmg-texte-discret);
	opacity: 1;
}

/* La croix native de Safari et Chrome est minuscule : on la retire, le
   visiteur efface au clavier ou en sélectionnant le texte. */
.jmg-recherche__saisie::-webkit-search-cancel-button {
	-webkit-appearance: none;
}

.jmg-recherche__bouton {
	flex: 0 0 auto;
}

/* Suggestions */

.jmg-recherche__liste {
	position: absolute;
	inset-inline: 0;
	inset-block-start: calc(100% + 4px);
	z-index: 50;
	max-height: min(70vh, 34rem);
	overflow-y: auto;
	background-color: var(--jmg-fond-carte);
	border: 2px solid var(--jmg-bordure-forte);
	border-radius: var(--jmg-rayon);
	box-shadow: 0 8px 24px rgba(26, 28, 36, 0.16);
}

.jmg-recherche__liste[hidden] {
	display: none;
}

.jmg-recherche__groupe-titre {
	margin: 0;
	padding: var(--jmg-e-3) var(--jmg-e-4) var(--jmg-e-1);
	font-size: var(--jmg-t-xs);
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--jmg-texte-doux);
}

.jmg-recherche__option {
	display: flex;
	align-items: center;
	gap: var(--jmg-e-3);
	min-height: calc( var(--jmg-cible) + 8px );
	padding: var(--jmg-e-2) var(--jmg-e-4);
	color: var(--jmg-texte);
	text-decoration: none;
	/* Le trait de gauche est là pour que l'option active ne soit pas
	   signalée par la seule couleur de fond. */
	border-inline-start: 4px solid transparent;
}

.jmg-recherche__option:hover,
.jmg-recherche__option.est-actif {
	background-color: var(--jmg-fond-bande);
	border-inline-start-color: var(--jmg-or);
}

.jmg-recherche__image {
	flex: 0 0 auto;
	width: 40px;
	height: 56px;
	object-fit: contain;
	background-color: var(--jmg-fond-eleve);
	box-shadow: 0 0 0 1px var(--jmg-tranche);
}

.jmg-recherche__texte {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.jmg-recherche__titre {
	font-size: var(--jmg-t-sm);
	font-weight: 600;
	line-height: 1.3;
}

.jmg-recherche__detail {
	font-size: var(--jmg-t-xs);
	color: var(--jmg-texte-doux);
	line-height: 1.3;
}

.jmg-recherche__option--tout {
	justify-content: center;
	margin-block-start: var(--jmg-e-1);
	border-block-start: 1px solid var(--jmg-bordure);
	font-size: var(--jmg-t-sm);
	font-weight: 600;
	color: var(--jmg-or);
}

.jmg-recherche__vide {
	padding: var(--jmg-e-4);
	font-size: var(--jmg-t-sm);
}

.jmg-recherche__vide p {
	margin: 0;
}

.jmg-recherche__vide p + p {
	margin-block-start: var(--jmg-e-2);
}

.jmg-recherche__correction {
	color: var(--jmg-or);
	font-weight: 600;
}

/* Page de résultats */

.jmg-recherche-auteurs {
	margin-block: 0 var(--jmg-e-5);
	padding-block-end: var(--jmg-e-5);
	border-block-end: 1px solid var(--jmg-bordure);
}

.jmg-recherche-auteurs__titre {
	margin: 0 0 var(--jmg-e-3);
	font-size: var(--jmg-t-h4);
}

.jmg-recherche-auteurs__liste {
	display: flex;
	flex-wrap: wrap;
	gap: var(--jmg-e-3);
	margin: 0;
	padding: 0;
	list-style: none;
}

.jmg-recherche-auteurs__lien {
	display: flex;
	align-items: center;
	gap: var(--jmg-e-3);
	min-height: var(--jmg-cible);
	padding: var(--jmg-e-2) var(--jmg-e-4) var(--jmg-e-2) var(--jmg-e-2);
	background-color: var(--jmg-fond-carte);
	border: 1px solid var(--jmg-bordure);
	border-radius: var(--jmg-rayon);
	color: var(--jmg-texte);
	font-size: var(--jmg-t-sm);
	font-weight: 600;
	text-decoration: none;
}

.jmg-recherche-auteurs__lien:hover {
	border-color: var(--jmg-or);
	color: var(--jmg-or);
}

.jmg-recherche-auteurs__lien img {
	width: 48px;
	height: 48px;
	object-fit: cover;
	border-radius: 50%;
}

.jmg-recherche-vide {
	margin-block: var(--jmg-e-5);
	font-size: var(--jmg-t-base);
}

.jmg-recherche-vide__correction a {
	color: var(--jmg-or);
	font-weight: 600;
}

/* Sur ordinateur, libellé, champ et bouton tiennent sur une seule ligne : la
   bande prend la hauteur d'un champ, pas celle de deux rangées. */
@media (min-width: 900px) {
	.jmg-recherche {
		padding-block: var(--jmg-e-3);
	}

	.jmg-recherche__form {
		display: flex;
		align-items: center;
		gap: var(--jmg-e-4);
	}

	.jmg-recherche__label {
		flex: 0 0 auto;
		margin: 0;
		white-space: nowrap;
	}

	.jmg-recherche__ligne {
		flex: 1 1 auto;
		min-width: 0;
	}
}

/* Mobile : le bouton passe sous le champ, sur toute la largeur. */
@media (max-width: 600px) {
	.jmg-recherche__bouton {
		flex: 1 1 100%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.jmg-recherche__option {
		transition: none;
	}
}

/* Le tri du catalogue remplacerait la pertinence : masqué sur les résultats
   (voir jmg_recherche_retirer_commandes()). */
.search-results .kadence-woo-ordering {
	display: none;
}
