/* Table of contents of article pages (linked after article-reading.css): a pill docked at the bottom on phones and tablets, a side rail from 1100 px; the grid that holds the rail. */
@layer site {
	.toc {
		position: fixed;
		inset-inline-start: 50%;
		inset-block-end: calc(14px + env(safe-area-inset-bottom));
		z-index: 25;
		inline-size: min(420px, calc(100vw - 32px));
		transform: translate(-50%, 16px);
		opacity: 0;
		pointer-events: none;
		transition:
			opacity 200ms cubic-bezier(0.23, 1, 0.32, 1),
			transform 250ms cubic-bezier(0.23, 1, 0.32, 1);
	}
	.toc.is-shown {
		opacity: 1;
		transform: translate(-50%, 0);
		pointer-events: auto;
	}
	.toc-pill {
		display: flex;
		align-items: center;
		gap: 10px;
		inline-size: 100%;
		min-block-size: 48px;
		padding-block: 0;
		padding-inline: 18px;
		border: 1px solid var(--art-rule);
		border-radius: 999px;
		background: var(--art-surface);
		box-shadow: var(--art-shadow);
		color: var(--art-ink);
		font:
			500 15px / 1.3 "Hanken Grotesk",
			-apple-system,
			sans-serif;
		text-align: start;
		cursor: pointer;
		transition: transform 120ms cubic-bezier(0.23, 1, 0.32, 1);
	}
	.toc-pill:active {
		transform: scale(0.98);
	}
	.toc-now {
		flex: 1;
		min-inline-size: 0;
		padding-block: 8px;
		padding-inline: 0;
		text-wrap: balance;
	}
	/* An eased fade of the page ground from the docked pill's top edge down, so no line shows under it. */
	.toc::before {
		content: "";
		position: absolute;
		inset-inline-start: calc(50% - 50vw);
		inline-size: 100vw;
		inset-block-start: 0;
		inset-block-end: calc(-14px - env(safe-area-inset-bottom));
		z-index: -1;
		pointer-events: none;
		background: linear-gradient(
			transparent 0%,
			color-mix(in srgb, var(--art-bg) 2%, transparent) 6%,
			color-mix(in srgb, var(--art-bg) 8%, transparent) 12%,
			color-mix(in srgb, var(--art-bg) 18%, transparent) 18%,
			color-mix(in srgb, var(--art-bg) 32%, transparent) 24%,
			color-mix(in srgb, var(--art-bg) 48%, transparent) 30%,
			color-mix(in srgb, var(--art-bg) 65%, transparent) 36%,
			color-mix(in srgb, var(--art-bg) 80%, transparent) 42%,
			color-mix(in srgb, var(--art-bg) 91%, transparent) 48%,
			color-mix(in srgb, var(--art-bg) 98%, transparent) 54%,
			var(--art-bg) 60%
		);
	}
	.toc-pill svg {
		flex: none;
		transform: rotate(180deg);
		transition: transform 200ms cubic-bezier(0.23, 1, 0.32, 1);
	}
	.toc.is-open .toc-pill svg {
		transform: none;
	}
	.toc-title {
		display: none;
	}
	.toc-list {
		position: absolute;
		inset-inline: 0;
		inset-block-end: calc(100% + 8px);
		max-block-size: min(60vh, 440px);
		overflow-y: auto;
		overscroll-behavior: contain;
		margin: 0;
		padding: 8px;
		list-style: none;
		border: 1px solid var(--art-rule);
		border-radius: 18px;
		background: var(--art-surface);
		box-shadow: var(--art-shadow);
		opacity: 0;
		visibility: hidden;
		transform: translateY(8px) scale(0.98);
		transform-origin: 50% 100%;
		transition:
			opacity 200ms cubic-bezier(0.23, 1, 0.32, 1),
			transform 200ms cubic-bezier(0.23, 1, 0.32, 1),
			visibility 0s 200ms;
	}
	.toc.is-open .toc-list {
		opacity: 1;
		visibility: visible;
		transform: none;
		transition-delay: 0s;
	}
	.toc-list a {
		display: flex;
		align-items: center;
		min-block-size: 44px;
		text-wrap: balance;
		padding-block: 8px;
		padding-inline: 12px;
		border-radius: 10px;
		font-size: 15px;
		line-height: 1.35;
		color: var(--art-muted);
	}
	.toc-list a[aria-current="true"] {
		color: var(--art-ink);
		font-weight: 600;
		background: color-mix(in srgb, var(--art-ink) 7%, transparent);
	}
	@media (prefers-reduced-motion: reduce) {
		.toc-list {
			transform: none;
		}
	}
	@media (min-width: 1100px) {
		.article-page main {
			display: grid;
			grid-template-columns: 220px 560px;
			column-gap: 64px;
			max-inline-size: 908px;
		}
		.article-page main > .back,
		.article-page main > .reading {
			grid-column: 2;
		}
		.article-page main > .back {
			justify-self: start;
		}
		.article-page main > .footer {
			grid-column: 1 / -1;
		}
		.article-page .toc,
		.article-page .toc.is-shown {
			position: sticky;
			inset-block: 40px auto;
			grid-column: 1;
			grid-row: 2;
			align-self: start;
			justify-self: end;
			inset-inline-start: auto;
			inline-size: 220px;
			margin-block-start: 5px;
			transform: none;
			opacity: 1;
			pointer-events: auto;
		}
		.toc-pill,
		.toc::before {
			display: none;
		}
		.toc-title {
			display: block;
			margin-block: 0 8px;
			margin-inline: 14px 0;
			font-size: 13px !important;
			font-weight: 600;
			line-height: 1.4 !important;
			color: var(--art-ink) !important;
		}
		.toc-list,
		.toc.is-open .toc-list {
			position: static;
			max-block-size: calc(100vh - 120px);
			padding: 0;
			border: 0;
			border-inline-start: 1px solid var(--art-rule);
			border-radius: 0;
			background: none;
			box-shadow: none;
			opacity: 1;
			visibility: visible;
			transform: none;
		}
		.toc-list a {
			min-block-size: 0;
			padding-block: 7px;
			padding-inline: 12px;
			margin-inline-start: -1px;
			border-inline-start: 2px solid transparent;
			border-radius: 0;
			font-size: 14px;
		}
		.toc-list a[aria-current="true"] {
			background: none;
			border-inline-start-color: var(--blue-secondary);
		}
	}
	@media (max-width: 640px) {
		.article-page main {
			padding-block-end: 96px;
		}
		.article-page .reading > h1 {
			margin-block-start: 8px;
		}
		.byline {
			gap: 8px 16px;
		}
	}
}
