/* =========================================================
   TradManga — Dossiers
   Tout est préfixé par .tm-dossier : aucun impact sur le reste du thème.
   ========================================================= */

.tm-dossier {
	/* Mode nuit (défaut) */
	--tmd-accent: #e8192c;
	--tmd-bg: #16151d;
	--tmd-surface: #1e1d28;
	--tmd-surface-2: #252433;
	--tmd-line: #2f2e40;
	--tmd-text: #d6d5df;
	--tmd-muted: #9897a8;
	--tmd-head: #ffffff;
	--tmd-accent-text: #ff3b4c;
	--tmd-on-accent: #ffffff;
	--tmd-zebra: rgba(255, 255, 255, .025);
	--tmd-hover: rgba(255, 255, 255, .05);

	font-family: 'Poppins', system-ui, sans-serif;
	color: var(--tmd-text);
	max-width: 1240px;
	margin: 0 auto;
	padding: 28px 16px 64px;
	box-sizing: border-box;
}
/* Mode jour : la classe .tmd-light est posée automatiquement par le script
   du module, qui lit la luminosité réelle du fond du site (aucune classe du thème à connaître). */
.tm-dossier.tmd-light {
	--tmd-accent: #f0c040;
	--tmd-accent-text: #9a6b00;
	--tmd-on-accent: #121219;
	--tmd-bg: #f4f4f7;
	--tmd-surface: #ffffff;
	--tmd-surface-2: #f3f2f7;
	--tmd-line: #e2e1ea;
	--tmd-text: #33323f;
	--tmd-muted: #6c6b7c;
	--tmd-head: #121219;
	--tmd-zebra: #fafaFC;
	--tmd-hover: #f6f5fa;
}
.tm-dossier.tmd-light .tmd-hero,
.tm-dossier.tmd-light .tmd-toc,
.tm-dossier.tmd-light .tmd-content,
.tm-dossier.tmd-light .tmd-card { box-shadow: 0 2px 14px rgba(18, 18, 25, .06); }
.tm-dossier.tmd-light .tmd-hero { background: linear-gradient(135deg, #ffffff 0%, #faf6e8 100%); }
.tm-dossier .tmd-hero, .tm-dossier .tmd-toc, .tm-dossier .tmd-content, .tm-dossier .tmd-card { transition: background-color .25s, border-color .25s, color .25s; }

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

/* Protection contre les styles du thème / snippets (flex, float, largeurs) */
.tm-dossier {
	display: block !important;
	float: none !important;
	width: 100% !important;
	flex: 0 0 100% !important;
	max-width: 1240px !important;
	margin-left: auto !important;
	margin-right: auto !important;
	grid-column: 1 / -1;
}
.tm-dossier .tmd-hero,
.tm-dossier .tmd-crumbs,
.tm-dossier .tmd-toc,
.tm-dossier .tmd-content,
.tm-dossier .tmd-filters {
	float: none !important;
	width: auto !important;
	max-width: none !important;
}
.tm-dossier .tmd-hero { display: block !important; }
.tm-dossier .tmd-crumbs { display: block !important; background: none !important; padding: 0 !important; height: auto !important; }
.tm-dossier .tmd-layout { display: grid !important; width: 100% !important; float: none !important; }
.tm-dossier .tmd-content { display: block !important; min-width: 0; word-break: normal; }

/* ---------- En-tête ---------- */
.tm-dossier .tmd-hero {
	background: linear-gradient(135deg, var(--tmd-surface) 0%, var(--tmd-bg) 100%);
	border: 1px solid var(--tmd-line);
	border-left: 4px solid var(--tmd-accent);
	border-radius: 12px;
	padding: 32px 36px;
	margin-bottom: 28px;
}
.tm-dossier .tmd-crumbs { font-size: 13px; color: var(--tmd-muted); margin-bottom: 10px; }
.tm-dossier .tmd-crumbs a { color: var(--tmd-accent-text); text-decoration: none; font-weight: 500; }
.tm-dossier .tmd-crumbs span { margin: 0 8px; }
.tm-dossier .tmd-title {
	font-size: clamp(28px, 4.2vw, 46px);
	line-height: 1.12;
	font-weight: 700;
	color: var(--tmd-head);
	margin: 0 0 12px;
	letter-spacing: -0.5px;
}
.tm-dossier .tmd-lead { font-size: 16px; line-height: 1.65; color: var(--tmd-muted); margin: 0 0 18px; max-width: 820px; }
.tm-dossier .tmd-meta { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; font-size: 13px; }
.tm-dossier .tmd-meta span {
	background: var(--tmd-surface-2);
	border: 1px solid var(--tmd-line);
	border-radius: 999px;
	padding: 4px 12px;
	color: var(--tmd-text);
}
.tm-dossier .tmd-print {
	margin-left: auto;
	background: transparent;
	color: var(--tmd-accent-text);
	border: 1px solid var(--tmd-accent);
	border-radius: 8px;
	padding: 6px 14px;
	font: 500 13px 'Poppins', sans-serif;
	cursor: pointer;
	text-decoration: none !important;
	display: inline-block;
	transition: background .15s, color .15s;
}
.tm-dossier .tmd-print:hover { background: var(--tmd-accent); color: var(--tmd-on-accent); border-color: var(--tmd-accent); }

/* ---------- Mise en page ---------- */
.tm-dossier .tmd-layout {
	display: grid;
	grid-template-columns: 270px minmax(0, 1fr);
	gap: 28px;
	align-items: start;
}
.tm-dossier .tmd-layout.tmd-no-toc { grid-template-columns: minmax(0, 1fr); }

/* ---------- Colonne latérale : image mise en avant + sommaire ---------- */
.tm-dossier .tmd-layout > .tmd-side { align-self: stretch; min-width: 0; }
.tm-dossier .tmd-cover {
	margin: 0 0 16px;
	border-radius: 12px;
	overflow: hidden;
	border: 1px solid var(--tmd-line);
	background: var(--tmd-surface);
}
.tm-dossier .tmd-cover img { display: block; width: 100%; height: auto; }

/* ---------- Sommaire ---------- */
.tm-dossier .tmd-toc {
	position: sticky !important;
	top: 90px;
	max-height: calc(100vh - 110px);
	overflow: auto;
	background: var(--tmd-surface);
	border: 1px solid var(--tmd-line);
	border-radius: 12px;
	padding: 16px 14px;
	scrollbar-width: thin;
}
.tm-dossier .tmd-toc summary {
	font-weight: 600;
	font-size: 14px;
	color: var(--tmd-head);
	text-transform: uppercase;
	letter-spacing: 1px;
	cursor: pointer;
	list-style: none;
	padding-bottom: 10px;
	border-bottom: 2px solid var(--tmd-accent);
	margin-bottom: 8px;
}
.tm-dossier .tmd-toc summary::-webkit-details-marker { display: none; }
.tm-dossier .tmd-toc ol { list-style: none; counter-reset: tmd; margin: 0; padding: 0; }
.tm-dossier .tmd-toc li { counter-increment: tmd; margin: 0; }
.tm-dossier .tmd-toc a {
	display: flex;
	gap: 8px;
	padding: 6px 8px;
	border-radius: 6px;
	font-size: 13px;
	line-height: 1.4;
	color: var(--tmd-muted);
	text-decoration: none;
	transition: background .15s, color .15s;
}
.tm-dossier .tmd-toc a::before {
	content: counter(tmd);
	min-width: 18px;
	font-weight: 600;
	color: var(--tmd-accent-text);
}
.tm-dossier .tmd-toc a:hover { background: var(--tmd-surface-2); color: var(--tmd-head); }
.tm-dossier .tmd-toc a.is-active { background: var(--tmd-surface-2); color: var(--tmd-head); box-shadow: inset 3px 0 0 var(--tmd-accent); }

/* ---------- Contenu ---------- */
.tm-dossier .tmd-content {
	background: var(--tmd-surface);
	border: 1px solid var(--tmd-line);
	border-radius: 12px;
	padding: 36px 44px 44px;
	font-size: 16px;
	line-height: 1.8;
	min-width: 0;
}
.tm-dossier .tmd-content > *:first-child { margin-top: 0; }
.tm-dossier .tmd-content h2[id],
.tm-dossier .tmd-content h3[id] { scroll-margin-top: 100px; }
.tm-dossier .tmd-content h2 {
	font-size: 25px;
	line-height: 1.25;
	font-weight: 700;
	color: var(--tmd-head);
	margin: 56px 0 18px;
	padding-top: 28px;
	border-top: 1px solid var(--tmd-line);
}
.tm-dossier .tmd-content h2:first-child { border-top: 0; padding-top: 0; }
.tm-dossier .tmd-content h3 {
	font-size: 19px;
	font-weight: 600;
	color: var(--tmd-head);
	margin: 34px 0 12px;
	padding-left: 12px;
	border-left: 3px solid var(--tmd-accent);
}
.tm-dossier .tmd-content p { margin: 0 0 16px; }
.tm-dossier .tmd-content strong { color: var(--tmd-head); font-weight: 600; }
.tm-dossier .tmd-content a { color: var(--tmd-accent-text); text-underline-offset: 3px; overflow-wrap: anywhere; }
.tm-dossier .tmd-content ul,
.tm-dossier .tmd-content ol { padding-left: 22px; margin: 0 0 18px; }
.tm-dossier .tmd-content li { margin-bottom: 8px; }

/* Renvois [S01] */
.tm-dossier .tmd-content a.tmd-ref,
.tm-dossier .tmd-content a[href^="#s"]:not([href^="#se"]) {
	display: inline-block;
	font-size: 11px;
	font-weight: 600;
	line-height: 1.5;
	padding: 0 6px;
	border-radius: 4px;
	background: var(--tmd-surface-2);
	border: 1px solid var(--tmd-line);
	color: var(--tmd-accent-text);
	text-decoration: none;
	white-space: nowrap;
	vertical-align: 1px;
}
.tm-dossier .tmd-content a.tmd-ref:hover { border-color: var(--tmd-accent-text); }

/* Bibliographie */
.tm-dossier .tmd-content li.tmd-source {
	list-style: none;
	margin: 0 0 0 -22px;
	padding: 10px 12px;
	font-size: 14px;
	line-height: 1.6;
	border-bottom: 1px solid var(--tmd-line);
	border-radius: 6px;
	scroll-margin-top: 100px;
	transition: background .3s;
}
.tm-dossier .tmd-content li.tmd-source:target {
	background: var(--tmd-surface-2);
	box-shadow: inset 3px 0 0 var(--tmd-accent);
}

/* Tableaux */
.tm-dossier .tmd-table {
	overflow-x: auto;
	margin: 24px 0;
	border: 1px solid var(--tmd-line);
	border-radius: 10px;
}
.tm-dossier .tmd-content figure.wp-block-table { margin: 24px 0; }
.tm-dossier .tmd-content figure.wp-block-table .tmd-table { margin: 0; }
.tm-dossier .tmd-content table {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
	line-height: 1.55;
	margin: 0;
	background: transparent;
}
.tm-dossier .tmd-content th {
	background: var(--tmd-surface-2);
	color: var(--tmd-head);
	text-align: left;
	font-weight: 600;
	padding: 12px 14px;
	border: 0;
	border-bottom: 2px solid var(--tmd-accent);
	white-space: normal;
	vertical-align: bottom;
}
.tm-dossier .tmd-content td {
	padding: 11px 14px;
	border: 0;
	border-bottom: 1px solid var(--tmd-line);
	vertical-align: top;
	color: var(--tmd-text);
	background: transparent;
}
.tm-dossier .tmd-content tr:last-child td { border-bottom: 0; }
.tm-dossier .tmd-content tbody tr:nth-child(even) td { background: var(--tmd-zebra); }
.tm-dossier .tmd-content tbody tr:hover td { background: var(--tmd-hover); }

.tm-dossier .tmd-top {
	display: inline-block;
	margin-top: 36px;
	font-size: 14px;
	text-decoration: none !important;
}


/* ---------- Texte justifié ---------- */
.tm-dossier .tmd-content p,
.tm-dossier .tmd-content > ul > li:not(.tmd-source),
.tm-dossier .tmd-content > ol > li {
	text-align: justify;
	text-justify: inter-word;
	-webkit-hyphens: auto;
	hyphens: auto;
	hyphenate-limit-chars: 7 3 3;
}
/* Ne pas justifier : bibliographie, tableaux, titres */
.tm-dossier .tmd-content li.tmd-source,
.tm-dossier .tmd-content td,
.tm-dossier .tmd-content th { text-align: left; }

/* Groupes de renvois [S11–S12] : crochets collés aux renvois */
.tm-dossier .tmd-content .tmd-nw { white-space: nowrap; }

/* ---------- Tableaux : tenir dans la colonne ---------- */
.tm-dossier .tmd-content table { font-size: 13.5px; line-height: 1.5; }
.tm-dossier .tmd-content th { padding: 10px 11px; font-size: 13px; }
.tm-dossier .tmd-content td {
	padding: 9px 11px;
	overflow-wrap: break-word;
	-webkit-hyphens: auto;
	hyphens: auto;
}
.tm-dossier .tmd-content td a.tmd-ref,
.tm-dossier .tmd-content td a.ref {
	font-size: 10px;
	padding: 0 4px;
}
.tm-dossier .tmd-content td a:not(.tmd-ref):not(.ref) { overflow-wrap: anywhere; }

/* ---------- Archive ---------- */
.tm-dossier .tmd-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.tm-dossier .tmd-filters a {
	padding: 6px 14px;
	border-radius: 999px;
	border: 1px solid var(--tmd-line);
	color: var(--tmd-text);
	font-size: 13px;
	text-decoration: none;
	transition: border-color .15s, color .15s;
}
.tm-dossier .tmd-filters a:hover,
.tm-dossier .tmd-filters a.is-active { border-color: var(--tmd-accent-text); color: var(--tmd-accent-text); }

.tm-dossier .tmd-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
	gap: 22px;
}
.tm-dossier .tmd-card {
	display: flex;
	flex-direction: column;
	background: var(--tmd-surface);
	border: 1px solid var(--tmd-line);
	border-radius: 12px;
	overflow: hidden;
	text-decoration: none;
	color: var(--tmd-text);
	transition: transform .18s, border-color .18s;
}
.tm-dossier .tmd-card:hover { transform: translateY(-3px); border-color: var(--tmd-accent-text); }
.tm-dossier .tmd-card-img { aspect-ratio: 16 / 9; background: var(--tmd-surface-2); overflow: hidden; }
.tm-dossier .tmd-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tm-dossier .tmd-card-ph {
	display: flex; align-items: center; justify-content: center;
	width: 100%; height: 100%;
	font-size: 64px; font-weight: 700;
	color: var(--tmd-accent-text);
	background: radial-gradient(circle at 30% 30%, var(--tmd-surface-2), var(--tmd-bg));
}
.tm-dossier .tmd-card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.tm-dossier .tmd-card-cat { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--tmd-accent-text); }
.tm-dossier .tmd-card h2 { font-size: 19px; line-height: 1.3; color: var(--tmd-head); margin: 0; font-weight: 600; }
.tm-dossier .tmd-card p { font-size: 14px; line-height: 1.6; color: var(--tmd-muted); margin: 0; }
.tm-dossier .tmd-card-meta { margin-top: auto; padding-top: 8px; font-size: 12px; color: var(--tmd-muted); }
.tm-dossier .tmd-empty { color: var(--tmd-muted); }
.tm-dossier .tmd-pagination { margin-top: 28px; text-align: center; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
	.tm-dossier { padding: 16px 12px 48px; }
	.tm-dossier .tmd-hero { padding: 22px 20px; }
	.tm-dossier .tmd-print { margin-left: 0; }
	.tm-dossier .tmd-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
	.tm-dossier .tmd-cover { display: none; }
	.tm-dossier .tmd-toc { position: sticky; top: 0; z-index: 20; max-height: 70vh; padding: 12px 14px; }
	.tm-dossier .tmd-toc summary { border-bottom: 0; padding-bottom: 0; margin-bottom: 0; }
	.tm-dossier .tmd-toc details[open] summary { border-bottom: 2px solid var(--tmd-accent); padding-bottom: 10px; margin-bottom: 8px; }
	.tm-dossier .tmd-toc summary::after { content: ' ▾'; color: var(--tmd-accent-text); }
	.tm-dossier .tmd-content { padding: 22px 18px 30px; font-size: 15.5px; }
	.tm-dossier .tmd-content h2 { font-size: 21px; margin-top: 40px; }
	.tm-dossier .tmd-content h3 { font-size: 17px; }
	.tm-dossier .tmd-content th { white-space: normal; }
	.tm-dossier .tmd-content table { min-width: 560px; font-size: 13px; }
	.tm-dossier .tmd-table { -webkit-overflow-scrolling: touch; }
}
/* ---------- Impression / PDF ---------- */
@media print {
	body * { visibility: hidden !important; }
	.tm-dossier, .tm-dossier * { visibility: visible !important; }
	.tm-dossier {
		position: absolute; left: 0; top: 0; width: 100%;
		max-width: none; padding: 0;
		--tmd-text: #111; --tmd-head: #000; --tmd-muted: #444;
		--tmd-surface: #fff; --tmd-surface-2: #f2f2f2; --tmd-line: #ccc;
	}
	.tm-dossier .tmd-hero { background: none; border: 0; border-left: 4px solid var(--tmd-accent); padding: 0 0 0 16px; }
	.tm-dossier .tmd-cover, .tm-dossier .tmd-toc, .tm-dossier .tmd-print, .tm-dossier .tmd-top, .tm-dossier .tmd-crumbs { display: none !important; }
	.tm-dossier .tmd-layout { display: block; }
	.tm-dossier .tmd-content { border: 0; padding: 0; font-size: 10.5pt; line-height: 1.5; }
	.tm-dossier .tmd-content h2 { break-after: avoid; margin-top: 24px; }
	.tm-dossier .tmd-content h3 { break-after: avoid; }
	.tm-dossier .tmd-table { overflow: visible; }
	.tm-dossier .tmd-content tr { break-inside: avoid; }
	.tm-dossier .tmd-content table { font-size: 8.5pt; }
	@page { size: A4; margin: 16mm; }
}
