html {
	scroll-behavior: smooth;
}

.ecs-post-toc-layout {
	display: grid;
	grid-template-columns: minmax(260px, 1.15fr) minmax(0, 2.85fr);
	gap: clamp(32px, 4vw, 64px);
	align-items: start;
}

.ecs-post-toc-layout__content,
.ecs-post-toc-layout__aside {
	min-width: 0;
}

.ecs-post-toc-layout__content h2[id],
.ecs-post-toc-layout__content h3[id] {
	scroll-margin-top: 140px;
}

.ecs-post-toc {
	position: sticky;
	top: 140px;
	padding: 24px;
	border-right: 2px solid var(--ecs_cyan);
	background: radial-gradient(
		ellipse at right center,
		var(--ecs_cyan_3, rgba(5, 196, 225, 0.14)) 0%,
		rgba(5, 196, 225, 0.08) 34%,
		rgba(5, 196, 225, 0) 76%
	);
	font-family: Montserrat, sans-serif;
}

.ecs-post-toc__title {
	margin: 0 0 18px;
	font-size: 20px;
	font-weight: 600;
	line-height: 1.3;
	color: var(--ecs_dblue);
}

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

.ecs-post-toc__item {
	position: relative;
	margin: 0 0 12px;
	padding-left: 32px;
	line-height: 1.45;
}

.ecs-post-toc__item:last-child {
	margin-bottom: 0;
}


.ecs-post-toc__item--h3 {
	margin-top: -4px;
	padding-left: 48px;
	font-size: 0.9em;
}

.ecs-post-toc__item--h3::before {
	content: "–";
	position: absolute;
	left: 24px;
	color: var(--ecs_dcyan);
}

.ecs-post-toc__item a,
.ecs-post-toc__item a:visited {
	color: var(--ecs_dgray);
	text-decoration: none;
	border-bottom: 1px solid transparent;
}

.ecs-post-toc__item a:hover,
.ecs-post-toc__item a:focus-visible {
	color: var(--ecs_dcyan);
	border-bottom-color: currentColor;
}

@media only screen and (max-width: 900px) {
	.ecs-post-toc-layout {
		grid-template-columns: 1fr;
	}

	.ecs-post-toc-layout__aside {
		grid-row: 1;
	}

	.ecs-post-toc {
		position: static;
	}
}

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}
}

/* TOC link and hierarchy refinements. Kept in the component stylesheet so
 * these styles remain tracked with the template rather than patched inline. */
.ecs-post-toc .ecs-post-toc__list,
.ecs-post-toc .ecs-post-toc__item {
	list-style: none !important;
}

.ecs-post-toc .ecs-post-toc__item::marker {
	content: "";
}

.ecs-post-toc .ecs-post-toc__item a,
.ecs-post-toc .ecs-post-toc__item a:visited,
.ecs-post-toc .ecs-post-toc__item a:hover,
.ecs-post-toc .ecs-post-toc__item a:focus,
.ecs-post-toc .ecs-post-toc__item a:focus-visible {
	text-decoration: none !important;
	border-bottom: 0 !important;
	box-shadow: none !important;
	background-image: none !important;
}

.ecs-post-toc .ecs-post-toc__item a::before,
.ecs-post-toc .ecs-post-toc__item a::after {
	content: none !important;
	display: none !important;
}

.ecs-post-toc .ecs-post-toc__item--h2 {
	padding-left: 0;
	font-size: 18px;
	font-weight: 500;
	line-height: 1.4;
}

.ecs-post-toc .ecs-post-toc__item--h3 {
	margin-top: -2px;
	padding-left: 52px;
	font-size: 15px;
	font-weight: 400;
	line-height: 1.45;
}

.ecs-post-toc .ecs-post-toc__item--h3::before {
	content: "–" !important;
	left: 30px;
	font-size: 14px;
	font-weight: 400;
}

/* Remove theme-injected list markers from every TOC level. */
.ecs-post-toc .ecs-post-toc__item::before,
.ecs-post-toc .ecs-post-toc__item::after {
	content: none !important;
	display: none !important;
}

.ecs-post-toc .ecs-post-toc__item--h3 {
	padding-left: 32px;
}

/* Sticky scroll-following behavior and active-section state. */
.ecs-post-toc-layout__aside {
	align-self: stretch;
}

.ecs-post-toc {
	max-height: calc(100vh - 170px);
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
}

.ecs-post-toc__item a {
	display: block;
	padding: 3px 0;
	transition: color 180ms ease, font-weight 180ms ease, transform 180ms ease;
}

.ecs-post-toc__item a.is-active,
.ecs-post-toc__item.is-active > a {
	color: var(--ecs_dcyan);
	font-weight: 600;
	transform: translateX(4px);
}

.ecs-post-toc__item--h3 a.is-active,
.ecs-post-toc__item--h3.is-active > a {
	font-weight: 500;
}

@media only screen and (max-width: 900px) {
	.ecs-post-toc {
		max-height: none;
		overflow-y: visible;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ecs-post-toc__item a {
		transition: none;
	}
}

/* Mobile TOC card: compact, soft, and aligned with the theme palette. */
@media only screen and (max-width: 900px) {
	.ecs-post-toc {
		border-right: 0;
		border-radius: 0;
		padding: 18px 18px 16px;
		background:
			radial-gradient(circle at 100% 0%, rgba(5, 196, 225, 0.12), rgba(5, 196, 225, 0) 54%),
			linear-gradient(145deg, rgba(236, 249, 252, 0.96), rgba(255, 255, 255, 0.98));
		box-shadow: 0 10px 28px rgba(8, 51, 70, 0.08);
	}

	.ecs-post-toc__title {
		margin-bottom: 12px;
		font-size: 19px;
	}

	.ecs-post-toc__item {
		margin-bottom: 7px;
	}

	.ecs-post-toc .ecs-post-toc__item--h2 {
		font-size: 17px;
		line-height: 1.32;
	}

	.ecs-post-toc .ecs-post-toc__item--h3 {
		margin-top: -1px;
		padding-left: 24px;
		font-size: 14px;
		line-height: 1.35;
	}

	.ecs-post-toc__item a {
		padding: 2px 0;
	}
}

/* Mobile interaction and spacing refinements. */
@media only screen and (max-width: 1003px) {
	/* Override the theme-wide .page-section ul li mobile spacing rule. */
	.page-section .ecs-post-toc .ecs-post-toc__item,
	.hero .ecs-post-toc .ecs-post-toc__item {
		margin-bottom: 4px;
	}

	.page-section .ecs-post-toc .ecs-post-toc__item--h3,
	.hero .ecs-post-toc .ecs-post-toc__item--h3 {
		margin-top: 0;
		margin-bottom: 3px;
	}

	.ecs-post-toc {
		border-radius: 0;
		overscroll-behavior: auto;
		touch-action: pan-y;
	}
}
