/* ==========================================================================
   Post table of contents
   Desktop: sticky left rail. Narrow screens: bottom-left button + overlay.
   ========================================================================== */

.tfht-toc,
.tfht-toc-toggle {
	font-family: var(--wp--preset--font-family--inter);
}

.tfht-toc a {
	text-decoration: none;
}

/* —— Mobile overlay + FAB (default) —— */

.tfht-toc__backdrop {
	position: fixed;
	top: var(--tfht-toc-overlay-top, 0px);
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 10000;
	background: rgba(44, 39, 47, 0.45);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.tfht-toc.is-open .tfht-toc__backdrop {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

.tfht-toc__panel {
	position: fixed;
	z-index: 10001;
	top: var(--tfht-toc-overlay-top, 0px);
	left: 0;
	bottom: 0;
	width: min(22rem, 88vw);
	background: var(--wp--preset--color--white);
	box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
	transform: translateX(-105%);
	visibility: hidden;
	pointer-events: none;
	transition: transform 0.3s ease-in-out, visibility 0.3s ease-in-out;
	display: flex;
	flex-direction: column;
	padding: 20px 8px 24px 20px;
}

.tfht-toc.is-open .tfht-toc__panel {
	transform: translateX(0);
	visibility: visible;
	pointer-events: auto;
}

.tfht-toc__header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	flex-shrink: 0;
	padding-right: 8px;
	margin-bottom: 8px;
}

.tfht-toc__title {
	font-family: var(--wp--preset--font-family--poppins);
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--wp--preset--color--charcoal);
	line-height: 1.3;
	margin: 0 0 12px;
	padding: 0 0 6px;
	border-bottom: 3px solid var(--wp--preset--color--orange);
	display: inline-block;
}

.tfht-toc__close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin: -8px 0 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--wp--preset--color--charcoal);
	cursor: pointer;
	flex-shrink: 0;
	border-radius: 4px;
}

.tfht-toc__close:hover,
.tfht-toc__close:focus {
	color: var(--wp--preset--color--orange);
}

.tfht-toc__list {
	list-style: none;
	margin: 0;
	padding: 0 12px 8px 0;
	flex: 1 1 auto;
	min-height: 0;
	overflow: auto;
	overscroll-behavior: contain;
	border-left: 2px solid rgba(44, 39, 47, 0.12);
	scrollbar-width: thin;
	scrollbar-color: rgba(44, 39, 47, 0.25) transparent;
}

.tfht-toc__item {
	margin: 0;
}

.tfht-toc__link {
	display: block;
	color: var(--wp--preset--color--charcoal);
	line-height: 1.35;
	padding: 0.4rem 0.7rem;
	margin-left: -2px;
	border-left: 2px solid transparent;
	border-radius: 0 6px 6px 0;
	transition: color 0.2s ease-in-out, border-color 0.2s ease-in-out, background-color 0.2s ease-in-out;
	overflow-wrap: anywhere;
}

.tfht-toc__item--h2 > .tfht-toc__link {
	font-weight: 700;
	font-size: 0.875rem;
}

.tfht-toc__item--h3 > .tfht-toc__link {
	font-weight: 400;
	font-size: 0.8125rem;
	padding-left: 1.35rem;
}

.tfht-toc__item--h4 > .tfht-toc__link {
	font-weight: 400;
	font-size: 0.8125rem;
	padding-left: 2.15rem;
}

.tfht-toc__link:hover,
.tfht-toc__link:focus {
	color: var(--wp--preset--color--orange);
	text-decoration: none;
}

.tfht-toc__link.is-active {
	color: var(--wp--preset--color--orange);
	border-left-color: var(--wp--preset--color--orange);
	background: rgba(255, 89, 41, 0.06);
}

.tfht-toc-toggle {
	position: fixed;
	z-index: 10000;
	left: max(16px, env(safe-area-inset-left));
	bottom: max(16px, env(safe-area-inset-bottom));
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding: 11px 18px 9px;
	border: 1px solid var(--wp--preset--color--orange);
	border-radius: 40px;
	background: var(--wp--preset--color--orange);
	color: var(--wp--preset--color--charcoal);
	font-family: var(--wp--preset--font-family--poppins);
	font-size: 0.9375rem;
	font-weight: 700;
	line-height: 1.2;
	cursor: pointer;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
	transition: background-color 0.3s ease-in-out, color 0.3s ease-in-out, border-color 0.3s ease-in-out;
}

.tfht-toc-toggle:hover,
.tfht-toc-toggle:focus {
	background: var(--wp--preset--color--charcoal);
	border-color: var(--wp--preset--color--charcoal);
	color: var(--wp--preset--color--white);
}

.tfht-toc-toggle svg {
	display: block;
	flex-shrink: 0;
}

body.tfht-toc-open {
	overflow: hidden;
}

body.tfht-toc-open .tfht-toc-toggle {
	visibility: hidden;
}

/* —— Desktop rail: sits in the left gutter beside the centered column —— */

body.tfht-toc-rail {
	--tfht-toc-width: 248px;
	--tfht-toc-clearance: calc(var(--tfht-toc-left, 16px) + var(--tfht-toc-width) + 16px);
}

body.tfht-toc-rail .tfht-toc-toggle,
body.tfht-toc-rail .tfht-toc__backdrop,
body.tfht-toc-rail .tfht-toc__close {
	display: none !important;
}

/* Alignwide (post nav, More posts, etc.) is 1620px and would slide under the
   TOC that sits beside the 1170px column. Keep it to the right of the rail. */
body.tfht-toc-rail main .alignwide {
	margin-left: var(--tfht-toc-clearance) !important;
	margin-right: auto !important;
	max-width: min(
		var(--wp--style--global--wide-size, 1620px),
		calc(100vw - var(--tfht-toc-clearance) - var(--wp--style--root--padding-right, 3.125rem))
	) !important;
}

body.tfht-toc-rail main .alignwide .alignwide {
	margin-left: 0 !important;
	margin-right: 0 !important;
	max-width: none !important;
}

body.tfht-toc-rail .tfht-toc__panel {
	position: fixed;
	z-index: 5;
	top: var(--tfht-header-offset, 137px);
	left: var(--tfht-toc-left, 16px);
	bottom: auto;
	width: 248px;
	max-height: calc(100vh - var(--tfht-header-offset, 137px) - 24px);
	padding: 0 8px 16px 4px;
	box-shadow: none;
	transform: none;
	visibility: visible;
	pointer-events: auto;
	background: transparent;
}

body.tfht-toc-rail .tfht-toc__header {
	padding-right: 8px;
	margin-bottom: 4px;
}

body.tfht-toc-rail .tfht-toc__list {
	max-height: calc(100vh - var(--tfht-header-offset, 137px) - 72px);
}

@media print {
	.tfht-toc,
	.tfht-toc-toggle {
		display: none !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tfht-toc__backdrop,
	.tfht-toc__panel,
	.tfht-toc__link,
	.tfht-toc-toggle {
		transition: none;
	}
}
