/**
 * Modulo Blocks — Sommaire (modulo/toc).
 * Sans réglage : même apparence qu'avant la 1.30.0 (encadré, barre à gauche).
 */
.mt-toc {
	--_A: var(--_ac, var(--mb-c-accent));
	--_IN: var(--_in, 16px);
	--_TOP: 24px;
	font-size: var(--_fs, .95em);
	line-height: 1.5;
	box-sizing: border-box;
}
.mt-toc *, .mt-toc *::before, .mt-toc *::after { box-sizing: border-box; }
.mt-toc--box {
	border: 1px solid var(--_bd, color-mix(in srgb, var(--mb-c-text) 8%, transparent));
	border-radius: var(--_r, var(--mb-r, 10px));
	padding: 16px 20px;
	background: var(--_bg, var(--mb-c-surface));
	box-shadow: var(--_sh, none);
}
.mt-toc--border { border-left: 3px solid var(--_bd, var(--_A)); padding: 4px 0 4px 18px; background: var(--_bg, transparent); }
.mt-toc--plain { background: var(--_bg, transparent); }

/* Titre. */
.mt-toc__head { margin: 0 0 10px; }
.mt-toc__title { margin: 0; font-weight: 700; font-size: 1em; line-height: 1.35; letter-spacing: .01em; color: var(--_tt, inherit); }
.mt-toc__count { font-weight: 400; opacity: .6; margin-left: .35em; }
.mt-toc__toggle {
	display: flex; align-items: center; justify-content: flex-start; gap: 0;
	width: 100%; margin: 0; padding: 0; border: 0; background: none;
	font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.mt-toc__toggle:focus-visible { outline: 2px solid var(--_A); outline-offset: 4px; border-radius: 4px; }
.mt-toc__chevron {
	flex: none; width: 9px; height: 9px; margin-left: auto;
	border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
	transform: translateY(-2px) rotate(45deg); opacity: .6; transition: transform .2s ease;
}
.mt-toc.is-closed .mt-toc__chevron { transform: translateY(1px) rotate(-135deg); }
.mt-toc.is-closed .mt-toc__head { margin-bottom: 0; }
.mt-toc.is-closed .mt-toc__body,
.mt-toc.is-closed .mt-toc__progress { display: none; }

/* Progression de lecture. */
.mt-toc__progress { height: 3px; margin: 0 0 12px; border-radius: 3px; background: color-mix(in srgb, var(--_A) 15%, transparent); overflow: hidden; }
.mt-toc__progress span { display: block; height: 100%; width: var(--_p, 0%); background: var(--_A); transition: width .15s linear; }

/* Liste. */
.mt-toc__list { list-style: none; margin: 0; padding: 0; }
.mt-toc__item { margin: 0; padding: calc(var(--_ig, 4px) / 2) 0; }
.mt-toc__item--l1 { padding-left: var(--_IN); }
.mt-toc__item--l2 { padding-left: calc(var(--_IN) * 2); }
.mt-toc__item--l3 { padding-left: calc(var(--_IN) * 3); }
.mt-toc__item--l4 { padding-left: calc(var(--_IN) * 4); }
.mt-toc--collapse-sub.is-ready .mt-toc__item:not(.mt-toc__item--l0):not(.is-open) { display: none; }

.mt-toc__link {
	display: inline-flex;
	align-items: baseline;
	gap: .5em;
	color: var(--_lk, var(--mb-link-color, inherit));
	text-decoration: none;
	border-left: 2px solid transparent;
	padding-left: 10px;
	margin-left: -12px;
	border-radius: 0;
	transition: color .15s ease, border-color .15s ease, background-color .15s ease;
}
.mt-toc a.mt-toc__link { color: var(--_lk, var(--mb-link-color, inherit)); }
.mt-toc__link:hover { color: var(--_A); }
.mt-toc__link:focus-visible { outline: 2px solid var(--_A); outline-offset: 2px; }
.mt-toc__num { flex: none; color: var(--_nu, inherit); font-variant-numeric: tabular-nums; opacity: .8; }
.mt-toc--nums-badge .mt-toc__num {
	display: inline-flex; align-items: center; justify-content: center;
	min-width: 1.6em; height: 1.6em; padding: 0 .35em;
	border-radius: 999px; font-size: .8em; font-weight: 700; opacity: 1;
	background: color-mix(in srgb, var(--_nu, var(--_A)) 14%, transparent);
	color: var(--_nu, var(--_A));
	transform: translateY(-.05em);
}

/* Partie en cours. */
.mt-toc a.mt-toc__link.is-active { color: var(--_A); }
.mt-toc--active-bar .mt-toc__link.is-active { border-left-color: var(--_A); font-weight: 600; }
.mt-toc--active-bold .mt-toc__link.is-active { font-weight: 700; }
.mt-toc--active-bg .mt-toc__link,
.mt-toc--active-pill .mt-toc__link { border-left: 0; margin-left: -8px; padding: 2px 8px; border-radius: 6px; }
.mt-toc--active-pill .mt-toc__link { border-radius: 999px; padding: 2px 10px; margin-left: -10px; }
.mt-toc--active-bg .mt-toc__link.is-active { background: color-mix(in srgb, var(--_A) 12%, transparent); font-weight: 600; }
.mt-toc--active-pill .mt-toc__link.is-active { background: var(--_A); color: var(--_at, var(--mb-c-on-accent)); font-weight: 600; }
.mt-toc--active-pill .mt-toc__link.is-active .mt-toc__num { color: inherit; background: color-mix(in srgb, var(--_at, var(--mb-c-on-accent)) 22%, transparent); }

/* Collant vertical (colonne latérale, ordinateur). */
@media (min-width: 981px) {
	.mt-toc--sticky {
		position: sticky;
		z-index: 30;
		top: var(--_TOP);
		max-height: calc(100vh - var(--_TOP) - 24px);
		overflow-y: auto;
		scrollbar-width: thin;
	}
}

/* Barre horizontale au défilement. */
.mt-tocbar {
	--_A: var(--_ac, var(--mb-c-accent));
	position: fixed;
	left: 0; right: 0;
	top: var(--_TOP, 0px);
	z-index: 9970;
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 6px 10px;
	background: var(--_bb, var(--mb-c-surface));
	color: var(--_bt, inherit);
	box-shadow: 0 4px 18px color-mix(in srgb, var(--mb-c-shadow) 9%, transparent);
	font-size: .9rem;
	line-height: 1.3;
	transform: translateY(-110%);
	opacity: 0;
	visibility: hidden;
	transition: transform .25s ease, opacity .25s ease, visibility .25s;
	box-sizing: border-box;
}
.mt-tocbar.is-visible { transform: none; opacity: 1; visibility: visible; }
.mt-tocbar__label { flex: none; font-weight: 700; padding: 0 6px; }
.mt-tocbar__scroller { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; scroll-behavior: smooth; }
.mt-tocbar__scroller::-webkit-scrollbar { display: none; }
.mt-tocbar__list { display: flex; gap: 6px; list-style: none; margin: 0; padding: 2px; }
.mt-tocbar__list li { margin: 0; flex: none; }
.mt-tocbar__chip {
	display: inline-flex; align-items: center; gap: .4em;
	max-width: 280px; padding: 6px 12px;
	border-radius: 999px;
	color: inherit; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
	background: color-mix(in srgb, currentColor 6%, transparent);
	transition: background-color .15s ease, color .15s ease;
}
.mt-tocbar__chip .mt-toc__text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.mt-tocbar__chip .mt-toc__num { flex: none; }
.mt-tocbar__chip:hover { background: color-mix(in srgb, var(--_A) 14%, transparent); }
.mt-tocbar__chip.is-active { background: var(--_A); color: var(--_at, var(--mb-c-on-accent)); font-weight: 600; }
.mt-tocbar__chip:focus-visible { outline: 2px solid var(--_A); outline-offset: 2px; }
.mt-tocbar__arrow {
	flex: none;
	width: 32px; height: 32px;
	display: inline-flex; align-items: center; justify-content: center;
	border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
	border-radius: 50%;
	background: transparent; color: inherit;
	font-size: 18px; line-height: 1; cursor: pointer;
}
.mt-tocbar__arrow:disabled { opacity: .3; cursor: default; }
.mt-tocbar__arrow:not(:disabled):hover { border-color: var(--_A); color: var(--_A); }
.mt-tocbar__progress { position: absolute; left: 0; bottom: 0; height: 2px; width: var(--_p, 0%); background: var(--_A); transition: width .15s linear; }
@media (max-width: 600px) {
	.mt-tocbar__label { display: none; }
	.mt-tocbar { padding: 6px; }
}

/* Bandeau « partie en cours » (mobile). */
.mt-tocnow {
	--_A: var(--_ac, var(--mb-c-accent));
	position: fixed;
	left: 0; right: 0;
	top: var(--_TOP, 0px);
	z-index: 9970;
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	margin: 0;
	padding: 10px 16px;
	border: 0;
	border-radius: 0;
	background: var(--_bb, var(--mb-c-surface));
	color: var(--_bt, var(--mb-c-text));
	box-shadow: 0 4px 18px var(--mb-c-shadow, color-mix(in srgb, var(--mb-c-shadow) 9%, transparent));
	font: inherit;
	font-size: .9rem;
	line-height: 1.3;
	text-align: left;
	cursor: pointer;
	transform: translateY(-110%);
	opacity: 0;
	visibility: hidden;
	transition: transform .25s ease, opacity .25s ease, visibility .25s;
	box-sizing: border-box;
}
.mt-tocnow.is-visible { transform: none; opacity: 1; visibility: visible; }
.mt-tocnow__label { flex: none; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--_A); }
.mt-tocnow__label::after { content: "·"; margin-left: 8px; color: var(--_bt, var(--mb-c-muted)); opacity: .5; }
.mt-tocnow__text { flex: 1 1 auto; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-tocnow__chev { flex: none; width: 18px; height: 18px; opacity: .7; }
.mt-tocnow[aria-expanded="true"] .mt-tocnow__chev { transform: rotate(180deg); }
.mt-tocnow__progress { position: absolute; left: 0; bottom: 0; height: 2px; width: var(--_p, 0%); background: var(--_A); transition: width .15s linear; }
.mt-tocnow:focus-visible { outline: 2px solid var(--_A); outline-offset: -2px; }
@media (min-width: 601px) {
	.mt-tocnow { display: none; }
}

/* Bouton « Sommaire » et panneau (mobile). */
.mt-tocbtn {
	position: fixed;
	right: 16px;
	bottom: calc(16px + env(safe-area-inset-bottom));
	z-index: 9971;
	display: inline-flex; align-items: center; gap: 8px;
	padding: 10px 16px;
	border: 0; border-radius: 999px;
	background: var(--_btb, var(--_A, var(--mb-c-accent))); color: var(--_btt, var(--mb-c-on-accent));
	font: inherit; font-size: .9rem; font-weight: 600;
	box-shadow: 0 6px 20px color-mix(in srgb, var(--mb-c-shadow) 20%, transparent);
	cursor: pointer;
	transform: translateY(150%);
	transition: transform .25s ease;
}
.mt-tocbtn.is-visible { transform: none; }
.mt-tocbtn svg { width: 18px; height: 18px; }
.mt-tocsheet { position: fixed; inset: 0; z-index: 9990; display: flex; align-items: flex-end; }
.mt-tocsheet[hidden] { display: none; }
.mt-tocsheet__backdrop { position: absolute; inset: 0; background: color-mix(in srgb, var(--mb-c-overlay) 45%, transparent); }
.mt-tocsheet__panel {
	position: relative;
	width: 100%;
	max-height: 75vh;
	overflow-y: auto;
	padding: 18px 20px calc(20px + env(safe-area-inset-bottom));
	border-radius: 16px 16px 0 0;
	background: var(--_sb, var(--mb-c-surface));
	box-shadow: 0 -8px 30px color-mix(in srgb, var(--mb-c-shadow) 20%, transparent);
}
.mt-tocsheet__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-weight: 700; }
.mt-tocsheet__close { border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: inherit; padding: 0 4px; }
.mt-tocsheet .mt-toc { border: 0; padding: 0; box-shadow: none; }
@media (min-width: 601px) {
	.mt-tocbtn { display: none; }
}

/* « Retour au sommaire ». */
.mt-toc-back { margin: 1.5em 0 .5em; font-size: .85em; }
.mt-toc-back a { text-decoration: none; opacity: .7; }
.mt-toc-back a:hover { opacity: 1; text-decoration: underline; }

/* Aperçu éditeur. */
.mt-toc--editor .mt-toc__link { cursor: default; }

@media (prefers-reduced-motion: reduce) {
	.mt-tocbar, .mt-tocbtn, .mt-tocnow, .mt-toc__chevron, .mt-toc__progress span, .mt-tocbar__progress, .mt-tocnow__progress { transition: none; }
}
@media print {
	.mt-tocbar, .mt-tocbtn, .mt-tocnow, .mt-tocsheet, .mt-toc-back { display: none !important; }
}
