/**
 * Mục lục bài viết — sidebar single post
 */

/* Sidebar sticky + scroll riêng (một lớp duy nhất) */
.blog-single .post-sidebar {
	position: sticky;
	top: var(--cuuho-toc-offset, 100px);
	align-self: flex-start;
}

.blog-single .post-sidebar #secondary.widget-area {
	max-height: calc(100vh - var(--cuuho-toc-offset, 100px) - 20px);
	overflow-x: hidden;
	overflow-y: auto;
	scrollbar-width: thin;
	scrollbar-color: var(--cuuho-amber) rgba(0, 0, 0, 0.06);
}

.blog-single .post-sidebar #secondary.widget-area::-webkit-scrollbar {
	width: 5px;
}

.blog-single .post-sidebar #secondary.widget-area::-webkit-scrollbar-thumb {
	background: var(--cuuho-amber);
	border-radius: 999px;
}

/* Widget mục lục */
.widget.cuuho-toc-widget,
.widget_cuuho_toc.widget {
	padding: 0 !important;
	overflow: hidden;
	margin-bottom: 24px;
	box-shadow: var(--cuuho-shadow);
}

.widget.cuuho-toc-widget .widget-title,
.widget_cuuho_toc .widget-title,
.widget.cuuho-toc-widget .is-divider,
.widget_cuuho_toc .is-divider {
	display: none !important;
}

.cuuho-toc {
	display: flex;
	flex-direction: column;
	min-height: 0;
	padding: 16px 14px 14px;
	background: var(--cuuho-white);
	border: 1px solid var(--cuuho-border);
	border-radius: var(--cuuho-radius);
}

.cuuho-toc[hidden] {
	display: none !important;
}

.cuuho-toc__head {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 12px;
	padding-bottom: 10px;
	border-bottom: 1px solid var(--cuuho-border);
}

.cuuho-toc__head-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: var(--cuuho-navy);
	color: #fff;
	flex-shrink: 0;
}

.cuuho-toc__head-title {
	font-size: 0.8rem;
	font-weight: 800;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--cuuho-navy);
}

.cuuho-toc__nav {
	flex: 1 1 auto;
	min-height: 0;
	max-height: min(260px, 36vh);
	overflow-x: hidden;
	overflow-y: auto;
	padding: 2px 2px 4px;
	scrollbar-width: thin;
	scrollbar-color: var(--cuuho-amber) rgba(0, 0, 0, 0.05);
}

.cuuho-toc__nav::-webkit-scrollbar {
	width: 4px;
}

.cuuho-toc__nav::-webkit-scrollbar-thumb {
	background: rgba(245, 166, 35, 0.55);
	border-radius: 999px;
}

.cuuho-toc__list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.cuuho-toc__item {
	margin: 0;
}

.cuuho-toc__item--h2 {
	margin-bottom: 2px;
}

.cuuho-toc__item--h3 {
	margin-left: 14px;
	padding-left: 10px;
	border-left: 2px solid var(--cuuho-border);
}

.cuuho-toc__item--h4 {
	margin-left: 28px;
	padding-left: 10px;
	border-left: 2px solid rgba(226, 234, 240, 0.9);
}

.cuuho-toc__item--h3 + .cuuho-toc__item--h2,
.cuuho-toc__item--h4 + .cuuho-toc__item--h2 {
	margin-top: 8px;
}

.cuuho-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: var(--cuuho-text) !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;
}

.cuuho-toc__item--h2 > .cuuho-toc__link {
	font-size: 0.9rem;
	font-weight: 700;
	color: var(--cuuho-navy) !important;
}

.cuuho-toc__item--h3 > .cuuho-toc__link {
	font-size: 0.84rem;
	font-weight: 500;
	color: var(--cuuho-muted) !important;
}

.cuuho-toc__item--h4 > .cuuho-toc__link {
	font-size: 0.8rem;
	font-weight: 400;
	color: var(--cuuho-muted) !important;
}

.cuuho-toc__link:hover {
	background: var(--cuuho-amber-soft);
	color: var(--cuuho-navy) !important;
}

.cuuho-toc__link.is-active {
	background: var(--cuuho-amber-soft);
	border-left-color: var(--cuuho-amber);
	color: var(--cuuho-navy) !important;
	font-weight: 700;
}

.cuuho-toc__text {
	display: block;
	word-break: break-word;
}

.cuuho-toc__progress {
	flex-shrink: 0;
	margin-top: 12px;
	padding-top: 12px;
	border-top: 1px solid var(--cuuho-border);
}

.cuuho-toc__progress-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: 7px;
}

.cuuho-toc__progress-label {
	font-size: 0.7rem;
	font-weight: 800;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--cuuho-muted);
}

.cuuho-toc__progress-pct {
	font-size: 0.8rem;
	font-weight: 800;
	color: var(--cuuho-navy);
}

.cuuho-toc__progress-track {
	height: 5px;
	border-radius: 999px;
	background: var(--cuuho-border);
	overflow: hidden;
}

.cuuho-toc__progress-bar {
	height: 100%;
	border-radius: inherit;
	background: linear-gradient(90deg, var(--cuuho-amber) 0%, var(--cuuho-amber-hover) 100%);
	transition: width 0.15s ease-out;
}

.entry-content.single-page :is(h2, h3, h4)[id] {
	scroll-margin-top: calc(var(--cuuho-toc-offset, 110px) + 8px);
}

@media (max-width: 849px) {
	/* Ẩn sidebar trên mobile — dùng FAB mục lục */
	.blog-single .post-sidebar {
		display: none !important;
	}

	.blog-single .large-9.col {
		max-width: 100% !important;
		flex-basis: 100% !important;
	}

	.cuuho-toc__item--h3 {
		margin-left: 10px;
		padding-left: 8px;
	}

	.cuuho-toc__item--h4 {
		margin-left: 20px;
		padding-left: 8px;
	}
}

/* ── Mobile FAB + panel ── */
.cuuho-toc-mobile__fab {
	position: fixed;
	left: 16px;
	bottom: calc(24px + env(safe-area-inset-bottom, 0px));
	z-index: 9990;
	width: 52px;
	height: 52px;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: var(--cuuho-navy);
	color: #fff;
	cursor: pointer;
	align-items: center;
	justify-content: center;
	box-shadow: 0 6px 24px rgba(11, 45, 74, 0.35), 0 0 0 4px rgba(245, 166, 35, 0.18);
	display: none;
	transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.cuuho-toc-mobile__fab.is-visible {
	display: inline-flex;
}

.cuuho-toc-mobile__fab:hover,
.cuuho-toc-mobile__fab:focus-visible {
	background: var(--cuuho-navy-light);
	transform: scale(1.05);
	outline: none;
	box-shadow: 0 8px 28px rgba(11, 45, 74, 0.4), 0 0 0 4px rgba(245, 166, 35, 0.28);
}

.cuuho-toc-mobile__fab[aria-expanded="true"] {
	background: var(--cuuho-amber);
	color: var(--cuuho-navy);
}

.cuuho-toc-mobile {
	position: fixed;
	inset: 0;
	z-index: 9989;
	pointer-events: none;
}

.cuuho-toc-mobile.is-open {
	pointer-events: auto;
}

.cuuho-toc-mobile__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(11, 45, 74, 0.35);
	opacity: 0;
	transition: opacity 0.25s ease;
}

.cuuho-toc-mobile.is-open .cuuho-toc-mobile__backdrop {
	opacity: 1;
}

.cuuho-toc-mobile__panel {
	position: fixed;
	left: 12px;
	bottom: calc(88px + env(safe-area-inset-bottom, 0px));
	width: min(calc(100vw - 24px), 340px);
	max-height: min(72vh, 520px);
	z-index: 9991;
	opacity: 0;
	visibility: hidden;
	transform: translateY(16px) scale(0.96);
	transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
}

.cuuho-toc-mobile.is-open .cuuho-toc-mobile__panel {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
}

.cuuho-toc--mobile {
	max-height: min(72vh, 520px);
	box-shadow: 0 16px 48px rgba(11, 45, 74, 0.18);
}

.cuuho-toc--mobile .cuuho-toc__nav {
	max-height: min(42vh, 340px);
}

.cuuho-toc--mobile .cuuho-toc__link {
	padding-left: 36px;
}

.cuuho-toc--mobile .cuuho-toc__link::before {
	content: "";
	position: absolute;
	left: 10px;
	top: 50%;
	transform: translateY(-50%);
	width: 16px;
	height: 16px;
	border-radius: 4px;
	background: var(--cuuho-navy);
	opacity: 0.15;
}

.cuuho-toc--mobile .cuuho-toc__link.is-active::before {
	opacity: 1;
	background: var(--cuuho-amber);
	box-shadow: inset 0 0 0 2px var(--cuuho-navy);
}

body.cuuho-toc-mobile-open {
	overflow: hidden;
}

@media (min-width: 850px) {
	.cuuho-toc-mobile,
	.cuuho-toc-mobile__fab {
		display: none !important;
	}
}
