/**
 * FDF Historique — visualiseur plein écran (Outfit, palette feux-de-foret).
 * Layout : carte plein écran en arrière-plan + sidebar filtres (gauche)
 * + drawer rétractable (bas) pour stats et tableau.
 *
 * --fdf-hist-top : décalage haut qui réserve la place de la pastille
 *                  « titre de page » posée par fdf-theme.css. Variable
 *                  unique pour garder filtres + bouton ☰ alignés.
 */

body.fdf-page-historique-full {
	overflow: hidden;
}

.fdf-hist {
	position: absolute;
	inset: 0;
	font-family: Outfit, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
	color: var(--wp--preset--color--gris-anthracite, #171717);
	background: var(--wp--preset--color--surface, #f5f5f5);

	/* Décalage à partir duquel placer panel/tab pour ne PAS recouvrir la
	   pastille de titre (cf. fdf-theme.css : main > .wp-block-group:first-of-type). */
	--fdf-hist-top: clamp(74px, 8vh, 92px);
	--fdf-hist-edge: clamp(12px, 2vw, 20px);
}

/* ===== Carte ===== */

.fdf-hist__map {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	background: #e8eef2;
}

/* ===== Sidebar filtres ===== */

.fdf-hist__filters {
	position: absolute;
	top: var(--fdf-hist-top);
	left: var(--fdf-hist-edge);
	bottom: 84px;
	width: clamp(280px, 22vw, 320px);
	background: #fff;
	border: 1px solid var(--wp--preset--color--bordure, #e5e5e5);
	border-radius: 16px;
	box-shadow: 0 12px 36px rgba(0, 0, 0, 0.12);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	z-index: 8;
	transition: transform 0.32s ease, opacity 0.2s ease;
}

.fdf-hist__filters.is-collapsed,
.fdf-hist--drawer-open .fdf-hist__filters {
	transform: translateX(-110%);
	opacity: 0;
	pointer-events: none;
}

/* Quand le drawer est ouvert, on libère un raccourci « Filtres » sur le
   bord gauche pour que l'utilisateur puisse les rappeler en un clic. */
.fdf-hist--drawer-open .fdf-hist__panel-tab--filters[hidden] {
	display: inline-flex;
}

/* Header compact qui rassemble titre + métrique + KPIs en un seul
   bloc visuel (séparé du formulaire par un seul liseré). */
.fdf-hist__panel-head {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 12px 12px 12px;
	border-bottom: 1px solid var(--wp--preset--color--bordure, #e5e5e5);
	background: linear-gradient(180deg, #fff 0%, #fafafa 100%);
}

.fdf-hist__panel-headline {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	min-height: 28px;
}

.fdf-hist__panel-title {
	margin: 0;
	font-size: 0.78rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--wp--preset--color--gris-moyen, #737373);
}

.fdf-hist__panel-toggle {
	all: unset;
	cursor: pointer;
	width: 28px;
	height: 28px;
	border-radius: 8px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 1.05rem;
	color: var(--wp--preset--color--gris-fonce, #404040);
	background: var(--wp--preset--color--surface, #f5f5f5);
	transition: background 0.15s ease, color 0.15s ease;
}

.fdf-hist__panel-toggle:hover,
.fdf-hist__panel-toggle:focus-visible {
	background: var(--wp--preset--color--bordure, #e5e5e5);
	color: var(--wp--preset--color--noir, #000);
}

.fdf-hist__panel-toggle:focus-visible {
	outline: 2px solid var(--wp--preset--color--cta-bleu, #0200ff);
	outline-offset: 2px;
}

/* Bouton flottant « ☰ Filtres » — visible quand le panneau est replié. */
.fdf-hist__panel-tab {
	all: unset;
	position: absolute;
	top: var(--fdf-hist-top);
	left: var(--fdf-hist-edge);
	z-index: 7;
	cursor: pointer;
	background: var(--wp--preset--color--noir, #000);
	color: var(--wp--preset--color--blanc, #fff);
	border-radius: 999px;
	padding: 10px 16px;
	font-weight: 600;
	font-size: 0.875rem;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
	transition: background 0.15s ease, transform 0.15s ease;
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.fdf-hist__panel-tab:hover {
	background: var(--wp--preset--color--gris-anthracite, #171717);
	transform: translateY(-1px);
}

.fdf-hist__panel-tab:focus-visible {
	outline: 2px solid var(--wp--preset--color--cta-bleu, #0200ff);
	outline-offset: 2px;
}

/* Backdrop pour fermer le panel en tapotant à côté (visible uniquement
   sur mobile et quand le panneau est ouvert). */
.fdf-hist__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(10, 10, 10, 0.42);
	z-index: 7;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease;
}

/* ===== Bascule métrique (Nb feux / Surface) ===== */

/* Pill segmentée intégrée au header : « Colorer par : Feux | Surface ».
   Pas de label séparé, on s'appuie sur la convention universelle des
   segmented controls (option active = fond plein). */
.fdf-hist__metric-switch {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 2px;
	padding: 3px;
	background: var(--wp--preset--color--surface, #f5f5f5);
	border-radius: 999px;
	border: 1px solid var(--wp--preset--color--bordure, #e5e5e5);
}

.fdf-hist__metric-btn {
	all: unset;
	cursor: pointer;
	text-align: center;
	padding: 6px 8px;
	font-size: 0.78rem;
	font-weight: 600;
	border-radius: 999px;
	color: var(--wp--preset--color--gris-fonce, #404040);
	background: transparent;
	transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
	min-height: 28px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 5px;
	line-height: 1;
}

.fdf-hist__metric-ico {
	font-size: 0.75em;
	opacity: 0.85;
}

.fdf-hist__metric-btn:hover {
	color: var(--wp--preset--color--noir, #000);
}

.fdf-hist__metric-btn.is-active {
	background: var(--wp--preset--color--noir, #000);
	color: #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.fdf-hist__metric-btn.is-active .fdf-hist__metric-ico {
	color: var(--wp--preset--color--cta-rouge, #d00100);
	opacity: 1;
}

.fdf-hist__metric-btn:focus-visible {
	outline: 2px solid var(--wp--preset--color--cta-bleu, #0200ff);
	outline-offset: 2px;
}

/* ===== Légende choroplèthe (en bas, centrée au-dessus du drawer) ===== */

.fdf-hist__legend {
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
	bottom: 70px;
	z-index: 5;
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 8px 14px;
	background: rgba(255, 255, 255, 0.96);
	border: 1px solid var(--wp--preset--color--bordure, #e5e5e5);
	border-radius: 14px;
	box-shadow: 0 6px 22px rgba(0, 0, 0, 0.14);
	font-weight: 600;
	color: var(--wp--preset--color--gris-anthracite, #171717);
	-webkit-backdrop-filter: blur(10px) saturate(150%);
	backdrop-filter: blur(10px) saturate(150%);
	pointer-events: none;
	max-width: calc(100% - 32px);
}

.fdf-hist__legend:empty {
	display: none;
}

.fdf-hist__legend-lbl {
	font-size: 0.66rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--wp--preset--color--gris-moyen, #737373);
	white-space: nowrap;
}

.fdf-hist__legend-scale {
	display: inline-flex;
	align-items: flex-end;
	gap: 2px;
	font-variant-numeric: tabular-nums;
}

.fdf-hist__legend-step {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	min-width: 28px;
}

.fdf-hist__legend-step[data-zero="1"] {
	margin-right: 4px;
	border-right: 1px dashed rgba(0, 0, 0, 0.18);
	padding-right: 6px;
}

.fdf-hist__legend-swatch {
	display: inline-block;
	width: 22px;
	height: 12px;
	border-radius: 3px;
	border: 1px solid rgba(0, 0, 0, 0.12);
}

.fdf-hist__legend-tick {
	font-size: 0.65rem;
	font-weight: 600;
	color: var(--wp--preset--color--gris-fonce, #404040);
	white-space: nowrap;
	line-height: 1;
}

/* KPIs intégrés au header : 4 colonnes très denses, valeur en
   première ligne et libellé en seconde. Pas de fond, on hérite du
   gradient du panel-head — on se contente de séparateurs verticaux
   pour économiser de la hauteur. */
.fdf-hist__panel-head > .fdf-hist__kpis,
.fdf-hist__filters > .fdf-hist__kpis {
	padding: 0;
}

.fdf-hist__kpis--compact {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 0;
	background: #fff;
	border-radius: 10px;
	border: 1px solid var(--wp--preset--color--bordure, #e5e5e5);
	overflow: hidden;
}

.fdf-hist__kpi {
	padding: 8px 6px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 2px;
	min-width: 0;
	text-align: center;
	border-left: 1px solid var(--wp--preset--color--bordure, #e5e5e5);
}

.fdf-hist__kpi:first-child {
	border-left: none;
}

.fdf-hist__kpi-val {
	font-size: 0.92rem;
	font-weight: 700;
	color: var(--wp--preset--color--noir, #000);
	line-height: 1.1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	max-width: 100%;
	font-variant-numeric: tabular-nums;
}

.fdf-hist__kpi-lbl {
	font-size: 0.6rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--wp--preset--color--gris-moyen, #737373);
	line-height: 1.1;
}

.fdf-hist__filter-form {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 10px 12px 12px;
	display: flex;
	flex-direction: column;
	gap: 9px;
	-webkit-overflow-scrolling: touch;
}

.fdf-hist__field {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.fdf-hist__field label,
.fdf-hist__label {
	font-size: 0.7rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--wp--preset--color--gris-moyen, #737373);
}

.fdf-hist__field input[type="date"],
.fdf-hist__field input[type="number"],
.fdf-hist__field input[type="search"],
.fdf-hist__field select {
	width: 100%;
	box-sizing: border-box;
	padding: 7px 10px;
	border-radius: 8px;
	border: 1px solid var(--wp--preset--color--bordure, #e5e5e5);
	font-family: inherit;
	font-size: 0.85rem;
	background: #fff;
	color: inherit;
	min-height: 34px;
}

.fdf-hist__field input:focus,
.fdf-hist__field select:focus {
	outline: none;
	border-color: var(--wp--preset--color--noir, #000);
	box-shadow: 0 0 0 2px rgba(2, 0, 255, 0.12);
}

.fdf-hist__field--inline {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}

.fdf-hist__field--inline > div {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

/* ===== Dual-range slider (années / surface) =====
   Engine pointer-event maison (cf. setupRangeSlider en JS). Pas
   d'overlap d'inputs natifs : chaque pouce est un élément DOM
   indépendant avec sa bulle de valeur ancrée dessus. */

.fdf-hist__field--range {
	gap: 10px;
	user-select: none;
}

.fdf-hist__range-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	min-width: 0;
}

.fdf-hist__range-clear {
	font-family: inherit;
	font-size: 0.7rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--wp--preset--color--rouge-feu, #d00100);
	background: transparent;
	border: 1px solid currentColor;
	border-radius: 999px;
	padding: 2px 9px;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

.fdf-hist__range-clear:hover,
.fdf-hist__range-clear:focus-visible {
	background: var(--wp--preset--color--rouge-feu, #d00100);
	color: #fff;
	outline: none;
}

/* Conteneur du slider :
   - hauteur généreuse pour pouvoir afficher la bulle au-dessus,
   - margin latérale = ½ thumb pour absorber l'overflow des pouces
     aux extrêmes (left:0%/100% + translateX(-50%) → moitié dehors),
   - touch-action pour que la page ne scroll pas pendant un drag. */
.fdf-hist__range {
	position: relative;
	height: 36px;
	margin: 22px 11px 6px;
	touch-action: none;
}

.fdf-hist__range-rail {
	position: absolute;
	left: 0;
	right: 0;
	top: 50%;
	height: 6px;
	background: var(--wp--preset--color--bordure, #e5e5e5);
	border-radius: 999px;
	transform: translateY(-50%);
	pointer-events: none;
	overflow: hidden;
}

.fdf-hist__range-fill {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	right: 100%;
	background: linear-gradient(90deg, #d00100, #ff6a00);
	border-radius: 999px;
	transition: left 0.04s linear, right 0.04s linear;
}

/* Les pouces sont des div positionnés en absolute. La position est
   pilotée par JS via la propriété custom `--pos` (en %). */
.fdf-hist__range-thumb {
	position: absolute;
	top: 50%;
	left: var(--pos, 0%);
	width: 22px;
	height: 22px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #fff;
	box-shadow:
		0 0 0 2px var(--wp--preset--color--rouge-feu, #d00100) inset,
		0 2px 6px rgba(0, 0, 0, 0.22);
	transform: translate(-50%, -50%);
	cursor: grab;
	touch-action: none;
	transition: box-shadow 0.15s ease, transform 0.15s ease;
	z-index: 2;
}

.fdf-hist__range-thumb:focus-visible {
	outline: none;
	box-shadow:
		0 0 0 2px var(--wp--preset--color--rouge-feu, #d00100) inset,
		0 0 0 4px rgba(208, 1, 0, 0.22),
		0 2px 6px rgba(0, 0, 0, 0.22);
}

.fdf-hist__range-thumb:hover {
	transform: translate(-50%, -50%) scale(1.08);
}

.fdf-hist__range-thumb.is-active {
	cursor: grabbing;
	z-index: 4;
	transform: translate(-50%, -50%) scale(1.15);
	box-shadow:
		0 0 0 2px var(--wp--preset--color--rouge-feu, #d00100) inset,
		0 0 0 6px rgba(208, 1, 0, 0.18),
		0 4px 12px rgba(208, 1, 0, 0.32);
}

/* La bulle de valeur : ancrée au pouce, légèrement au-dessus.
   Toujours visible (l'utilisateur doit pouvoir lire les bornes en
   un coup d'œil). Le pouce actif a une bulle plus contrastée. */
.fdf-hist__range-bubble {
	position: absolute;
	bottom: calc(100% + 8px);
	left: 50%;
	transform: translateX(-50%);
	background: var(--wp--preset--color--gris-anthracite, #171717);
	color: #fff;
	font-size: 0.72rem;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.01em;
	white-space: nowrap;
	padding: 3px 8px;
	border-radius: 6px;
	pointer-events: none;
	opacity: 0.85;
	transition: opacity 0.15s ease, background 0.15s ease;
}

.fdf-hist__range-bubble::after {
	content: '';
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%);
	width: 0;
	height: 0;
	border: 4px solid transparent;
	border-top-color: var(--wp--preset--color--gris-anthracite, #171717);
}

.fdf-hist__range-thumb:hover .fdf-hist__range-bubble,
.fdf-hist__range-thumb:focus-visible .fdf-hist__range-bubble,
.fdf-hist__range-thumb.is-active .fdf-hist__range-bubble {
	opacity: 1;
	background: #d00100;
}

.fdf-hist__range-thumb:hover .fdf-hist__range-bubble::after,
.fdf-hist__range-thumb:focus-visible .fdf-hist__range-bubble::after,
.fdf-hist__range-thumb.is-active .fdf-hist__range-bubble::after {
	border-top-color: #d00100;
}

/* État « par défaut » (slider à pleine course) : on grise la barre
   de remplissage pour signaler que rien n'est filtré. */
.fdf-hist__field--range:not(.is-touched) .fdf-hist__range-fill {
	background: linear-gradient(90deg, #cbd5e1, #94a3b8);
	opacity: 0.55;
}

@media (prefers-reduced-motion: reduce) {
	.fdf-hist__range-fill,
	.fdf-hist__range-thumb,
	.fdf-hist__range-bubble {
		transition: none;
	}
}

.fdf-hist__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.fdf-hist__chip {
	font-size: 0.75rem;
	border: 1px solid var(--wp--preset--color--bordure, #e5e5e5);
	border-radius: 999px;
	padding: 6px 10px;
	cursor: pointer;
	background: #fff;
	display: inline-flex;
	align-items: center;
	gap: 4px;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.fdf-hist__chip:hover {
	background: var(--wp--preset--color--surface, #f5f5f5);
}

.fdf-hist__chip:has(.fdf-hist__chip-input:checked) {
	background: var(--wp--preset--color--noir, #000);
	border-color: var(--wp--preset--color--noir, #000);
	color: #fff;
}

.fdf-hist__chip-input {
	margin: 0;
	vertical-align: middle;
	accent-color: var(--wp--preset--color--cta-rouge, #d00100);
}

.fdf-hist__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 4px;
}

.fdf-hist__btn {
	flex: 1 1 auto;
	cursor: pointer;
	border-radius: 8px;
	padding: 11px 14px;
	font-family: inherit;
	font-weight: 600;
	font-size: 0.875rem;
	border: 1px solid transparent;
	transition: background 0.15s ease, color 0.15s ease;
	min-height: 42px;
}

.fdf-hist__btn--primary {
	background: var(--wp--preset--color--noir, #000);
	color: var(--wp--preset--color--blanc, #fff);
	border-color: var(--wp--preset--color--noir, #000);
}

.fdf-hist__btn--primary:hover {
	background: var(--wp--preset--color--gris-anthracite, #171717);
}

.fdf-hist__btn--ghost {
	background: transparent;
	color: var(--wp--preset--color--noir, #000);
	border-color: var(--wp--preset--color--noir, #000);
}

.fdf-hist__btn--ghost:hover {
	background: var(--wp--preset--color--surface, #f5f5f5);
}

.fdf-hist__btn:focus-visible {
	outline: 2px solid var(--wp--preset--color--cta-bleu, #0200ff);
	outline-offset: 2px;
}

/* ===== Fiche commune (action sheet) =====
   Modal centrée sur desktop, bottom-sheet sur mobile. */

.fdf-hist__sheet-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(10, 10, 10, 0.5);
	z-index: 18;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.22s ease;
}

.fdf-hist__sheet-backdrop.is-visible {
	opacity: 1;
	pointer-events: auto;
}

.fdf-hist__sheet {
	position: absolute;
	z-index: 19;
	background: #fff;
	border-radius: 18px;
	box-shadow: 0 30px 80px rgba(0, 0, 0, 0.22),
		0 8px 24px rgba(0, 0, 0, 0.1);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	font-family: Outfit, system-ui, sans-serif;
	color: var(--wp--preset--color--gris-anthracite, #171717);

	/* Desktop : modal centrée. */
	top: 50%;
	left: 50%;
	transform: translate(-50%, -46%) scale(0.97);
	width: min(560px, calc(100% - 32px));
	max-height: min(720px, calc(100% - 60px));
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.22s ease, transform 0.28s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.fdf-hist__sheet.is-open {
	opacity: 1;
	pointer-events: auto;
	transform: translate(-50%, -50%) scale(1);
}

.fdf-hist__sheet-grip {
	display: none;
}

.fdf-hist__sheet-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	padding: 18px 22px 12px;
	border-bottom: 1px solid var(--wp--preset--color--bordure, #e5e5e5);
	background: linear-gradient(180deg, #fff 0%, var(--wp--preset--color--surface, #f5f5f5) 100%);
}

.fdf-hist__sheet-titles {
	min-width: 0;
	flex: 1 1 auto;
}

.fdf-hist__sheet-title {
	margin: 0;
	font-size: 1.25rem;
	font-weight: 800;
	letter-spacing: -0.02em;
	color: var(--wp--preset--color--noir, #000);
	line-height: 1.2;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.fdf-hist__sheet-sub {
	margin: 4px 0 0;
	font-size: 0.8125rem;
	color: var(--wp--preset--color--gris-moyen, #737373);
	font-weight: 500;
}

.fdf-hist__sheet-close {
	all: unset;
	cursor: pointer;
	width: 36px;
	height: 36px;
	border-radius: 999px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 1.5rem;
	line-height: 1;
	color: var(--wp--preset--color--gris-fonce, #404040);
	background: var(--wp--preset--color--surface, #f5f5f5);
	transition: background 0.15s ease, color 0.15s ease;
	flex: 0 0 auto;
}

.fdf-hist__sheet-close:hover {
	background: var(--wp--preset--color--bordure, #e5e5e5);
	color: var(--wp--preset--color--noir, #000);
}

.fdf-hist__sheet-close:focus-visible {
	outline: 2px solid var(--wp--preset--color--cta-bleu, #0200ff);
	outline-offset: 2px;
}

.fdf-hist__sheet-body {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	padding: 16px 22px;
	-webkit-overflow-scrolling: touch;
}

.fdf-hist__sheet-body > * + * {
	margin-top: 18px;
}

.fdf-hist__sheet-body #fdf-hist-sheet-kpis.fdf-hist__kpis--compact {
	grid-template-columns: repeat(2, 1fr);
}

.fdf-hist__sheet-chart {
	display: block;
}

.fdf-hist__sheet-chart .fdf-hist__chart-title + .fdf-hist__sheet-canvas-wrap {
	margin-top: 8px;
}

.fdf-hist__sheet-chart .fdf-hist__chart-title {
	margin: 0;
	font-size: 0.78rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--wp--preset--color--gris-anthracite, #171717);
}

.fdf-hist__sheet-canvas-wrap {
	position: relative;
	height: 200px;
	background: var(--wp--preset--color--surface, #f5f5f5);
	border: 1px solid var(--wp--preset--color--bordure, #e5e5e5);
	border-radius: 12px;
	overflow: hidden;
	flex: 0 0 auto;
}

.fdf-hist__sheet-canvas-wrap--doughnut {
	height: 240px;
}

.fdf-hist__sheet-canvas-wrap canvas {
	display: block;
	width: 100% !important;
	height: 100% !important;
}

.fdf-hist__sheet-empty {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 12px;
	text-align: center;
	font-size: 0.85rem;
	color: var(--wp--preset--color--gris-anthracite, #525252);
	opacity: 0.7;
}

.fdf-hist__sheet-foot {
	display: flex;
	gap: 8px;
	padding: 14px 22px 18px;
	border-top: 1px solid var(--wp--preset--color--bordure, #e5e5e5);
	background: linear-gradient(0deg, var(--wp--preset--color--surface, #f5f5f5) 0%, #fff 100%);
}

.fdf-hist__sheet-foot .fdf-hist__btn {
	flex: 1 1 auto;
}

/* Mobile : feuille glissante depuis le bas (bottom-sheet). */
@media (max-width: 768px) {
	.fdf-hist__sheet {
		top: auto;
		bottom: 0;
		left: 0;
		right: 0;
		width: 100%;
		max-height: min(85dvh, 85vh);
		border-radius: 22px 22px 0 0;
		transform: translateY(40px);
		padding-bottom: env(safe-area-inset-bottom, 0px);
	}

	.fdf-hist__sheet.is-open {
		transform: translateY(0);
	}

	.fdf-hist__sheet-grip {
		display: block;
		width: 48px;
		height: 4px;
		background: var(--wp--preset--color--bordure, #d4d4d4);
		border-radius: 999px;
		margin: 8px auto 0;
		flex: 0 0 auto;
	}

	.fdf-hist__sheet-head {
		padding: 12px 18px 12px;
	}

	.fdf-hist__sheet-title {
		font-size: 1.1rem;
	}

	.fdf-hist__sheet-body {
		padding: 12px 16px 14px;
	}

	.fdf-hist__sheet-body > * + * {
		margin-top: 14px;
	}

	.fdf-hist__sheet-canvas-wrap {
		height: 170px;
	}

	.fdf-hist__sheet-canvas-wrap--doughnut {
		height: 210px;
	}

	.fdf-hist__sheet-foot {
		padding: 12px 16px 14px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.fdf-hist__sheet,
	.fdf-hist__sheet-backdrop {
		transition: none !important;
	}
}

/* ===== Drawer (bas) — pattern bottom-sheet moderne =====
   - drag handle horizontal centré au-dessus
   - barre de tabs en pills (icône + libellé)
   - chevron secondaire à droite pour réduire/déplier
   - le clic sur un onglet ouvre le drawer ; clic sur l'onglet
     déjà actif quand le drawer est ouvert le ferme. */

.fdf-hist__drawer {
	position: absolute;
	bottom: 0;
	z-index: 6;
	display: flex;
	flex-direction: column;
	transition: background 0.25s ease, box-shadow 0.25s ease;
}

/* État OUVERT : vraie bottom-sheet pleine largeur. */
.fdf-hist__drawer.is-open {
	left: 0;
	right: 0;
	background: #fff;
	border-top: 1px solid var(--wp--preset--color--bordure, #e5e5e5);
	box-shadow: 0 -10px 32px rgba(0, 0, 0, 0.1);
	border-top-left-radius: 18px;
	border-top-right-radius: 18px;
	max-height: 72vh;
	max-height: 72dvh;
	padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* État FERMÉ : on rétracte le container à la taille du handle pour ne
   pas bloquer les clics sur la carte autour du pill flottant. */
.fdf-hist__drawer:not(.is-open) {
	left: 50%;
	transform: translateX(-50%);
	bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
	max-width: calc(100% - 32px);
	background: transparent;
	border-top: none;
	box-shadow: none;
	border-radius: 0;
	padding: 0;
}

.fdf-hist__drawer-handle {
	flex: 0 0 auto;
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	grid-template-rows: auto auto;
	grid-template-areas:
		"grip grip grip"
		". tabs chevron";
	align-items: center;
	gap: 4px 10px;
	padding: 4px 14px 8px;
	position: relative;
	transition: background 0.25s ease, box-shadow 0.25s ease,
		padding 0.2s ease;
}

/* Quand le drawer est FERMÉ : on transforme le handle en pill flottante
   compacte, centrée en bas, qui n'occupe plus toute la largeur. */
.fdf-hist__drawer:not(.is-open) .fdf-hist__drawer-handle {
	pointer-events: auto;
	display: inline-flex;
	align-items: center;
	width: auto;
	max-width: calc(100% - 32px);
	background: #fff;
	border: 1px solid var(--wp--preset--color--bordure, #e5e5e5);
	border-radius: 999px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.16);
	padding: 5px 8px 5px 12px;
	gap: 8px;
	grid-template-columns: initial;
	grid-template-rows: initial;
	grid-template-areas: initial;
}

.fdf-hist__drawer:not(.is-open) .fdf-hist__drawer-grip {
	display: none;
}

.fdf-hist__drawer:not(.is-open) .fdf-hist__drawer-tabs {
	background: transparent;
	border: none;
	padding: 0;
}

.fdf-hist__drawer:not(.is-open) .fdf-hist__drawer-body {
	display: none;
}

/* Drag-handle (pill horizontale centrée tout en haut) */
.fdf-hist__drawer-grip {
	all: unset;
	grid-area: grip;
	display: flex;
	justify-content: center;
	align-items: center;
	cursor: grab;
	padding: 6px 0 4px;
	width: 100%;
	box-sizing: border-box;
}

.fdf-hist__drawer-grip:active {
	cursor: grabbing;
}

.fdf-hist__drawer-pull {
	display: block;
	width: 42px;
	height: 4px;
	border-radius: 999px;
	background: var(--wp--preset--color--bordure, #d4d4d4);
	transition: background 0.15s ease, width 0.18s ease;
}

.fdf-hist__drawer-grip:hover .fdf-hist__drawer-pull,
.fdf-hist__drawer-grip:focus-visible .fdf-hist__drawer-pull {
	background: var(--wp--preset--color--gris-fonce, #404040);
	width: 56px;
}

.fdf-hist__drawer-grip:focus-visible {
	outline: 2px solid var(--wp--preset--color--cta-bleu, #0200ff);
	outline-offset: 2px;
	border-radius: 12px;
}

/* Onglets façon segmented control / pills */
.fdf-hist__drawer-tabs {
	grid-area: tabs;
	justify-self: center;
	display: inline-flex;
	gap: 4px;
	padding: 3px;
	background: var(--wp--preset--color--surface, #f5f5f5);
	border: 1px solid var(--wp--preset--color--bordure, #e5e5e5);
	border-radius: 999px;
	max-width: 100%;
}

.fdf-hist__drawer-tab {
	all: unset;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 7px 14px;
	font-family: inherit;
	font-size: 0.82rem;
	font-weight: 600;
	color: var(--wp--preset--color--gris-fonce, #404040);
	background: transparent;
	border-radius: 999px;
	white-space: nowrap;
	transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
	line-height: 1;
}

.fdf-hist__drawer-tab:hover {
	color: var(--wp--preset--color--noir, #000);
}

.fdf-hist__drawer-tab.is-active {
	background: #fff;
	color: var(--wp--preset--color--noir, #000);
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.fdf-hist__drawer-tab.is-active .fdf-hist__drawer-tab-ico {
	color: var(--wp--preset--color--cta-rouge, #d00100);
}

.fdf-hist__drawer-tab:focus-visible {
	outline: 2px solid var(--wp--preset--color--cta-bleu, #0200ff);
	outline-offset: 2px;
}

.fdf-hist__drawer-tab-ico {
	width: 14px;
	height: 14px;
	flex: 0 0 auto;
	color: var(--wp--preset--color--gris-moyen, #737373);
	fill: currentColor;
	transition: color 0.15s ease;
}

/* Chevron compact à droite : raccourci visuel pour fermer */
.fdf-hist__drawer-chevron-btn {
	all: unset;
	grid-area: chevron;
	justify-self: end;
	cursor: pointer;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--wp--preset--color--gris-fonce, #404040);
	background: var(--wp--preset--color--surface, #f5f5f5);
	border: 1px solid var(--wp--preset--color--bordure, #e5e5e5);
	transition: background 0.15s ease, color 0.15s ease;
}

.fdf-hist__drawer-chevron-btn:hover,
.fdf-hist__drawer-chevron-btn:focus-visible {
	background: #fff;
	color: var(--wp--preset--color--noir, #000);
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.fdf-hist__drawer-chevron-btn:focus-visible {
	outline: 2px solid var(--wp--preset--color--cta-bleu, #0200ff);
	outline-offset: 2px;
}

.fdf-hist__drawer-chevron {
	width: 14px;
	height: 14px;
	transition: transform 0.32s ease;
}

.fdf-hist__drawer:not(.is-open) .fdf-hist__drawer-chevron {
	transform: rotate(180deg);
}

.fdf-hist__drawer-body {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	padding: 12px 22px 24px;
	-webkit-overflow-scrolling: touch;
}

.fdf-hist__pane {
	display: none;
}

.fdf-hist__pane.is-active {
	display: block;
}

/* ===== À propos / sources ===== */

.fdf-hist__about {
	max-width: 820px;
	margin: 0 auto;
	font-size: 0.9375rem;
	line-height: 1.6;
	color: var(--wp--preset--color--gris-anthracite, #171717);
}

.fdf-hist__about-h {
	margin: 0 0 0.75rem;
	font-size: 1.25rem;
	font-weight: 700;
	letter-spacing: -0.01em;
	color: var(--wp--preset--color--noir, #000);
}

.fdf-hist__about-h2 {
	margin: 1.5rem 0 0.5rem;
	font-size: 1rem;
	font-weight: 700;
	letter-spacing: -0.01em;
	color: var(--wp--preset--color--noir, #000);
}

.fdf-hist__about p {
	margin: 0 0 0.75rem;
}

.fdf-hist__about a {
	color: var(--wp--preset--color--cta-bleu, #0200ff);
	text-decoration: underline;
	text-underline-offset: 3px;
}

.fdf-hist__about-list {
	margin: 0;
	padding-left: 1.25rem;
}

.fdf-hist__about-list li {
	margin-bottom: 0.35rem;
}

/* Cache le contenu post du WP éventuellement présent (texte SEO résiduel) :
   tout le rendu est géré par le shortcode et son drawer "À propos". */
body.fdf-page-historique-full .wp-block-post-content > *:not(.fdf-hist):not(p:empty) {
	display: none !important;
}

/* ===== Stats / charts ===== */

.fdf-hist__charts {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	gap: 14px;
}

.fdf-hist__chart-wrap {
	background: #fff;
	border: 1px solid var(--wp--preset--color--bordure, #e5e5e5);
	border-radius: 10px;
	padding: 12px 14px 8px;
	min-width: 0;
}

.fdf-hist__chart-wrap--wide {
	grid-column: 1 / -1;
}

.fdf-hist__chart-title {
	margin: 0 0 8px;
	font-size: 0.875rem;
	font-weight: 700;
	letter-spacing: 0.02em;
	color: var(--wp--preset--color--gris-anthracite, #171717);
	text-transform: uppercase;
}

.fdf-hist__chart-canvas-wrap {
	position: relative;
	height: 220px;
}

.fdf-hist__chart-canvas-wrap canvas {
	width: 100% !important;
	height: 100% !important;
}

/* ===== Tableau ===== */

.fdf-hist__table-scroll {
	overflow-x: auto;
	border-radius: 8px;
	border: 1px solid var(--wp--preset--color--bordure, #e5e5e5);
	-webkit-overflow-scrolling: touch;
}

.fdf-hist__table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.875rem;
	background: #fff;
}

.fdf-hist__table th,
.fdf-hist__table td {
	padding: 10px 12px;
	text-align: left;
	border-bottom: 1px solid var(--wp--preset--color--bordure, #e5e5e5);
	white-space: nowrap;
}

.fdf-hist__table th {
	font-weight: 700;
	background: var(--wp--preset--color--surface, #f5f5f5);
	user-select: none;
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	position: sticky;
	top: 0;
	z-index: 1;
}

.fdf-hist__table th.fdf-hist__sortable {
	padding: 0;
	cursor: pointer;
}

.fdf-hist__table th.fdf-hist__sortable:hover {
	background: #ececec;
}

.fdf-hist__th-btn {
	all: unset;
	display: flex;
	align-items: center;
	gap: 6px;
	width: 100%;
	box-sizing: border-box;
	padding: 10px 12px;
	cursor: pointer;
	font: inherit;
	font-weight: inherit;
	color: inherit;
}

.fdf-hist__th-btn:focus-visible {
	outline: 2px solid var(--wp--preset--color--cta-bleu, #0200ff);
	outline-offset: -2px;
}

.fdf-hist__sort-ind {
	font-size: 0.75rem;
	color: var(--wp--preset--color--gris-moyen, #737373);
	min-width: 8px;
	display: inline-block;
}

.fdf-hist__table th[aria-sort] .fdf-hist__sort-ind {
	color: var(--wp--preset--color--noir, #000);
}

.fdf-hist__pager {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	margin-top: 12px;
	flex-wrap: wrap;
}

.fdf-hist__pager-info {
	font-size: 0.8125rem;
	color: var(--wp--preset--color--gris-fonce, #404040);
}

/* ===== Auto-complétion communes ===== */

.fdf-hist__suggest {
	list-style: none;
	margin: 4px 0 0;
	padding: 0;
	border: 1px solid var(--wp--preset--color--bordure, #e5e5e5);
	border-radius: 8px;
	max-height: 200px;
	overflow-y: auto;
	background: #fff;
	position: absolute;
	z-index: 20;
	left: 0;
	right: 0;
	top: 100%;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.fdf-hist__suggest li {
	border-bottom: 1px solid var(--wp--preset--color--bordure, #e5e5e5);
}

.fdf-hist__suggest li:last-child {
	border-bottom: none;
}

.fdf-hist__suggest button {
	width: 100%;
	text-align: left;
	padding: 10px 12px;
	border: none;
	background: transparent;
	cursor: pointer;
	font-family: inherit;
	font-size: 0.8125rem;
	min-height: 40px;
}

.fdf-hist__suggest button:hover {
	background: var(--wp--preset--color--surface, #f5f5f5);
}

/* ===== États ===== */

.fdf-hist__error {
	color: var(--wp--preset--color--cta-rouge, #d00100);
	font-weight: 600;
	padding: 8px 10px;
	background: var(--wp--preset--color--surface, #f5f5f5);
	border-radius: 6px;
	font-size: 0.8125rem;
}

.fdf-hist__loading {
	color: var(--wp--preset--color--gris-moyen, #737373);
	font-weight: 500;
	font-size: 0.8125rem;
	padding: 4px 0;
}

.maplibregl-ctrl-attrib {
	font-size: 11px !important;
}

.fdf-hist .maplibregl-ctrl-top-right {
	top: var(--fdf-hist-top) !important;
	right: var(--fdf-hist-edge) !important;
}

/* ===== Responsive : ≤ 1024px (tablette) ===== */

@media (max-width: 1024px) {
	.fdf-hist {
		--fdf-hist-top: clamp(78px, 11vh, 100px);
	}
}

/* ===== Responsive : ≤ 768px (mobile) =====
   - panneau filtres en feuille latérale, fermé par défaut (cf. JS)
   - backdrop activé quand ouvert
   - tab ☰ Filtres placé sous la pastille de titre
   - drawer plus compact
*/

@media (max-width: 768px) {
	.fdf-hist {
		--fdf-hist-top: clamp(74px, 14vw, 96px);
		--fdf-hist-edge: 10px;
	}

	.fdf-hist__filters {
		top: var(--fdf-hist-top);
		left: var(--fdf-hist-edge);
		right: var(--fdf-hist-edge);
		bottom: auto;
		width: auto;
		max-height: calc(100dvh - var(--fdf-hist-top) - 76px);
		max-height: calc(100vh - var(--fdf-hist-top) - 76px);
		box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
		border-radius: 16px;
		z-index: 12;
	}

	.fdf-hist__filters.is-collapsed {
		transform: translateY(-12px);
	}

	.fdf-hist__panel-tab {
		top: var(--fdf-hist-top);
		left: var(--fdf-hist-edge);
		padding: 11px 18px;
		font-size: 0.9rem;
	}

	.fdf-hist__panel-toggle {
		width: 32px;
		height: 32px;
		font-size: 1.15rem;
	}

	.fdf-hist__panel-head {
		padding: 10px 12px;
		gap: 8px;
	}

	.fdf-hist__panel-title {
		font-size: 0.78rem;
	}

	.fdf-hist__backdrop.is-visible {
		opacity: 1;
		pointer-events: auto;
	}

	.fdf-hist__panel-head > .fdf-hist__kpis,
	.fdf-hist__filters > .fdf-hist__kpis {
		padding: 0;
	}

	.fdf-hist__kpi {
		padding: 7px 4px;
	}

	.fdf-hist__kpi-val {
		font-size: 0.85rem;
	}

	.fdf-hist__kpi-lbl {
		font-size: 0.58rem;
	}

	.fdf-hist__filter-form {
		padding: 10px 12px 12px;
		gap: 8px;
	}

	.fdf-hist__drawer-handle {
		padding: 4px 10px 8px;
		gap: 4px 6px;
	}

	.fdf-hist__drawer-tabs {
		gap: 2px;
		max-width: calc(100vw - 60px);
		overflow-x: auto;
		scrollbar-width: none;
	}

	.fdf-hist__drawer-tabs::-webkit-scrollbar {
		display: none;
	}

	.fdf-hist__drawer-tab {
		padding: 6px 10px;
		font-size: 0.78rem;
	}

	.fdf-hist__drawer-tab-ico {
		width: 12px;
		height: 12px;
	}

	.fdf-hist__drawer-chevron-btn {
		width: 28px;
		height: 28px;
	}

	.fdf-hist__drawer-body {
		padding: 12px 14px 18px;
	}

	.fdf-hist__chart-canvas-wrap {
		height: 180px;
	}

	.fdf-hist__charts {
		grid-template-columns: 1fr;
		gap: 10px;
	}

	.fdf-hist__chart-wrap {
		padding: 10px 12px 6px;
	}

	.fdf-hist__about {
		font-size: 0.9rem;
	}

	.fdf-hist__about-h {
		font-size: 1.1rem;
	}

	.fdf-hist__field--inline {
		grid-template-columns: 1fr;
		gap: 8px;
	}

	/* Du/Au gardent leur disposition côte à côte même sur mobile —
	   c'est plus compact et la datepicker iOS reste large. */
	.fdf-hist__field--dates {
		grid-template-columns: 1fr 1fr;
		gap: 8px;
	}

	.fdf-hist .maplibregl-ctrl-top-right {
		top: var(--fdf-hist-top) !important;
	}

	.fdf-hist__legend {
		left: 50%;
		bottom: 60px;
		max-width: calc(100% - 16px);
		padding: 6px 10px;
		gap: 8px;
		overflow-x: auto;
		scrollbar-width: none;
	}

	.fdf-hist__legend::-webkit-scrollbar {
		display: none;
	}

	.fdf-hist__legend-step {
		min-width: 22px;
	}

	.fdf-hist__legend-swatch {
		width: 16px;
		height: 10px;
	}

	.fdf-hist__legend-tick {
		font-size: 0.6rem;
	}

	/* Le panneau de filtres et le drawer ne sont pas affichés en
	   simultané : quand le panel est ouvert sur mobile on rétrécit
	   visuellement le drawer derrière le backdrop pour éviter la fuite
	   de focus tactile. */
	.fdf-hist:has(.fdf-hist__filters:not(.is-collapsed)) .fdf-hist__drawer {
		pointer-events: none;
	}

	/* Cache la légende quand le panel est ouvert (mobile) pour éviter
	   un encombrement visuel inutile. */
	.fdf-hist:has(.fdf-hist__filters:not(.is-collapsed)) .fdf-hist__legend {
		display: none;
	}
}

/* ===== Responsive : ≤ 480px (petits mobiles) ===== */

@media (max-width: 480px) {
	.fdf-hist {
		--fdf-hist-top: clamp(70px, 16vw, 92px);
		--fdf-hist-edge: 8px;
	}

	.fdf-hist__panel-head {
		padding: 9px 10px;
		gap: 7px;
	}

	.fdf-hist__panel-title {
		font-size: 0.74rem;
	}

	.fdf-hist__filter-form {
		padding: 9px 10px 10px;
		gap: 7px;
	}

	.fdf-hist__panel-head > .fdf-hist__kpis,
	.fdf-hist__filters > .fdf-hist__kpis {
		padding: 0;
	}

	.fdf-hist__kpi {
		padding: 6px 3px;
	}

	.fdf-hist__kpi-val {
		font-size: 0.78rem;
	}

	.fdf-hist__kpi-lbl {
		font-size: 0.55rem;
	}

	.fdf-hist__metric-btn {
		font-size: 0.72rem;
		padding: 5px 6px;
	}

	.fdf-hist__drawer-tab {
		font-size: 0.74rem;
		padding: 5px 9px;
		gap: 5px;
	}

	.fdf-hist__drawer-tab-ico {
		width: 12px;
		height: 12px;
	}

	.fdf-hist__chart-canvas-wrap {
		height: 160px;
	}

	.fdf-hist__table th,
	.fdf-hist__table td {
		padding: 8px 10px;
		font-size: 0.8125rem;
	}
}

/* Réduit les motion lorsque l'utilisateur le demande. */
@media (prefers-reduced-motion: reduce) {
	.fdf-hist__filters,
	.fdf-hist__drawer,
	.fdf-hist__backdrop,
	.fdf-hist__drawer-chevron,
	.fdf-hist__panel-tab,
	.fdf-hist__chip,
	.fdf-hist__btn,
	.fdf-hist__panel-toggle {
		transition: none !important;
	}
}
