/**
 * Table of contents on posts (includes/toc.php). Card in the site's post
 * language (green accent like the CTA box, green-tint like the h2 bars,
 * card radius and shadow); collapsed by default. Tokens only.
 */

.evergreen-toc {
	margin-block: var(--wp--preset--spacing--40, 1.25rem);
	overflow: hidden;
	background: var(--wp--preset--color--white, #fff);
	border: 1px solid var(--wp--preset--color--blue-grey, #c8d5dc);
	border-left: 4px solid var(--wp--preset--color--green, #007244);
	border-radius: var(--wp--preset--border-radius--card, 10px);
	box-shadow: var(--wp--preset--shadow--card, 0 0 10px 0 rgb(0 0 0 / 10%));
	color: var(--wp--preset--color--body, #181818);
}

/* Summary bar: icon tile | title + section count | chevron. */
.evergreen-toc__summary {
	display: flex;
	align-items: center;
	gap: var(--wp--preset--spacing--30, 0.9375rem);
	padding: var(--wp--preset--spacing--30, 0.9375rem) var(--wp--preset--spacing--40, 1.25rem);
	cursor: pointer;
	list-style: none;
	user-select: none;
}

.evergreen-toc__summary::-webkit-details-marker {
	display: none;
}

.evergreen-toc__summary:focus-visible {
	outline: 2px solid var(--wp--preset--color--green, #007244);
	outline-offset: -4px;
	border-radius: var(--wp--preset--border-radius--card, 10px);
}

.evergreen-toc__badge {
	display: grid;
	flex: none;
	place-items: center;
	width: 40px;
	height: 40px;
	border-radius: 8px;
	background: var(--wp--preset--color--green-tint, #edf5f2);
	color: var(--wp--preset--color--green, #007244);
}

.evergreen-toc__heading {
	display: flex;
	flex: 1;
	flex-wrap: wrap;
	align-items: baseline;
	column-gap: var(--wp--preset--spacing--20, 0.625rem);
	min-width: 0;
}

.evergreen-toc__title {
	color: var(--wp--preset--color--black, #000);
	font-size: var(--wp--preset--font-size--medium, 1.125rem);
	font-weight: 800;
	line-height: var(--wp--custom--line-height--title, 1.4);
}

.evergreen-toc__count {
	color: var(--wp--preset--color--input-border, #69727d);
	font-size: var(--wp--preset--font-size--small, 1rem);
}

.evergreen-toc__chevron {
	display: block;
	flex: none;
	box-sizing: content-box;
	padding: 6px;
	border-radius: 50%;
	background: var(--wp--preset--color--blue-light, #f9fafd);
	color: var(--wp--preset--color--green, #007244);
	transition: transform 0.2s ease, background-color 0.2s ease;
}

.evergreen-toc__summary:hover .evergreen-toc__chevron {
	background: var(--wp--preset--color--green-tint, #edf5f2);
}

.evergreen-toc[open] .evergreen-toc__chevron {
	transform: rotate(180deg);
}

/* List. */
.evergreen-toc__nav {
	padding: var(--wp--preset--spacing--30, 0.9375rem) var(--wp--preset--spacing--40, 1.25rem) var(--wp--preset--spacing--40, 1.25rem);
	border-top: 1px solid var(--wp--preset--color--blue-grey, #c8d5dc);
}

.evergreen-toc[open] .evergreen-toc__nav {
	animation: evergreen-toc-in 0.2s ease-out;
}

@keyframes evergreen-toc-in {

	from {
		opacity: 0;
		transform: translateY(-4px);
	}
}

.evergreen-toc__list {
	counter-reset: evergreen-toc;
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: var(--wp--preset--font-size--small, 1rem);
	line-height: 1.5;
}

.evergreen-toc__list > li {
	margin: 0;
}

.evergreen-toc__list a {
	display: flex;
	gap: var(--wp--preset--spacing--20, 0.625rem);
	padding: 6px var(--wp--preset--spacing--20, 0.625rem);
	border-radius: 6px;
	color: inherit;
	font-weight: 600;
	text-decoration: none;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.evergreen-toc__list a::before {
	content: counters(evergreen-toc, ".", decimal);
	counter-increment: evergreen-toc;
	flex: none;
	min-width: 1.5em;
	color: var(--wp--preset--color--green, #007244);
	font-variant-numeric: tabular-nums;
	font-weight: 800;
}

/* Sub-sections: indented under a guide line, lighter weight. */
.evergreen-toc__list .evergreen-toc__list {
	margin: 2px 0 6px calc(var(--wp--preset--spacing--20, 0.625rem) + 0.75em);
	padding-left: var(--wp--preset--spacing--20, 0.625rem);
	border-left: 2px solid var(--wp--preset--color--blue-grey, #c8d5dc);
}

.evergreen-toc__list .evergreen-toc__list a {
	font-weight: 400;
}

.evergreen-toc__list .evergreen-toc__list a::before {
	min-width: 2em;
	color: var(--wp--preset--color--input-border, #69727d);
	font-weight: 600;
}

.evergreen-toc__list a:hover,
.evergreen-toc__list a:focus-visible {
	background: var(--wp--preset--color--green-tint, #edf5f2);
	color: var(--wp--preset--color--green, #007244);
}

.evergreen-toc__list a:focus-visible {
	outline: 2px solid var(--wp--preset--color--green, #007244);
	outline-offset: -2px;
}

@media (prefers-reduced-motion: reduce) {

	.evergreen-toc__chevron,
	.evergreen-toc__list a {
		transition: none;
	}

	.evergreen-toc[open] .evergreen-toc__nav {
		animation: none;
	}
}

@media (max-width: 767px) {

	.evergreen-toc__summary {
		padding-inline: var(--wp--preset--spacing--30, 0.9375rem);
	}

	.evergreen-toc__nav {
		padding-inline: var(--wp--preset--spacing--20, 0.625rem);
	}
}

/* Smooth scroll to headings, a little below the sticky header
   (+ admin bar). */
html:has(.evergreen-toc) {
	scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {

	html:has(.evergreen-toc) {
		scroll-behavior: auto;
	}
}

.single-post :is(h1, h2, h3, h4, h5, h6)[id],
.evergreen-toc-anchor {
	--evergreen-toc-offset: calc(60px + 2vw);
	scroll-margin-top: calc(var(--evergreen-toc-offset) + var(--wp-admin--admin-bar--height, 0px) + var(--wp--preset--spacing--30, 0.9375rem));
}

@media (max-width: 1024px) {

	.single-post :is(h1, h2, h3, h4, h5, h6)[id],
	.evergreen-toc-anchor {
		--evergreen-toc-offset: 60px;
	}
}

@media (max-width: 767px) {

	.single-post :is(h1, h2, h3, h4, h5, h6)[id],
	.evergreen-toc-anchor {
		--evergreen-toc-offset: 50px;
	}
}
