/*!
 * Big Wall Article TOC
 * Ported from the `.toc` / `.post` / `.progress` rules in the long-form
 * article prototypes (how-seo-works.html and siblings). Values are the
 * prototype's values; only the class names and the custom properties are new.
 *
 * Big Wall gold is #fcba04. Never #facc15.
 */

:root {
	/* Palette — override any of these in the theme to re-skin the card. */
	--bwd-toc-gold: #fcba04;
	--bwd-toc-gold-hairline: rgba(252, 186, 4, 0.18);
	--bwd-toc-gold-hairline-soft: rgba(252, 186, 4, 0.1);
	--bwd-toc-gold-number: rgba(252, 186, 4, 0.55);
	--bwd-toc-navy: #1c1b4d;
	--bwd-toc-ink: #14133b;
	--bwd-toc-text: #f4f4ff;
	--bwd-toc-muted: rgba(233, 235, 255, 0.66);
	--bwd-toc-muted-soft: rgba(233, 235, 255, 0.52);

	/* Type */
	--bwd-toc-font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
	--bwd-toc-font-body: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
	--bwd-toc-font-mono: ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;

	/* Layout */
	--bwd-toc-column: 236px;
	--bwd-toc-gap: clamp(30px, 4.5vw, 72px);
	--bwd-toc-sticky-top: 34px;
	--bwd-toc-offset: 26px; /* scroll-margin; the script overwrites this with the measured header height */
	--bwd-toc-progress-height: 3px;
	--bwd-toc-progress-z: 60;
	--bwd-toc-easing: cubic-bezier(0.22, 0.9, 0.26, 1);
}

/* ── Layout ──────────────────────────────────────────────────────────────
   The prototype's `.wrap.post` grid. `align-items: start` is what makes
   position: sticky work on the grid child, so it is not optional. */
.bwd-toc-layout {
	display: grid;
	grid-template-columns: var(--bwd-toc-column) minmax(0, 1fr);
	gap: var(--bwd-toc-gap);
	align-items: start;
}

.bwd-toc-body {
	min-width: 0;
}

@media (max-width: 960px) {
	.bwd-toc-layout {
		grid-template-columns: 1fr;
		gap: 34px;
	}
}

/* ── Route card shell ────────────────────────────────────────────────── */
.bwd-toc {
	position: sticky;
	top: var(--bwd-toc-sticky-top);
	/* The script moves `top` below whatever is fixed to the top of the window
	   (admin bar, a header that slides in and out); ease that move. */
	transition: top 0.3s var(--bwd-toc-easing);
	min-width: 0;
	font-family: var(--bwd-toc-font-body);
	/* GeneratePress puts generous margins on flow children; the card sets its own. */
	margin: 0;
	padding: 0;
}

.bwd-toc,
.bwd-toc * {
	box-sizing: border-box;
}

.bwd-toc--static {
	position: static;
}

@media (max-width: 960px) {
	.bwd-toc {
		position: static;
	}
}

.bwd-toc .bwd-toc__nav {
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
}

/* ── Label ───────────────────────────────────────────────────────────── */
.bwd-toc .bwd-toc__title {
	font: 600 10.5px/1 var(--bwd-toc-font-mono);
	letter-spacing: 0.22em;
	text-transform: uppercase;
	color: var(--bwd-toc-gold);
	margin: 0 0 14px;
	padding: 0;
}

/* ── List ────────────────────────────────────────────────────────────── */
.bwd-toc .bwd-toc__list {
	list-style: none;
	margin: 0;
	padding: 0;
	border-left: 1px solid var(--bwd-toc-gold-hairline);
}

.bwd-toc .bwd-toc__list--root {
	counter-reset: bwd-toc-pitch;
}

.bwd-toc .bwd-toc__list--sub {
	border-left-color: var(--bwd-toc-gold-hairline-soft);
	margin: 0 0 4px 15px;
}

.bwd-toc .bwd-toc__item {
	list-style: none;
	margin: 0;
	padding: 0;
	text-indent: 0;
}

.bwd-toc .bwd-toc__item::marker {
	content: "";
}

/* ── Links ───────────────────────────────────────────────────────────────
   Specificity is deliberately (0,3,0) so GeneratePress' `.entry-content a`
   rules lose without needing !important. */
.bwd-toc a.bwd-toc__link {
	display: block;
	padding: 8px 0 8px 15px;
	margin-left: -1px;
	border-left: 2px solid transparent;
	border-bottom: 0;
	text-decoration: none;
	box-shadow: none;
	background: none;
	font-family: var(--bwd-toc-font-body);
	font-size: 12.5px;
	font-weight: 400;
	line-height: 1.42;
	color: var(--bwd-toc-muted);
	transition: color 0.25s, border-color 0.25s;
}

.bwd-toc a.bwd-toc__link--h2::before {
	counter-increment: bwd-toc-pitch;
	content: counter(bwd-toc-pitch, decimal-leading-zero) "  ";
	font: 600 10px/1 var(--bwd-toc-font-mono);
	letter-spacing: 0.1em;
	color: var(--bwd-toc-gold-number);
}

/* h3 rows have no precedent in the prototype: an em dash keeps the mono
   rhythm without pretending to be a numbered pitch of its own. */
.bwd-toc a.bwd-toc__link--h3 {
	padding-top: 6px;
	padding-bottom: 6px;
	font-size: 11.5px;
	color: var(--bwd-toc-muted-soft);
}

.bwd-toc a.bwd-toc__link--h3::before {
	content: "—  ";
	font: 600 10px/1 var(--bwd-toc-font-mono);
	letter-spacing: 0.1em;
	color: var(--bwd-toc-gold-number);
}

.bwd-toc a.bwd-toc__link:hover,
.bwd-toc a.bwd-toc__link:focus {
	color: var(--bwd-toc-text);
	text-decoration: none;
}

.bwd-toc a.bwd-toc__link.is-active {
	color: var(--bwd-toc-gold);
	border-left-color: var(--bwd-toc-gold);
}

.bwd-toc a.bwd-toc__link:focus {
	outline: 2px solid var(--bwd-toc-gold);
	outline-offset: 2px;
}

.bwd-toc a.bwd-toc__link:focus:not(:focus-visible) {
	outline: none;
}

.bwd-toc a.bwd-toc__link:focus-visible {
	outline: 2px solid var(--bwd-toc-gold);
	outline-offset: 2px;
}

/* ── Collapsible variant (opt-in) ────────────────────────────────────── */
.bwd-toc .bwd-toc__details {
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
}

.bwd-toc .bwd-toc__summary {
	list-style: none;
	cursor: pointer;
	display: block;
	position: relative;
	padding: 0 26px 14px 0;
	font: 600 10.5px/1 var(--bwd-toc-font-mono);
	letter-spacing: 0.22em;
	text-transform: uppercase;
	color: var(--bwd-toc-gold);
}

.bwd-toc .bwd-toc__summary::-webkit-details-marker {
	display: none;
}

.bwd-toc .bwd-toc__summary::after {
	content: "+";
	position: absolute;
	right: 4px;
	top: -4px;
	font: 400 18px/1 var(--bwd-toc-font-body);
	color: var(--bwd-toc-gold);
}

.bwd-toc .bwd-toc__details[open] > .bwd-toc__summary::after {
	content: "\2212";
}

.bwd-toc .bwd-toc__summary:focus-visible {
	outline: 2px solid var(--bwd-toc-gold);
	outline-offset: 2px;
}

@media (min-width: 961px) {
	.bwd-toc .bwd-toc__summary {
		display: none;
	}
}

/* ── Reading progress ────────────────────────────────────────────────────
   Decorative and aria-hidden. With JS off the width stays at 0 and nothing
   else on the page depends on it. */
.bwd-toc-progress {
	position: fixed;
	top: 0;
	left: 0;
	height: var(--bwd-toc-progress-height);
	width: 0;
	max-width: 100%;
	z-index: var(--bwd-toc-progress-z);
	background: var(--bwd-toc-gold);
	transition: width 0.12s linear;
	pointer-events: none;
}

/* ── Anchor landing offset ───────────────────────────────────────────────
   Covers the plain hash-jump path, which never goes through the script. */
:target {
	scroll-margin-top: var(--bwd-toc-offset);
}

.bwd-toc-body h2,
.bwd-toc-body h3,
.bwd-toc-body .pitch,
.bwd-toc-body [id] {
	scroll-margin-top: var(--bwd-toc-offset);
}

/* ── Motion ──────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
	.bwd-toc-progress {
		transition: none;
	}

	.bwd-toc a.bwd-toc__link {
		transition: none;
	}
}
