/*
 * Auto layout for Slides Extended decks.
 * Full reference (what to write, tuning, where the source lives): content/slides/README.md
 * Pairs with plugin/auto-layout/auto-layout.js,
 * which adds the .al-* classes. Opt in per deck:
 *   css: [css/vik.css, css/auto-layout.css]
 *   scripts: plugin/auto-layout/auto-layout.js
 *
 * Canvas is a fixed 1920×1080, so sizes are px/em on that canvas. Every text role has one
 * size; the script only scales a box down (--al-scale, never below 0.7) when it overflows.
 */

.reveal {
	--al-pad-x: 96px; /* left/right safe margin */
	--al-pad-b: 72px; /* bottom safe margin (and top, when there's no title) */
	--al-title-h: 200px; /* title band */
	--al-gap: 64px; /* between text and media, and between stacked items */
	--al-title-size: 1.4em; /* 84px on the 60px body */
	--al-section-size: 2em; /* 120px */
	--al-source-size: 0.45em; /* 27px, <small> citations */
	--al-footer-size: 0.8em; /* 48px, <footer> lines */
	--al-footer-gap: 40px; /* space between the body and the footer */
	--al-footer-b: 28px; /* footer's distance from the bottom edge */
}

/* ---- Frame ---------------------------------------------------------------------- */

.reveal .slides section.al-slide > .al {
	display: grid;
	grid-template-rows: var(--al-title-h) minmax(0, 1fr) auto;
	padding: 0 var(--al-pad-x) var(--al-pad-b);
	box-sizing: border-box;
	width: 1920px;
	height: 1080px;
}

.reveal .slides section.al-notitle > .al {
	grid-template-rows: minmax(0, 1fr) auto;
	padding-top: var(--al-pad-b);
}

.reveal .slides section.al-nosource > .al {
	grid-template-rows: var(--al-title-h) minmax(0, 1fr);
}

.reveal .slides section.al-notitle.al-nosource > .al {
	grid-template-rows: minmax(0, 1fr);
}

/* ---- Title band ------------------------------------------------------------------ */

.reveal .al-title {
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 0;
	text-align: center;
}

.reveal .al-title > * {
	margin: 0;
	font-size: calc(var(--al-title-size) * var(--al-scale, 1));
	line-height: 1.15;
	text-wrap: balance;
}

/* ---- Body: text + media, vertically centered ------------------------------------ */

.reveal .al-body {
	display: flex;
	gap: var(--al-gap);
	align-items: center;
	justify-content: center;
	min-height: 0;
	min-width: 0;
}

.reveal .al-textbox {
	flex: 1 1 0;
	align-self: stretch;
	min-width: 0;
	display: flex;
	flex-direction: column;
	/* safe: if text ever overflows, it runs down past the bottom, never up into the title */
	justify-content: safe center;
	align-items: center;
}

/* <split> columns: full width, never wrapping, images kept inside their column */
/* biome-ignore lint/correctness/noUnknownTypeSelector: <split> is Slides Extended\'s column element */
.reveal .al-text:has(> split) {
	width: 100%;
}

/* biome-ignore lint/correctness/noUnknownTypeSelector: <split> is Slides Extended\'s column element */
.reveal .al-text split:not([wrap]) {
	flex-wrap: nowrap;
	/* parallel text columns line up at the top; an image beside text stays centered */
	align-items: flex-start;
	gap: var(--al-gap);
}

/* biome-ignore lint/correctness/noUnknownTypeSelector: <split> is Slides Extended's column element */
.reveal .al-text split > :is(img, p:has(> img:only-child)) {
	align-self: center;
}

/* biome-ignore lint/correctness/noUnknownTypeSelector: <split> is Slides Extended\'s column element */
.reveal .al-text split > * {
	min-width: 0;
}

/* biome-ignore lint/correctness/noUnknownTypeSelector: <split> is Slides Extended\'s column element */
.reveal .al-text split > * > :first-child {
	margin-top: 0;
}

/* biome-ignore lint/correctness/noUnknownTypeSelector: <split> is Slides Extended\'s column element */
.reveal .al-text split > * > :last-child {
	margin-bottom: 0;
}

/* Icon columns: an icon alone at the top of a column (Font Awesome turns the <i> into an
   <svg>) is centered over it, and so is a heading right after the icon */
/* biome-ignore lint/correctness/noUnknownTypeSelector: <split> is Slides Extended\'s column element */
.reveal .al-text split > * > p:first-child:has(> :is(svg.svg-inline--fa, i[class*="fa-"]):only-child),
/* biome-ignore lint/correctness/noUnknownTypeSelector: <split> is Slides Extended\'s column element */
.reveal .al-text split > * > p:first-child:has(> :is(svg.svg-inline--fa, i[class*="fa-"]):only-child) + :is(h1, h2, h3, h4, h5, h6) {
	text-align: center;
}

.reveal .al-text {
	flex: 0 0 auto;
	max-width: 100%;
	font-size: calc(1em * var(--al-scale, 1));
	text-align: left;
}

/* Reveal animates fragments with `transition: all`, which would also animate the font
   size while the script measures it. Keep the fade, drop the size animation. */
.reveal .al .fragment {
	transition-property: opacity, visibility, transform, color, background-color;
}

.reveal .al-text > :first-child {
	margin-top: 0;
}

.reveal .al-text > :last-child {
	margin-bottom: 0;
}

/* The theme gives blockquotes a fixed width; inside auto layout they follow their box */
.reveal .al-text blockquote {
	width: auto;
	max-width: 100%;
	box-sizing: border-box;
	margin-inline: 0;
}

.reveal .al-text img {
	max-width: 100%;
	max-height: 640px;
	height: auto;
	object-fit: contain;
}

.reveal .al-media {
	flex: 0 0 auto;
	align-self: stretch;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: safe center;
	gap: calc(var(--al-gap) / 2);
	min-height: 0;
}

.reveal .al-media p {
	margin: 0;
}

.reveal .al-media img,
.reveal .al-media video {
	display: block;
	max-width: none;
	max-height: none;
	margin: 0;
	object-fit: contain;
}

/* ---- Wide image stacked with its text (set by the script for images 2:1 or wider) -- */

.reveal .al-stack .al-body {
	flex-direction: column;
	gap: calc(var(--al-gap) / 2);
}

.reveal .al-stack .al-textbox {
	flex: 0 0 auto;
	align-self: stretch;
}

.reveal .al-stack .al-media {
	flex: 1 1 0;
	align-self: stretch;
}

.reveal .al-stack.al-media-first .al-media {
	order: -1;
}

/* ---- iframe slides: the iframe takes the whole body ------------------------------ */

.reveal .al-fill .al-textbox {
	justify-content: stretch;
	align-items: stretch;
}

.reveal .al-fill .al-text {
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: calc(var(--al-gap) / 4);
	text-align: center;
}

.reveal .al-fill .al-text > * {
	margin: 0;
}

.reveal .al-fill .al-text > iframe,
.reveal .al-fill .al-text > p:has(iframe) {
	flex: 1 1 auto;
	min-height: 0;
	width: 100%;
}

.reveal .al-fill .al-text iframe {
	width: 100%;
	height: 100%;
}

/* ---- Footer, pinned to the bottom ------------------------------------------------- */
/* Sits in the bottom margin, with a clear gap above it. <small> = citation, <footer> = a
   readable line (e.g. "Questions? Comments?" under a centered image). */

.reveal .slides section.al-slide:not(.al-nosource) > .al {
	padding-bottom: var(--al-footer-b);
}

.reveal .al-source {
	padding-top: var(--al-footer-gap);
	text-align: center;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.25em;
}

.reveal .al-source > * {
	margin: 0;
}

.reveal .al-source small {
	font-size: var(--al-source-size);
	opacity: 0.75;
}

.reveal .al-source footer {
	font-size: var(--al-footer-size);
}

/* ---- Section slides --------------------------------------------------------------- */

.reveal .slides section.al-section > .al {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: var(--al-pad-b) var(--al-pad-x);
}

.reveal .al-sectionbox {
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	font-size: calc(1em * var(--al-scale, 1));
}

.reveal .al-sectionbox > :is(h1, h2, h3, h4, h5, h6) {
	font-size: var(--al-section-size);
	line-height: 1.1;
	margin: 0 0 0.4em;
	text-wrap: balance;
}

.reveal .al-sectionbox > p {
	margin: 0;
}

