:root {
	--chapterrail-scroll-offset: 96px;
}

html {
	scroll-padding-top: var(--chapterrail-scroll-offset);
}

[data-chapterrail-heading] {
	scroll-margin-top: var(--chapterrail-scroll-offset);
}

.chapterrail,
.chapterrail * {
	box-sizing: border-box;
}

.chapterrail {
	--cr-ink: currentColor;
	--cr-surface: var(--wp--preset--color--base, Canvas);
	--cr-muted: color-mix(in srgb, var(--cr-ink) 48%, transparent);
	--cr-line: color-mix(in srgb, var(--cr-ink) 14%, transparent);
	--cr-line-strong: color-mix(in srgb, var(--cr-ink) 30%, transparent);
	--cr-current-row: var(--cr-row);
	--cr-visible-rows: var(--cr-collapsed-rows);
	position: fixed;
	z-index: 9990;
	top: 50%;
	width: var(--cr-width);
	color: var(--cr-ink);
	font-family: inherit;
	font-size: 16px;
	line-height: 1.4;
	transform: translateY(-50%);
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	user-select: none;
	opacity: 0;
	pointer-events: none;
	transition: opacity 180ms ease;
}

.chapterrail.is-ready {
	opacity: 1;
	pointer-events: auto;
}

.chapterrail--right {
	right: max(24px, env(safe-area-inset-right));
}

.chapterrail--left {
	left: max(24px, env(safe-area-inset-left));
}

/* Shortcode instances stay inside their widget, column, or content container on desktop.
 * Keep this selector more specific than the fixed left/right placement rules so a
 * theme or cached rule cannot pull an embedded rail back to the viewport edge. */
.chapterrail.chapterrail--embedded:not(.is-mobile) {
	position: relative;
	z-index: 1;
	inset: auto;
	width: 100%;
	max-width: var(--cr-width);
	transform: none;
}

.chapterrail--embedded.chapterrail--right {
	margin-right: 0;
	margin-left: auto;
}

.chapterrail--embedded.chapterrail--left {
	margin-right: auto;
	margin-left: 0;
}

.chapterrail.chapterrail--embedded.chapterrail--sticky:not(.is-mobile) {
	position: sticky;
	top: var(--cr-sticky-top, var(--chapterrail-scroll-offset));
	right: auto;
	bottom: auto;
	left: auto;
	align-self: flex-start;
}

/* Hide the automatic fixed instance immediately in browsers that support :has();
 * JavaScript performs the same replacement for broader compatibility. */
body:has(.chapterrail--embedded[data-replace-auto="true"]) .chapterrail--fixed {
	display: none;
}

.chapterrail.is-index-open {
	--cr-visible-rows: var(--cr-expanded-rows);
}

.chapterrail__head,
.chapterrail__foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	min-width: 0;
}

.chapterrail--right .chapterrail__head,
.chapterrail--right .chapterrail__foot {
	margin-left: 20px;
	padding-left: 55px;
}

.chapterrail--left .chapterrail__head,
.chapterrail--left .chapterrail__foot {
	margin-right: 20px;
	padding-right: 55px;
}

.chapterrail__head {
	margin-bottom: 17px;
}

.chapterrail__foot {
	margin-top: 17px;
}

.chapterrail__toggle {
	display: inline-flex;
	align-items: center;
	gap: 9px;
	min-height: 28px;
	padding: 0;
	border: 0;
	color: inherit;
	background: transparent;
	font: inherit;
	font-size: 9px;
	font-weight: 720;
	letter-spacing: .16em;
	text-transform: uppercase;
	cursor: pointer;
}

.chapterrail__toggle-mark {
	position: relative;
	display: inline-block;
	width: 10px;
	height: 10px;
}

.chapterrail__toggle-mark::before,
.chapterrail__toggle-mark::after {
	content: "";
	position: absolute;
	left: 0;
	top: 50%;
	width: 10px;
	height: 1px;
	background: currentColor;
	transform: translateY(-50%);
	transition: transform 240ms ease, opacity 180ms ease;
}

.chapterrail__toggle-mark::after {
	transform: translateY(-50%) rotate(90deg);
}

.chapterrail.is-index-open .chapterrail__toggle-mark::after {
	opacity: 0;
	transform: translateY(-50%) rotate(90deg) scaleX(0);
}

.chapterrail__count,
.chapterrail__progress,
.chapterrail__mode,
.chapterrail__mobile-number {
	color: var(--cr-muted);
	font-size: 8px;
	font-variant-numeric: tabular-nums;
	letter-spacing: .13em;
	text-transform: uppercase;
}

.chapterrail__stage {
	position: relative;
	height: calc(var(--cr-current-row) * var(--cr-visible-rows));
	overflow: hidden;
	outline: none;
	overscroll-behavior: contain;
	scrollbar-color: var(--cr-line-strong) transparent;
	scrollbar-gutter: stable;
	scrollbar-width: thin;
	transition: height 380ms cubic-bezier(.22, .7, .22, 1);
}

.chapterrail.is-index-open .chapterrail__stage {
	overflow-y: auto;
}

.chapterrail__stage::-webkit-scrollbar {
	width: 4px;
}

.chapterrail__stage::-webkit-scrollbar-track {
	background: transparent;
}

.chapterrail__stage::-webkit-scrollbar-thumb {
	border-radius: 999px;
	background: var(--cr-line-strong);
}

.chapterrail__stage:focus-visible,
.chapterrail__toggle:focus-visible,
.chapterrail__mobile-toggle:focus-visible,
.chapterrail__mobile-current:focus-visible,
.chapterrail__mobile-track:focus-visible,
.chapterrail__rail-hit:focus-visible,
.chapterrail__label a:focus-visible {
	outline: 2px solid var(--cr-accent);
	outline-offset: 4px;
}

.chapterrail__stage-content {
	position: relative;
	width: 100%;
	min-height: 100%;
}

.chapterrail__baseline {
	position: absolute;
	width: 1px;
	background: var(--cr-line);
	pointer-events: none;
}

.chapterrail--right .chapterrail__baseline,
.chapterrail--right .chapterrail__rail-hit,
.chapterrail--right .chapterrail__dot,
.chapterrail--right .chapterrail__tick {
	left: 20px;
}

.chapterrail--left .chapterrail__baseline,
.chapterrail--left .chapterrail__rail-hit,
.chapterrail--left .chapterrail__dot,
.chapterrail--left .chapterrail__tick {
	right: 20px;
}

.chapterrail__rail-hit {
	position: absolute;
	z-index: 4;
	top: 0;
	width: 53px;
	height: 100%;
	border: 0;
	background: transparent;
	cursor: ns-resize;
	touch-action: none;
}

.chapterrail--right .chapterrail__rail-hit {
	transform: translateX(-22px);
}

.chapterrail--left .chapterrail__rail-hit {
	transform: translateX(22px);
}

.chapterrail.is-drag-disabled .chapterrail__rail-hit {
	cursor: default;
}

.chapterrail__dot {
	position: absolute;
	z-index: 6;
	top: 0;
	width: 12px;
	height: 12px;
	border: 1px solid var(--cr-surface);
	border-radius: 50%;
	background: var(--cr-ink);
	box-shadow: 0 0 0 1px var(--cr-ink), 0 0 0 6px color-mix(in srgb, var(--cr-surface) 74%, transparent);
	pointer-events: none;
	transform: translate(-50%, -50%);
	will-change: transform;
}

.chapterrail--left .chapterrail__dot {
	transform: translate(50%, -50%);
}

.chapterrail.is-dragging .chapterrail__dot {
	width: 14px;
	height: 14px;
}

.chapterrail__ticks,
.chapterrail__labels {
	position: absolute;
	inset: 0;
	margin: 0;
	padding: 0;
	list-style: none;
	pointer-events: none;
}

.chapterrail__tick {
	position: absolute;
	height: 1px;
	color: var(--cr-muted);
	background: currentColor;
	will-change: transform, width, opacity;
}

.chapterrail--right .chapterrail__tick {
	transform-origin: left center;
}

.chapterrail--left .chapterrail__tick {
	transform-origin: right center;
}

.chapterrail__label {
	position: absolute;
	width: calc(100% - 90px);
	opacity: .34;
	pointer-events: auto;
	transform: translateY(-50%);
	transition: opacity 190ms ease;
	will-change: transform, opacity;
}

.chapterrail--right .chapterrail__label {
	left: 75px;
}

.chapterrail--left .chapterrail__label {
	right: 75px;
	text-align: right;
}

.chapterrail__label.is-near {
	opacity: .62;
}

.chapterrail__label.is-active {
	opacity: 1;
}

.chapterrail__label a {
	display: block;
	min-height: calc(var(--cr-current-row) - 12px);
	padding: 6px 10px 6px 0;
	color: inherit;
	text-decoration: none;
}

.chapterrail--left .chapterrail__label a {
	padding-right: 0;
	padding-left: 10px;
}

.chapterrail__label small {
	display: block;
	margin-bottom: 4px;
	color: var(--cr-muted);
	font-size: 7px;
	font-weight: 700;
	letter-spacing: .15em;
	text-transform: uppercase;
}

.chapterrail__label strong {
	display: -webkit-box;
	overflow: hidden;
	max-width: 100%;
	color: color-mix(in srgb, var(--cr-ink) 76%, transparent);
	font-family: inherit;
	font-size: 13px;
	font-weight: 500;
	line-height: 1.32;
	letter-spacing: -.015em;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	transition: color 180ms ease, font-size 220ms ease;
}

.chapterrail--type-editorial .chapterrail__label strong,
.chapterrail--type-editorial .chapterrail__mobile-current strong {
	font-family: Iowan Old Style, Baskerville, "Times New Roman", Georgia, serif;
}

.chapterrail:not(.chapterrail--flat) .chapterrail__label[data-level="3"] strong {
	padding-inline-start: 8px;
	font-size: 12.5px;
}

.chapterrail:not(.chapterrail--flat) .chapterrail__label[data-level="4"] strong,
.chapterrail:not(.chapterrail--flat) .chapterrail__label[data-level="5"] strong,
.chapterrail:not(.chapterrail--flat) .chapterrail__label[data-level="6"] strong {
	padding-inline-start: 16px;
	font-size: 12px;
}

.chapterrail__label.is-active small {
	color: var(--cr-accent);
}

.chapterrail__label.is-active strong {
	color: var(--cr-ink);
	font-size: 15px;
}

.chapterrail__label a:hover strong,
.chapterrail__label a:focus-visible strong {
	color: var(--cr-ink);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 4px;
}

.chapterrail__mode {
	display: inline-flex;
	align-items: center;
	gap: 7px;
}

.chapterrail.is-index-open .chapterrail__mode::before {
	content: "";
	width: 12px;
	height: 1px;
	background: currentColor;
	opacity: .65;
}

.chapterrail--hide-progress .chapterrail__progress {
	display: none;
}

.chapterrail__mobile-bar {
	display: none;
}

.chapterrail.is-mobile {
	position: fixed;
	z-index: 9990;
	inset: auto 12px max(12px, env(safe-area-inset-bottom)) 12px;
	width: auto;
	max-width: none;
	margin: 0;
	transform: none;
}

.chapterrail.is-mobile .chapterrail__desktop {
	display: none;
}

.chapterrail.is-mobile .chapterrail__mobile-bar {
	position: relative;
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	align-items: center;
	min-height: 66px;
	padding: 13px 14px 11px;
	border: 1px solid rgba(255, 255, 255, .12);
	border-radius: 15px;
	color: #fbfaf6;
	background: rgba(20, 20, 18, .94);
	box-shadow: 0 18px 48px rgba(20, 20, 18, .18);
	backdrop-filter: blur(16px) saturate(120%);
}

.chapterrail__mobile-track {
	position: absolute;
	left: 15px;
	right: 15px;
	top: 0;
	height: 20px;
	transform: translateY(-50%);
	touch-action: none;
	cursor: ew-resize;
}

.chapterrail__mobile-track-line {
	position: absolute;
	left: 0;
	right: 0;
	top: 50%;
	height: 1px;
	background: rgba(255, 255, 255, .2);
}

.chapterrail__mobile-ticks {
	position: absolute;
	inset: 0;
	pointer-events: none;
}

.chapterrail__mobile-tick {
	position: absolute;
	top: 50%;
	width: 1px;
	height: 5px;
	background: rgba(255, 255, 255, .35);
	transform: translate(-50%, -50%);
}

.chapterrail__mobile-dot {
	position: absolute;
	z-index: 2;
	left: 0;
	top: 50%;
	width: 9px;
	height: 9px;
	border: 2px solid #1b1b18;
	border-radius: 50%;
	background: var(--cr-accent);
	box-shadow: 0 0 0 1px rgba(255, 255, 255, .75);
	transform: translate(-50%, -50%);
	pointer-events: none;
}

.chapterrail__mobile-number {
	min-width: 50px;
	color: rgba(255, 255, 255, .58);
}

.chapterrail__mobile-current {
	min-width: 0;
	padding: 0 13px;
	border: 0;
	color: inherit;
	background: transparent;
	font: inherit;
	text-align: left;
	cursor: pointer;
}

.chapterrail__mobile-current small {
	display: block;
	margin-bottom: 3px;
	color: rgba(255, 255, 255, .48);
	font-size: 7px;
	font-weight: 700;
	letter-spacing: .13em;
	text-transform: uppercase;
}

.chapterrail__mobile-current strong {
	display: block;
	overflow: hidden;
	font-size: 14px;
	font-weight: 500;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.chapterrail__mobile-toggle {
	padding: 8px 0 8px 10px;
	border: 0;
	color: rgba(255, 255, 255, .78);
	background: transparent;
	font: inherit;
	font-size: 8px;
	font-weight: 720;
	letter-spacing: .14em;
	text-transform: uppercase;
	cursor: pointer;
}

.chapterrail.is-mobile.is-index-open {
	--cr-current-row: 56px;
	color: #fbfaf6;
}

.chapterrail.is-mobile.is-index-open .chapterrail__desktop {
	display: block;
	width: 100%;
	padding: 18px 14px 15px;
	border: 1px solid rgba(255, 255, 255, .12);
	border-radius: 16px;
	background: rgba(20, 20, 18, .96);
	box-shadow: 0 22px 60px rgba(20, 20, 18, .28);
	backdrop-filter: blur(18px) saturate(120%);
}

.chapterrail.is-mobile.is-index-open .chapterrail__mobile-bar {
	display: none;
}

.chapterrail.is-mobile.is-index-open .chapterrail__head,
.chapterrail.is-mobile.is-index-open .chapterrail__foot {
	margin-inline: 0;
	padding-inline: 55px 0;
}

.chapterrail.is-mobile.is-index-open .chapterrail__head {
	margin-bottom: 12px;
}

.chapterrail.is-mobile.is-index-open .chapterrail__foot {
	margin-top: 12px;
}

.chapterrail.is-mobile.is-index-open .chapterrail__stage {
	overflow-y: auto;
}

.chapterrail.is-mobile.is-index-open .chapterrail__baseline,
.chapterrail.is-mobile.is-index-open .chapterrail__rail-hit,
.chapterrail.is-mobile.is-index-open .chapterrail__dot,
.chapterrail.is-mobile.is-index-open .chapterrail__tick {
	left: 20px;
	right: auto;
}

.chapterrail.is-mobile.is-index-open .chapterrail__rail-hit {
	transform: translateX(-22px);
}

.chapterrail.is-mobile.is-index-open .chapterrail__dot {
	border-color: #1b1b18;
	background: var(--cr-accent);
	box-shadow: 0 0 0 1px rgba(255, 255, 255, .72), 0 0 0 6px rgba(20, 20, 18, .84);
	transform: translate(-50%, -50%);
}

.chapterrail.is-mobile.is-index-open .chapterrail__tick {
	transform-origin: left center;
}

.chapterrail.is-mobile.is-index-open .chapterrail__label {
	left: 75px;
	right: auto;
	width: calc(100vw - 132px);
	text-align: left;
}

.chapterrail.is-mobile.is-index-open .chapterrail__label a {
	padding-right: 10px;
	padding-left: 0;
}

.chapterrail.is-mobile.is-index-open .chapterrail__label strong {
	color: rgba(255, 255, 255, .72);
}

.chapterrail.is-mobile.is-index-open .chapterrail__label.is-active strong {
	color: #fbfaf6;
}

.chapterrail.is-mobile.is-index-open .chapterrail__count,
.chapterrail.is-mobile.is-index-open .chapterrail__progress,
.chapterrail.is-mobile.is-index-open .chapterrail__mode,
.chapterrail.is-mobile.is-index-open .chapterrail__label small {
	color: rgba(255, 255, 255, .46);
}

.chapterrail.is-mobile.is-index-open .chapterrail__label.is-active small {
	color: var(--cr-accent);
}

.chapterrail.is-mobile-disabled.is-mobile {
	display: none;
}

@supports not (color: color-mix(in srgb, black 50%, transparent)) {
	.chapterrail {
		--cr-muted: #7a7a74;
		--cr-line: rgba(21, 21, 19, .14);
		--cr-line-strong: rgba(21, 21, 19, .3);
	}
}

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

	.chapterrail,
	.chapterrail *,
	.chapterrail *::before,
	.chapterrail *::after {
		scroll-behavior: auto !important;
		transition-duration: .01ms !important;
		animation-duration: .01ms !important;
		animation-iteration-count: 1 !important;
	}
}
