@import url("https://cdn.jsdelivr.net/npm/bootstrap-icons@1/font/bootstrap-icons.css");
@import url("css/theme.css");

object:not(.interactive) {
	pointer-events: none;
}

#intro {
	color-scheme: dark;
	background: var(--color-accent-3) url("images/pixelized-teapot.svg") 5rem 100% / 10em no-repeat;

	h1 {
		font-size: 20vh;
		line-height: .9;
		text-shadow: .03em .03em black;
	}

	.is {
		display: block;
		text-align: center;
		text-indent: -.65em;
	}

	span:nth-child(3) {
		margin-left: 0.75em;
	}

	.by {
		text-align: center;
		color-scheme: light;
		color: canvastext;
		line-height: 1;
		margin-top: 2rem;
		font-size: 130%;

		small {
			font-size: 50%;
			font-weight: 500;
		}
	}
}

.tip.slide {
	--label: "API Design Tip";
	--label-color: var(--color-accent-3);
	--label-font-size: 35%;
}

#pain {
	background: var(--color-red);
	color-scheme: dark;

	mark {
		position: relative;
		--mark-color: oklab(from var(--color-red) calc(l * .7) a b);
		color: white;
	}

	.asterisk {
		color: black;
	}

	.footnote {
		position: absolute;
		bottom: var(--slide-padding);
		right: var(--slide-padding);
		font-family: var(--font-serif);
		font-style: italic;

		.asterisk {
			display: inline-block;
			vertical-align: -.08em;
			font: bold 200%/.5 var(--font-sans);
		}
	}
}

#svg-dom {
	color-scheme: dark;
	background: var(--color-red);

	img {
		max-height: 90vh;
	}
}

#alan-kay {
	flex-flow: row;
	gap: 1em;

	img {
		border-radius: .2em;
	}

	blockquote {
		font-size: 110%;

		@supports not (hanging-punctuation: first) {
			text-indent: -.2em;
		}
	}
}

#dx {
	background: var(--color-accent-2);
	color-scheme: dark;
}

#progressive-complexity {
	color-scheme: dark;
	padding-left: 35%;
	background: url("images/iceberg.jpg") 30% / cover no-repeat;

	h1 {
		max-width: 7em;

		&::before {
			margin-bottom: 1rem;
		}
	}
}

#select {
	pre {
		width: 100%;

		&:has(h2) {
			display: flex;
			align-items: center;
			justify-content: center;
			white-space: normal;
		}
	}

	code {
		mark {
			background: color(display-p3 1 1 0);
			text-shadow: 0 0 .1em white;
			box-shadow: none;
		}

		h2 {
			font-family: var(--font-heading);
			font-size: 300%;
			margin: 0;
		}
	}

	&[data-visit="2"] .delayed {
		opacity: 1 !important;
	}
}

#video-controls {
	> div {
		video {
			width: 100%;
		}
	}
	pre {
		margin-bottom: 1em;
		font-size: 110%;
	}
}

#video-no-controls {
	counter-reset: total-loc 0;

	pre:where(.current, .displayed, :not(.delayed, .delayed-children > *)) {
		counter-increment: total-loc var(--loc, 1);
	}

	.columns {
		align-items: start;
		margin-top: 1em;
	}

	pre {
		&.language-js,
		&.language-css {
			--height: calc(100vh - 9.5em);
			overflow: hidden;
			font-size: calc(var(--height) / var(--loc) / 1.3);
		}
	}

	.total-loc {
		position: absolute;
		top: 50%;
		transform: translateY(-50%);
		right: var(--slide-padding);
		text-align: center;
		line-height: 1;

		&::before {
			content: counter(total-loc);
			display: block;
			font-size: 300%;
		}
	}
}

.slide > :is(object, img, video, svg, figure),
.full-height {
	&:only-child,
	&.full-height,
	&:where(:first-child, :first-child:is(h1, h2, header) + *):where(:last-child, :has(+ details.notes:last-child)) {
		flex: 1;
		min-height: 0;
	}

	&:is(figure) {
		display: flex;
		flex-flow: column;

		> :is(object, img, video, svg) {
			flex: 1;
			min-height: 0;
		}
	}
}

ul.examples {
	> li {
		margin-block: .5em;
		list-style: none;
	}
}

pre:is(.examples > li > *, .good, .good *, .bad, .bad *) {
	position: relative;

	&::before {
		position: absolute;
		top: -.5em;
		right: -.4em;
		z-index: 2;
		font-size: 2rem;
	}

	&:is(.good, .good *) {
		--color: var(--color-green);

		&::before {
			content: "👍🏼";
		}
	}

	&:is(.bad, .bad *) {
		--color: var(--color-red);

		&::before {
			content: "👎🏼";
		}
	}
}

#components {
	.bad {
		font-size: 50%;
	}
}

.slide .dictionary-dfn {
	font-size: 150%;
	width: fit-content;
	margin: auto;

	header {
		text-align: left;
		font-size: 100%;
		line-height: 1;
		margin-bottom: 1em;
	}

	h1 {
		font-family: Adobe Caslon Pro, Baskerville;
		margin-bottom: 0;
		text-align: left;
		font-size: 400%;
		line-height: .8;

		+ p {
			margin-top: 0;
		}
	}

	.ipa {
		opacity: .6;

		&::before,
		&::after {
			content: "/";
		}
	}

	.pos {
		font-style: italic;

		&::before {
			content: "(";
		}

		&::after {
			content: ")";
		}
	}

	ol {
		margin-inline-start: 1ch;

		> li {
			margin-block: .3em;
		}
	}
}

#use-case {
	background: var(--color-accent-2);
	color-scheme: dark;

	.dictionary-dfn {
		max-width: 21em;
	}
}

#use-case-examples,
#use-case-examples-2 {
	flex-flow: row;

	header, h1 {
		align-self: center;
		text-align: left;
	}

	ul {
		align-self: stretch;
		display: flex;
		flex-flow: column;
		list-style-type: none;
		flex-grow: 1;
		text-align: right;
		margin-right: 1em;
		padding: 0;

		li {
			margin-block: .2em;
			line-height: 1.2;

			&:empty {
				flex: 1;
			}

			h2 {
				text-align: inherit;
			}
		}
	}

	object {
		align-self: stretch;
		min-height: 0;
	}
}

h1 mark {
	background: linear-gradient(-5deg, transparent 20%, var(--mark-color, var(--color-yellow)) 0 70%, transparent 0);
}

#overfitting {
	background: var(--color-accent-1) url(images/overfitting.svg) top right / auto 5.7em no-repeat content-box border-box;
	color-scheme: dark;

	.dictionary-dfn {
		font-size: 130%;
		max-width: 26em;
	}
}

#priority-of-constituencies {
	blockquote {
		text-align: right;
		transition: .5s;
		transition-property: color, opacity;
		counter-reset: line;

		> div:not(.cite) {
			counter-increment: line;
			--line-color-clamped: oklch(from var(--line-color, var(--color-neutral-50)) clamp(0, l, .75) c h);

			&:nth-child(1) { --index: 1 }
			&:nth-child(2) { --index: 2 }
			&:nth-child(3) { --index: 3 }
			&:nth-child(4) { --index: 4 }
			&:nth-child(5) { --index: 5 }

			&:nth-child(1) { --line-color: var(--color-green); }
			&:nth-child(2) { --line-color: color-mix(in oklch, var(--color-green), var(--color-yellow)); }
			&:nth-child(3) { --line-color: var(--color-yellow); }
			&:nth-child(4) { --line-color: var(--color-orange); }
			&:nth-child(5) { --line-color: var(--color-red); }

			&::after {
				content: counter(line);
				position: absolute;
				display: inline-block;
				vertical-align: -.2em;
				width: 1.2em;
				margin-inline-start: .5em;
				margin-top: .2em;
				text-align: center;
				font-weight: bold;
				background: var(--line-color-clamped);
				color: white;
				border-radius: 1em;
				font-size: 70%;
				line-height: 1.2;
				padding: .15em;
				opacity: 0;

				font-style: normal;
			}
		}

		*, ::after {
			transition: inherit;
			transition-property: inherit;
		}
	}

	&[data-step-all~="1"] {
		blockquote {
			color: var(--color-neutral-70);

			> div {
				strong,
				&::after {
					transition-duration: .2s;
				}

				strong {
					color: var(--line-color-clamped);
					transition-delay: calc(1s + .5s * var(--index) );
				}

				&::after {
					opacity: 1;
					transition-delay: calc(.8s + .5s * var(--index) );
				}
			}
		}
	}

	strong {
		font-weight: 500;
		color: var(--color-neutral-0);
	}
}

#video-complex {
	img {
		max-width: 90vw;
		max-height: 90vh;

		&:not(.delayed) {
			max-height: 80vh;
		}

		&.delayed {
			position: absolute;
			bottom: 15vh;
		}
	}
}

#internal-over-external {
	> div {
		min-width: 42ch;
		min-height: 6lh;
	}

	.delayed {
		transition: display .01s, opacity .5s .5s;
		transition-behavior: allow-discrete;

		&:not(.current) {

		}
	}
}

#dogfood {
	background: linear-gradient(to bottom right, rgb(0 0 0 / .5) 20%, transparent 60%), url(images/dogfood.jpg) bottom / cover;
	align-items: start;
	justify-content: start;
	padding-right: 50vw;
	color-scheme: dark;

	& h1 {
		text-align: left;
	}
}

#user-testing {
	video {
		filter: contrast(1.5);
	}
}

#dateformat {
	color-scheme: dark;
	background: var(--color-green);

	.subtitle {
		color: white;

		code {
			background: none;
			color: canvastext;

			* {
				color: inherit;
			}
		}
	}
}

#beginner {
	justify-content: start;
	background: url("images/student.avif") 50% 45% / auto 390%;

	h1 {
		max-width: 5em;
		text-shadow: 0 0 .3em white;
	}
}

#empathy {
	background: url("images/empathy.png") bottom / 60% auto no-repeat hsl(220 68% 19%);
	color-scheme: dark;

	h1 {
		margin-bottom: 3em;

		strong {
			color: var(--color-green)
		}
	}
}

/* Media credits */
.slide[data-credits]:after {
	content: "Media credits: " attr(data-credits);
	position: absolute;
	bottom: .5rem;
	right: 1rem;
	z-index: 100;
	color: canvastext;
	font-size: .8rem;
	font-weight: 300;
	text-shadow: 0 0 .1em canvas;
	text-shadow: 0 0 .1em .1em canvas;
}
#end {
	background: center / cover no-repeat;
	color-scheme: dark;
	justify-content: space-between;
	font-weight: 400;
	padding-block: 2.5rem;

	&:target {
		background-image: url("css/images/thats-all-folks.webp");
	}

	&::after {
		content: "Animation by Fabrizio Bergamo";
		position: absolute;
		bottom: .5rem;
		right: .8rem;
		font-size: 40%;
		color: white;
		font-weight: 500;
		opacity: .8;
	}

	p.slides {
		margin: 0;
	}

	.info {
		list-style: none;
		display: grid;
		grid-template-columns: repeat(2, max-content);
		gap: .2em 6em;
		margin-left: 3em;
		justify-content: space-between;
		padding: 0;

		small {
			font-size: 60%;
			font-style: italic;
		}
	}

	a {
		font-weight: 600;
	}
}