/* ==========================================================================
   WT TOC — mục lục
   Phong cách: nền xám nhạt phẳng, không viền, số thứ tự mảnh, nhấn màu bằng chữ.
   Tuỳ biến bằng biến CSS (đặt trên .wt-toc) hoặc trang cài đặt của plugin.
   ========================================================================== */

.wt-toc {
	/* mặc định = bộ màu "gray" */
	--wt-toc-bg: #e9ece8;
	--wt-toc-border: #d6dbd4;
	--wt-toc-title: #141a14;
	--wt-toc-link: #2b342d;
	--wt-toc-sub: #7d887f;
	--wt-toc-active: #008a00;
	--wt-toc-num: #a2aba4;
	--wt-toc-line: #d4d9d2;
}

.wt-toc--cream {
	--wt-toc-bg: #f8f0de;
	--wt-toc-border: #eadfc3;
	--wt-toc-link: #2d2a20;
	--wt-toc-sub: #8b7d5e;
	--wt-toc-num: #b9a982;
	--wt-toc-line: #eadfc3;
}

.wt-toc--mint {
	--wt-toc-bg: #ecf5ec;
	--wt-toc-border: #d3e6d4;
	--wt-toc-link: #1f2d22;
	--wt-toc-sub: #6b8a6e;
	--wt-toc-num: #9cbf9f;
	--wt-toc-line: #d3e6d4;
}

.wt-toc--white {
	--wt-toc-bg: #ffffff;
	--wt-toc-border: #e2e6e1;
	--wt-toc-num: #b5bdb7;
	--wt-toc-line: #e8ebe7;
}

.wt-toc--white.wt-toc {
	box-shadow: 0 1px 2px rgba(15, 26, 18, 0.06), 0 12px 32px -20px rgba(15, 26, 18, 0.28);
}

.wt-toc--dark {
	--wt-toc-bg: #151f19;
	--wt-toc-border: #263a2e;
	--wt-toc-title: #ffffff;
	--wt-toc-link: #dbe4dc;
	--wt-toc-sub: #8fa095;
	--wt-toc-active: #4ade80;
	--wt-toc-num: #5d7164;
	--wt-toc-line: #263a2e;
}

.wt-toc,
.wt-toc *,
.wt-toc *::before,
.wt-toc *::after {
	box-sizing: border-box;
}

nav.wt-toc {
	position: relative;
	margin: 0 0 28px;
	background: var(--wt-toc-bg);
	border: 1px solid var(--wt-toc-border);
	border-radius: var(--wt-toc-r, 16px);
	color: var(--wt-toc-link);
	font-size: var(--wt-toc-fs, 15px);
	line-height: 1.5;
	overflow: hidden;
	text-align: left;
}

.wt-toc--bar::before {
	content: '';
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: 3px;
	background: var(--wt-toc-active);
	z-index: 1;
}

.wt-toc--shadow {
	box-shadow: 0 18px 40px -26px rgba(15, 26, 18, 0.45);
}

.wt-toc--auto {
	width: fit-content;
	max-width: 100%;
	min-width: min(340px, 100%);
}

.wt-toc--auto.wt-toc--align-center {
	margin-left: auto;
	margin-right: auto;
}

.wt-toc--auto.wt-toc--align-right {
	margin-left: auto;
}

/* ---- thanh tiêu đề (bấm cả thanh để thu gọn / mở rộng) ---- */
.wt-toc .wt-toc__bar {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	margin: 0;
	padding: var(--wt-toc-pad, 22px);
	background: transparent;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	color: var(--wt-toc-title);
	font: inherit;
	line-height: 1.3;
	letter-spacing: 0;
	text-transform: none;
	text-align: left;
	text-shadow: none;
	min-height: 0;
}

.wt-toc.is-open .wt-toc__bar {
	padding-bottom: calc(var(--wt-toc-pad, 22px) - 8px);
}

.wt-toc button.wt-toc__bar {
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.wt-toc button.wt-toc__bar:focus-visible {
	outline: 2px solid var(--wt-toc-active);
	outline-offset: -4px;
	border-radius: var(--wt-toc-r, 16px);
}

.wt-toc__icon {
	flex: 0 0 auto;
	display: inline-flex;
	color: var(--wt-toc-active);
}

.wt-toc__heading {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 2px 10px;
}

.wt-toc__title {
	font-size: 1.1em;
	font-weight: 700;
	letter-spacing: -0.01em;
	color: var(--wt-toc-title);
}

.wt-toc__count {
	font-size: 0.84em;
	font-weight: 500;
	color: var(--wt-toc-sub);
}

.wt-toc__toggle {
	flex: 0 0 auto;
	margin-left: auto;
	display: inline-flex;
	align-items: center;
	gap: 4px;
	color: var(--wt-toc-sub);
	font-size: 0.86em;
	font-weight: 600;
	line-height: 1;
	white-space: nowrap;
	transition: color 0.2s;
}

.wt-toc button.wt-toc__bar:hover .wt-toc__toggle {
	color: var(--wt-toc-active);
}

.wt-toc__chev {
	transition: transform 0.3s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.wt-toc.is-open .wt-toc__chev {
	transform: rotate(180deg);
}

/* ---- thân (hiệu ứng trượt) ---- */
.wt-toc__body {
	display: grid;
	grid-template-rows: 0fr;
	transition: grid-template-rows 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.wt-toc.is-open .wt-toc__body {
	grid-template-rows: 1fr;
}

.wt-toc__inner {
	min-height: 0;
	overflow: hidden;
	visibility: hidden;
	transition: visibility 0s linear 0.35s;
}

.wt-toc.is-open .wt-toc__inner {
	visibility: visible;
	transition-delay: 0s;
}

.wt-toc ol.wt-toc__list {
	list-style: none;
	margin: 0;
	padding: 0 var(--wt-toc-pad, 22px) calc(var(--wt-toc-pad, 22px) - 6px);
}

/* chỉ khi đặt "chiều cao tối đa" mới có thanh cuộn riêng; còn lại cuộn chuột đi thẳng xuống trang */
.wt-toc--scroll ol.wt-toc__list {
	max-height: var(--wt-toc-maxh, none);
	overflow-y: auto;
	scrollbar-width: thin;
	scrollbar-color: var(--wt-toc-line) transparent;
}

.wt-toc li.wt-toc__item {
	list-style: none;
	margin: 0;
	padding: 0;
}

.wt-toc .wt-toc__item--d1 {
	margin-left: 38px;
}

.wt-toc .wt-toc__item--d2 {
	margin-left: 76px;
}

.wt-toc .wt-toc__item--d3,
.wt-toc .wt-toc__item--d4,
.wt-toc .wt-toc__item--d5 {
	margin-left: 100px;
}

.wt-toc a.wt-toc__link {
	display: flex;
	align-items: baseline;
	gap: 12px;
	padding: 6px 0;
	color: var(--wt-toc-link);
	font-weight: 600;
	text-decoration: none;
	box-shadow: none;
	border: 0;
	background: none;
	transition: color 0.2s, transform 0.2s;
}

.wt-toc .wt-toc__item--d1 a.wt-toc__link,
.wt-toc .wt-toc__item--d2 a.wt-toc__link {
	font-weight: 400;
	font-size: 0.95em;
	padding: 4px 0;
}

.wt-toc a.wt-toc__link:hover,
.wt-toc a.wt-toc__link:focus-visible {
	color: var(--wt-toc-active);
	text-decoration: none;
	transform: translateX(3px);
}

.wt-toc a.wt-toc__link.is-active {
	color: var(--wt-toc-active);
	font-weight: 700;
}

.wt-toc .wt-toc__item--d1 a.wt-toc__link.is-active,
.wt-toc .wt-toc__item--d2 a.wt-toc__link.is-active {
	font-weight: 600;
}

.wt-toc .wt-toc__num {
	flex: 0 0 auto;
	min-width: 26px;
	color: var(--wt-toc-num);
	font-size: 0.82em;
	font-weight: 600;
	letter-spacing: 0.02em;
	font-variant-numeric: tabular-nums;
	transition: color 0.2s;
}

.wt-toc .wt-toc__item--d1 .wt-toc__num,
.wt-toc .wt-toc__item--d2 .wt-toc__num {
	min-width: 28px;
	font-weight: 500;
}

.wt-toc .wt-toc__link:hover .wt-toc__num,
.wt-toc .wt-toc__link.is-active .wt-toc__num {
	color: var(--wt-toc-active);
}

.wt-toc .wt-toc__text {
	min-width: 0;
	overflow-wrap: anywhere;
}

.wt-toc--num-bullet .wt-toc__num {
	min-width: 0;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--wt-toc-num);
	align-self: center;
	margin: 0 4px 0 2px;
}

.wt-toc--num-bullet .wt-toc__link:hover .wt-toc__num,
.wt-toc--num-bullet .wt-toc__link.is-active .wt-toc__num {
	background: var(--wt-toc-active);
}

.wt-toc--num-bullet .wt-toc__item--d1,
.wt-toc--num-bullet .wt-toc__item--d2 {
	margin-left: 22px;
}

.wt-toc--num-none .wt-toc__item--d1 {
	margin-left: 18px;
}

.wt-toc--num-none .wt-toc__item--d2 {
	margin-left: 36px;
}

/* ---- responsive ---- */
/* Điện thoại: thu gọn sẵn (JS giữ nguyên lựa chọn của người đọc nếu có) — CSS chặn nháy mở trước khi JS chạy */
@media (max-width: 767px) {
	.wt-toc--collapse-sm:not(.is-js) .wt-toc__body {
		grid-template-rows: 0fr;
	}

	.wt-toc--collapse-sm:not(.is-js) .wt-toc__inner {
		visibility: hidden;
	}

	.wt-toc--collapse-sm:not(.is-js) .wt-toc__chev {
		transform: none;
	}

	.wt-toc--collapse-sm:not(.is-js) .wt-toc__bar {
		padding-bottom: var(--wt-toc-pad, 22px);
	}
}

@media (max-width: 549px) {
	.wt-toc .wt-toc__item--d1 {
		margin-left: 26px;
	}

	.wt-toc .wt-toc__item--d2,
	.wt-toc .wt-toc__item--d3 {
		margin-left: 52px;
	}

	.wt-toc__toggle-label {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wt-toc__body,
	.wt-toc__chev,
	.wt-toc a.wt-toc__link {
		transition: none;
	}
}

@media print {
	.wt-toc__toggle {
		display: none;
	}

	.wt-toc__body {
		grid-template-rows: 1fr;
	}

	.wt-toc__inner {
		visibility: visible;
	}
}
