/**
 * Floating scroll-spy table of contents for single posts (Medium-style).
 *
 * Normal mode = a compact vertical gauge of tick marks (one per heading); the
 * active section's tick is longer and brand-green. On hover or keyboard focus it
 * expands into a card that reveals the section labels. Progressive enhancement,
 * built by tabswire-toc.js; hidden on narrow screens where the in-content TOC
 * block serves. Active color = --action (#078143), 4.96:1 AA.
 */

/* Anchor jumps clear the fixed site header. */
html {
	scroll-padding-top: 96px;
}

.tabswire-toc {
	display: none;
	position: fixed;
	top: 50%;
	left: clamp(16px, 2vw, 32px);
	transform: translateY(-50%);
	width: 48px;
	max-height: 76vh;
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
	box-sizing: border-box;
	border: 1px solid transparent;
	border-radius: 12px;
	padding: 8px 10px;
	font-family: "Lexend Deca", sans-serif;
	scrollbar-width: thin;
	z-index: 30;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: width 200ms ease, background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease, padding 180ms ease, opacity 240ms ease, visibility 240ms ease;
}

@media (min-width: 1080px) {
	.tabswire-toc {
		display: block;
	}
}

/* Revealed only while the post content is in the reading area (set by JS). */
.tabswire-toc.is-active {
	opacity: 1;
	pointer-events: auto;
	visibility: visible;
}

/* Heading label is part of the expanded card only. */
.tabswire-toc__heading {
	color: var(--muted, #626963);
	font-size: 0.72rem;
	font-weight: 800;
	letter-spacing: 0.09em;
	margin: 0;
	max-height: 0;
	opacity: 0;
	overflow: hidden;
	text-transform: uppercase;
	transition: max-height 200ms ease, opacity 160ms ease, margin 200ms ease;
}

.tabswire-toc__list {
	display: flex;
	flex-direction: column;
	gap: 9px;
	list-style: none;
	margin: 0;
	padding: 0;
	transition: gap 180ms ease;
}

/* Roomier rhythm once the labels are revealed. */
.tabswire-toc:hover .tabswire-toc__list,
.tabswire-toc:focus-within .tabswire-toc__list {
	gap: 10px;
}

.tabswire-toc__item {
	margin: 0;
}

.tabswire-toc__link {
	align-items: center;
	color: var(--muted, #626963);
	display: flex;
	gap: 12px;
	padding-left: 0;
	text-decoration: none;
	transition: padding-left 200ms ease;
}

/* The tick — the whole of "normal mode". */
.tabswire-toc__tick {
	background: var(--n-400, #9ea5a0);
	border-radius: 2px;
	display: block;
	flex: none;
	height: 2px;
	width: 16px;
	transition: width 160ms ease, background-color 160ms ease;
}

/* Collapsed gauge: tick length signals heading depth. */
.tabswire-toc__item--l3 .tabswire-toc__tick {
	width: 10px;
}

.tabswire-toc__item--l4 .tabswire-toc__tick {
	width: 6px;
}

.tabswire-toc__link[aria-current="location"] .tabswire-toc__tick {
	background: var(--action, #078143);
	width: 26px;
}

/* The label — clipped in normal mode, revealed when expanded. */
.tabswire-toc__text {
	font-size: 0.84rem;
	line-height: 0;
	max-width: 0;
	min-width: 0;
	opacity: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	transition: max-width 220ms ease, opacity 160ms ease, line-height 180ms ease;
	white-space: nowrap;
}

.tabswire-toc__item--l3 .tabswire-toc__text {
	font-size: 0.8rem;
}

.tabswire-toc__item--l4 .tabswire-toc__text {
	color: var(--n-500, #7d847f);
	font-size: 0.78rem;
}

/* Expanded card: indent deeper levels so the hierarchy reads clearly. */
.tabswire-toc:hover .tabswire-toc__item--l3 .tabswire-toc__link,
.tabswire-toc:focus-within .tabswire-toc__item--l3 .tabswire-toc__link {
	padding-left: 16px;
}

.tabswire-toc:hover .tabswire-toc__item--l4 .tabswire-toc__link,
.tabswire-toc:focus-within .tabswire-toc__item--l4 .tabswire-toc__link {
	padding-left: 32px;
}

/* Expanded state: hover or keyboard focus within the gauge. */
.tabswire-toc:hover,
.tabswire-toc:focus-within {
	width: 272px;
	background: var(--surface, #ffffff);
	border-color: var(--border, #e1e7e3);
	box-shadow: 0 10px 34px -14px rgba(17, 21, 18, 0.22);
	padding: 16px 18px;
}

.tabswire-toc:hover .tabswire-toc__heading,
.tabswire-toc:focus-within .tabswire-toc__heading {
	margin: 0 0 12px 3px;
	max-height: 2rem;
	opacity: 1;
}

.tabswire-toc:hover .tabswire-toc__text,
.tabswire-toc:focus-within .tabswire-toc__text {
	line-height: 1.35;
	max-width: 216px;
	opacity: 1;
}

/* Shrink ticks to a neat dot beside the text when expanded. */
.tabswire-toc:hover .tabswire-toc__tick,
.tabswire-toc:focus-within .tabswire-toc__tick {
	width: 6px;
}

.tabswire-toc:hover .tabswire-toc__link[aria-current="location"] .tabswire-toc__tick,
.tabswire-toc:focus-within .tabswire-toc__link[aria-current="location"] .tabswire-toc__tick {
	width: 6px;
}

.tabswire-toc:hover .tabswire-toc__link:hover .tabswire-toc__text,
.tabswire-toc:focus-within .tabswire-toc__link:focus-visible .tabswire-toc__text {
	color: var(--heading, #212622);
}

.tabswire-toc__link[aria-current="location"] .tabswire-toc__text {
	color: var(--action, #078143);
	font-weight: 700;
}

.tabswire-toc__link:focus-visible {
	border-radius: 4px;
	outline: 2px solid var(--focus, #0ea457);
	outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
	.tabswire-toc,
	.tabswire-toc__tick,
	.tabswire-toc__text,
	.tabswire-toc__heading {
		transition: none;
	}
}
