/* Itemize Blog Template
 * Floating table of contents beside the post.
 *
 * The post body is a centered 780px column inside .itemize-post-body-wrap. The
 * rail is positioned absolute against that container, to the left of the
 * column, and the index is sticky inside the rail: it follows the article's
 * scroll and stops when the body ends, never overlapping the CTA or the footer
 * (both of which are outside that container).
 *
 * The site variables (--ink, --muted, --line, --max...) are defined by the
 * theme in itemize-footer.css; they are used here with fallbacks in case the
 * ZIP changes.
 */

/* `position:sticky` does not work if any ancestor has overflow:hidden: that
 * ancestor becomes the scroll container and the element sticks to nothing. The
 * theme sets `overflow:hidden` on `.itemize-post-template` (itemize-fse.css) to
 * clip anything overflowing. `clip` clips the same way but does NOT create a
 * scroll container, so the index can stay fixed. On an old browser without
 * `clip` the declaration is ignored, `hidden` remains and the index simply does
 * not follow the scroll: it is still visible and the links still work.
 * Scoped to the post: no page of the site is affected. */
body.itemize-blog-single .itemize-post-template {
	overflow: clip;
}

body.itemize-blog-single .itemize-post-body-wrap {
	position: relative;
}

.itemize-toc-rail {
	position: absolute;
	top: 0;
	bottom: 0;
	/* 390px = half the content column; 300px = rail width + breathing room */
	left: calc(50% - 390px - 300px);
	width: 260px;
	pointer-events: none;
}

.itemize-post-toc {
	position: sticky;
	top: 104px; /* el header del sitio es sticky y mide ~78px */
	max-height: calc(100vh - 150px);
	overflow-y: auto;
	padding: 20px 18px 18px;
	border: 1px solid var(--line, #e3eaf2);
	border-radius: 16px;
	background: #fff;
	box-shadow: 0 10px 30px rgba(10, 24, 48, .05);
	pointer-events: auto;
	overscroll-behavior: contain;
}

.itemize-toc-title {
	margin: 0 0 12px;
	color: #6f8aaa;
	font: 700 10px ui-monospace, SFMono-Regular, Consolas, monospace;
	letter-spacing: .14em;
	text-transform: uppercase;
	list-style: none;
	cursor: default;
}

.itemize-toc-title::-webkit-details-marker,
.itemize-toc-title::marker {
	display: none;
	content: "";
}

.itemize-toc-list {
	margin: 0;
	padding: 0;
	list-style: none;
	counter-reset: none;
}

.itemize-toc-item {
	margin: 0;
	padding: 0;
	list-style: none;
}

.itemize-toc-item::marker {
	content: "";
}

.itemize-toc-item > a {
	display: block;
	padding: 7px 0 7px 14px;
	border-left: 2px solid var(--line, #e3eaf2);
	color: #52627a;
	font-size: 13.5px;
	line-height: 1.4;
	text-decoration: none;
	transition: color .18s ease, border-color .18s ease;
}

.itemize-toc-item > a:hover,
.itemize-toc-item > a:focus-visible {
	color: var(--ink, #0a1830);
	border-left-color: #9cc3ee;
}

/* The section the reader is currently in (marked by the JS). */
.itemize-toc-item.is-current > a {
	color: #1268e7;
	font-weight: 700;
	border-left-color: #1268e7;
}

.itemize-toc-depth-1 > a {
	padding-left: 26px;
	font-size: 12.5px;
	color: #76869b;
}

.itemize-toc-depth-2 > a {
	padding-left: 38px;
	font-size: 12.5px;
	color: #8796ab;
}

/* So the anchor is not hidden behind the sticky header when jumping. */
body.itemize-blog-single .itemize-post-body-wrap h2[id],
body.itemize-blog-single .itemize-post-body-wrap h3[id],
body.itemize-blog-single .itemize-post-body-wrap h4[id],
body.itemize-blog-single .itemize-post-body-wrap h5[id],
body.itemize-blog-single .itemize-post-body-wrap h6[id] {
	scroll-margin-top: 100px;
}

/* Screens with no room at the side: a collapsible box above the content.
 * The JS leaves it closed in this range. */
@media (max-width: 1259px) {
	.itemize-toc-rail {
		position: static;
		left: auto;
		width: auto;
		max-width: 780px;
		margin: 0 auto 32px;
	}

	.itemize-post-toc {
		position: static;
		max-height: none;
		overflow: visible;
		padding: 14px 18px;
	}

	.itemize-toc-title {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin: 0;
		cursor: pointer;
	}

	.itemize-post-toc[open] .itemize-toc-title {
		margin-bottom: 12px;
	}

	.itemize-toc-title::after {
		content: "+";
		font-size: 15px;
		line-height: 1;
	}

	.itemize-post-toc[open] .itemize-toc-title::after {
		content: "–";
	}
}

@media (max-width: 720px) {
	.itemize-toc-rail {
		margin-bottom: 24px;
	}
}

@media print {
	.itemize-toc-rail {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.itemize-toc-item > a {
		transition: none;
	}
}
