/* Barre d'annonce — styles du site. Mobile : jusqu'à 767 px de large. */

.bda {
	--bda-z: 9990;
	position: relative;
	z-index: var(--bda-z);
	box-sizing: border-box;
	width: 100%;
	margin: 0;
	background: var(--bda-bg, #16201b);
	color: var(--bda-fg, #fff);
	font-size: var(--bda-fs, 16px);
	line-height: 1.35;
	-webkit-font-smoothing: antialiased;
}

.bda *,
.bda *::before,
.bda *::after {
	box-sizing: border-box;
}

.bda:not(.bda--in),
html.bda-off .bda,
.bda [hidden] {
	display: none !important;
}

/*
 * Plusieurs barres possibles sur une page : le script du <head> choisit celle à montrer.
 * Sans JavaScript, seule la première de la liste reste visible.
 */
.bda ~ .bda {
	display: none;
}

.bda__inner {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 8px 18px;
	max-width: 1200px;
	min-height: var(--bda-min-h, 48px);
	margin: 0 auto;
	padding: 8px 20px;
	text-align: center;
}

/*
 * Styles visuels renforcés : certains thèmes stylent les <button> et les <img> avec des
 * sélecteurs très forts (Twenty Twenty-One…). « :is(.bda, #bda-preview) » vise toutes les
 * barres avec le poids d'un identifiant (un :is() prend le poids de son sélecteur le plus fort).
 * L'affichage (display) reste sur les classes pour que les réglages par appareil puissent
 * masquer logo, bouton et croix.
 */

.bda__logo {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	line-height: 0;
}

:is(.bda, #bda-preview) .bda__logo img {
	display: block;
	width: auto;
	max-width: 240px;
	height: var(--bda-logo-h, 40px);
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: var(--bda-logo-r, 0px);
	box-shadow: none;
	object-fit: contain;
}
:is(.bda, #bda-preview) .bda__text {
	margin: 0;
	padding: 0;
	color: inherit;
	font-size: inherit;
	font-weight: 400;
	line-height: inherit;
}

:is(.bda, #bda-preview) .bda__text strong,
:is(.bda, #bda-preview) .bda__text b {
	font-weight: 700;
}

/* Petit texte, pour une mention légale (« *Investir comporte des risques »…). */
:is(.bda, #bda-preview) .bda__text small {
	font-size: 0.8em;
	line-height: inherit;
}

:is(.bda, #bda-preview) .bda__text a {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
}

.bda__btn {
	display: inline-flex;
}

:is(.bda, #bda-preview) .bda__btn {
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: auto;
	min-height: 0;
	margin: 0;
	padding: 8px 18px;
	border: 0;
	border-radius: 6px;
	background: var(--bda-btn-bg, #c98a3e);
	color: var(--bda-btn-fg, #16201b);
	font: inherit;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	text-transform: none;
	letter-spacing: normal;
	white-space: nowrap;
	cursor: pointer;
	box-shadow: none;
	transition: filter 0.2s ease;
}

:is(.bda, #bda-preview) .bda__btn:hover,
:is(.bda, #bda-preview) .bda__btn:focus {
	background: var(--bda-btn-bg, #c98a3e);
	color: var(--bda-btn-fg, #16201b);
	text-decoration: none;
	filter: brightness(1.1);
}

:is(.bda, #bda-preview) .bda__btn:focus-visible,
:is(.bda, #bda-preview) .bda__close:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.bda__close {
	position: absolute;
	top: 50%;
	right: 8px;
	display: none;
}

:is(.bda, #bda-preview) .bda__close {
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	min-height: 0;
	margin: -20px 0 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--bda-x, #fff);
	font-size: 0;
	line-height: 1;
	cursor: pointer;
	box-shadow: none;
}

:is(.bda, #bda-preview) .bda__close:hover,
:is(.bda, #bda-preview) .bda__close:focus {
	background: rgba(127, 127, 127, 0.22);
	color: var(--bda-x, #fff);
}

:is(.bda, #bda-preview) .bda__close svg {
	display: block;
	width: 18px;
	height: 18px;
	pointer-events: none;
}

/* Sans JavaScript, la croix ne servirait à rien. */
html:not(.bda-js) .bda .bda__close {
	display: none !important;
}

/* Espace réservé sous une barre fixée en bas, pour ne jamais masquer le pied de page. */
html.bda-pad-b body::after {
	content: "";
	display: block;
	height: var(--bda-h, 0px);
}

/* Bouton « retour en haut » de GeneratePress : remonté au-dessus d'une barre du bas. */
html.bda-pad-b .generate-back-to-top {
	bottom: calc(var(--bda-h, 0px) + 20px);
}

/* Les liens vers une ancre (#devis…) ne finissent pas cachés sous une barre du haut. */
html.bda-pad-t {
	scroll-padding-top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--bda-h, 0px));
}

/* Ordinateur et tablette */
@media (min-width: 768px) {
	.bda--no-d {
		display: none !important;
	}
	.bda--d-top {
		position: -webkit-sticky;
		position: sticky;
		top: var(--wp-admin--admin-bar--height, 0px);
	}
	.bda--d-top.bda--static {
		position: relative;
		top: auto;
	}
	.bda--d-top.bda--overlay {
		position: fixed;
		top: var(--wp-admin--admin-bar--height, 0px);
		right: 0;
		left: 0;
	}
	.bda--d-top.bda--overlay.bda--static {
		position: absolute;
	}
	.bda--d-bottom {
		position: fixed;
		right: 0;
		bottom: 0;
		left: 0;
	}
	.bda--x-d .bda__inner {
		padding-right: 56px;
		padding-left: 56px;
	}
	.bda--x-d .bda__close {
		display: inline-flex;
	}
	.bda--nobtn-d .bda__btn,
	.bda--nologo-d .bda__logo,
	.bda .bda__text--m {
		display: none;
	}
}

/* Mobile */
@media (max-width: 767px) {
	.bda {
		font-size: var(--bda-fs-m, 14px);
	}
	.bda--no-m {
		display: none !important;
	}
	.bda--m-top {
		position: -webkit-sticky;
		position: sticky;
		top: var(--wp-admin--admin-bar--height, 0px);
	}
	.bda--m-top.bda--static {
		position: relative;
		top: auto;
	}
	.bda--m-top.bda--overlay {
		position: fixed;
		top: var(--wp-admin--admin-bar--height, 0px);
		right: 0;
		left: 0;
	}
	.bda--m-top.bda--overlay.bda--static {
		position: absolute;
	}
	.bda--m-bottom {
		position: fixed;
		right: 0;
		bottom: 0;
		left: 0;
		padding-bottom: env(safe-area-inset-bottom, 0px);
	}
	.bda__inner {
		flex-wrap: nowrap;
		justify-content: space-between;
		gap: 12px;
		min-height: var(--bda-min-h-m, var(--bda-min-h, 48px));
		padding: 8px 14px;
		text-align: left;
	}
	.bda .bda__text {
		flex: 1 1 auto;
		min-width: 0;
	}
	:is(.bda, #bda-preview) .bda__btn {
		padding: 8px 14px;
	}
	:is(.bda, #bda-preview) .bda__logo img {
		max-width: 30vw;
		height: var(--bda-logo-h-m, 28px);
		border-radius: var(--bda-logo-r-m, 0px);
	}
	.bda--x-m .bda__inner {
		padding-right: 50px;
	}
	.bda--x-m .bda__close {
		display: inline-flex;
		right: 4px;
	}
	.bda--nobtn-m .bda__btn,
	.bda--nologo-m .bda__logo,
	.bda .bda__text--d {
		display: none;
	}
	.bda--nobtn-m .bda__inner,
	.bda__inner:not(:has(.bda__btn:not([hidden]))) {
		justify-content: center;
		text-align: center;
	}

	/* Disposition « sur deux lignes » : logo et texte, puis le bouton sur toute la largeur. */
	.bda--m-stack .bda__inner {
		flex-wrap: wrap;
		row-gap: 8px;
		padding-top: 10px;
		padding-bottom: 10px;
	}
	.bda--m-stack .bda__text {
		flex: 1 1 0; /* le texte reste à côté du logo, quelle que soit sa longueur */
	}
	.bda--m-stack.bda--x-m .bda__inner {
		padding-right: 14px;
	}
	:is(.bda, #bda-preview).bda--m-stack.bda--x-m .bda__text {
		margin-right: 34px; /* place de la croix, en haut à droite */
	}
	:is(.bda, #bda-preview).bda--m-stack .bda__btn {
		flex: 1 0 100%;
		padding-top: 10px;
		padding-bottom: 10px;
	}
	:is(.bda, #bda-preview).bda--m-stack .bda__close {
		top: 4px;
		margin-top: 0;
	}

	/* Disposition « logo au-dessus » : logo, texte puis bouton, empilés et centrés. */
	.bda--m-logotop .bda__inner,
	.bda--m-logotop.bda--x-m .bda__inner {
		flex-direction: column;
		flex-wrap: nowrap;
		align-items: center;
		justify-content: center;
		gap: 8px;
		padding: 12px 14px;
		text-align: center;
	}
	.bda--m-logotop .bda__text {
		flex: 0 0 auto;
		width: 100%;
	}
	:is(.bda, #bda-preview).bda--m-logotop.bda--x-m .bda__text {
		padding: 0 26px; /* le texte ne passe jamais sous la croix */
	}
	:is(.bda, #bda-preview).bda--m-logotop .bda__btn {
		align-self: stretch;
		padding-top: 10px;
		padding-bottom: 10px;
	}
	:is(.bda, #bda-preview).bda--m-logotop .bda__close {
		top: 4px;
		margin-top: 0;
	}
}

/* Sur petit écran, la barre d'administration défile avec la page. */
@media (max-width: 600px) {
	.bda--m-top {
		top: 0;
	}
}

/* Apparition */
@keyframes bda-from-top {
	from { transform: translateY(-100%); }
	to { transform: none; }
}
@keyframes bda-from-bottom {
	from { transform: translateY(100%); }
	to { transform: none; }
}
@keyframes bda-fade {
	from { opacity: 0; }
	to { opacity: 1; }
}

.bda--fx-fade.bda--in {
	animation: bda-fade 0.5s ease-out both;
}

@media (min-width: 768px) {
	.bda--fx-slide.bda--d-top.bda--in {
		animation: bda-from-top 0.45s ease-out both;
	}
	.bda--fx-slide.bda--d-bottom.bda--in {
		animation: bda-from-bottom 0.45s ease-out both;
	}
}

@media (max-width: 767px) {
	.bda--fx-slide.bda--m-top.bda--in {
		animation: bda-from-top 0.45s ease-out both;
	}
	.bda--fx-slide.bda--m-bottom.bda--in {
		animation: bda-from-bottom 0.45s ease-out both;
	}
}

/* Fermeture (sélecteur plus fort que celui de l'animation d'apparition) */
.bda.bda--in.bda--out {
	opacity: 0;
	animation: none;
	transition: opacity 0.3s ease, transform 0.3s ease;
}

@media (min-width: 768px) {
	.bda--d-top.bda--out { transform: translateY(-100%); }
	.bda--d-bottom.bda--out { transform: translateY(100%); }
}

@media (max-width: 767px) {
	.bda--m-top.bda--out { transform: translateY(-100%); }
	.bda--m-bottom.bda--out { transform: translateY(100%); }
}

/* Animation du bouton : quelques fois, puis il se calme. */
@keyframes bda-pulse {
	0%, 30%, 100% { transform: scale(1); }
	15% { transform: scale(1.08); }
}
@keyframes bda-shake {
	0%, 24%, 100% { transform: translateX(0); }
	4%, 12%, 20% { transform: translateX(-4px); }
	8%, 16% { transform: translateX(4px); }
}

.bda--att-pulse.bda--in .bda__btn {
	animation: bda-pulse 2.5s ease-in-out 1.5s 4;
}

.bda--att-shake.bda--in .bda__btn {
	animation: bda-shake 3s ease-in-out 1.5s 4;
}

@media (prefers-reduced-motion: reduce) {
	.bda,
	.bda * {
		animation: none !important;
		transition: none !important;
	}
}

@media print {
	.bda {
		display: none !important;
	}
}
