/* Site styles using Stellar CSS tokens */

* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

body {
	font-family: var(--font-sans);
	background: var(--neutral-1);
	color: var(--neutral-12);
	line-height: var(--font-line-height-1);
	min-height: 100dvh;
	display: flex;
}

a {
	color: var(--tertiary-6);
	text-decoration: none;
}

a:hover {
	text-decoration: underline;
}

/* In running prose, links need a non-color cue (WCAG 1.4.1) — color alone
   doesn't distinguish them for color-blind readers. Nav/card links stay
   underline-on-hover. */
.post-body a {
	text-decoration: underline;
	text-decoration-color: color-mix(in oklch, currentColor 45%, transparent);
	text-underline-offset: 0.15em;
}

/* Screen-reader-only content */
.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* Keyboard users skip the fixed sidebar nav (~8 tab stops) straight to main */
.skip-link {
	position: fixed;
	top: var(--size-1);
	left: var(--size-1);
	z-index: 100;
	padding: var(--size-0) var(--size-1);
	background: var(--neutral-2);
	border: var(--border-width-0) solid var(--primary-7);
	border-radius: var(--border-radius-1);
	transform: translateY(-200%);
}

.skip-link:focus {
	transform: none;
}

@media (prefers-reduced-motion: reduce) {
	*,
	::before,
	::after {
		transition-duration: 0.01ms !important;
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		scroll-behavior: auto !important;
	}

	.slide-figures figure img:hover {
		transform: none;
	}
}

/* Sidebar — RIA Pulse pattern: fixed nav + margin-based layout */

.sidebar {
	/* Hide on mobile until Datastar initializes (prevents flash) */
	&:not([data-sidebar-initialized]) {
		@media (width < 48rem) {
			display: none;
		}
	}

	/* Mobile overlay backdrop */
	&[aria-hidden="false"] {
		@media (width < 48rem) {
			position: fixed;
			inset: 0;
			z-index: 40;
			background: rgba(0, 0, 0, 0.4);
		}
	}
}

.sidebar-nav {
	position: fixed;
	inset-block: 0;
	left: 0;
	width: 14rem;
	z-index: 50;
	background: var(--neutral-2);
	border-right: var(--border-width-0) solid var(--neutral-4);
	display: flex;
	flex-direction: column;
	transition: transform 0.3s ease-in-out;
}

/* Closed: slide nav off-screen */
.sidebar[aria-hidden="true"] .sidebar-nav {
	transform: translateX(-100%);
}

/* Main content: margin tracks sidebar on desktop */
.sidebar + .main-wrapper {
	transition: margin-left 0.3s ease-in-out;
	@media (width >= 48rem) {
		margin-left: 14rem;
	}
}

.sidebar[aria-hidden="true"] + .main-wrapper {
	@media (width >= 48rem) {
		margin-left: 0;
	}
}

.sidebar-header {
	padding: var(--size-2) var(--size-2);
}

.site-title {
	font-family: var(--font-mono);
	font-size: var(--font-size-3);
	font-weight: var(--font-weight-bold);
	color: var(--neutral-12);
}

.site-title:hover {
	text-decoration: none;
	color: var(--primary-9);
}

.sidebar-links {
	list-style: none;
	flex: 1;
	padding: var(--size-1) 0;
}

.sidebar-links li a,
.sidebar-links li .sidebar-link-btn {
	display: flex;
	align-items: center;
	gap: var(--size-1);
	padding: var(--size-1) var(--size-2);
	color: var(--neutral-11);
	font-size: var(--font-size-1);
	text-decoration: none;
	border: none;
	background: none;
	width: 100%;
	cursor: pointer;
	font-family: var(--font-sans);
}

.sidebar-links li a:hover,
.sidebar-links li .sidebar-link-btn:hover {
	background: var(--neutral-3);
	color: var(--primary-9);
	text-decoration: none;
}

.sidebar-links svg {
	width: 1.1em;
	height: 1.1em;
	flex-shrink: 0;
}

.sidebar-footer {
	padding: var(--size-2);
	border-top: var(--border-width-0) solid var(--neutral-4);
}


/* Content header with sidebar toggle */
.content-header {
	padding: var(--size-1) var(--size-2);
	position: sticky;
	top: 0;
	z-index: var(--z-header);
	background: linear-gradient(
		to bottom,
		color-mix(in oklch, var(--neutral-1) 70%, transparent) 0%,
		color-mix(in oklch, var(--neutral-1) 55%, transparent) 60%,
		color-mix(in oklch, var(--neutral-1) 30%, transparent) 100%
	);
	backdrop-filter: blur(14px) saturate(1.4);
	-webkit-backdrop-filter: blur(14px) saturate(1.4);
}

.sidebar-toggle {
	background: none;
	border: none;
	cursor: pointer;
	color: var(--neutral-8);
	padding: var(--size-0);
	display: flex;
	align-items: center;
}

.sidebar-toggle:hover {
	color: var(--neutral-12);
}

.sidebar-toggle svg {
	width: 1.25em;
	height: 1.25em;
}

/* Main wrapper */

.main-wrapper {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-height: 100dvh;
	min-width: 0;
}

main.content {
	max-width: 48rem;
	margin: 0 auto;
	padding: var(--size-4) var(--size-3);
	width: 100%;
	flex: 1;
}

/* Skip-link target: focusable programmatically, but a page-sized focus ring
   helps no one. */
main.content:focus {
	outline: none;
}

@media (width < 48rem) {
	main.content {
		padding-top: var(--size-2);
	}
}

/* Theme toggle */

.theme-toggle {
	background: none;
	border: var(--border-width-0) solid var(--neutral-4);
	border-radius: var(--border-radius-1);
	padding: var(--size-0) var(--size-1);
	cursor: pointer;
	color: var(--neutral-11);
	font-size: var(--font-size-0);
	display: flex;
	align-items: center;
	gap: var(--size-0);
}

.theme-toggle:hover {
	border-color: var(--primary-7);
	color: var(--primary-9);
}

.theme-toggle svg {
	width: 1em;
	height: 1em;
	display: none;
}

[data-theme="light"] .theme-icon-light,
[data-theme="dark"] .theme-icon-dark,
[data-theme="auto"] .theme-icon-auto {
	display: block;
}

/* Post cards */

.post-card {
	padding: var(--size-2) 0;
	border-bottom: var(--border-width-0) solid var(--neutral-3);
}

.post-card:last-child {
	border-bottom: none;
}

.post-card h2 {
	font-size: var(--font-size-2);
	margin-bottom: var(--size-0);
}

.post-card .meta {
	color: var(--neutral-7);
	font-size: var(--font-size-0);
	margin-bottom: var(--size-0);
}

.post-card .excerpt {
	color: var(--neutral-10);
}

.tag {
	display: inline-block;
	color: var(--secondary-7); /* secondary-5 measured ~2:1 contrast — invisible */
	padding: 0.1em 0.5em;
	font-size: var(--font-size-0);
}

/* Landing page */

.landing {
	margin-top: var(--size-4);
}

.landing p {
	font-size: var(--font-size-2);
	margin-bottom: var(--size-2);
}

/* Search overlay */

.search-overlay {
	position: fixed;
	inset: 0;
	z-index: var(--z-overlay);
}

.search-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.4);
}

.search-dialog {
	position: relative;
	max-width: 36rem;
	margin: 10vh auto 0;
	background: var(--neutral-1);
	border: var(--border-width-0) solid var(--neutral-4);
	border-radius: var(--border-radius-1);
	box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
	display: flex;
	flex-direction: column;
	max-height: 70vh;
	overflow: hidden;
}

@media (width < 48rem) {
	.search-dialog {
		margin: var(--size-2);
		max-width: none;
		max-height: calc(100dvh - var(--size-4));
	}
}

.search-input-row {
	display: flex;
	align-items: center;
	border-bottom: var(--border-width-0) solid var(--neutral-4);
}

/* Visible focus cue for the search input (its own outline is suppressed) */
.search-input-row:focus-within {
	border-bottom-color: var(--primary-7);
}

.search-spinner {
	padding: 0 var(--size-1);
	opacity: 0;
	transition: opacity 0.15s;
}

.search-spinner.active {
	opacity: 1;
}

.search-spinner svg {
	width: 1.2em;
	height: 1.2em;
	color: var(--neutral-8);
}

.search-dialog input[type="search"] {
	width: 100%;
	flex: 1;
	padding: var(--size-2);
	border: none;
	border-radius: 0;
	background: transparent;
	color: var(--neutral-12);
	font-size: var(--font-size-2);
	font-family: var(--font-sans);
}

.search-dialog input[type="search"]:focus {
	outline: none;
	box-shadow: none;
}

.search-dialog input[type="search"]::placeholder {
	color: var(--neutral-8);
}

#search-results {
	overflow-y: auto;
	flex: 1;
}

.search-hint {
	padding: var(--size-2);
	color: var(--neutral-8);
	text-align: center;
}

.search-result {
	display: block;
	padding: var(--size-1) var(--size-2);
	border-bottom: var(--border-width-0) solid var(--neutral-3);
	color: var(--neutral-12);
	text-decoration: none;
}

.search-result:hover {
	background: var(--neutral-2);
	text-decoration: none;
}

.search-result:last-child {
	border-bottom: none;
}

.search-result-header {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: var(--size-1);
}

.search-result-title {
	font-weight: var(--font-weight-bold);
}

.search-result-kind {
	font-size: var(--font-size-0);
	color: var(--neutral-8);
	text-transform: uppercase;
	letter-spacing: 0.05em;
	flex-shrink: 0;
}

.search-result-snippet {
	display: block;
	font-size: var(--font-size-0);
	color: var(--neutral-10);
	margin-top: 0.2em;
}

.search-result-snippet mark,
.search-result-meta .tag mark {
	background: var(--primary-3);
	color: var(--neutral-12);
	border-radius: 2px;
	padding: 0 0.15em;
}

.search-result-meta {
	margin-top: 0.3em;
	font-size: var(--font-size-0);
	color: var(--neutral-8);
	display: flex;
	align-items: center;
	gap: var(--size-0);
}

.search-footer {
	padding: var(--size-0) var(--size-2);
	border-top: var(--border-width-0) solid var(--neutral-4);
	font-size: var(--font-size-0);
	color: var(--neutral-8);
	display: flex;
	gap: var(--size-2);
}

.search-footer kbd {
	background: var(--neutral-3);
	border: var(--border-width-0) solid var(--neutral-5);
	border-radius: var(--border-radius-0);
	padding: 0 0.4em;
	font-family: var(--font-mono);
	font-size: 0.85em;
}

/* Post content */

.post-body h1 { font-size: var(--font-size-5); margin: var(--size-3) 0 var(--size-1); }
.post-body h2 { font-size: var(--font-size-4); margin: var(--size-3) 0 var(--size-1); }
.post-body h3 { font-size: var(--font-size-3); margin: var(--size-2) 0 var(--size-0); }
.post-body p { margin-bottom: var(--size-2); }
.post-body ul, .post-body ol { margin-bottom: var(--size-2); padding-left: var(--size-3); }
.post-body li { margin-bottom: var(--size-2); }
.post-body li > ul, .post-body li > ol { margin-bottom: 0; margin-top: var(--size-1); }

/* Figures center their content (img / svg) within the column. */
.post-body figure { margin-left: auto; margin-right: auto; text-align: center; }
.post-body figure img { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.post-body figcaption { text-align: center; font-size: var(--font-size--1); color: var(--neutral-11); margin-top: var(--size-1); }

/* Inline diagrams (hand-coded SVG) */
.post-body figure svg.diagram { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.post-body .diagram text { font-family: var(--font-mono); font-size: 14px; fill: currentColor; }
.post-body .diagram .dlabel { font-style: italic; opacity: 0.7; font-size: 13px; }
.post-body .diagram .dhd { font-weight: 600; opacity: 0.7; font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; }
.post-body .diagram .dnote { font-style: italic; opacity: 0.6; font-size: 11px; }
.post-body .diagram .dbox { stroke: currentColor; stroke-width: 1.5; fill: none; }
.post-body .diagram .dgrid { stroke: currentColor; stroke-opacity: 0.35; stroke-width: 1; fill: none; }
.post-body .diagram .dhi { fill: var(--tertiary-6); fill-opacity: 0.28; }
.post-body .diagram .darrow { stroke: currentColor; stroke-opacity: 0.55; stroke-width: 1.5; fill: none; }

/* Tufte-style sidenotes — pulled into the right margin on wide viewports.
   On narrower viewports they hide, and the footnotes section at the bottom
   takes over. */
.post-body .sidenote { display: none; }
.post-body sup a { text-decoration: none; }

@media (width >= 88rem) {
	.post-body .sidenote {
		display: block;
		float: right;
		clear: right;
		width: 12rem;
		margin-right: -13rem;
		margin-left: 1rem;
		margin-top: 0.3rem;
		margin-bottom: 0.6rem;
		padding-left: 0.6rem;
		border-left: 2px solid var(--tertiary-6);
		font-size: 0.82em;
		line-height: 1.4;
		color: var(--neutral-10);
	}
	.post-body .sidenote-num {
		color: var(--tertiary-7);
		font-weight: 700;
		margin-right: 0.25em;
	}
	.post-body .footnotes-section { display: none; }
}

.post-body ol.footnotes {
	counter-reset: footnote;
	padding-left: 0;
	list-style: none;
}
.post-body ol.footnotes > li {
	counter-increment: footnote;
	position: relative;
	padding-left: 2rem;
}
.post-body ol.footnotes > li::before {
	content: counter(footnote) ".";
	position: absolute;
	left: 0;
	color: var(--tertiary-7);
	font-weight: 700;
}

/* Wider viewports: roomier sidenote */
@media (width >= 100rem) {
	.post-body .sidenote {
		width: 15rem;
		margin-right: -16rem;
	}
}
.post-body pre {
	background: var(--neutral-2);
	padding: var(--size-2);
	border-radius: var(--border-radius-1);
	overflow-x: auto;
	margin-bottom: var(--size-2);
	font-family: var(--font-mono);
	font-size: var(--font-size-0);
}
.post-body code {
	font-family: var(--font-mono);
	font-size: 0.9em;
}
.post-body blockquote {
	border-left: 3px solid var(--primary-7);
	padding-left: var(--size-2);
	color: var(--neutral-10);
	margin-bottom: var(--size-2);
}

/* 404 page — tongue-in-cheek geocities-counter vibe */

.notfound {
	text-align: center;
	padding-block: var(--size-4);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--size-2);
}

.notfound-code {
	font-family: var(--font-mono);
	font-size: clamp(6rem, 22vw, 14rem);
	font-weight: var(--font-weight-bold);
	line-height: 1;
	letter-spacing: -0.05em;
	color: var(--primary-9);
	margin-block-end: var(--size-1);
}

.notfound h1 {
	font-size: var(--font-size-3);
	color: var(--neutral-12);
}

.notfound-path {
	color: var(--neutral-10);
	font-size: var(--font-size-1);
}

.notfound-path code {
	font-family: var(--font-mono);
	background: var(--neutral-3);
	padding: 0.15em 0.4em;
	border-radius: var(--border-radius-0);
	color: var(--neutral-12);
}

.notfound-blurb {
	color: var(--neutral-10);
	max-width: 32rem;
}

.notfound-counter {
	margin-block-start: var(--size-3);
}

.hit-counter {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	gap: var(--size-1);
	padding: var(--size-2) var(--size-3);
	border: var(--border-width-0) solid var(--neutral-4);
	border-radius: var(--border-radius-1);
	background: var(--neutral-2);
}

.hit-counter-label {
	font-size: var(--font-size-0);
	color: var(--neutral-8);
	text-transform: uppercase;
	letter-spacing: 0.12em;
}

.hit-counter-digits {
	font-family: var(--font-mono);
	font-size: var(--font-size-5);
	font-weight: var(--font-weight-bold);
	letter-spacing: 0.1em;
	color: var(--primary-9);
	background: var(--neutral-3);
	padding: var(--size-1) var(--size-2);
	border-radius: var(--border-radius-0);
	box-shadow: inset 0 1px 3px color-mix(in oklch, var(--neutral-12) 20%, transparent);
}

.notfound-back {
	margin-block-start: var(--size-2);
	font-size: var(--font-size-1);
}

/* Stats page */

.stats-loading {
	color: var(--neutral-8);
	padding: var(--size-3) 0;
	text-align: center;
}

.stats-header {
	margin-block-end: var(--size-3);
}

.stats-header h1 {
	font-size: var(--font-size-4);
	margin-block-end: var(--size-0);
}

.stats-since {
	color: var(--neutral-8);
	font-size: var(--font-size-0);
	font-family: var(--font-mono);
}

.stats-since-rel {
	color: var(--neutral-7);
	margin-inline-start: var(--size-0);
}

.stats-tiles {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
	gap: var(--size-2);
	margin-block-end: var(--size-4);
}

.stat-tile {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--size-0);
	padding: var(--size-2);
	border: var(--border-width-0) solid var(--neutral-4);
	border-radius: var(--border-radius-1);
	background: var(--neutral-2);
}

.stat-tile--live {
	border-color: var(--primary-7);
	background: color-mix(in oklch, var(--primary-3) 30%, var(--neutral-2));
}

.stat-tile-num {
	font-family: var(--font-mono);
	font-size: var(--font-size-5);
	font-weight: var(--font-weight-bold);
	color: var(--neutral-12);
	line-height: 1;
}

.stat-tile--live .stat-tile-num {
	color: var(--primary-9);
}

.stat-tile-label {
	font-size: var(--font-size-0);
	color: var(--neutral-9);
	text-transform: uppercase;
	letter-spacing: 0.08em;
}

.stats-tops {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
	gap: var(--size-3);
}

.stats-top h2 {
	font-size: var(--font-size-1);
	color: var(--neutral-10);
	margin-block-end: var(--size-1);
	font-weight: var(--font-weight-bold);
	text-transform: uppercase;
	letter-spacing: 0.08em;
}

.stats-list {
	list-style: none;
	padding: 0;
	margin: 0;
}

.stats-list li {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: var(--size-1);
	padding: var(--size-0) 0;
	border-bottom: var(--border-width-0) solid var(--neutral-3);
	font-size: var(--font-size-1);
}

.stats-list li:last-child {
	border-bottom: none;
}

.stats-list-name {
	font-family: var(--font-mono);
	color: var(--neutral-11);
	overflow-wrap: anywhere;
	min-width: 0;
}

.stats-list-count {
	font-family: var(--font-mono);
	color: var(--primary-9);
	font-weight: var(--font-weight-bold);
	flex-shrink: 0;
}

.stats-empty {
	color: var(--neutral-7);
	font-style: italic;
	padding: var(--size-1) 0;
}

/* Talks */

/* Talk grid */

.talk-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
	gap: var(--size-3);
	margin-top: var(--size-2);
}

.talk-card {
	display: flex;
	flex-direction: column;
	border: var(--border-width-0) solid var(--neutral-4);
	border-radius: var(--border-radius-1);
	overflow: hidden;
	color: var(--neutral-12);
	text-decoration: none;
	transition: border-color 0.15s, box-shadow 0.15s;
}

.talk-card:hover {
	border-color: var(--primary-7);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
	text-decoration: none;
}

.talk-card-logo {
	aspect-ratio: 3 / 2;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--neutral-2);
	padding: var(--size-2);
}

.talk-card-logo img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;

	.dark & {
		filter: invert(1);
	}
}

.talk-card-logo--empty {
	background: var(--neutral-3);
}

.talk-card-body {
	padding: var(--size-2);
}

.talk-card-body h2 {
	font-size: var(--font-size-1);
	margin-bottom: var(--size-0);
	line-height: 1.3;
}

.talk-card-body time {
	font-size: var(--font-size-0);
	color: var(--neutral-7);
}

/* When talk is active, go full viewport */
.talk-shell {
	background: var(--neutral-1);
	color: var(--neutral-12);
	flex: 1;
	display: flex;
	flex-direction: column;
}

main.content:has(.talk-shell) {
	max-width: none;
	padding: 0;
	display: flex;
	flex-direction: column;
}

main.content:has(.talk-grid) {
	max-width: none;
}


.talk-viewport {
	width: 100%;
	flex: 1;
	position: relative;
	overflow: hidden;
	/* Letterbox: center the fixed-aspect stage; size container so the stage
	   can size itself against the viewport via cq units. */
	container-type: size;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* Slides
 *
 * Slides render on a fixed 16:9 stage letterboxed into whatever window shape
 * is available, like a real presentation. All type/spacing inside the slide is
 * sized in container-query units of the stage, so a slide looks IDENTICAL on a
 * 4K monitor, an old 1024x768 projector, and the print/PDF view (print.templ's
 * 1280x720 .print-page picks up the same container) — only bigger or smaller.
 * Portrait screens (phones) drop the stage for a scrollable reading mode; see
 * the orientation media query at the end of this section. */

.talk-viewport > .slide {
	width: min(100cqw, calc(100cqh * 16 / 9));
	aspect-ratio: 16 / 9;
}

.slide {
	container: stage / size;
	padding: 4% 6%;
	display: flex;
	flex-direction: column;

	/* Stage-relative type scale. 1cqw = 1% of stage width (= 16/9 cqh, since
	   the aspect is locked). Values chosen to match the old rem/vw sizes at a
	   1280px-wide stage. */
	--slide-fs-h1: 10cqw;
	--slide-fs-h2: 7cqw;
	--slide-fs-h3: 2.6cqw;
	--slide-fs-text: 2.5cqw;
	--slide-fs-quote: 2.4cqw;
	--slide-fs-small: 1.25cqw;
	--slide-fs-fine: 1.4cqw;
	--slide-img-h: 55cqh;
	--slide-measure: 65cqw;
}

.slide > .slide-row,
.slide > .slide-body {
	margin-block: auto;
}

.slide > .slide-body {
	max-width: var(--slide-measure);
}

.slide > p, .slide > ul:not(.bibliography), .slide > ol:not(.bibliography) {
	max-width: var(--slide-measure);
}

/* h1 is reserved for slide-cover so the raw talk html pages are still valid-ish html w/o h* clobbers */

.slide h2 {
	font-size: var(--slide-fs-h2);
	margin-bottom: 0.1em;
}

.slide h3 {
	font-size: var(--slide-fs-h3);
	margin-bottom: 0.5em;
	color: var(--neutral-10);
	margin-top: 0.4em;
}

.slide p, .slide li {
	font-size: var(--slide-fs-text);
	line-height: var(--font-line-height-7);
}

.slide ul, .slide ol {
	padding-left: 1em;
	margin-bottom: 0.5em;
}

.slide li {
	margin-bottom: 0.7em;
}


.slide a {
	color: var(--tertiary-6);
}

/* Cover slide */
.slide-cover {
	text-align: center;
	justify-content: center;
	align-items: center;
}

.slide-cover h1 {
	font-size: var(--slide-fs-h1);
}

/* Center layout */
.slide-center {
	text-align: center;
	align-items: center;
}

/* A .slide-row inside a center slide is just a figure wrapper: give it the
   slide's remaining height (flex:1) and stretch the figure to fill it, so the
   image's max-height:100% resolves against a real box (same mechanism as a
   figure placed directly under .slide). */
.slide-center > .slide-row {
	flex: 1;
	min-height: 0;
	width: 100%;
	display: flex;
	justify-content: center;
}

/* Quote-driven slides: text-only, centered, larger type */
.slide-quote {
	text-align: center;
	align-items: center;
}

.slide-quote blockquote,
.slide-quote p,
.slide-quote li {
	font-size: var(--slide-fs-quote);
	line-height: 1.5;
}

.slide-quote cite {
	display: block;
	font-style: italic;
	font-size: 0.7em;
	color: var(--neutral-7);
	margin-top: 0.3em;
	font-weight: normal;
}

/* Next-token prediction tables */
.token-pred {
	border-collapse: collapse;
	margin: 0 auto;
	font-family: var(--font-family-mono, monospace);
	font-size: var(--slide-fs-text);
}

.token-pred td {
	padding: 0.4em 0.9em;
	border: 1px solid var(--neutral-7);
	text-align: center;
}

.token-pred .subject {
	color: var(--error-6);
}

.token-pred td:empty,
.token-pred .empty {
	border: 0;
	padding: 0;
}

.token-pred .pred {
	text-align: left;
	color: var(--tertiary-6);
}

.token-pred .prob {
	text-align: right;
	color: var(--neutral-5);
	font-variant-numeric: tabular-nums;
}

.token-pred tr:first-child .pred,
.token-pred tr:first-child .prob {
	font-weight: bold;
}

/* Side-by-side: heading top, body left, figure right */
.slide-side {
	flex-direction: column;
}

.slide-side > .slide-row {
	flex: 1;
	display: flex;
	gap: 4vw;
	align-items: center;
}

.slide-side > .slide-row > .slide-body {
	flex: 1;
}

.slide-side > .slide-row > figure {
	flex: 1;
}

/* Figures in slides */
.slide figure {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 0;
}

.slide figure img, .slide img {
	max-width: 100%;
	max-height: var(--slide-img-h);
	object-fit: contain;
	border-radius: var(--border-radius-1);
}

/* Center-layout figures are the full-width sole content of the slide, so their
   image should fill the flex box the layout grants — not a fixed viewport
   fraction. A hard 55vh cap can exceed that box on wide-but-short screens (old
   projectors, landscape phones): the image then overflowed and spilled over the
   heading above and footnote below. max-height:100% ties it to the real box.
   (slide-side/slide-figures images stay capped at 55vh/45vh — their figures are
   sized by content, not a definite flex box, so a % height has nothing to
   resolve against.) */
.slide-center figure img {
	max-height: 100%;
}

.slide figure.molecule img {
	border-radius: 0;

	.dark & {
		filter: invert(1) hue-rotate(180deg);
	}
}

.slide figcaption {
	text-align: center;
	font-size: var(--slide-fs-small);
	color: var(--neutral-7); /* neutral-6 fails WCAG AA (~3.2:1) at this size */
	margin-top: 0.5em;
}

/* Side-by-side figure pairs */
.slide-figures {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: var(--size-3);
	align-items: center;
	margin-block: auto;
	width: 100%;
}

.slide-figures figure img {
	max-height: 45cqh;
	transition: transform 0.2s ease;
	cursor: zoom-in;
}

.slide-figures figure img:hover {
	transform: scale(1.4);
	position: relative;
	z-index: 10;
}

/* Definition grid — for cards-of-definitions slide layouts */
.slide-defs {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: var(--size-3);
	margin-block: auto;
	width: 100%;
}

.slide-defs > div {
	padding: var(--size-2);
}

.slide-defs dt {
	font-weight: 600;
	margin-bottom: var(--size-1);
}

.slide-defs dd {
	margin: 0;
	font-size: var(--slide-fs-fine);
}

/* Tables in slides — covers stray TableGenerator tg-* classes */
.slide table {
	border-collapse: collapse;
	margin: 0.8em auto;
	font-size: var(--slide-fs-fine);
}

.slide table th,
.slide table td {
	padding: var(--size-1) var(--size-2);
	border: var(--border-width-0) solid var(--neutral-7);
	text-align: left;
	vertical-align: top;
}

.slide table th,
.slide table .tg-head,
.slide table .tg-row-head {
	background: var(--neutral-3);
	font-weight: 600;
}

/* List items in table cells. Two quirks to normalize: (a) Stellar's reset
   strips markers from every <ul>, so nested <ul><li> cells lost their bullets
   while (b) bare <li> dropped straight into a <td> (a TableGenerator export
   quirk, no <ul>) escaped the reset and showed bullets — hanging left onto the
   gridline. Re-assert a disc marker on both, positioned inside so it can't
   collide with the cell border. Scoped to tables; body lists elsewhere stay
   deliberately marker-less. */
.slide table li {
	list-style-type: disc;
	list-style-position: inside;
	margin-bottom: 0.2em;
	/* Match the cell's table font size — .slide li otherwise forces body size,
	   making bulleted cells tower over plain ones in the same table. */
	font-size: inherit;
	line-height: 1.35;
}

/* Slide controls — visible on hover */
.slide-controls {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--size-2);
	padding: var(--size-2);
	opacity: 0;
	transition: opacity 0.2s;
}

.talk-viewport:hover .slide-controls,
.talk-viewport:focus-within .slide-controls {
	opacity: 1;
}

/* No hover on touch devices: keep the controls visible (landscape; portrait
   has its own sticky treatment below), on a translucent strip for legibility
   over slide content. */
@media (hover: none) {
	.slide-controls {
		opacity: 1;
		background: color-mix(in oklch, var(--neutral-1) 70%, transparent);
		backdrop-filter: blur(8px);
	}
}

.slide-control {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 2.5rem;
	height: 2.5rem;
	border-radius: var(--border-radius-1);
	color: var(--neutral-8);
	text-decoration: none;
	transition: color 0.15s, background 0.15s;
}

.slide-control:hover {
	color: var(--neutral-12);
	background: var(--neutral-3);
	text-decoration: none;
}

.slide-control.disabled {
	visibility: hidden;
}

.slide-control svg {
	width: 1.25em;
	height: 1.25em;
}

.slide-counter {
	font-size: var(--font-size-0);
	color: var(--neutral-7);
	font-family: var(--font-mono);
}

/* Overview grid */
.talk-overview {
	padding: var(--size-4) var(--size-3);
}

.talk-overview h1 {
	font-size: var(--font-size-4);
	margin-bottom: var(--size-1);
}

.talk-overview-meta {
	font-size: var(--font-size-0);
	color: var(--neutral-7);
	margin-bottom: var(--size-3);
}

.slide-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
	gap: var(--size-3);
}

.slide-thumb {
	display: block;
	border: var(--border-width-0) solid var(--neutral-4);
	border-radius: var(--border-radius-1);
	overflow: hidden;
	text-decoration: none;
	color: var(--neutral-12);
	transition: border-color 0.15s, box-shadow 0.15s;
}

.slide-thumb:hover {
	border-color: var(--primary-7);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
	text-decoration: none;
}

.slide-thumb-content {
	aspect-ratio: 16 / 9;
	padding: var(--size-2);
	overflow: hidden;
	pointer-events: none;
	font-size: 0.45rem;
	position: relative;
}

/* Thumbnail overrides — no .slide class on thumbs, just tame the content */
.slide-thumb-content .slide-row {
	display: flex;
	gap: 0.3rem;
}

.slide-thumb-content .slide-body,
.slide-thumb-content .slide-row,
.slide-thumb-content figure {
	margin-block: 0;
	flex: initial;
	min-height: 0;
}

.slide-thumb-content .slide-footnotes {
	display: none;
}

.slide-thumb-content h1 { font-size: clamp(0.6rem, 1.5vw, 0.9rem); margin-bottom: 0.2em; }
.slide-thumb-content h2 { font-size: clamp(0.5rem, 1.2vw, 0.7rem); margin-bottom: 0.1em; }
.slide-thumb-content h3 { font-size: clamp(0.45rem, 1vw, 0.6rem); margin-bottom: 0.1em; }
.slide-thumb-content p, .slide-thumb-content li { font-size: 0.4rem; line-height: 1.3; }
.slide-thumb-content ul, .slide-thumb-content ol { padding-left: 0.5rem; margin-bottom: 0.1em; }
.slide-thumb-content img { max-height: 4rem; max-width: 100%; object-fit: contain; }

.slide-thumb-number {
	display: block;
	padding: var(--size-0) var(--size-1);
	font-size: var(--font-size-0);
	color: var(--neutral-7);
	font-family: var(--font-mono);
	border-top: var(--border-width-0) solid var(--neutral-3);
}

/* Click-reveal lists */
.clicks {
	list-style: none;
	padding-left: 0;
}

/* Safety valve: a slide whose content genuinely exceeds the stage (dense old
   decks, bibliographies, image galleries) scrolls instead of clipping. Slides
   that fit are unaffected — their centered layout has no overflow. */
.slide {
	overflow-y: auto;
	position: relative;
}

/* Scroll affordance: an over-full slide otherwise looks complete, giving no
   hint there's more below the fold. A sticky bottom fade signals "keep
   scrolling" and disappears at the end via a scroll-driven animation. Behind
   @supports so browsers without scroll-timelines simply get no fade (rather
   than one stuck on permanently). The pseudo-element uses negative margin so it
   overlays content instead of adding height, and a high order so it sits after
   the footnotes (which carry order:99). */
@supports (animation-timeline: scroll()) {
	.slide::after {
		content: "";
		order: 100;
		position: sticky;
		bottom: 0;
		align-self: stretch;
		height: 3em;
		margin-top: -3em;
		pointer-events: none;
		background: linear-gradient(transparent, var(--neutral-1));
		/* Base = invisible, so slides that fit (inactive scroll timeline) show
		   nothing. When the slide actually scrolls the timeline drives opacity
		   from 1 at the top to 0 at the bottom — present until you reach the
		   end. */
		opacity: 0;
		animation: slide-scroll-fade linear;
		animation-timeline: scroll(self block);
	}

	@keyframes slide-scroll-fade {
		from { opacity: 1; }
		to { opacity: 0; }
	}
}

.bibliography {
	columns: 3;
	column-gap: var(--size-3);
	font-size: var(--slide-fs-small);
	line-height: 1.4;
	padding-left: var(--size-3);
	width: 100%;
}

.bibliography li {
	margin-bottom: 0.5em;
	break-inside: avoid;
	font-size: var(--slide-fs-small);
}

.slide-footnotes {
	margin-top: auto;
	padding-top: var(--size-1);
	border-top: var(--border-width-0) solid var(--neutral-8);
	order: 99;
	text-align: right;
}

/* Everything in a footnote block is footnote-sized, not just <small>. Some
   older slides put a <ul> of source links here, which otherwise rendered at
   body size and pushed the slide off the stage. neutral-7 not neutral-6: the
   lighter gray fails WCAG AA (~3.2:1) at footnote size. */
.slide-footnotes,
.slide-footnotes small,
.slide-footnotes p,
.slide-footnotes li {
	color: var(--neutral-7);
	font-size: var(--slide-fs-small);
}

.slide-footnotes li {
	margin-bottom: 0.2em;
}

/* Portrait (phones): the 16:9 stage would render slides as an unreadable
   thumbnail, so drop the stage entirely and become a document — normal flow,
   rem-based type, side-by-side rows stacked, the whole slide scrollable. */
@media (orientation: portrait) {
	.talk-viewport {
		display: block;
		overflow-y: auto;
	}

	.talk-viewport > .slide {
		width: 100%;
		aspect-ratio: auto;
		min-height: 100%;
		container-type: normal;
		/* extra bottom clearance for the sticky slide-controls bar */
		padding: var(--size-2) var(--size-2) 5rem;

		--slide-fs-h1: var(--font-size-8);
		--slide-fs-h2: var(--font-size-7);
		--slide-fs-h3: var(--font-size-3);
		--slide-fs-text: var(--font-size-1);
		--slide-fs-quote: var(--font-size-2);
		--slide-fs-small: var(--font-size-0);
		--slide-fs-fine: var(--font-size-0);
		--slide-img-h: 45vh;
		--slide-measure: 100%;
	}

	.talk-viewport .slide-side > .slide-row {
		flex-direction: column;
		align-items: stretch;
	}

	.talk-viewport .slide-figures,
	.talk-viewport .slide-defs {
		grid-template-columns: 1fr;
	}

	.talk-viewport .slide-figures figure img {
		max-height: 40vh;
	}

	.talk-viewport .bibliography {
		columns: 1;
	}

	/* No hover on touch: keep controls visible, riding the bottom of the
	   scrollable viewport. */
	.talk-viewport .slide-controls {
		position: sticky;
		bottom: 0;
		opacity: 1;
		background: color-mix(in oklch, var(--neutral-1) 80%, transparent);
		backdrop-filter: blur(8px);
	}
}

/* Recipes */

.recipes-intro {
	color: var(--neutral-7);
	font-size: var(--font-size-0);
	margin-bottom: var(--size-3);
}

.recipe-group {
	margin-bottom: var(--size-3);
}

.recipe-group h2 {
	font-size: var(--font-size-2);
	margin-bottom: var(--size-1);
}

.recipe-links {
	list-style: none;
	padding: 0;
}

.recipe-links li {
	padding: var(--size-0) 0;
	border-bottom: var(--border-width-0) solid var(--neutral-3);
	display: flex;
	justify-content: space-between;
	gap: var(--size-1);
	flex-wrap: wrap;
}

.recipe-links li:last-child {
	border-bottom: none;
}

.recipe-chef {
	color: var(--neutral-7);
	font-size: var(--font-size-0);
}

.breadcrumb {
	font-size: var(--font-size-0);
	margin-bottom: var(--size-1);
}

/* Menus */

.menu-index {
	list-style: none;
	padding: 0;
}

.menu-index li {
	padding: var(--size-1) 0;
	border-bottom: var(--border-width-0) solid var(--neutral-3);
	display: flex;
	justify-content: space-between;
	gap: var(--size-1);
}

.menu-index li:last-child {
	border-bottom: none;
}

.menu-index .meta {
	color: var(--neutral-7);
	font-size: var(--font-size-0);
	display: flex;
	gap: var(--size-1);
}

.menu-checklist {
	list-style: none;
	padding: 0;
	margin-top: var(--size-2);
}

.menu-item {
	display: flex;
	align-items: baseline;
	gap: var(--size-1);
	padding: var(--size-1) 0;
	border-bottom: var(--border-width-0) solid var(--neutral-3);
	font-size: var(--font-size-2);
}

.menu-item:last-child {
	border-bottom: none;
}

.menu-item input[type="checkbox"] {
	/* ≥24px touch target (WCAG 2.5.8) at the checklist's font size */
	width: 1.4em;
	height: 1.4em;
	accent-color: var(--secondary-5);
	cursor: pointer;
	flex-shrink: 0;
}

.menu-item .menu-label-wrap {
	display: flex;
	align-items: baseline;
	gap: var(--size-1);
	cursor: pointer;
}

.menu-item.checked .menu-label {
	text-decoration: line-through;
	color: var(--neutral-7);
}

/* Cooking sessions */

.cook-actions {
	display: flex;
	align-items: center;
	gap: var(--size-2);
	flex-wrap: wrap;
	margin-top: var(--size-1);
}

.cook-start-btn,
.cook-done-btn {
	font: inherit;
	font-size: var(--font-size-0);
	padding: var(--size-0) var(--size-2);
	border: var(--border-width-0) solid var(--neutral-6);
	border-radius: var(--radius-1);
	background: var(--neutral-2);
	color: var(--neutral-12);
	cursor: pointer;
}

.cook-start-btn:hover,
.cook-done-btn:hover {
	background: var(--neutral-3);
	border-color: var(--secondary-5);
}

.cook-done-btn {
	margin-top: var(--size-3);
}

.cook-open-link,
.cook-provenance {
	font-size: var(--font-size-0);
	color: var(--neutral-7);
}

.cooking-done-badge {
	font-size: var(--font-size-0);
	color: var(--secondary-5);
}

.cooking-progress {
	font-size: var(--font-size-2);
	font-weight: 600;
	color: var(--secondary-5);
	margin-top: var(--size-0);
}

.cook-group {
	margin-top: var(--size-2);
}

.cook-group h2 {
	font-size: var(--font-size-2);
	margin-bottom: var(--size-0);
}

.cook-step-num {
	color: var(--neutral-7);
	margin-right: var(--size-0);
}
