/**
 * Recherche rapide : champ toujours visible dans la barre du menu, entre le logo et le menu, et liste des suggestions, à sa largeur.
 *
 * Point de rupture 991 px : celui de Max Mega Menu (menu replié en dessous).
 * Sélecteurs par id : bootstrap.css et Sequex, chargés après cette feuille, l'emporteraient sinon.
 */

.qf-quick-search {
	--qf-qs-accent: #2196f3;
	--qf-qs-text: #222;
	--qf-qs-muted: #666;
	--qf-qs-line: #e0e0e0;
	--qf-qs-field: #f2f3f5;
	--qf-qs-hover: #f2f7fd;
	color: var(--qf-qs-text);
	min-width: 0;
	position: relative;
}

/* En-tête : logo, champ puis menu sur une ligne */

@media (min-width: 992px) {
	#sequex-main-menu-wrapper > .container {
		align-items: center;
		display: flex;
		gap: 24px;
	}

	#sequex-main-menu-wrapper .navbar-brand {
		flex: none;
		order: 1;
	}

	/* Le champ prend toute la place laissée entre le logo et le menu. */
	#qf-quick-search {
		flex: 1 1 auto;
		min-width: 160px;
		order: 2;
	}

	/*
	 * Max Mega Menu occupe toute la largeur par défaut : il se réduit à ses éléments, collés au champ,
	 * sans passer sur deux lignes (c'est le champ qui rétrécit).
	 */
	#sequex-main-menu-wrapper #mega-menu-wrap-sequex-main-menu {
		flex: none;
		margin-left: 0;
		order: 3;
		width: auto;
	}
}

/* Écrans moyens : logo et liens du menu resserrés pour garder le champ sur la même ligne. */
@media (min-width: 992px) and (max-width: 1399px) {
	#sequex-main-menu-wrapper .navbar-brand img {
		height: auto;
		max-width: 180px;
	}

	#mega-menu-wrap-sequex-main-menu #mega-menu-sequex-main-menu > li.mega-menu-item > a.mega-menu-link {
		font-size: 14px;
		padding-left: 8px;
		padding-right: 8px;
	}
}

/*
 * Menu replié (< 992 px) : logo du thème centré sur la première ligne ; dessous, le champ et le bouton du menu
 * à sa droite. La boîte de Max Mega Menu s'efface (`display: contents`) pour que sa barre et sa liste
 * deviennent des éléments de la ligne de l'en-tête ; la liste dépliée passe en dessous, pleine largeur.
 */
@media (max-width: 991px) {
	#sequex-main-menu-wrapper > .container {
		align-items: center;
		display: flex;
		flex-wrap: wrap;
		gap: 0 8px;
	}

	/* Logo : taille, centrage et marge du thème, seul sur sa ligne. */
	#sequex-main-menu-wrapper .navbar-brand {
		flex: 0 0 100%;
		order: 1;
	}

	#mega-menu-wrap-sequex-main-menu {
		display: contents;
	}

	/*
	 * Même marge basse que la barre de Max Mega Menu (10 px) : champ et bouton du menu centrés sur la même ligne.
	 * Position statique : la liste des suggestions se place par rapport au conteneur de l'en-tête (positionné par le
	 * thème), sur toute sa largeur (champ et bouton du menu), marges de la page conservées.
	 */
	#qf-quick-search {
		flex: 1 1 0;
		margin-bottom: 10px;
		order: 2;
		position: static;
	}

	/* Bas du conteneur = bas du champ + sa marge (10 px) : liste à 6 px du champ. */
	#qf-quick-search .qf-quick-search__dropdown {
		left: 0;
		right: 0;
		top: calc(100% - 4px);
	}

	#mega-menu-wrap-sequex-main-menu .mega-menu-toggle {
		background: transparent;
		border: 0;
		box-shadow: none;
		flex: none;
		order: 3;
		padding: 0;
		width: auto;
	}

	#mega-menu-wrap-sequex-main-menu .mega-menu-toggle .mega-toggle-blocks-left,
	#mega-menu-wrap-sequex-main-menu .mega-menu-toggle .mega-toggle-blocks-right {
		flex: none;
		padding: 0;
	}

	#mega-menu-wrap-sequex-main-menu .mega-menu-toggle .mega-toggle-blocks-center,
	#mega-menu-wrap-sequex-main-menu .mega-menu-toggle .mega-toggle-blocks-left:not(:has(*)) {
		display: none;
	}

	/*
	 * Bouton du menu : même hauteur (40 px), même fond et mêmes coins que le champ. Le fond est porté par le bloc,
	 * car Max Mega Menu réduit le bouton lui-même (`transform: scale()`).
	 */
	#mega-menu-wrap-sequex-main-menu .mega-menu-toggle .mega-toggle-block {
		align-items: center;
		background: #f2f3f5;
		border-radius: 8px;
		display: flex;
		height: 40px;
		justify-content: center;
		margin: 0;
		width: 44px;
	}

	#mega-menu-wrap-sequex-main-menu .mega-menu-toggle .mega-toggle-block .mega-toggle-animated {
		box-shadow: none;
		transform: scale(.55);
	}

	#mega-menu-wrap-sequex-main-menu .mega-menu-toggle .mega-toggle-block .mega-toggle-animated-inner,
	#mega-menu-wrap-sequex-main-menu .mega-menu-toggle .mega-toggle-block .mega-toggle-animated-inner::before,
	#mega-menu-wrap-sequex-main-menu .mega-menu-toggle .mega-toggle-block .mega-toggle-animated-inner::after {
		background-color: #666;
	}

	#mega-menu-wrap-sequex-main-menu #mega-menu-sequex-main-menu {
		flex: 0 0 100%;
		order: 4;
	}
}

/* Champ */

#qf-quick-search .qf-quick-search__form {
	align-items: center;
	background: var(--qf-qs-field);
	border: 1px solid transparent;
	border-radius: 8px;
	display: flex;
	gap: 8px;
	margin: 0;
	padding: 0 10px;
	transition: background-color .15s, border-color .15s, box-shadow .15s;
}

#qf-quick-search .qf-quick-search__form:focus-within {
	background: #fff;
	border-color: var(--qf-qs-accent);
	box-shadow: 0 0 0 3px rgba(33, 150, 243, .15);
}

.qf-quick-search__form > .qf-quick-search-icon {
	color: var(--qf-qs-muted);
	flex: none;
	height: 18px;
	width: 18px;
}

#qf-quick-search .qf-quick-search__input,
#qf-quick-search .qf-quick-search__input:focus {
	-webkit-appearance: none;
	appearance: none;
	background: transparent;
	border: 0;
	box-shadow: none;
	color: var(--qf-qs-text);
	flex: 1;
	font-size: 15px;
	height: 38px;
	line-height: 1.3;
	margin: 0;
	min-width: 0;
	outline: none;
	padding: 0;
}

.qf-quick-search__input::-webkit-search-cancel-button {
	display: none;
}

.qf-quick-search__spinner {
	animation: qf-quick-search-spin .7s linear infinite;
	border: 2px solid var(--qf-qs-line);
	border-radius: 50%;
	border-top-color: var(--qf-qs-accent);
	flex: none;
	height: 14px;
	visibility: hidden;
	width: 14px;
}

.qf-quick-search.is-loading .qf-quick-search__spinner {
	visibility: visible;
}

@keyframes qf-quick-search-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Liste des suggestions : même largeur que le champ */

.qf-quick-search__dropdown {
	animation: qf-quick-search-drop .16s cubic-bezier(.2, .8, .2, 1);
	background: #fff;
	border: 1px solid var(--qf-qs-line);
	border-radius: 8px;
	box-shadow: 0 16px 32px -12px rgba(0, 0, 0, .3);
	left: 0;
	padding: 4px;
	position: absolute;
	right: 0;
	text-align: left;
	top: calc(100% + 6px);
	z-index: 10000;
}

.qf-quick-search__dropdown[hidden],
.qf-quick-search__results[hidden],
.qf-quick-search__empty[hidden],
.qf-quick-search__all[hidden] {
	display: none;
}

@keyframes qf-quick-search-drop {
	from {
		opacity: 0;
		transform: translateY(-6px);
	}
}

.qf-quick-search__results {
	list-style: none;
	margin: 0;
	max-height: min(70vh, 600px);
	overflow-y: auto;
	padding: 0;
}

.qf-quick-search__option {
	animation: qf-quick-search-fade .18s ease-out both;
	border-radius: 6px;
	margin: 0;
}

@keyframes qf-quick-search-fade {
	from {
		opacity: 0;
		transform: translateY(4px);
	}
}

.qf-quick-search__option.is-active {
	background: var(--qf-qs-hover);
}

.qf-quick-search__result,
.qf-quick-search__result:hover,
.qf-quick-search__result:focus {
	align-items: center;
	color: var(--qf-qs-text);
	display: flex;
	gap: 12px;
	padding: 6px 8px;
	text-decoration: none;
}

.qf-quick-search__poster {
	aspect-ratio: 3 / 4;
	background: #ededed;
	border-radius: 4px;
	flex: none;
	overflow: hidden;
	width: 48px;
}

.qf-quick-search__poster img {
	display: block;
	height: 100%;
	object-fit: cover;
	width: 100%;
}

.qf-quick-search__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 1px;
	min-width: 0;
}

.qf-quick-search__title {
	font-size: 16px;
	font-weight: 600;
	line-height: 1.25;
}

.qf-quick-search__meta {
	color: var(--qf-qs-muted);
	font-size: 14px;
	line-height: 1.35;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.qf-quick-search__result mark {
	background: none;
	color: inherit;
	padding: 0;
	text-decoration: underline;
	text-decoration-color: var(--qf-qs-accent);
	text-decoration-thickness: 1.5px;
	text-underline-offset: 2px;
}

.qf-quick-search__rating {
	color: #f5a623;
	flex: none;
	font-size: 13px;
	font-weight: 600;
	white-space: nowrap;
}

.qf-quick-search__empty {
	color: var(--qf-qs-muted);
	font-size: 14px;
	margin: 8px 8px 4px;
}

/* Pied */

.qf-quick-search__footer {
	align-items: center;
	border-top: 1px solid var(--qf-qs-line);
	display: flex;
	flex-wrap: wrap;
	font-size: 15px;
	gap: 6px 16px;
	margin-top: 4px;
	padding: 8px 8px 4px;
}

.qf-quick-search__all {
	font-weight: 600;
}

.qf-quick-search__advanced {
	margin-left: auto;
}

.qf-quick-search__all,
.qf-quick-search__advanced {
	color: var(--qf-qs-accent);
}

/* Ordinateur : affiches un peu plus grandes. */
@media (min-width: 992px) {
	.qf-quick-search__poster {
		width: 56px;
	}
}

@media (max-width: 991px) {
	#qf-quick-search .qf-quick-search__input,
	#qf-quick-search .qf-quick-search__input:focus {
		font-size: 16px; /* ≥ 16 px : pas de zoom automatique sur iOS. */
	}

	.qf-quick-search__results {
		max-height: 60vh;
	}

	.qf-quick-search__title {
		font-size: 14px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.qf-quick-search__dropdown,
	.qf-quick-search__option {
		animation: none;
	}

	.qf-quick-search__spinner {
		animation-duration: 2s;
	}
}
