/**
 * Hotim — expérience de lecture (tous contenus).
 *
 * Tout est soit préfixé .hotim-*, soit scopé sous .dynamic-entry-content
 * (le conteneur du contenu d'article rendu par le template GenerateBlocks).
 * Rien ici ne touche au header, au hero ni au footer.
 */

:root {
	/* Rouge de marque assombri : 5,5:1 sur blanc, contre 4,0:1 pour le #ff0000
	   du thème qui échoue au minimum AA de 4,5:1.
	   Une seule variable à remettre à #ff0000 pour revenir en arrière. */
	--hotim-link: #d40000;
	--hotim-link-hover: #101014;

	--hotim-rule: #e4e4f0;
	--hotim-surface: #f7f7fc;
	--hotim-muted: #5a5a72;

	/* Décalage des ancres : la barre de navigation est collante. */
	--hotim-anchor-offset: 6.5rem;
}

/* -------------------------------------------------------------------------
 * 1. Rythme typographique
 * ---------------------------------------------------------------------- */

/* Les titres injectés par ce module (sommaire, « À lire aussi ») vivent dans
   .dynamic-entry-content : ils doivent échapper au traitement des titres de
   contenu, sinon ils héritent du filet et des marges de section. */
.dynamic-entry-content h2:not(.hotim-toc__title):not(.hotim-related__heading) {
	margin-top: 2.75em;
	margin-bottom: 0.65em;
}

.dynamic-entry-content h3 {
	margin-top: 2em;
	margin-bottom: 0.55em;
}

.dynamic-entry-content h4 {
	margin-top: 1.75em;
	margin-bottom: 0.5em;
}

.dynamic-entry-content > *:first-child,
.dynamic-entry-content h2:first-child,
.dynamic-entry-content h3:first-child {
	margin-top: 0;
}

.dynamic-entry-content h2,
.dynamic-entry-content h3,
.dynamic-entry-content h4 {
	scroll-margin-top: var(--hotim-anchor-offset);
	text-wrap: balance;
}

/* Filet fin sous les h2 de contenu : repère de section sans alourdir. */
.dynamic-entry-content h2:not(.hotim-toc__title):not(.hotim-related__heading) {
	padding-bottom: 0.35em;
	border-bottom: 2px solid var(--hotim-rule);
}

/* Confort de lecture. Mesuré sur le rendu réel : Inter 18px donne une largeur
   moyenne de caractère de 8,43px, soit ~95 caractères par ligne sur les 800px
   du conteneur — bien au-delà de la fourchette lisible (45-85).
   60ch = 681px = ~81 caractères. Attention : 1ch = 11,35px ici (largeur du
   glyphe « 0 »), nettement plus large que la moyenne d'une prose française,
   donc raisonner en ch sans mesurer conduit à un plafond inopérant.
   Tableaux, images et encadrés gardent toute la largeur du conteneur. */
.dynamic-entry-content > p,
.dynamic-entry-content > ul,
.dynamic-entry-content > ol,
.dynamic-entry-content > blockquote,
.dynamic-entry-content > h3,
.dynamic-entry-content > h4 {
	max-width: 60ch;
}

.dynamic-entry-content p,
.dynamic-entry-content li {
	line-height: 1.68;
}

.dynamic-entry-content li + li {
	margin-top: 0.4em;
}

.dynamic-entry-content ul,
.dynamic-entry-content ol {
	padding-left: 1.35em;
}

/* -------------------------------------------------------------------------
 * 2. Liens du corps de texte
 * ---------------------------------------------------------------------- */

/* Le thème sort les liens en rouge sans soulignement : la couleur seule ne
   suffit pas (WCAG 1.4.1) et le rouge pur échoue au contraste AA.
   Les exclusions passent par :where() — spécificité nulle — pour que les
   composants de ce module (sommaire, fil d'Ariane, cartes liées) gardent
   leur propre style avec une simple règle de classe. Avec des :not()
   classiques, cette règle pesait (0,4,1) et écrasait tout le reste. */
.dynamic-entry-content a:not(:where(.gb-text, [class*="button"], .hotim-toc a, .hotim-breadcrumb a, .hotim-related a)) {
	color: var(--hotim-link);
	text-decoration: underline;
	text-decoration-thickness: 0.075em;
	text-underline-offset: 0.18em;
	text-decoration-color: color-mix(in srgb, var(--hotim-link) 45%, transparent);
	transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.dynamic-entry-content a:not(:where(.gb-text, [class*="button"], .hotim-toc a, .hotim-breadcrumb a, .hotim-related a)):hover,
.dynamic-entry-content a:not(:where(.gb-text, [class*="button"], .hotim-toc a, .hotim-breadcrumb a, .hotim-related a)):focus-visible {
	color: var(--hotim-link-hover);
	text-decoration-color: currentColor;
}

/* Repli pour les navigateurs sans color-mix(). */
@supports not (color: color-mix(in srgb, red 50%, transparent)) {
	.dynamic-entry-content a:not(:where(.gb-text, [class*="button"], .hotim-toc a, .hotim-breadcrumb a, .hotim-related a)) {
		text-decoration-color: currentColor;
	}
}

:where(.dynamic-entry-content, .hotim-toc, .hotim-related) a:focus-visible {
	outline: 2px solid var(--hotim-link);
	outline-offset: 2px;
	border-radius: 2px;
}

/* -------------------------------------------------------------------------
 * 3. Tableaux — correctif du débordement horizontal
 * ---------------------------------------------------------------------- */

.hotim-table__wrap {
	margin: 2em 0;
}

/* Sans ce conteneur, un tableau large étire tout le document : sur un
   viewport de 390px, la page entière défilait horizontalement. */
.hotim-table__scroll {
	overflow-x: auto;
	overflow-y: hidden;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior-x: contain;
	border: 1px solid var(--hotim-rule);
	border-radius: 8px;

	/* Ombres de bord : indiquent qu'il reste du contenu à droite/gauche. */
	background:
		linear-gradient(to right, #fff 30%, rgba(255, 255, 255, 0)) left center,
		linear-gradient(to left, #fff 30%, rgba(255, 255, 255, 0)) right center,
		radial-gradient(farthest-side at 0 50%, rgba(16, 16, 20, 0.14), transparent) left center,
		radial-gradient(farthest-side at 100% 50%, rgba(16, 16, 20, 0.14), transparent) right center;
	background-repeat: no-repeat;
	background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
	background-attachment: local, local, scroll, scroll;
}

.hotim-table__scroll:focus-visible {
	outline: 2px solid var(--hotim-link);
	outline-offset: 2px;
}

table.hotim-table {
	width: 100%;
	min-width: 100%;
	margin: 0;
	border-collapse: collapse;
	border: 0;
	font-size: 0.9375rem;
	line-height: 1.45;

	/* Chiffres de même largeur : les colonnes de valeurs se comparent à l'œil. */
	font-variant-numeric: tabular-nums;
	font-feature-settings: "tnum" 1;
}

table.hotim-table th,
table.hotim-table td {
	padding: 0.7em 0.85em;
	border: 0;
	border-bottom: 1px solid var(--hotim-rule);
	text-align: left;
	vertical-align: top;
}

table.hotim-table thead th {
	background: var(--hotim-surface);
	border-bottom: 2px solid #cfcfe0;
	font-weight: 700;
	font-size: 0.875rem;
	line-height: 1.35;
	white-space: normal;
}

table.hotim-table tbody tr {
	background: #fff;
}

table.hotim-table tbody tr:nth-child(even) {
	background: #fafaff;
}

table.hotim-table tbody tr:last-child th,
table.hotim-table tbody tr:last-child td {
	border-bottom: 0;
}

/* Les colonnes de chiffres s'alignent à droite, en-tête compris : c'est ce
   qui rend une colonne de nombres comparable en un coup d'œil. Classe posée
   en PHP, par colonne (cf. hotim_reading_align_columns). */
table.hotim-table .hotim-cell--num {
	text-align: right;
}

/* nowrap sur les valeurs seulement : un en-tête comme « Trafic de
   stupéfiants » doit pouvoir passer à la ligne. */
table.hotim-table td.hotim-cell--num {
	white-space: nowrap;
}

/* Première colonne collante : on garde le libellé de ligne visible pendant
   le défilement horizontal. */
table.hotim-table .hotim-cell--head {
	position: sticky;
	left: 0;
	z-index: 2;
	background: inherit;
	font-weight: 600;
	box-shadow: 1px 0 0 var(--hotim-rule);
}

table.hotim-table thead .hotim-cell--head {
	z-index: 3;
	background: var(--hotim-surface);
}

@media (max-width: 600px) {
	table.hotim-table {
		font-size: 0.875rem;
	}

	table.hotim-table th,
	table.hotim-table td {
		padding: 0.6em 0.7em;
	}

	/* Sur écran étroit, la colonne collante mangerait tout l'espace. */
	table.hotim-table .hotim-cell--head {
		position: static;
		box-shadow: none;
	}
}

/* -------------------------------------------------------------------------
 * 4. Sommaire
 * ---------------------------------------------------------------------- */

.hotim-toc {
	margin: 2.25em 0 2.75em;
	padding: 1.15rem 1.35rem 1.25rem;
	background: var(--hotim-surface);
	border: 1px solid var(--hotim-rule);
	border-radius: 10px;
	font-size: 0.9375rem;
}

.hotim-toc__title {
	margin: 0 0 0.75rem;
	padding: 0;
	border: 0;
	font-size: 0.8125rem;
	font-weight: 700;
	letter-spacing: 0.09em;
	text-transform: uppercase;
	color: var(--hotim-muted);
}

.hotim-toc__list,
.hotim-toc__sub {
	margin: 0;
	padding: 0;
	list-style: none;
}

.hotim-toc__list {
	counter-reset: hotim-toc;
}

.hotim-toc__list > li {
	counter-increment: hotim-toc;
	margin: 0;
	padding-left: 1.9rem;
	position: relative;
}

.hotim-toc__list > li + li {
	margin-top: 0.45rem;
}

.hotim-toc__list > li::before {
	content: counter(hotim-toc);
	position: absolute;
	left: 0;
	top: 0.05em;
	width: 1.35rem;
	text-align: right;
	font-variant-numeric: tabular-nums;
	font-weight: 700;
	font-size: 0.8125rem;
	color: var(--hotim-muted);
}

.hotim-toc a {
	color: var(--contrast, #101014);
	text-decoration: none;
	line-height: 1.45;
	display: inline-block;
	border-bottom: 1px solid transparent;
}

.hotim-toc a:hover,
.hotim-toc a:focus-visible {
	color: var(--hotim-link);
	border-bottom-color: currentColor;
}

.hotim-toc__sub {
	margin: 0.35rem 0 0.6rem;
	padding-left: 0.85rem;
	border-left: 2px solid var(--hotim-rule);
}

.hotim-toc__sub li + li {
	margin-top: 0.3rem;
}

.hotim-toc__sub a {
	font-size: 0.875rem;
	color: var(--hotim-muted);
}

/* Rail collant : le gabarit laisse ~320px de gouttière à gauche du contenu.
   Le JS ne l'affiche que si la place mesurée est réellement suffisante. */
.hotim-toc-rail {
	position: fixed;
	z-index: 20;
	max-height: calc(100vh - 11rem);
	overflow-y: auto;
	overscroll-behavior: contain;
	font-size: 0.875rem;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s ease, visibility 0.2s ease;
	scrollbar-width: thin;
}

.hotim-toc-rail.is-visible {
	opacity: 1;
	visibility: visible;
}

.hotim-toc-rail .hotim-toc {
	margin: 0;
	background: transparent;
	border: 0;
	border-left: 2px solid var(--hotim-rule);
	border-radius: 0;
	padding: 0.25rem 1rem 0.25rem 1.1rem;
}

.hotim-toc-rail .hotim-toc__list > li {
	padding-left: 0;
}

.hotim-toc-rail .hotim-toc__list > li::before {
	content: none;
}

.hotim-toc-rail .hotim-toc__sub {
	display: none;
}

.hotim-toc-rail a {
	color: var(--hotim-muted);
	border-bottom: 0;
	padding: 0.1rem 0;
}

.hotim-toc-rail a.is-current {
	color: var(--contrast, #101014);
	font-weight: 700;
}

/* -------------------------------------------------------------------------
 * 5. Fil d'Ariane + ligne méta
 * ---------------------------------------------------------------------- */

.hotim-article-head {
	margin: 0 0 2rem;
	padding-bottom: 1rem;
	border-bottom: 1px solid var(--hotim-rule);
	font-size: 0.875rem;
	line-height: 1.5;
}

.hotim-breadcrumb ol {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.4rem;
	margin: 0 0 0.6rem;
	padding: 0;
	list-style: none;
}

.hotim-breadcrumb li {
	margin: 0;
	color: var(--hotim-muted);
}

.hotim-breadcrumb li + li::before {
	content: "›";
	margin-right: 0.4rem;
	color: #a8a8c0;
}

.hotim-breadcrumb a {
	color: var(--hotim-muted);
	text-decoration: none;
}

.hotim-breadcrumb a:hover,
.hotim-breadcrumb a:focus-visible {
	color: var(--hotim-link);
	text-decoration: underline;
}

.hotim-breadcrumb__current {
	/* Un fil d'Ariane ne doit pas se transformer en pavé sur les titres longs. */
	max-width: 28ch;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.hotim-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem 1.1rem;
	color: var(--hotim-muted);
}

.hotim-meta__item strong {
	color: var(--contrast, #101014);
	font-weight: 700;
}

/* -------------------------------------------------------------------------
 * 6. Encadrés générés dans le contenu (.quick-answer / .danger-list)
 *
 * Ces classes sortent du générateur de contenu mais n'ont jamais eu de
 * styles : le « TL;DR » se lisait comme un paragraphe ordinaire.
 * ---------------------------------------------------------------------- */

.dynamic-entry-content .quick-answer {
	margin: 0 0 2.25em;
	padding: 1.35rem 1.5rem 1.4rem;
	background: var(--hotim-surface);
	border: 1px solid var(--hotim-rule);
	border-left: 4px solid var(--contrast, #101014);
	border-radius: 8px;
}

.dynamic-entry-content .quick-answer > *:first-child {
	margin-top: 0;
}

.dynamic-entry-content .quick-answer > *:last-child {
	margin-bottom: 0;
}

.dynamic-entry-content .quick-answer h2,
.dynamic-entry-content .quick-answer h3,
.dynamic-entry-content .quick-answer h4 {
	margin-top: 0;
	margin-bottom: 0.7rem;
	padding-bottom: 0;
	border-bottom: 0;
	font-size: 1.125rem;
	line-height: 1.35;
}

.dynamic-entry-content .quick-answer p,
.dynamic-entry-content .quick-answer li {
	font-size: 1rem;
}

.dynamic-entry-content .danger-list {
	list-style: none;
	padding-left: 0;
}

.dynamic-entry-content .danger-list > li {
	position: relative;
	padding-left: 1.5rem;
}

.dynamic-entry-content .danger-list > li::before {
	content: "";
	position: absolute;
	left: 0.15rem;
	top: 0.6em;
	width: 0.5rem;
	height: 0.5rem;
	border-radius: 50%;
	background: var(--hotim-link);
}

/* -------------------------------------------------------------------------
 * 7. Articles liés
 * ---------------------------------------------------------------------- */

.hotim-related {
	margin: 3.5em 0 0;
	padding-top: 2em;
	border-top: 1px solid var(--hotim-rule);
}

.hotim-related__heading {
	margin: 0 0 1.25rem;
	padding: 0;
	border: 0;
	font-size: 1.375rem;
}

.hotim-related__list {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 1.25rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.hotim-related__item {
	margin: 0;
}

.hotim-related__link {
	display: flex;
	flex-direction: column;
	gap: 0.7rem;
	height: 100%;
	color: var(--contrast, #101014);
	text-decoration: none;
}

.hotim-related__media {
	display: block;
	overflow: hidden;
	border-radius: 8px;
	background: var(--hotim-surface);
	aspect-ratio: 3 / 2;
}

.hotim-related__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.3s ease;
}

.hotim-related__media:empty {
	display: none;
}

.hotim-related__title {
	font-family: var(--gp-font--figtree, inherit);
	font-weight: 700;
	font-size: 1rem;
	line-height: 1.35;
}

.hotim-related__link:hover .hotim-related__media img,
.hotim-related__link:focus-visible .hotim-related__media img {
	transform: scale(1.04);
}

.hotim-related__link:hover .hotim-related__title,
.hotim-related__link:focus-visible .hotim-related__title {
	color: var(--hotim-link);
}

/* -------------------------------------------------------------------------
 * 8. Progression de lecture + retour en haut
 * ---------------------------------------------------------------------- */

.hotim-progress {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 3px;
	z-index: 999;
	pointer-events: none;
	background: transparent;
}

.hotim-progress__bar {
	display: block;
	height: 100%;
	width: 0;
	background: var(--hotim-link);
	transform-origin: 0 50%;
}

.hotim-totop {
	position: fixed;
	right: 1.25rem;
	bottom: 1.25rem;
	z-index: 100;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	border: 1px solid var(--hotim-rule);
	border-radius: 50%;
	background: #fff;
	color: var(--contrast, #101014);
	box-shadow: 0 4px 14px rgba(16, 16, 20, 0.14);
	cursor: pointer;
	transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.hotim-totop[hidden] {
	display: none;
}

.hotim-totop:hover,
.hotim-totop:focus-visible {
	background: var(--contrast, #101014);
	color: #fff;
	transform: translateY(-2px);
}

/* -------------------------------------------------------------------------
 * 9. Préférences utilisateur & impression
 * ---------------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
	html {
		scroll-behavior: smooth;
	}
}

@media (prefers-reduced-motion: reduce) {
	.hotim-related__media img,
	.hotim-totop,
	.hotim-toc-rail {
		transition: none;
	}
}

@media print {
	.hotim-progress,
	.hotim-totop,
	.hotim-toc-rail,
	.hotim-toc,
	.hotim-related {
		display: none !important;
	}

	.hotim-table__scroll {
		overflow: visible;
		border: 0;
		background: none;
	}

	.dynamic-entry-content h2 {
		border-bottom: 1px solid #000;
	}
}
