/**
 * Fanny J — bandeau et panneau de consentement.
 *
 * Reprend les variables de la charte définies dans style.css, avec des valeurs
 * de repli : la feuille est chargée sur toutes les pages, y compris celles qui
 * n'utilisent pas les gabarits du thème.
 */

/*
 * Garde indispensable : une règle d'auteur (display: flex sur l'overlay)
 * l'emporte toujours sur la feuille du navigateur, quelle que soit la
 * spécificité. Sans cela l'attribut « hidden » n'a aucun effet, la modale
 * reste affichée en permanence et aucun bouton ne parvient à la fermer.
 */
.fj-consent[hidden],
.fj-consent [hidden] {
	display: none !important;
}

.fj-consent {
	--fjc-ink: var(--ink, #050505);
	--fjc-line: var(--ink-line, rgba(255, 255, 255, .14));
	--fjc-paper: var(--paper, #FFFFFF);
	--fjc-mute: var(--paper-mute, #A8A8A8);
	--fjc-clay: var(--clay, #FFFFFF);

	font-family: var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
}

/* --- Bandeau ------------------------------------------------------------- */

.fj-consent__bar {
	position: fixed;
	z-index: 9998;
	right: 0;
	bottom: 0;
	left: 0;
	background: var(--fjc-ink);
	border-top: 1px solid var(--fjc-line);
	box-shadow: 0 -18px 50px rgba(0, 0, 0, .35);
	animation: fj-consent-up .45s var(--ease, cubic-bezier(.22, .61, .36, 1)) both;
}

.fj-consent__bar {
	max-height: 88vh;
	overflow-y: auto;
	padding-bottom: env(safe-area-inset-bottom);
}

.fj-consent__inner {
	display: flex;
	gap: clamp(16px, 3vw, 40px);
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	/* Reprend trait pour trait le conteneur .fj-shell du thème : la barre est
	   fixe elle aussi, son contenu doit tomber sur la même colonne. */
	width: 100%;
	max-width: var(--shell, 1240px);
	margin: 0 auto;
	padding-top: clamp(18px, 2.4vw, 26px);
	padding-bottom: clamp(18px, 2.4vw, 26px);
	padding-left: max(var(--gut, 24px), env(safe-area-inset-left));
	padding-right: max(var(--gut, 24px), env(safe-area-inset-right));
}

.fj-consent__body {
	flex: 1 1 420px;
	min-width: 0;
}

.fj-consent__title {
	margin: 0 0 6px;
	font-family: var(--serif, Georgia, serif);
	font-size: clamp(17px, 2vw, 20px);
	font-weight: 600;
	color: var(--fjc-paper);
	line-height: 1.2;
}

.fj-consent__text {
	margin: 0;
	font-size: 14px;
	line-height: 1.6;
	color: var(--fjc-mute);
}

.fj-consent__text a {
	color: var(--fjc-clay);
	text-decoration: underline;
	text-underline-offset: 2px;
}

/* --- Boutons ------------------------------------------------------------- */

.fj-consent__actions {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
	align-items: center;
}

.fj-consent__btn {
	appearance: none;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 11px 20px;
	border-radius: 2px;
	border: 1px solid var(--fjc-clay);
	font-family: inherit;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: .04em;
	text-transform: uppercase;
	white-space: nowrap;
	transition: background-color .25s, color .25s, border-color .25s;
}

/*
 * Refuser doit être aussi simple qu'accepter : les deux actions partagent la
 * même taille et la même lisibilité, seul le remplissage les distingue.
 */
.fj-consent__btn--ghost {
	background: transparent;
	color: var(--fjc-paper);
	border-color: var(--fjc-line);
}

.fj-consent__btn--ghost:hover,
.fj-consent__btn--ghost:focus-visible {
	border-color: var(--fjc-clay);
	color: var(--fjc-clay);
}

.fj-consent__btn--solid {
	background: var(--fjc-clay);
	color: var(--fjc-ink);
}

.fj-consent__btn--solid:hover,
.fj-consent__btn--solid:focus-visible {
	background: var(--clay-deep, #DCDCDC);
}

.fj-consent__btn:focus-visible,
.fj-consent__close:focus-visible {
	outline: 2px solid var(--fjc-clay);
	outline-offset: 3px;
}

/* --- Panneau de préférences ---------------------------------------------- */

.fj-consent__overlay {
	position: fixed;
	z-index: 9999;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: var(--gut, 24px);
	background: rgba(5, 5, 5, .78);
	backdrop-filter: blur(3px);
	animation: fj-consent-fade .25s ease both;
}

.fj-consent__panel {
	display: flex;
	flex-direction: column;
	width: min(680px, 100%);
	max-height: min(84vh, 760px);
	background: var(--ink-soft, #0A0A0A);
	border: 1px solid var(--fjc-line);
	border-radius: 4px;
	box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
}

.fj-consent__panelhead {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 22px clamp(20px, 3vw, 30px);
	border-bottom: 1px solid var(--fjc-line);
}

.fj-consent__panelhead h2 {
	margin: 0;
	font-family: var(--serif, Georgia, serif);
	font-size: 20px;
	font-weight: 600;
	color: var(--fjc-paper);
}

.fj-consent__close {
	appearance: none;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	background: transparent;
	border: 1px solid var(--fjc-line);
	border-radius: 2px;
	color: var(--fjc-mute);
	font-size: 16px;
	transition: color .25s, border-color .25s;
}

.fj-consent__close:hover {
	color: var(--fjc-clay);
	border-color: var(--fjc-clay);
}

.fj-consent__list {
	overflow-y: auto;
	padding: 6px clamp(20px, 3vw, 30px);
}

.fj-consent__item {
	padding: 20px 0;
	border-bottom: 1px solid var(--fjc-line);
}

.fj-consent__item:last-child {
	border-bottom: 0;
}

.fj-consent__itemhead {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-bottom: 6px;
}

.fj-consent__itemhead label {
	flex: 1;
	font-size: 15px;
	font-weight: 600;
	color: var(--fjc-paper);
	cursor: pointer;
}

.fj-consent__always {
	font-size: 11px;
	font-weight: 600;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--fjc-clay);
}

.fj-consent__itemhead input[type="checkbox"] {
	flex: none;
	width: 20px;
	height: 20px;
	accent-color: var(--fjc-clay);
	cursor: pointer;
}

.fj-consent__itemhead input[type="checkbox"]:disabled {
	cursor: default;
	opacity: .55;
}

.fj-consent__item p {
	margin: 0;
	font-size: 13.5px;
	line-height: 1.6;
	color: var(--fjc-mute);
}

.fj-consent__panelfoot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
	padding: 20px clamp(20px, 3vw, 30px);
	border-top: 1px solid var(--fjc-line);
}

.fj-consent__more {
	font-size: 13px;
	color: var(--fjc-mute);
	text-decoration: underline;
	text-underline-offset: 3px;
}

.fj-consent__more:hover {
	color: var(--fjc-clay);
}

body.fj-consent-open {
	overflow: hidden;
}

/* --- Mouvement ----------------------------------------------------------- */

@keyframes fj-consent-up {
	from { transform: translateY(100%); }
	to   { transform: translateY(0); }
}

@keyframes fj-consent-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
	.fj-consent__bar,
	.fj-consent__overlay {
		animation: none;
	}
}

@media (max-width: 720px) {
	.fj-consent__inner {
		flex-direction: column;
		align-items: stretch;
	}

	.fj-consent__actions {
		width: 100%;
	}

	.fj-consent__actions .fj-consent__btn {
		flex: 1 1 auto;
	}

	.fj-consent__panelfoot {
		flex-direction: column;
		align-items: stretch;
	}
}

/*
 * Trois boutons côte à côte deviennent illisibles sur un téléphone étroit :
 * ils passent l'un sous l'autre, à largeur égale — refuser reste aussi
 * accessible qu'accepter.
 */
/*
 * Le reset « body.fj button { background: none } » du thème l'emporte par
 * spécificité sur les variantes de bouton : sans ces règles, « Tout accepter »
 * s'affichait en simple texte, sans son aplat ocre.
 */
body.fj button.fj-consent__btn--solid { background: var(--fjc-clay); color: var(--fjc-ink); }
body.fj button.fj-consent__btn--solid:hover,
body.fj button.fj-consent__btn--solid:focus-visible { background: var(--clay-deep, #DCDCDC); }
body.fj button.fj-consent__btn--ghost { background: transparent; }
body.fj button.fj-consent__btn--ghost:hover,
body.fj button.fj-consent__btn--ghost:focus-visible { background: transparent; color: var(--fjc-clay); }

@media (max-width: 720px) {
	/*
	 * En colonne, « flex: 1 1 420px » du corps s'applique à la hauteur : le
	 * bandeau se réservait 420 px de vide et occupait les trois quarts de
	 * l'écran. La base repasse au contenu réel.
	 */
	.fj-consent__body { flex: 0 1 auto; }

	.fj-consent__inner {
		justify-content: flex-start;
		gap: 16px;
		padding-top: 18px;
		padding-bottom: 18px;
	}

	.fj-consent__title { font-size: 16px; }
	.fj-consent__text { font-size: 13px; line-height: 1.55; }
}

@media (max-width: 480px) {
	/* Refuser et accepter côte à côte, à parts strictement égales ;
	   « Personnaliser » en retrait dessous, sans peser sur le choix. */
	.fj-consent__bar .fj-consent__actions {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 8px;
		width: 100%;
	}

	.fj-consent__bar .fj-consent__btn {
		width: 100%;
		padding: 12px 8px;
		font-size: .68rem;
		letter-spacing: .06em;
	}

	.fj-consent__bar [data-fj-consent-action="reject"] { order: 1; }
	.fj-consent__bar [data-fj-consent-action="accept"] { order: 1; }

	.fj-consent__bar [data-fj-consent-action="open"] {
		order: 2;
		grid-column: 1 / -1;
		min-height: 0;
		padding: 2px;
		border-color: transparent;
		background: none;
		color: var(--fjc-mute);
		text-decoration: underline;
		text-underline-offset: 3px;
		letter-spacing: .1em;
	}

	.fj-consent__panelfoot .fj-consent__actions { flex-direction: column; gap: 8px; }
	.fj-consent__panelfoot .fj-consent__btn { width: 100%; }

	.fj-consent__panel { max-height: 92vh; }
	.fj-consent__overlay { padding: 12px; }
}
