/**
 * Mục lục bài viết — widget sidebar.
 */

/* Sidebar cố định khi đọc bài */
.blog-wrapper.blog-single .ntm-post-row--single .post-sidebar,
.blog-wrapper.blog-single .ntm-post-row--single .post-sidebar .ntm-sidebar-scope,
.blog-wrapper.blog-single .ntm-post-row--single .post-sidebar #secondary {
	position: sticky;
	top: var(--ntm-toc-offset, 100px);
	align-self: flex-start;
	max-height: calc(100vh - var(--ntm-toc-offset, 100px) - 20px);
	overflow-x: hidden;
	overflow-y: auto;
	scrollbar-width: thin;
	scrollbar-color: var(--ntm-home-primary, var(--primary-color)) rgba(0, 0, 0, 0.06);
}

.blog-wrapper.blog-single .ntm-post-row--single .post-sidebar #secondary::-webkit-scrollbar,
.blog-wrapper.blog-single .ntm-post-row--single .post-sidebar .ntm-sidebar-scope::-webkit-scrollbar {
	width: 5px;
}

.blog-wrapper.blog-single .ntm-post-row--single .post-sidebar #secondary::-webkit-scrollbar-thumb,
.blog-wrapper.blog-single .ntm-post-row--single .post-sidebar .ntm-sidebar-scope::-webkit-scrollbar-thumb {
	background: var(--ntm-home-primary, var(--primary-color));
	border-radius: 999px;
}

/* Widget mục lục */
.widget_ntm_toc.widget,
.widget_ntm-toc-widget.widget {
	padding: 0;
	overflow: hidden;
}

.widget_ntm_toc .widget-title,
.widget_ntm-toc-widget .widget-title,
.widget_ntm_toc .is-divider,
.widget_ntm-toc-widget .is-divider {
	display: none !important;
}

.ntm-toc {
	display: flex;
	flex-direction: column;
	min-height: 0;
	padding: 16px 14px 14px;
}

.ntm-toc[hidden] {
	display: none !important;
}

.ntm-toc__head {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 12px;
	padding-bottom: 10px;
	border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}

.ntm-toc__head-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: var(--ntm-home-primary, var(--primary-color));
	color: #fff;
	flex-shrink: 0;
}

.ntm-toc__head-title {
	font-size: 0.8rem;
	font-weight: 700;
	letter-spacing: 0.07em;
	text-transform: uppercase;
	color: var(--ntm-home-primary, var(--primary-color));
}

.ntm-toc__nav {
	flex: 1 1 auto;
	min-height: 80px;
	max-height: min(320px, 42vh);
	overflow-x: hidden;
	overflow-y: auto;
	padding: 2px 2px 4px;
	scrollbar-width: thin;
	scrollbar-color: var(--ntm-home-primary, var(--primary-color)) rgba(0, 0, 0, 0.05);
}

.ntm-toc__nav::-webkit-scrollbar {
	width: 4px;
}

.ntm-toc__nav::-webkit-scrollbar-track {
	background: transparent;
}

.ntm-toc__nav::-webkit-scrollbar-thumb {
	background: color-mix(in srgb, var(--ntm-home-primary, var(--primary-color)) 55%, #ccc);
	border-radius: 999px;
}

.ntm-toc__list {
	list-style: none;
	margin: 0;
	padding: 0;
}

/* —— Phân cấp H2 / H3 / H4 —— */
.ntm-toc__item {
	margin: 0;
}

.ntm-toc__item--h2 {
	margin-bottom: 2px;
}

.ntm-toc__item--h3 {
	margin-left: 14px;
	padding-left: 10px;
	border-left: 2px solid rgba(0, 0, 0, 0.07);
}

.ntm-toc__item--h4 {
	margin-left: 28px;
	padding-left: 10px;
	border-left: 2px solid rgba(0, 0, 0, 0.05);
}

.ntm-toc__item--h3 + .ntm-toc__item--h2,
.ntm-toc__item--h4 + .ntm-toc__item--h2 {
	margin-top: 8px;
}

.ntm-toc__link {
	display: block;
	position: relative;
	padding: 9px 10px 9px 12px;
	border-left: 3px solid transparent;
	border-radius: 0 8px 8px 0;
	text-decoration: none !important;
	color: #3d3d3d !important;
	font-size: 0.875rem;
	font-weight: 500;
	line-height: 1.5;
	transition:
		background 0.18s ease,
		color 0.18s ease,
		border-color 0.18s ease;
}

.ntm-toc__item--h2 > .ntm-toc__link {
	font-size: 0.9rem;
	font-weight: 600;
	color: #222 !important;
}

.ntm-toc__item--h3 > .ntm-toc__link {
	font-size: 0.84rem;
	font-weight: 500;
	color: #505050 !important;
}

.ntm-toc__item--h4 > .ntm-toc__link {
	font-size: 0.8rem;
	font-weight: 400;
	color: #666 !important;
}

.ntm-toc__link:hover {
	background: color-mix(in srgb, var(--ntm-home-primary, var(--primary-color)) 6%, #fff);
	color: var(--ntm-home-primary, var(--primary-color)) !important;
}

.ntm-toc__link.is-active {
	background: color-mix(in srgb, var(--ntm-home-primary, var(--primary-color)) 11%, #fff);
	border-left-color: var(--ntm-home-primary, var(--primary-color));
	color: var(--ntm-home-primary, var(--primary-color)) !important;
	font-weight: 600;
}

.ntm-toc__item--h2 > .ntm-toc__link.is-active {
	font-weight: 700;
}

.ntm-toc__text {
	display: block;
	word-break: break-word;
}

.ntm-toc__progress {
	flex-shrink: 0;
	margin-top: 12px;
	padding-top: 12px;
	border-top: 1px solid rgba(0, 0, 0, 0.07);
}

.ntm-toc__progress-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: 7px;
}

.ntm-toc__progress-label {
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: #999;
}

.ntm-toc__progress-pct {
	font-size: 0.8rem;
	font-weight: 700;
	color: var(--ntm-home-primary, var(--primary-color));
}

.ntm-toc__progress-track {
	height: 5px;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.07);
	overflow: hidden;
}

.ntm-toc__progress-bar {
	height: 100%;
	border-radius: inherit;
	background: var(--ntm-home-primary, var(--primary-color));
	transition: width 0.15s ease-out;
}

.ntm-single-content :is(h2, h3, h4, p.ntm-toc-heading)[id] {
	scroll-margin-top: calc(var(--ntm-toc-offset, 110px) + 8px);
}

.ntm-single-content p.ntm-toc-heading {
	margin: 1.4em 0 0.6em;
	font-size: 1.05rem;
	line-height: 1.4;
	color: #1a1a1a;
}

@media (max-width: 849px) {
	.blog-wrapper.blog-single .ntm-post-row--single .post-sidebar,
	.blog-wrapper.blog-single .ntm-post-row--single .post-sidebar .ntm-sidebar-scope,
	.blog-wrapper.blog-single .ntm-post-row--single .post-sidebar #secondary {
		position: relative;
		top: auto;
		max-height: none;
		overflow: visible;
	}

	.ntm-toc__nav {
		max-height: 220px;
	}

	.ntm-toc__item--h3 {
		margin-left: 10px;
		padding-left: 8px;
	}

	.ntm-toc__item--h4 {
		margin-left: 20px;
		padding-left: 8px;
	}
}
