@import './fonts.css';

:root {
	color-scheme: dark;
	--bg: #111215;
	--panel: rgba(23, 25, 29, 0.82);
	--line: rgba(255, 249, 238, 0.14);
	--text: #fff9ee;
	--muted: #a9a6a0;
	--blue: #2563eb;
	--focus: #93c5fd;
	--ui: 'Inter', system-ui, sans-serif;
	background: var(--bg);
	font-family: var(--ui);
}
* {
	box-sizing: border-box;
}
body {
	margin: 0;
	overflow: hidden;
	background: var(--bg);
	color: var(--text);
}
body.idle.is-fullscreen,
body.idle.is-fullscreen * {
	cursor: none;
}

/* Stage: a 16:9 box that fills the viewport without cropping. */
main {
	width: 100vw;
	height: 100dvh;
	display: grid;
	place-items: center;
}
#stage {
	position: relative;
	width: min(100vw, calc(100dvh * 16 / 9));
	aspect-ratio: 16 / 9;
	overflow: hidden;
	background: #fff9ee;
	box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}
body.is-fullscreen #stage {
	box-shadow: none;
}
#frames {
	position: absolute;
	inset: 0;
	cursor: pointer;
}
.frame {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
	user-select: none;
	opacity: 0;
	transition: opacity 240ms ease;
}
.frame.visible {
	opacity: 1;
}
#annotation {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
}
#progress {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 4px;
	background: rgba(37, 99, 235, 0.12);
	pointer-events: none;
	transition: opacity 200ms;
}
#progress span {
	display: block;
	height: 100%;
	background: var(--blue);
	transform-origin: left;
	transition: transform 300ms ease;
}

/* Control bar: auto-hides; never shown in fullscreen or when hidden with H. */
nav {
	position: fixed;
	bottom: 18px;
	left: 50%;
	transform: translate(-50%, 8px);
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 6px;
	border: 1px solid var(--line);
	border-radius: 14px;
	background: var(--panel);
	backdrop-filter: blur(14px) saturate(1.4);
	-webkit-backdrop-filter: blur(14px) saturate(1.4);
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
	opacity: 0;
	pointer-events: none;
	transition: opacity 180ms, transform 180ms;
	white-space: nowrap;
}
body.controls-visible nav,
nav:hover,
nav:focus-within {
	opacity: 1;
	transform: translate(-50%, 0);
	pointer-events: auto;
}
body.is-fullscreen nav,
body.panel-hidden nav,
body.overview-open nav {
	display: none;
}
body.is-fullscreen #progress,
body.panel-hidden #progress {
	opacity: 0;
}
nav button {
	display: grid;
	place-items: center;
	min-width: 40px;
	height: 40px;
	padding: 0 10px;
	border: 0;
	border-radius: 9px;
	background: transparent;
	color: var(--text);
	font: 600 15px/1 var(--ui);
	cursor: pointer;
	transition: background 120ms;
}
nav button:hover:not(:disabled) {
	background: rgba(255, 249, 238, 0.1);
}
nav button:disabled {
	opacity: 0.3;
	cursor: default;
}
nav svg {
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}
#position output {
	min-width: 64px;
	font-variant-numeric: tabular-nums;
	text-align: center;
}
.divider {
	width: 1px;
	height: 24px;
	margin: 0 4px;
	background: var(--line);
}
button:focus-visible,
a:focus-visible {
	outline: 3px solid var(--focus);
	outline-offset: 2px;
}

/* Toast, timer and blackout. */
#toast {
	position: fixed;
	top: 20px;
	left: 50%;
	transform: translate(-50%, -8px);
	padding: 8px 16px;
	border-radius: 10px;
	background: var(--panel);
	backdrop-filter: blur(14px);
	-webkit-backdrop-filter: blur(14px);
	font: 600 15px var(--ui);
	opacity: 0;
	pointer-events: none;
	transition: opacity 160ms, transform 160ms;
	z-index: 5;
}
#toast.visible {
	opacity: 1;
	transform: translate(-50%, 0);
}
#timer {
	position: fixed;
	top: 16px;
	right: 18px;
	display: none;
	padding: 6px 12px;
	border-radius: 9px;
	background: var(--panel);
	font: 600 16px var(--ui);
	font-variant-numeric: tabular-nums;
	z-index: 4;
}
body.timer-on #timer {
	display: block;
}
#blackout {
	position: fixed;
	inset: 0;
	background: #000;
	opacity: 0;
	pointer-events: none;
	transition: opacity 250ms;
	z-index: 6;
}
body.blackout #blackout {
	opacity: 1;
	pointer-events: auto;
	cursor: none;
}

/* Overview grid. */
#overview {
	position: fixed;
	inset: 0;
	overflow-y: auto;
	padding: 40px clamp(16px, 4vw, 56px) 56px;
	background: rgba(12, 13, 16, 0.96);
	z-index: 3;
}
#overview header {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 24px;
	flex-wrap: wrap;
	margin-bottom: 24px;
}
#overview h1 {
	margin: 0;
	font: italic 400 40px 'Fraunces', serif;
}
#overview p {
	margin: 0;
	color: var(--muted);
	font-size: 15px;
}
#grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	gap: 22px;
	margin: 0;
	padding: 0;
	list-style: none;
}
#grid button {
	display: block;
	width: 100%;
	padding: 0;
	border: 0;
	background: none;
	color: var(--text);
	text-align: left;
	cursor: pointer;
}
#grid img {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 9;
	border-radius: 8px;
	outline: 2px solid transparent;
	outline-offset: 3px;
	transition: outline-color 120ms, transform 160ms;
}
#grid button:hover img {
	transform: translateY(-2px);
	outline-color: rgba(255, 249, 238, 0.35);
}
#grid li.current img {
	outline-color: var(--blue);
}
#grid span {
	display: block;
	margin-top: 10px;
	color: var(--muted);
	font-size: 13px;
	line-height: 1.35;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
#grid b {
	color: var(--text);
	margin-right: 4px;
}

/* Dialogs. */
dialog {
	max-width: 520px;
	border: 0;
	border-radius: 16px;
	padding: 32px;
	background: #fff9ee;
	color: #282723;
	font-family: var(--ui);
	box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
dialog::backdrop {
	background: rgba(0, 0, 0, 0.6);
	backdrop-filter: blur(3px);
}
dialog h1 {
	margin: 0 0 20px;
	font: italic 400 36px 'Fraunces', serif;
}
dialog a {
	display: inline-block;
	margin: 0 20px 15px 0;
	color: #1e3a8a;
	font-weight: 600;
}
dialog p {
	font-size: 16px;
	color: #706f72;
}
dialog form button {
	margin-top: 12px;
	padding: 8px 18px;
	border: 1px solid #dbd8d0;
	border-radius: 9px;
	background: #fff;
	color: #282723;
	font: 600 15px var(--ui);
	cursor: pointer;
}
#help dl {
	display: grid;
	grid-template-columns: auto 1fr;
	gap: 10px 24px;
	margin: 0;
	font-size: 15px;
}
#help dt {
	text-align: right;
	white-space: nowrap;
}
#help dd {
	margin: 0;
	align-self: center;
	color: #4a4945;
}
kbd {
	display: inline-block;
	min-width: 26px;
	padding: 2px 7px;
	border: 1px solid #dbd8d0;
	border-bottom-width: 2px;
	border-radius: 6px;
	background: #fff;
	font: 600 13px var(--ui);
	text-align: center;
}

@media (max-width: 600px) {
	nav button {
		min-width: 34px;
		height: 36px;
		padding: 0 6px;
	}
	#help-button,
	.divider {
		display: none;
	}
}
@media (prefers-reduced-motion: reduce) {
	nav,
	.frame,
	#progress span,
	#toast,
	#blackout {
		transition: none;
	}
}

@keyframes draw-annotation {
	to {
		stroke-dashoffset: 0;
	}
}
@keyframes show-arrow {
	to {
		opacity: 1;
	}
}
