/* ==========================================================
   Module tri_histoire — Histoires de migration
   Couleurs tirées de la maquette XD « De vives voies »
   ========================================================== */

.tri-hist,
.tri-hist-motscles,
.tri-hist-auteurs,
.tri-hist-connexes,
.tri-hist-lectures {
	--tri-hist-vert-fonce: #1f443d;
	--tri-hist-vert: #2d6b61;
	--tri-hist-sarcelle: #4a8f86;
	--tri-hist-pastille-fond: #e8f6f2;
	--tri-hist-pastille-bord: #7fb3aa;
	--tri-hist-pale: #d5ebe6;
	--tri-hist-colonne: #7fbcae;
	--tri-hist-bande: #c5e1dc;
	--tri-hist-texte: #2b2b2b;
}

.tri-hist .screen-reader-text,
.tri-hist-periode-annees,	/* Années lues par les lecteurs d'écran ; visibles sur téléphone */
.tri-hist-periode input,
.tri-hist-pastille input {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	white-space: nowrap;
}

.tri-hist {
	container-type: inline-size;	/* Mise en page selon la largeur réelle de la colonne Divi */
}

.tri-hist fieldset {
	border: 0;
	margin: 0;
	padding: 0;
	min-width: 0;
}


/* ---------- Thèmes (pastilles) ---------- */

.tri-hist .tri-hist-themes {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px 24px;
	margin-bottom: 22px;
}

.tri-hist-themes-titre {
	padding: 0;
	font-size: 20px;
	font-weight: 500;
	color: var(--tri-hist-vert);
}

.tri-hist-pastilles {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.tri-hist-pastille span {
	display: inline-block;
	min-width: 110px;
	padding: 6px 20px;
	border: 1px solid var(--tri-hist-pastille-bord);
	border-radius: 999px;
	background: var(--tri-hist-pastille-fond);
	color: var(--tri-hist-vert-fonce);
	font-size: 15px;
	line-height: 1.4;
	text-align: center;
	cursor: pointer;
	transition: background-color .2s, color .2s, border-color .2s;
}

.tri-hist-pastille span:hover {
	border-color: var(--tri-hist-vert-fonce);
}

.tri-hist-pastille input:checked + span {
	background: var(--tri-hist-vert-fonce);
	border-color: var(--tri-hist-vert-fonce);
	color: #fff;
}

.tri-hist-pastille input:focus-visible + span,
.tri-hist-periode input:focus-visible + .tri-hist-periode-nom {
	outline: 2px solid var(--tri-hist-vert-fonce);
	outline-offset: 3px;
}


/* ---------- Région / groupe (listes déroulantes) ---------- */

.tri-hist-selects {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 60px;
}

.tri-hist-select select {
	appearance: none;
	-webkit-appearance: none;
	padding: 12px 44px 12px 22px;
	border: 0;
	border-radius: 999px;
	background-color: var(--tri-hist-vert-fonce);
	/* Flèches haut / bas de la maquette */
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='14' viewBox='0 0 8 14'%3E%3Cpath fill='%23fff' d='M4 0l4 5H0zM4 14L0 9h8z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 20px center;
	color: #fff;
	font-family: inherit;
	font-size: 15px;
	cursor: pointer;
	box-shadow: 0 2px 4px rgba(0, 0, 0, .15);
}

.tri-hist-select select:focus-visible {
	outline: 2px solid var(--tri-hist-vert-fonce);
	outline-offset: 3px;
}

.tri-hist-select option {
	background: #fff;
	color: var(--tri-hist-texte);
}


/* ---------- Frise des périodes ---------- */

.tri-hist .tri-hist-frise {
	margin: 0 0 70px;
	padding: 0 4px;
}

.tri-hist-frise-piste {
	position: relative;
	height: 60px;
}

.tri-hist-frise-ligne {
	position: absolute;
	left: 0;
	right: 0;
	top: 28px;
	height: 4px;
	background: var(--tri-hist-sarcelle);
}

.tri-hist-frise-repere {
	position: absolute;
	top: 14px;
	width: 4px;
	height: 32px;
	margin-left: -2px;
	background: var(--tri-hist-sarcelle);
}

.tri-hist-frise-annee {
	position: absolute;
	top: 40px;
	left: 50%;
	transform: translateX(-50%);
	font-size: 15px;
	font-weight: 700;
	color: var(--tri-hist-vert);
}

.tri-hist-periode {
	position: absolute;
	top: 0;
	height: 46px;
	cursor: pointer;
}

/* Segment de la période (survol / actif) */
.tri-hist-periode::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	top: 26px;
	height: 8px;
	border-radius: 4px;
	background: transparent;
	transition: background-color .2s;
}

.tri-hist-periode:hover::after {
	background: rgba(31, 68, 61, .35);
}

.tri-hist-periode:has(input:checked)::after {
	background: var(--tri-hist-vert-fonce);
}

.tri-hist-periode-nom {
	position: absolute;
	top: 0;
	left: 16px;
	padding: 1px 8px;
	border-radius: 4px;
	font-size: 15px;
	font-weight: 700;
	text-transform: uppercase;
	white-space: nowrap;
	color: var(--tri-hist-vert);
	transition: background-color .2s, color .2s;
}

/* Segment trop court : étiquette placée avant le repère (maquette : « Période 4 ») */
.tri-hist-periode.is-etroit .tri-hist-periode-nom {
	left: auto;
	right: calc(100% + 16px);
}

.tri-hist-periode input:checked + .tri-hist-periode-nom {
	background: var(--tri-hist-vert-fonce);
	color: #fff;
}


/* ---------- Grille de résultats ---------- */

.tri-hist-resultats {
	transition: opacity .2s;
}

.tri-hist.is-chargement .tri-hist-resultats {
	opacity: .4;
	pointer-events: none;
}

.tri-hist-grille {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 40px 30px;
}

.tri-hist-carte-lien {
	display: block;
	color: inherit;
	text-decoration: none;
}

.tri-hist-carte-image {
	display: block;
	padding: 6px;
	background: #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

.tri-hist-carte-image img {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 9;
	object-fit: cover;
}

.tri-hist-carte-titre {
	margin: 14px 0 6px;
	padding: 0;
	font-size: 16px;
	font-weight: 700;
	line-height: 1.4;
	color: var(--tri-hist-texte);
}

.tri-hist-carte-lien:hover .tri-hist-carte-titre,
.tri-hist-carte-lien:focus-visible .tri-hist-carte-titre {
	text-decoration: underline;
}

.tri-hist-carte-auteurs {
	margin: 0;
	padding: 0;
	font-size: 15px;
	line-height: 1.6;
	color: var(--tri-hist-sarcelle);
}

.tri-hist-carte-auteurs strong {
	color: var(--tri-hist-vert);
}

.tri-hist-aucun {
	padding: 40px 0;
	font-size: 17px;
	color: var(--tri-hist-vert);
}


/* ---------- Pagination ---------- */

.tri-hist-pagination {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 50px;
}

.tri-hist-pagination .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: #fff;
	color: var(--tri-hist-vert);
	font-size: 15px;
	text-decoration: none;
}

.tri-hist-pagination a.page-numbers:hover {
	background: var(--tri-hist-pale);
}

.tri-hist-pagination .page-numbers.current {
	background: var(--tri-hist-vert-fonce);
	color: #fff;
}

.tri-hist-pagination .page-numbers.dots {
	background: transparent;
}


/* ---------- Fiche : mots-clés ---------- */

/* Sélecteurs doublés + !important : Divi ajoute puces et retrait aux <ul> du contenu */
.tri-hist-motscles.tri-hist-motscles {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0 0 20px;
	padding: 0 !important;
	list-style: none !important;
}

.tri-hist-motscles .tri-hist-motcle.tri-hist-motcle {
	margin: 0;
	list-style: none !important;
}

.tri-hist-motscles .tri-hist-motcle::marker {
	content: none;
}

.tri-hist-motscles .tri-hist-motcle {
	padding: 3px 10px;
	background: var(--tri-hist-pale);
	color: var(--tri-hist-vert-fonce);
	font-size: 15px;
	line-height: 1.4;
}


/* ---------- Fiche : auteurs ---------- */

.tri-hist-auteurs {
	font-size: 16px;
	color: var(--tri-hist-sarcelle);
}

.tri-hist-auteurs strong {
	color: var(--tri-hist-vert);
}


/* ---------- Fiche : histoires connexes ---------- */

/* Option fixe="oui" : la colonne suit le défilement (désactivée par défaut).
   La colonne Divi qui la contient doit occuper toute la hauteur de la rangée (défaut Divi). */
.tri-hist-connexes {
	padding: 40px 30px;
	background: var(--tri-hist-colonne);
}

.tri-hist-connexes.is-fixe {
	position: sticky;
	top: var(--tri-hist-sticky-top, 120px);
}

.admin-bar .tri-hist-connexes.is-fixe {
	top: calc(var(--tri-hist-sticky-top, 120px) + 32px);
}

.tri-hist-connexes-titre {
	margin: 0 0 20px;
	padding: 0;
	font-size: 22px;
	font-weight: 600;
	color: var(--tri-hist-vert-fonce);
}

.tri-hist-connexes-liste {
	display: grid;
	gap: 36px;
}

.tri-hist-connexes .tri-hist-carte-titre,
.tri-hist-connexes .tri-hist-carte-auteurs strong {
	color: var(--tri-hist-vert-fonce);
}

.tri-hist-connexes .tri-hist-carte-auteurs {
	color: #3d6f67;
}


/* ---------- Fiche : suggestions de lecture ---------- */

.tri-hist-lectures {
	padding: 50px 0;
	color: var(--tri-hist-texte);
}

/* Bande pleine largeur : la section Divi qui contient le shortcode prend la couleur.
   Si le champ est vide, le shortcode ne sort rien et la section reste invisible
   (section et rangée à 0 de padding dans le gabarit). */
.et_pb_section:has(.tri-hist-lectures) {
	background-color: #c5e1dc;
}

/* Les rangées Divi 5 de ce site n'ont pas de largeur fixe (elles prennent la
   largeur de leur contenu) : même largeur pour l'article et les suggestions,
   pour qu'ils restent alignés. Ajustable ici. */
.et_pb_row:has(.tri-hist-connexes),
.et_pb_row:has(.tri-hist-lectures) {
	width: 90%;
	max-width: 1640px;
}

.et_pb_row:has(.tri-hist-lectures) > .et_pb_column {
	flex: 1 1 100%;
	max-width: 100%;
}

.tri-hist-lectures-titre {
	margin: 0 0 20px;
	padding: 0;
	font-size: 22px;
	font-weight: 500;
	color: var(--tri-hist-texte);
}

.tri-hist-lectures-contenu p {
	padding: 0;
	font-size: 15px;
	line-height: 1.8;
}


/* ---------- Tablette / mobile ---------- */

@container (max-width: 900px) {
	.tri-hist-grille {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@container (max-width: 560px) {
	.tri-hist-grille {
		grid-template-columns: minmax(0, 1fr);
	}
}

@media (max-width: 980px) {
	.tri-hist-connexes.is-fixe {
		position: static;
	}
}

/* Colonne plus étroite que la maquette : même ligne de temps, plus compacte.
   L'étiquette placée avant son repère (Période 4) monte d'un cran
   pour ne pas chevaucher celle de la période précédente. */
@container (max-width: 800px) {
	.tri-hist .tri-hist-frise {
		padding-top: 24px;
	}

	.tri-hist-periode-nom {
		left: 8px;
		font-size: 13px;
	}

	.tri-hist-periode.is-etroit .tri-hist-periode-nom {
		top: -24px;
		right: auto;
		left: 50%;
		transform: translateX(-50%);
	}

	.tri-hist-frise-annee {
		font-size: 13px;
	}

	/* Premières et dernières années collées aux extrémités */
	.tri-hist-frise-repere.is-premier .tri-hist-frise-annee {
		left: 0;
		transform: none;
	}

	.tri-hist-frise-repere.is-dernier .tri-hist-frise-annee {
		left: auto;
		right: 0;
		transform: none;
	}
}

/* Téléphone : la ligne de temps passe à la verticale */
@container (max-width: 480px) {
	.tri-hist .tri-hist-frise {
		padding: 0 0 0 4px;
	}

	.tri-hist-frise-piste {
		height: auto;
		display: flex;
		flex-direction: column;
		gap: 18px;
		padding: 4px 0 4px 26px;
	}

	.tri-hist-frise-ligne {
		left: 9px;
		right: auto;
		top: 0;
		bottom: 0;
		width: 4px;
		height: auto;
	}

	.tri-hist-frise-repere {
		display: none;
	}

	.tri-hist-periode {
		position: relative;
		left: auto !important;
		width: auto !important;
		height: auto;
	}

	/* Repère horizontal sur la ligne pour chaque période */
	.tri-hist-periode::before {
		content: "";
		position: absolute;
		left: -24px;
		top: 50%;
		width: 16px;
		height: 4px;
		margin-top: -2px;
		background: var(--tri-hist-sarcelle);
	}

	.tri-hist-periode::after {
		display: none;
	}

	.tri-hist-periode-nom,
	.tri-hist-periode.is-etroit .tri-hist-periode-nom {
		position: static;
		display: inline-block;
		transform: none;
		font-size: 14px;
	}

	.tri-hist-periode .tri-hist-periode-annees {
		position: static !important;
		width: auto;
		height: auto;
		clip: auto;
		margin-left: 8px;
		font-weight: 400;
	}
}
