/* Sidebar Page Switcher — override any variable from your theme, e.g. .sps { --sps-accent: #c00; } */
.sps {
	--sps-accent: #e8501c;          /* arrow, subtitle */
	--sps-heading: #1b2c5c;         /* sidebar title, active item, document headings */
	--sps-link: #2b4a8b;            /* sidebar links */
	--sps-text: #4b5565;            /* document body text */
	--sps-border: #e2e6ee;
	--sps-heading-font: inherit;    /* e.g. "Noto Serif", Georgia, serif */
	--sps-side-width: 260px;
	--sps-gap: 52px;
	--sps-sticky-top: 32px;         /* space for a sticky site header */
	--sps-sticky-top-mobile: 0px;   /* same, on tablets and phones */
	--sps-bg: #fff;                 /* dropdown / sticky bar background */
	--sps-breakpoint-gap: 20px;
}

.sps *,
.sps *::before,
.sps *::after { box-sizing: border-box; }

/* ── Sidebar menu ───────────────────────────────────────── */
.sps-menu { margin: 0 0 2em; }

.sps-title {
	margin: 0;
	padding: 0 0 .75em;
	border-bottom: 1px solid var(--sps-border);
	font-family: var(--sps-heading-font);
	font-size: 1.05rem;
	font-weight: 600;
	line-height: 1.35;
	color: var(--sps-heading);
}

.sps-list,
.sps-list .sps-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.sps-item { border-bottom: 1px solid var(--sps-border); margin: 0; }
.sps-list .sps-list { margin: -.35em 0 .7em 1em; }
.sps-list .sps-list .sps-item { border: 0; }
.sps-list .sps-list .sps-link { padding-top: .4em; padding-bottom: .4em; font-size: .875rem; }

.sps-link {
	position: relative;
	display: block;
	padding: .9em 0;
	font-size: .9rem;
	line-height: 1.45;
	color: var(--sps-link);
	text-decoration: none;
	transition: color .15s ease, padding-left .2s ease;
}

.sps-link:focus-visible { outline: 2px solid var(--sps-accent); outline-offset: 2px; }

/* Hover: underline (default) | color | shift | none */
.sps--hover-underline .sps-link:hover { color: var(--sps-heading); text-decoration: underline; text-underline-offset: 3px; }
.sps--hover-color .sps-link:hover { color: var(--sps-accent); }
.sps--hover-shift .sps-link:hover { color: var(--sps-heading); }
.sps--hover-shift .sps-item:not(.is-active) > .sps-link:hover { padding-left: .5em; }

/* Active item + marker: arrow (default) | chevron | dot | bar | none */
.sps-item.is-active > .sps-link {
	padding-left: 1.35em;
	font-weight: 600;
	color: var(--sps-heading);
}

.sps-item.is-active > .sps-link::before {
	content: "\2192";
	position: absolute;
	left: 0;
	color: var(--sps-accent);
	font-weight: 400;
}

.sps--marker-chevron .sps-item.is-active > .sps-link::before { content: "\203A"; font-size: 1.35em; line-height: 1.05; }
.sps--marker-dot .sps-item.is-active > .sps-link::before { content: "\2022"; }
.sps--marker-bar .sps-item.is-active > .sps-link::before {
	content: "";
	top: .75em;
	bottom: .75em;
	width: 3px;
	border-radius: 2px;
	background: var(--sps-accent);
}
.sps--marker-bar .sps-item.is-active > .sps-link { padding-left: 1em; }
.sps--marker-none .sps-item.is-active > .sps-link { padding-left: 0; }
.sps--marker-none .sps-item.is-active > .sps-link::before { content: none; }

/* Mobile toggle (hidden on wide screens) */
.sps-toggle { display: none; }

/* ── Tablet & phone (< 1024px) ──────────────────────────────
 * mobile="dropdown" (default): a button showing the current page opens the list over the content.
 * mobile="scroll": one row of swipeable pills.
 * mobile="list": the normal list.
 */
@media (max-width: 1023.98px) {
	/* Dropdown */
	.sps-menu--dropdown { position: relative; }
	.sps-menu--dropdown .sps-title { display: none; } /* shown inside the button instead */

	.sps-menu--dropdown .sps-toggle {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 12px;
		width: 100%;
		min-height: 48px;
		margin: 0;
		padding: .6em 1em;
		border: 1px solid var(--sps-border);
		border-radius: 10px;
		background: var(--sps-bg);
		color: var(--sps-heading);
		font: inherit;
		font-size: .95rem;
		font-weight: 600;
		line-height: 1.35;
		text-align: left;
		cursor: pointer;
		-webkit-tap-highlight-color: transparent;
	}

	.sps-menu--dropdown .sps-toggle:focus-visible { outline: 2px solid var(--sps-accent); outline-offset: 2px; }

	.sps-toggle-text { display: flex; flex-direction: column; min-width: 0; }
	.sps-toggle-eyebrow {
		font-size: .72rem;
		font-weight: 500;
		letter-spacing: .02em;
		color: var(--sps-text);
	}
	.sps-toggle-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

	.sps-toggle-icon {
		flex: none;
		width: 8px;
		height: 8px;
		margin-top: -4px;
		border-right: 2px solid currentColor;
		border-bottom: 2px solid currentColor;
		transform: rotate(45deg);
		transition: transform .2s ease;
	}

	.sps-menu--dropdown.is-open .sps-toggle-icon { transform: rotate(-135deg); margin-top: 4px; }

	.sps-menu--dropdown > .sps-list {
		display: none;
		position: absolute;
		z-index: 30;
		top: calc(100% + 6px);
		left: 0;
		right: 0;
		max-height: min(65vh, 440px);
		overflow-y: auto;
		overscroll-behavior: contain;
		padding: 0 1em;
		border: 1px solid var(--sps-border);
		border-radius: 10px;
		background: var(--sps-bg);
		box-shadow: 0 12px 32px rgba(16, 24, 40, .14);
	}

	.sps-menu--dropdown.is-open > .sps-list { display: block; }
	.sps-menu--dropdown > .sps-list > .sps-item:last-child { border-bottom: 0; }
	.sps-menu--dropdown .sps-link { padding-top: .85em; padding-bottom: .85em; }

	/* Swipeable pills */
	.sps-menu--scroll .sps-title { border-bottom: 0; padding-bottom: .5em; }

	.sps-menu--scroll > .sps-list {
		position: relative;
		display: flex;
		gap: 8px;
		overflow-x: auto;
		padding: 2px 2px 6px;
		scroll-snap-type: x proximity;
		scrollbar-width: none;
		-webkit-overflow-scrolling: touch;
	}
	.sps-menu--scroll > .sps-list::-webkit-scrollbar { display: none; }

	/* Child pages become pills in the same row. */
	.sps-menu--scroll .sps-item.has-children,
	.sps-menu--scroll .sps-list .sps-list { display: contents; }

	.sps-menu--scroll .sps-item { flex: none; border: 0; scroll-snap-align: start; }

	.sps-menu--scroll .sps-link,
	.sps-menu--scroll .sps-list .sps-list .sps-link,
	.sps--hover-shift .sps-menu--scroll .sps-item:not(.is-active) > .sps-link:hover,
	.sps-menu--scroll.sps--hover-shift .sps-item:not(.is-active) > .sps-link:hover {
		padding: .55em 1.05em;
		border: 1px solid var(--sps-border);
		border-radius: 999px;
		background: var(--sps-bg);
		font-size: .875rem;
		white-space: nowrap;
		text-decoration: none;
		/* Long titles are shortened so the next tab peeks in and the row reads as swipeable. */
		max-width: min(72vw, 300px);
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.sps-menu--scroll .sps-item.is-active > .sps-link {
		padding: .55em 1.05em;
		border-color: var(--sps-heading);
		background: var(--sps-heading);
		color: #fff;
	}
	.sps-menu--scroll .sps-item.is-active > .sps-link::before { content: none; }
}

/* ── [sps_tabs] layout ──────────────────────────────────── */
.sps-crumbs ol {
	display: flex;
	flex-wrap: wrap;
	gap: .35em;
	list-style: none;
	margin: 0 0 2em;
	padding: 0;
	font-size: .8rem;
	color: var(--sps-link);
}

.sps-crumbs li { margin: 0; }
.sps-crumbs li + li::before { content: "\203A"; margin-right: .35em; color: var(--sps-text); }
.sps-crumbs a { color: inherit; text-decoration: none; }
.sps-crumbs a:hover { text-decoration: underline; }

.sps-tabs-grid {
	display: grid;
	grid-template-columns: var(--sps-side-width) minmax(0, 1fr);
	gap: var(--sps-gap);
	align-items: start;
}

.sps-tabs--sticky .sps-tabs-side {
	position: sticky;
	top: var(--sps-sticky-top);
}

/* Long lists scroll inside the sticky column instead of running off the screen. */
.sps-tabs--sticky .sps-tabs-side {
	max-height: calc(100vh - var(--sps-sticky-top) - 16px);
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
}

/* ── [sps_toc] ──────────────────────────────────────────── */
.sps-toc-body { min-width: 0; }
.sps-toc--sticky {
	position: sticky;
	top: var(--sps-sticky-top);
	max-height: calc(100vh - var(--sps-sticky-top) - 16px);
	overflow-y: auto;
	scrollbar-width: thin;
}
.sps-toc-target:focus { outline: none; }
.sps-toc-note {
	margin: .75em 0 0;
	padding: .75em 1em;
	border: 1px dashed var(--sps-accent);
	border-radius: 8px;
	font-size: .8rem;
	line-height: 1.5;
	color: var(--sps-text);
}

/* Sidebar / widget: the box around the TOC is made sticky by sps.js (desktop only). */
@media (min-width: 1024px) {
	.sps-sticky-host {
		position: sticky;
		top: var(--sps-host-top, 32px);
		z-index: 5;
	}
}

.sps-panel { min-width: 0; scroll-margin-top: var(--sps-sticky-top); transition: opacity .2s ease; }
.sps-tabs.is-loading .sps-panel { opacity: .45; }

.sps-heading {
	margin: 0 0 .35em;
	font-family: var(--sps-heading-font);
	font-size: clamp(1.9rem, 1.2rem + 2.4vw, 2.75rem);
	font-weight: 600;
	line-height: 1.15;
	color: var(--sps-heading);
	outline: none;
}

.sps-subtitle {
	margin: 0 0 1em;
	font-size: .875rem;
	font-weight: 600;
	color: var(--sps-accent);
}

.sps-content { color: var(--sps-text); font-size: .95rem; line-height: 1.85; }
.sps-content > :first-child { margin-top: 0; }

.sps-content h2,
.sps-content h3 {
	margin: 1.8em 0 .6em;
	font-family: var(--sps-heading-font);
	font-weight: 500;
	line-height: 1.3;
	color: var(--sps-heading);
}

.sps-content h2 { font-size: 1.35rem; }
.sps-content h3 { font-size: 1.1rem; }
.sps-content a { color: var(--sps-heading); text-decoration: underline; }

/* Long words, e-mail addresses, wide images and tables never push the page sideways. */
.sps-content { overflow-wrap: anywhere; }
.sps-content img,
.sps-content video,
.sps-content iframe { max-width: 100%; height: auto; }
.sps-content table { display: block; max-width: 100%; overflow-x: auto; }
.sps-content pre { overflow-x: auto; }

/* Tablet & phone: one column; the switcher stays at the top of the screen while reading. */
@media (max-width: 1023.98px) {
	.sps-tabs-grid { grid-template-columns: minmax(0, 1fr); gap: var(--sps-breakpoint-gap); }
	.sps-tabs .sps-menu,
	.sps-toc-layout .sps-menu { margin: 0; }
	.sps-tabs .sps-menu--list .sps-title,
	.sps-toc-layout .sps-menu--list .sps-title { border-bottom: 1px solid var(--sps-border); }

	.sps-tabs--sticky .sps-tabs-side { position: static; max-height: none; overflow: visible; }
	.sps-toc--sticky { position: relative; max-height: none; overflow: visible; }
	.sps-tabs--sticky-compact .sps-tabs-side {
		position: sticky;
		top: var(--sps-sticky-top-mobile);
		z-index: 20;
		padding: 8px 0;
		background: var(--sps-bg);
	}
	.sps-panel { scroll-margin-top: calc(var(--sps-sticky-top-mobile) + 76px); }

	.sps-crumbs ol { margin-bottom: 1.25em; }
	.sps-heading { margin-bottom: .3em; }
}

@media (max-width: 600px) {
	.sps-content { font-size: .95rem; line-height: 1.75; }
	.sps-content h2 { font-size: 1.2rem; }
	.sps-content h3 { font-size: 1.05rem; }
}

@media (prefers-reduced-motion: reduce) {
	.sps-link,
	.sps-panel,
	.sps-toggle-icon { transition: none; }
}
