:root {
	--bg: #1a1a1c;
	--pad: clamp(12px, 4vmin, 64px);
	--max: min(92vmin, 1600px);
	--min: 200px;
}

html,
body {
	height: 100%;
	margin: 0;
	background: var(--bg);
	overflow: hidden;
}

body {
	height: 100svh;
	display: grid;
	place-items: center;
}

.crt {
	/* CRT screen effects */
	filter: blur(0.5px);
	border-radius: 12px;
}

.crt::after {
	content: '';
	position: fixed;
	top: 0;
	left: 0;
	width: 100vw;
	height: 100vh;
	background: repeating-linear-gradient(
		0deg,
		transparent 0px,
		transparent clamp(1px, 0.3vmin, 3px),
		rgba(0, 0, 0, clamp(0.06, 0.12, 0.18)) clamp(1px, 0.3vmin, 3px),
		rgba(0, 0, 0, clamp(0.06, 0.12, 0.18)) clamp(2px, 0.6vmin, 6px)
	);
	animation: scanlines infinite 55s linear;
	pointer-events: none;
	z-index: 1000;
}

@media (prefers-reduced-motion: reduce) {
	.crt {
		animation-duration: 0.1s;
		animation-iteration-count: 1;
	}

	.masked {
		animation: fadeIn 2s ease-out;
		animation-fill-mode: forwards;
	}
}

@keyframes scanlines {
	from {
		background-position: 0 0;
	}
	to {
		background-position: 0 4px;
	}
}

main {
	display: grid;
	place-items: center;
	padding: min(var(--pad), 2vh);
	width: 100%;
	height: 100%;
	box-sizing: border-box;
}

.stage {
	width: clamp(var(--min), var(--max), 100%);
	aspect-ratio: 1/1;
	display: grid;
	place-items: center;
	filter: blur(clamp(0.5px, 0.5vmin, 3px));
	will-change: filter;
}

.masked {
	width: 100%;
	height: 100%;
	display: block;
	background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
	background-size: 400% 400%;
	animation:
		gradientShift 15s ease infinite,
		vhsGlitch 8s linear infinite,
		fadeIn 2s ease-out;
	filter: contrast(1.4) saturate(1.3) sepia(0.1) hue-rotate(10deg);
	/* Use the animated SVG as a mask (alpha channel). Safari needs -webkit- prefix. */
	-webkit-mask-image: url('image.svg');
	-webkit-mask-repeat: no-repeat;
	-webkit-mask-position: center;
	-webkit-mask-size: contain;
	mask-image: url('image.svg');
	mask-repeat: no-repeat;
	mask-position: center;
	mask-size: contain;
	position: relative;
	opacity: 0;
	animation-fill-mode: forwards;
	will-change: transform, opacity;
}

@keyframes gradientShift {
	0% {
		background-position: 0% 50%;
	}
	50% {
		background-position: 100% 50%;
	}
	100% {
		background-position: 0% 50%;
	}
}

@keyframes vhsGlitch {
	0% {
		transform: translate(0, 0) scaleY(1);
	}
	2% {
		transform: translate(-2px, 0) scaleY(0.998);
	}
	4% {
		transform: translate(0, 0) scaleY(1);
	}
	15% {
		transform: translate(1px, 0) scaleY(1.002);
	}
	17% {
		transform: translate(0, 0) scaleY(1);
	}
	45% {
		transform: translate(-1px, 0) scaleY(0.999);
	}
	47% {
		transform: translate(0, 0) scaleY(1);
	}
	78% {
		transform: translate(2px, 0) scaleY(1.001);
	}
	80% {
		transform: translate(0, 0) scaleY(1);
	}
	100% {
		transform: translate(0, 0) scaleY(1);
	}
}

@keyframes fadeIn {
	0% {
		opacity: 0;
	}
	100% {
		opacity: 1;
	}
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}
