/*
 * Table of contents.
 *
 * Tokens come from the GenerateBlocks global stylesheet
 * (wp-content/uploads/generateblocks/style-global.css). Every custom property
 * referenced here is defined there, with a literal fallback so the component
 * still looks right if it is ever rendered outside that stylesheet's scope.
 *
 * NOTHING HERE IS EVER FIXED TO THE BOTTOM OF THE VIEWPORT. Mediavine's
 * adhesion unit owns that edge and it is the site's main revenue.
 */

:root {
	--ghs-toc-top: 0px;
	--ghs-toc-offset: 5.5rem;
}

/* Anchor targets must clear the sticky nav and the bar, otherwise every one of
   the in-article anchor links lands with its heading hidden underneath them. */
.entry-content :is(h2, h3, h4, h5, h6)[id] {
	scroll-margin-top: var(--ghs-toc-offset);
}

/* ---------------------------------------------------------------------------
 * The conventional list at the top of the article
 * ------------------------------------------------------------------------ */

.ghs-toc-inline {
	margin-bottom: var(--margin-body, 1.4em);
	padding: var(--space-m, 1.5rem);
	border: 1px solid var(--color-primary-light, #99c5c7);
	border-radius: var(--radius-card, 1rem);
	background-color: var(--color-primary-extra-light, #e6f0f1);
}

/* The title is the <summary> of a <details> that loads closed. */
.ghs-toc-inline__title {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin: 0;
	cursor: pointer;
	color: var(--color-primary-extra-dark, #264653);
	font-family: var(--font-ui, inherit);
	font-size: var(--text-body-s, 0.9375rem);
	font-weight: var(--font-weight-bold, 700);
	letter-spacing: 0.08em;
	line-height: 1.2;
	text-transform: uppercase;
}

.ghs-toc-inline__title::-webkit-details-marker {
	display: none;
}

/* Chevron: points right when closed, down when open, like the branch toggles. */
.ghs-toc-inline__title::after {
	width: 0.5rem;
	height: 0.5rem;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	content: "";
	transform: rotate(-45deg);
	transition: transform 0.18s ease;
}

.ghs-toc-inline__details[open] > .ghs-toc-inline__title {
	margin-bottom: var(--space-s, 1rem);
}

.ghs-toc-inline__details[open] > .ghs-toc-inline__title::after {
	transform: rotate(45deg);
}

/* ---------------------------------------------------------------------------
 * Shared list
 * ------------------------------------------------------------------------ */

.ghs-toc-inline__list,
.ghs-toc-bar__list,
.ghs-toc-side__list,
.ghs-toc-sublist {
	margin: 0;
	padding: 0;
	list-style: none;
}

.ghs-toc-sublist {
	margin-top: 0.25rem;
	padding-left: var(--space-m, 1.5rem);
	border-left: 2px solid var(--color-primary-light, #99c5c7);
}

.ghs-toc-item {
	margin: 0;
}

.ghs-toc-item + .ghs-toc-item,
.ghs-toc-sublist .ghs-toc-item + .ghs-toc-item {
	margin-top: 0.25rem;
}

/* The anchor and the disclosure button sit side by side in a row, so the
   button is a sibling of the link rather than wrapping or being wrapped by it.
   Two controls, two hit areas, no nested interactive elements. */
.ghs-toc-row {
	display: flex;
	align-items: flex-start;
	gap: 0.125rem;
}

.ghs-toc-item--1 > .ghs-toc-row > .ghs-toc-link {
	font-weight: var(--font-weight-bold, 700);
}

.ghs-toc-link {
	display: block;
	/* `min-width: 0` is what lets a long heading wrap instead of forcing the
	   row wider than the panel, which is what causes horizontal overflow. */
	min-width: 0;
	flex: 1 1 auto;
	padding: 0.3125rem 0.5rem;
	border-radius: 0.375rem;
	color: var(--color-primary-extra-dark, #264653);
	font-size: var(--text-body-s, 0.9375rem);
	line-height: 1.35;
	text-decoration: none;
	text-underline-offset: 0.2em;
}

.ghs-toc-link:is(:hover, :focus-visible) {
	background-color: #fff;
	color: var(--color-primary, #018087);
	text-decoration: underline;
}

.ghs-toc-link:focus-visible {
	outline: 2px solid var(--color-focus, #018087);
	outline-offset: 2px;
}

.ghs-toc-link[aria-current="true"] {
	background-color: var(--color-primary, #018087);
	color: #fff;
	font-weight: var(--font-weight-bold, 700);
	text-decoration: none;
}

.ghs-toc-link[aria-current="true"]:is(:hover, :focus-visible) {
	background-color: var(--color-primary-dark, #015a5f);
	color: #fff;
}

/* An accent rule on the current entry, so it is not colour alone. */
.ghs-toc-bar__list .ghs-toc-link[aria-current="true"],
.ghs-toc-side__list .ghs-toc-link[aria-current="true"] {
	box-shadow: inset 0.25rem 0 0 0 var(--color-accent, #f1c40f);
}

/* ---------------------------------------------------------------------------
 * The persistent bar
 *
 * `position: fixed` plus a starting transform off the top of the screen. It is
 * never in flow, so it cannot shift layout, which is the whole CLS argument.
 * ------------------------------------------------------------------------ */

.ghs-toc-bar {
	position: fixed;
	z-index: 490; /* under the GeneratePress sticky nav at 500, over the content. */
	top: var(--ghs-toc-top, 0px);
	right: 0;
	left: 0;
	box-sizing: border-box;
	/* Some posts overflow horizontally on their own: /van-build-insulation/ has a
	   Ninja Tables footable 406px wide inside a 375px viewport. That widens the
	   containing block a fixed element resolves against, so `left:0;right:0`
	   alone would stretch this bar past the screen. JS keeps --ghs-toc-vw at
	   documentElement.clientWidth, which is the viewport without its scrollbar. */
	max-width: var(--ghs-toc-vw, 100%);
	background-color: var(--color-primary-extra-dark, #264653);
	box-shadow: 0 0.125rem 0.75rem rgb(0 0 0 / 18%);
	opacity: 0;
	transform: translateY(-110%);
	transition: transform 0.22s ease, opacity 0.22s ease;
}

.ghs-toc-bar.is-visible {
	opacity: 1;
	transform: translateY(0);
}

.ghs-toc-bar__inner {
	position: relative;
	box-sizing: border-box;
	max-width: 80rem; /* 1280px, the GeneratePress container width. */
	margin: 0 auto;
	padding: 0 var(--space-gutter, 1.25rem);
}

.ghs-toc-bar__toggle {
	display: flex;
	box-sizing: border-box;
	width: 100%;
	align-items: center;
	padding: 0.625rem 0;
	border: 0;
	background: none;
	color: #fff;
	cursor: pointer;
	font-family: var(--font-ui, inherit);
	font-size: var(--text-body-s, 0.9375rem);
	gap: 0.625rem;
	line-height: 1.3;
	text-align: left;
}

.ghs-toc-bar__toggle:focus-visible {
	outline: 2px solid var(--color-accent, #f1c40f);
	outline-offset: -2px;
}

.ghs-toc-bar__label {
	flex: 0 0 auto;
	font-weight: var(--font-weight-bold, 700);
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

/* `min-width: 0` is what actually lets the ellipsis happen inside a flex item,
   and is what stops a long section title forcing horizontal overflow at 375px. */
.ghs-toc-bar__current {
	min-width: 0;
	flex: 1 1 auto;
	overflow: hidden;
	color: var(--color-primary-light, #99c5c7);
	text-overflow: ellipsis;
	white-space: nowrap;
}

.ghs-toc-bar__chevron {
	flex: 0 0 auto;
	transition: transform 0.22s ease;
}

.ghs-toc-bar__toggle[aria-expanded="true"] .ghs-toc-bar__chevron {
	transform: rotate(180deg);
}

/* The panel drops DOWNWARD from the bar. Never upward from a bottom edge. */
.ghs-toc-bar__panel {
	position: absolute;
	top: 100%;
	right: 0;
	left: 0;
	box-sizing: border-box;
	/* The third term is what keeps the panel clear of Mediavine's bottom
	   adhesion unit. JS keeps --ghs-toc-panel-max at the height actually free
	   between the bar and the top of that unit; see the note in the JS. */
	max-height: min(60vh, 30rem, var(--ghs-toc-panel-max, 60vh));
	padding: var(--space-s, 1rem) var(--space-gutter, 1.25rem) var(--space-m, 1.5rem);
	border-bottom-right-radius: var(--radius-button, 0.5rem);
	border-bottom-left-radius: var(--radius-button, 0.5rem);
	background-color: var(--color-primary-extra-light, #e6f0f1);
	box-shadow: 0 0.5rem 1.5rem rgb(0 0 0 / 22%);
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.ghs-toc-bar__panel[hidden] {
	display: none;
}

@media (min-width: 48rem) {
	.ghs-toc-bar__panel {
		right: var(--space-gutter, 1.25rem);
		left: auto;
		width: min(32rem, calc(100vw - 2 * var(--space-gutter, 1.25rem)));
		border-radius: var(--radius-button, 0.5rem);
	}
}


/* ---------------------------------------------------------------------------
 * Progressive disclosure
 *
 * Collapsed sublists are hidden with the `hidden` attribute, not a class, so
 * they are out of the accessibility tree and out of the tab order with no help
 * from CSS. The reveal is therefore an animation on appearance rather than a
 * height transition: `hidden` and `transition` cannot coexist.
 * ------------------------------------------------------------------------ */

.ghs-toc-disclosure {
	display: flex;
	width: 1.875rem;
	height: 1.875rem;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 0;
	border-radius: 0.375rem;
	background: none;
	color: var(--color-primary-extra-dark, #264653);
	cursor: pointer;
}

.ghs-toc-disclosure:is(:hover, :focus-visible) {
	background-color: #fff;
	color: var(--color-primary, #018087);
}

.ghs-toc-disclosure:focus-visible {
	outline: 2px solid var(--color-focus, #018087);
	outline-offset: 2px;
}

.ghs-toc-disclosure__icon {
	transform: rotate(-90deg);
	transition: transform 0.18s ease;
}

.ghs-toc-disclosure[aria-expanded="true"] .ghs-toc-disclosure__icon {
	transform: rotate(0deg);
}

/* Visually hidden, still read. The button's only visible content is an icon. */
.ghs-toc-disclosure__label {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	clip-path: inset(50%);
	overflow: hidden;
	white-space: nowrap;
}

.ghs-toc-sublist[hidden] {
	display: none;
}

@keyframes ghs-toc-reveal {
	from {
		opacity: 0;
		transform: translateY(-0.25rem);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.ghs-toc-sublist.is-revealing {
	animation: ghs-toc-reveal 0.18s ease both;
}


/* ---------------------------------------------------------------------------
 * Mode `side`: a floating icon with an overlay
 *
 * NOT A CONSTANT DISTANCE FROM THE BOTTOM. `#fixed_container_bottom` owns the
 * bottom edge, and that adhesion unit measured 400px tall at 375x812, so JS
 * keeps --ghs-toc-side-bottom at the unit's height plus a gap and the icon rides
 * above it. The overlay opens UPWARD from the icon, so its bottom edge is above
 * the icon's and clears the unit by construction.
 *
 * BOTTOM RIGHT AT EVERY WIDTH (2026-11-20). Up to 1024px the content runs
 * 1.5rem (24px) from each edge, so a 3rem (48px) icon covers text wherever it
 * goes; on the left it covered the first characters of every line. On the right
 * it covers only the ragged ends of lines. From 1025px the right-hand column is
 * the sidebar, so the icon covers no article text. The left margin only holds
 * the icon clear of the text from about 1300px, which is why the old desktop
 * spot on the left was dropped. It sits 0.75rem (12px) in, centred over
 * GeneratePress's back-to-top button (`ghs-layout.css`), which is hidden on
 * phones and which the icon rides above from 769px.
 * ------------------------------------------------------------------------ */

.ghs-toc-side {
	position: fixed;
	z-index: 490; /* Same stacking as the bar: under the sticky nav, over content. */
	right: 0.75rem;
	bottom: var(--ghs-toc-side-bottom, 1rem);
	opacity: 0;
	transform: translateY(0.5rem);
	transition: opacity 0.22s ease, transform 0.22s ease, bottom 0.22s ease;
}

.ghs-toc-side.is-visible {
	opacity: 1;
	transform: translateY(0);
}

.ghs-toc-side__trigger {
	display: flex;
	width: 3rem;
	height: 3rem;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background-color: var(--color-primary-extra-dark, #264653);
	box-shadow: 0 0.125rem 0.75rem rgb(0 0 0 / 28%);
	color: #fff;
	cursor: pointer;
}

.ghs-toc-side__trigger:is(:hover, :focus-visible) {
	background-color: var(--color-primary, #018087);
}

.ghs-toc-side__trigger:focus-visible {
	outline: 2px solid var(--color-accent, #f1c40f);
	outline-offset: 2px;
}

/* The icon swaps for a cross while the overlay is open, so the one control
   reads as both "open contents" and "close contents". */
.ghs-toc-side__close {
	display: none;
}

.ghs-toc-side__trigger[aria-expanded="true"] .ghs-toc-side__icon {
	display: none;
}

.ghs-toc-side__trigger[aria-expanded="true"] .ghs-toc-side__close {
	display: flex;
}

/* Visually hidden, still the button's accessible name. */
.ghs-toc-side__label {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	clip-path: inset(50%);
	overflow: hidden;
	white-space: nowrap;
}

.ghs-toc-side__panel {
	position: absolute;
	right: 0; /* Opens from the icon's corner. */
	bottom: calc(3rem + 0.75rem);
	box-sizing: border-box;
	width: min(22rem, calc(var(--ghs-toc-vw, 100vw) - 2 * var(--space-gutter, 1.25rem)));
	/* Same cap as the bar's panel, from the same JS measurement. */
	max-height: min(70vh, 30rem, var(--ghs-toc-panel-max, 70vh));
	padding: var(--space-s, 1rem) var(--space-s, 1rem) var(--space-m, 1.5rem);
	border-radius: var(--radius-card, 1rem);
	background-color: var(--color-primary-extra-light, #e6f0f1);
	box-shadow: 0 0.5rem 1.5rem rgb(0 0 0 / 28%);
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.ghs-toc-side__panel[hidden] {
	display: none;
}

/* Above the back-to-top button, which shows from 769px (`ghs-layout.css`: 5rem
   up, 2.5rem tall), with a 0.75rem gap. The adhesion lift still wins when the
   unit is taller than that. */
@media (min-width: 48.0625rem) { /* 769px */
	.ghs-toc-side {
		bottom: max(var(--ghs-toc-side-bottom, 1rem), 8.25rem);
	}
}

.ghs-toc-side__head {
	display: flex;
	margin-bottom: var(--space-s, 1rem);
	flex-direction: column;
	gap: 0.125rem;
}

.ghs-toc-side__title {
	color: var(--color-primary-extra-dark, #264653);
	font-family: var(--font-ui, inherit);
	font-size: var(--text-body-s, 0.9375rem);
	font-weight: var(--font-weight-bold, 700);
	letter-spacing: 0.08em;
	line-height: 1.2;
	text-transform: uppercase;
}

/* `min-width: 0` plus the ellipsis, same reason as the bar's current label:
   a long section title must not force the overlay wider than the viewport. */
.ghs-toc-side__current {
	min-width: 0;
	overflow: hidden;
	color: var(--color-primary, #018087);
	font-size: var(--text-body-s, 0.9375rem);
	line-height: 1.3;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.ghs-toc-side__current:empty {
	display: none;
}

@media (prefers-reduced-motion: reduce) {
	.ghs-toc-bar,
	.ghs-toc-bar__chevron,
	.ghs-toc-disclosure__icon,
	.ghs-toc-inline__title::after,
	.ghs-toc-side {
		transition: none;
	}

	/* The JS never adds `is-revealing` under reduced motion. This is the belt
	   to that braces: if the class ever lands anyway, nothing animates. */
	.ghs-toc-sublist.is-revealing {
		animation: none;
	}
}
