/* PRESENTATION (/presentations/<slug>; templates/pages/presentation.php).

   A presentation is its own surface (future.md, "The presentation"). The
   window holds a 16 by 9 stage - as big as fits, letterboxed when the window
   is another shape - and EVERYTHING on a slide is measured from the stage's
   width: type and spacing alike. So a slide is the same slide on a laptop, a
   TV or a billboard. This is the house's poster-style exception to "type
   steps at breakpoints": no breakpoints, no clamp() - a maximum would stop
   the billboard, a minimum would break the ratios between voices.

   Why the stage and not the window (cqw, not vw): a window of another shape
   letterboxes the slide, and type measured from the window would outgrow it.

   Why the whole ladder is restated here: the site computes its steps and
   voice sizes at :root, from a rem anchor, and a custom property is settled
   where it's declared - so changing only the anchor here would change
   nothing below it. Same reason the settings panel restates its own
   (settings-panel.css). Families, weights and colors are NOT restated: they
   stay the theme's, so every look repaints the presentation. */

.presentation {
	position: fixed;
	inset: 0;
	display: grid;
	place-items: center;

	/* The window around the stage is the slide's own color, so the slide
	   runs seamlessly to the edges and the content stays centered in its
	   16 by 9 (Derek, 2026-11-16). A dark slide darkens the whole window. */
	background-color: var(--fill-primary);

	/* Nothing on a presentation is for selecting (Derek, 2026-11-16): a
	   stray click-drag while presenting shouldn't paint a highlight. */
	user-select: none;

	/* A light or dark slide takes the window with it. */
	&:has(.slide.is-current[data-scheme='dark']) {
		color-scheme: dark;
	}

	&:has(.slide.is-current[data-scheme='light']) {
		color-scheme: light;
	}
}

.presentation-stage {
	container: stage / inline-size;
	position: relative;
	width: min(100vw, 100dvh * 16 / 9);
	aspect-ratio: 16 / 9;
	overflow: hidden;
	background-color: var(--fill-primary);
	color: var(--ink-primary);

	/* The two values the presentation changes: body is 1.25% of the stage's
	   width (24px on a 1920 stage), and steps are a fourth apart - more
	   contrast than the site's 1.25, because slides need it. */
	--type-anchor: 1.25cqw;
	--scale-ratio: 1.333;

	/* The ladder, restated from these two (font-scales.css has the site's). */
	--step-down-2: calc(var(--step-down-1) / var(--scale-ratio));
	--step-down-1: calc(var(--step-0) / var(--scale-ratio));
	--step-0: var(--type-anchor);
	--step-up-1: calc(var(--step-0) * var(--scale-ratio));
	--step-up-2: calc(var(--step-up-1) * var(--scale-ratio));
	--step-up-3: calc(var(--step-up-2) * var(--scale-ratio));
	--step-up-4: calc(var(--step-up-3) * var(--scale-ratio));
	--step-up-5: calc(var(--step-up-4) * var(--scale-ratio));
	--step-up-6: calc(var(--step-up-5) * var(--scale-ratio));
	--step-up-7: calc(var(--step-up-6) * var(--scale-ratio));
	--step-up-8: calc(var(--step-up-7) * var(--scale-ratio));

	/* Which step each voice speaks at on a slide (future.md, "The type"). */
	--stamp-voice-font-size: var(--step-down-2);
	--data-voice-font-size: var(--step-down-2);
	--quiet-voice-font-size: var(--step-down-1);
	--label-voice-font-size: var(--step-down-1);
	--calm-voice-font-size: var(--step-0);
	--firm-voice-font-size: var(--step-0);
	--strong-voice-font-size: var(--step-up-1);
	--attention-voice-font-size: var(--step-up-2);
	--loud-voice-font-size: var(--step-up-3);
	--loud-voice-line-height: 1.15;

	/* Sans for every small thing, serif for the big headings (Derek,
	   2026-11-16) - the presentation's own pairing, the same in every
	   theme. The serif is Georgia for now (Derek, 2026-11-16: "Prefer just
	   Georgia for the serif" - the site's Boska didn't hold up big; a
	   better serif is still to pick). */
	--presentation-serif: Georgia, serif;
	--stamp-voice-font-family: var(--font-sans);
	--data-voice-font-family: var(--font-sans);
	--quiet-voice-font-family: var(--font-sans);
	--label-voice-font-family: var(--font-sans);
	--calm-voice-font-family: var(--font-sans);
	--firm-voice-font-family: var(--font-sans);
	--strong-voice-font-family: var(--font-sans);
	--attention-voice-font-family: var(--presentation-serif);
	--loud-voice-font-family: var(--presentation-serif);

	/* The presentation's own two voices, for the biggest moments: a group's
	   title on its opener, and the cover. Deck-only - they exist inside the
	   stage and nowhere else on the site. */
	--title-voice-font-size: var(--step-up-5);
	--title-voice-line-height: 1;
	--cover-voice-font-size: var(--step-up-8);
	--cover-voice-line-height: 1;

	/* Space scales with the stage too: one unit, the body size. */
	--slide-space: var(--step-0);

	/* The slide's margin, on every side: two units, so the biggest type
	   (the cover, its descenders) keeps clear of the edge (Derek,
	   2026-11-16: one unit was "pretty tight to the bottom"). */
	--slide-margin: calc(var(--slide-space) * 2);

	.title-voice {
		font-family: var(--loud-voice-font-family);
		font-weight: var(--loud-voice-font-weight);
		font-size: var(--title-voice-font-size);
		line-height: var(--title-voice-line-height);
	}

	.cover-voice {
		font-family: var(--loud-voice-font-family);
		font-weight: var(--loud-voice-font-weight);
		font-size: var(--cover-voice-font-size);
		line-height: var(--cover-voice-line-height);
	}
}

/* THE GRID. Every slide is twelve columns inside the slide's padding, and
   everything on it starts on a column line (Derek, 2026-11-16: "We should
   be working with an underlying grid for sure") - the frame, every layout's
   slots, a one-off's parts. The center line is the start of column 7.
   Rows: the frame, then the slide's content. G shows the columns
   (.presentation-grid, presentation.js). */
.slide,
.presentation-grid {
	position: absolute;
	inset: 0;
	display: grid;
	grid-template-columns: repeat(12, 1fr);
	column-gap: var(--slide-space);
	padding: var(--slide-margin);
}

/* One slide at a time. The server marks the first current, so with no
   script the presentation still opens on its first slide. */
.slide {
	grid-template-rows: auto 1fr;
	row-gap: calc(var(--slide-space) * 3);
	background-color: var(--fill-primary);
	color: var(--ink-primary);

	/* A slide on its way out still shows while it leaves. A change of
	   slide is a clean cut for now (Derek, 2026-11-16: a crossfade was
	   tried and felt "a little clunky"), so nothing animates on
	   .is-arriving / .is-leaving and presentation.js takes them straight
	   off - the hooks wait there for a slide that wants an entrance. */
	&:not(.is-current, .is-leaving) {
		display: none;
	}
}

/* The columns, drawn: a thin tint on each, over the slide. Off until G. */
.presentation-grid {
	z-index: 1;
	pointer-events: none;

	span {
		background-color: color-mix(in srgb, var(--accent) 15%, transparent);
	}

	.presentation:not([data-show-grid]) & {
		display: none;
	}
}

/* The frame: who, which presentation, where to find more - each starting
   on a line: the name at the left edge, the title on the center line, the
   site at column 10. */
.slide-frame {
	grid-column: 1 / -1;
	display: grid;
	grid-template-columns: subgrid;

	p:nth-child(1) {
		grid-column: 1 / 7;
	}

	p:nth-child(2) {
		grid-column: 7 / 10;
	}

	p:nth-child(3) {
		grid-column: 10 / -1;
	}
}

/* LAYOUTS (PRESENTATION_LAYOUTS in includes/presentation.php). A layout is
   where its slots sit on the grid, nothing more - a slot holds its components
   in a stack. */
.slot {
	grid-row: 2;
	display: grid;
	align-content: start;
	row-gap: var(--slide-space);
}

.slide[data-layout='cover'] {
	[data-slot='main'] {
		grid-column: 1 / 11;
		align-self: end;
	}
}

.slide[data-layout='title'] {
	[data-slot='main'] {
		grid-column: 7 / -1;
		align-self: end;
	}
}

.slide[data-layout='full'] {
	[data-slot='main'] {
		grid-column: 1 / 11;
		align-self: center;
	}
}

.slide[data-layout='halves'] {
	[data-slot='left'] {
		grid-column: 1 / 7;
	}

	[data-slot='right'] {
		grid-column: 7 / -1;
	}
}

/* The picture runs past the slide's padding to its left and bottom edges,
   and stops at the end of column 6. */
.slide[data-layout='picture-beside-text'] {
	[data-slot='picture'] {
		grid-column: 1 / 7;
		align-content: stretch;
		margin-left: calc(var(--slide-margin) * -1);
		margin-bottom: calc(var(--slide-margin) * -1);
	}

	[data-slot='text'] {
		grid-column: 7 / -1;
	}
}

/* One big picture, past the padding to the left, right and bottom edges. */
.slide[data-layout='picture'] {
	[data-slot='main'] {
		grid-column: 1 / -1;
		align-content: stretch;
		margin: 0 calc(var(--slide-margin) * -1) calc(var(--slide-margin) * -1);
	}
}

.slide[data-layout='thirds'] {
	[data-slot='first'] {
		grid-column: 1 / 5;
	}

	[data-slot='second'] {
		grid-column: 5 / 9;
	}

	[data-slot='third'] {
		grid-column: 9 / -1;
	}
}

.slide[data-layout='quarters'] {
	[data-slot='first'] {
		grid-column: 1 / 4;
	}

	[data-slot='second'] {
		grid-column: 4 / 7;
	}

	[data-slot='third'] {
		grid-column: 7 / 10;
	}

	[data-slot='fourth'] {
		grid-column: 10 / -1;
	}
}

/* A picture is 16 by 9, so pictures side by side line up whatever shape
   their files are; its caption, if any, sits under it. */
.slide-picture {
	display: grid;
	row-gap: calc(var(--slide-space) / 2);
	margin: 0;

	img {
		width: 100%;
		aspect-ratio: 16 / 9;
		object-fit: cover;
	}
}

/* In the big-picture layouts it fills its whole slot instead. */
:is(.slide[data-layout='picture'], .slide[data-layout='picture-beside-text']) .slide-picture {
	grid-template-rows: minmax(0, 1fr) auto;
	height: 100%;

	img {
		height: 100%;
		aspect-ratio: auto;
	}
}

/* A list: numbered, the number above each statement. */
.slide-list {
	display: grid;
	row-gap: calc(var(--slide-space) * 1.5);
	list-style: none;
	margin: 0;
	padding: 0;
	counter-reset: slide-list;

	li {
		display: grid;
		row-gap: calc(var(--slide-space) / 3);
		counter-increment: slide-list;

		&::before {
			content: counter(slide-list, decimal-leading-zero);
			font-family: var(--data-voice-font-family);
			font-size: var(--data-voice-font-size);
			color: var(--ink-secondary);
		}
	}

	p {
		margin: 0;
	}
}

.slide-quote {
	display: grid;
	row-gap: var(--slide-space);
	margin: 0;

	blockquote {
		margin: 0;
	}
}

/* A metric: the number big, what it measures, then when. */
.slide-metric {
	display: grid;
	row-gap: calc(var(--slide-space) / 3);
	margin: 0;

	strong {
		font-weight: var(--loud-voice-font-weight);
	}
}

/* THE PLAN (includes/presentation/plan.php) - a slide's goal, outcome and
   the need it answers, on Derek's machine only. Always there on a planned
   slide; on a built one only while P is on. It sits at the foot of the
   slide, over whatever's there, its parts on the grid - the talk's, the
   section's and the slide's, four columns each. */
.slide-plan {
	position: relative;
	z-index: 2;
	grid-row: 2;
	grid-column: 1 / -1;
	align-self: end;
	display: grid;
	grid-template-columns: subgrid;
	padding: var(--slide-space) 0;
	border-top: 1px dashed var(--stroke-secondary);
	background-color: var(--fill-secondary);

	dl {
		grid-column: span 4;
		display: grid;
		align-content: start;
		row-gap: calc(var(--slide-space) / 4);
		margin: 0;
	}

	/* The last part - the slide's own - is the one being worked on. */
	dl:last-child {
		grid-column: -5 / -1;
	}

	dd {
		margin: 0 0 calc(var(--slide-space) / 2);
	}

	.slide:not([data-planned]) & {
		display: none;

		.presentation[data-show-plan] & {
			display: grid;
		}
	}
}

/* ONE-OFFS (includes/presentation/one-offs/) - a slide that's its own
   template. It still sits on the grid, in the content row. */
.color-slots {
	grid-column: 1 / -1;
	grid-row: 2;
	display: grid;
	grid-template-columns: subgrid;
	align-content: end;
	row-gap: var(--slide-space);
	list-style: none;
	margin: 0;
	padding: 0;

	li {
		grid-column: span 2;
		display: grid;
		align-content: end;
		aspect-ratio: 1;
		padding: calc(var(--slide-space) / 2);
		border: 1px solid var(--stroke-secondary);
		background-color: var(--swatch);
	}

	/* The name on its own swatch, in a box of the page's color so every
	   name reads whatever color it's on. */
	span {
		justify-self: start;
		padding: 0 0.25em;
		background-color: var(--fill-primary);
	}
}

/* The controls are chrome (data-ui='app'): fixed to the window's corner,
   outside the stage, at the chrome's own size - they never scale. */
.presentation-controls {
	position: fixed;
	right: var(--gutter);
	bottom: var(--gutter);
	display: flex;
	gap: calc(var(--gutter) / 2);
}

/* PRESENTATION LOOKS - a slide's own colors, instead of the page's theme
   ("look": "bright" in the presentation's file; the list of looks is
   PRESENTATION_LOOKS in includes/presentation.php). Flat colors, the same
   in light and dark, and the whole set of ten color slots, so no part
   mixes the look with the theme. The window around the stage wears the
   look too while that slide is on. Red light still wins: it stomps every
   color, a slide's own included (settings/red-light.css). */
html:not([data-red-light]) :is(.slide[data-look='bright'], .presentation:has(.slide.is-current[data-look='bright'])) {
	--fill-primary: var(--color-blue-600);
	--fill-secondary: var(--color-blue-700);
	--fill-auxiliary: var(--color-blue-800);
	--ink-primary: var(--color-yellow-300);
	--ink-secondary: var(--color-yellow-100);
	--ink-auxiliary: var(--color-yellow-200);
	--stroke-primary: var(--color-yellow-300);
	--stroke-secondary: var(--color-blue-400);
	--stroke-auxiliary: var(--color-blue-500);
	--accent: var(--color-pink-400);
}

/* The overview (presentation.js opens it): every slide at once, over a
   cover that dims the page - a row per group, a 16 by 9 box per slide.
   The same over every slide, whatever its colors (Derek, 2026-11-16): the
   cover is always dark, so the overview always wears the chrome's dark
   scheme. No panel behind the boxes - they sit right on the cover. The
   cover comes in first, then the boxes. Chrome, at the chrome's own sizes. */
.presentation-overview {
	/* It sits on the slide's left half, from the left content edge, just
	   under the frame - where a slide's own content starts. A dialog lives
	   in the top layer, outside the stage, so the stage's box is worked out
	   here from the window with the same rule the stage uses
	   (.presentation-stage). One unit is 1.25% of the stage's width; the
	   slide's margin is two of them (--slide-margin). */
	--stage-width: min(100vw, 100dvh * 16 / 9);
	--stage-height: calc(var(--stage-width) * 9 / 16);
	--stage-padding: calc(var(--stage-width) * 0.0125);

	/* The cover: dark enough that any slide - dark, light, bright - reads
	   as "behind" it. */
	--overview-cover: rgb(0 0 0 / 0.8);
	--overview-cover-in: 180ms;

	color-scheme: dark;
	position: fixed;
	inset: auto;
	top: calc((100dvh - var(--stage-height)) / 2 + var(--stage-padding) * 4);
	left: calc((100vw - var(--stage-width)) / 2 + var(--stage-padding) * 2);
	margin: 0;
	max-width: none;
	width: calc(var(--stage-width) / 2 - var(--stage-padding) * 3);

	/* A long presentation scrolls inside the overview; the page behind it
	   is fixed and can't. */
	max-height: calc(100dvh - var(--stage-padding) * 6);
	overflow: auto;
	padding: 0;
	border: none;
	background-color: transparent;
	color: var(--app-ink);

	/* Its colors don't follow the slide behind it: a mood that lends the
	   chrome the page's ink (Technical) would hand it a bright slide's
	   yellow. Red light still repaints it - red light repaints all. */
	html:not([data-red-light]) &[data-ui='app'] {
		--app-ink: var(--app-gray-ink);
		--app-ink-secondary: var(--app-gray-ink-secondary);
		--app-stroke-secondary: var(--app-gray-stroke-secondary);
	}

	&::backdrop {
		background-color: var(--overview-cover);
		animation: overview-cover var(--overview-cover-in) ease-out both;
	}

	/* The boxes arrive once the cover is mostly down. Motion the presenter
	   asked for - functional, not gated (CLAUDE.md, Motion policy). */
	&[open] .overview-groups {
		animation: overview-boxes 200ms ease-out calc(var(--overview-cover-in) * 0.6) both;
	}

	ol {
		list-style: none;
		margin: 0;
		padding: 0;
	}

	.overview-groups {
		display: grid;
		gap: calc(var(--gutter) * 1.5);
	}

	.overview-slides {
		display: flex;
		flex-wrap: wrap;
		gap: var(--gutter);
	}
}

.overview-slide {
	display: grid;
	place-items: center;
	width: 8rem;
	aspect-ratio: 16 / 9;
	border: 1px solid var(--app-stroke-secondary);

	/* Solid, like the slides they stand for (Derek, 2026-11-16: "These are
	   going to be opaque slides") - a picture of each slide can drop in
	   later without anything behind showing through. */
	background-color: var(--app-gray-fill);
	color: var(--app-ink-secondary);
	cursor: pointer;

	/* The slide you're on. */
	&[aria-current] {
		border-color: var(--app-ink);
		color: var(--app-ink);
	}
}

@keyframes overview-cover {
	from {
		opacity: 0;
	}
}

@keyframes overview-boxes {
	from {
		opacity: 0;
		transform: translateY(0.5rem);
	}
}

/* The list of presentations (/presentations; templates/pages/presentations.php)
   - an ordinary site page, not the stage: titles, one per line. */
.presentation-index {
	ol {
		list-style: none;
		padding: 0;
		margin-top: 2em;
	}

	li + li {
		margin-top: 1em;
	}
}
