/* 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;
}

/* 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;
}

@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-5);
	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);
}

.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 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);
}

/* 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;
}

/* Slides */

.slide {
	position: absolute;
	inset: 0;
	padding: 6vh 6vw;
	display: flex;
	flex-direction: column;
}

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

.slide > .slide-body {
	max-width: 50rem;
}

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

/* 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(--font-size-10);
	margin-bottom: var(--size-0);
}

.slide h3 {
	font-size: var(--font-size-4);
	margin-bottom: var(--size-2);
	color: var(--neutral-10);
	margin-top: var(--size-2);
}

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

.slide ul, .slide ol {
	padding-left: var(--size-3);
	margin-bottom: var(--size-2);
}

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

.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(--font-size-12);
}

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

/* 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: 55vh;
	object-fit: contain;
	border-radius: var(--border-radius-1);
}

.slide figcaption {
	text-align: center;
	font-size: var(--font-size-0);
	color: var(--neutral-6);
	margin-top: var(--size-0);
}

/* 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: 45vh;
	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(--font-size-1);
}

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

.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 {
	background: var(--neutral-9);
	font-weight: 600;
}

/* 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 {
	opacity: 1;
}

.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-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;
}

/* Footnotes in slides */
/* Bibliography */
.slide:has(.bibliography) {
	overflow-y: auto;
}

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

.bibliography li {
	margin-bottom: var(--size-1);
	break-inside: avoid;
	font-size: var(--font-size-0);
}

.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;
}

.slide-footnotes small {
	color: var(--neutral-6);
	font-size: var(--font-size-0);
}
