@font-face {
	font-family: 'JetBrains Mono';
	src: url('/jetbrains-mono.woff2') format('woff2');
	font-weight: 100 800;
	font-display: swap;
}

:root {
	color-scheme: dark;
	--bg: #00020f;
	--text: #dbe9ff;
	--muted: #8399bd;
	--line: #12203f;
	--accent: #5cc8ff;
	--glow: #1e90ff;
	/* Pointer position, -1 to 1. Written by stars.js. */
	--px: 0;
	--py: 0;
}

* {
	box-sizing: border-box;
	margin: 0;
}

html {
	scroll-behavior: smooth;
}

body {
	background: var(--bg);
	color: var(--text);
	font: 400 16px/1.5 'JetBrains Mono', ui-monospace, Consolas, monospace;
	font-variant-ligatures: none; /* keeps C++ evenly spaced */
}

a {
	color: inherit;
	text-decoration: none;
	transition: color 150ms;
}

a:hover {
	color: var(--accent);
}

a:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

nav {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
}

nav a {
	padding: 10px 12px;
}

/* The moving stars. Once they run, the still layers below give way. */
.stars {
	position: fixed;
	z-index: -1;
	inset: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
}

.live-stars body::before,
.live-stars body::after {
	display: none;
}

/* Two still star layers, for when scripts are off or motion is reduced. */
body::before,
body::after {
	content: '';
	position: fixed;
	z-index: -1;
	inset: -40px -40px -340px;
	pointer-events: none;
}

body::before {
	--rise: -100px;
	background:
		radial-gradient(1px 1px at 40px 70px, #5f86c4, transparent),
		radial-gradient(1px 1px at 190px 220px, #47689c, transparent),
		radial-gradient(1px 1px at 290px 120px, #3d5a8a, transparent);
	background-size: 330px 290px;
}

body::after {
	--rise: -300px;
	background:
		radial-gradient(1.5px 1.5px at 110px 330px, #8fc4ff, transparent),
		radial-gradient(1.5px 1.5px at 420px 90px, #5c8fd6, transparent);
	background-size: 530px 470px;
}

@keyframes rise {
	to {
		transform: translateY(var(--rise));
	}
}

@keyframes sink {
	to {
		transform: translate(-50%, -42%) scale(0.8);
		opacity: 0.2;
	}
}

/* Scroll parallax. Browsers without scroll timelines just scroll normally. */
@supports (animation-timeline: scroll()) {
	body::before,
	body::after {
		animation: rise linear both;
		animation-timeline: scroll(root);
	}

	.ring {
		animation: sink linear both;
		animation-timeline: scroll(root);
		animation-range: 0 100svh;
	}
}

/* Hero: the text sits inside the ring. The box is 1.5x the ring so flames can fade out. */
.hero {
	--ring: max(440px, min(128vw, 96svh, 880px));
	position: relative;
	isolation: isolate;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 100svh;
	padding-top: 16px; /* the ring centre sits below the middle; so does its text */
	overflow: clip;
	text-align: center;
	user-select: none;
	-webkit-user-select: none;
}

.hero > :not(.ring) {
	translate: calc(var(--px) * 10px) calc(var(--py) * 10px);
}

.ring {
	position: absolute;
	z-index: -1;
	top: 50%;
	left: 50%;
	width: var(--ring);
	aspect-ratio: 1;
	transform: translate(-50%, -50%);
	translate: calc(var(--px) * -16px) calc(var(--py) * -16px);
}

.ring img,
.ring canvas {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	transition: opacity 600ms;
}

.ring canvas,
.ring.live img {
	opacity: 0;
}

.ring.live canvas {
	opacity: 1;
}

h1 {
	position: relative;
	/* As wide as the tagline below; the caret hangs outside. Offsets the trailing tracking. */
	left: -0.0225em;
	font-size: calc(var(--ring) * 0.0705);
	font-weight: 700;
	letter-spacing: -0.045em;
	line-height: 1.2;
}

h1::after {
	content: '';
	position: absolute;
	/* Sits on the baseline and reaches just past cap height. */
	top: 0.2em;
	left: calc(100% + 0.12em);
	width: 0.28em; /* light enough not to pull the centred name to the right */
	height: 0.76em;
	background: var(--accent);
	animation: blink 1.1s steps(1) infinite;
}

@keyframes blink {
	50% {
		opacity: 0;
	}
}

.hero p {
	max-width: calc(var(--ring) * 0.46);
	line-height: 1.4;
	font-size: max(15px, var(--ring) * 0.0208);
	text-wrap: balance;
	margin: 8px 0 14px;
	color: var(--muted);
}

.hero .hint {
	position: absolute;
	bottom: 24px;
	max-width: none;
	margin: 0;
	font-size: 0.875rem;
	opacity: 0;
	transition: opacity 600ms;
}

.ring.live ~ .hint {
	opacity: 1;
}

@media (max-height: 560px) {
	.hero .hint {
		display: none;
	}
}

main:not(.hero),
footer {
	width: min(720px, 100% - 48px);
	margin-inline: auto;
}

/* Monospace glyphs carry a little empty space on each side. Pulling text out by that
   much lines its ink up with the rules at every size. */
.about,
h2,
.work b,
.work span {
	margin-left: -0.04em;
}

.work i {
	margin-right: -0.04em;
}

.about {
	padding-block: 64px 96px;
	font-size: 1.25rem;
	letter-spacing: -0.015em;
	text-wrap: pretty;
}

.about a {
	color: var(--accent);
}

.about a:hover {
	text-decoration: underline;
	text-underline-offset: 4px;
}

section {
	scroll-margin-top: 48px;
}

section + section {
	margin-top: 72px;
}

h2 {
	margin-bottom: 16px;
	color: var(--muted);
	font-size: 1rem;
	font-weight: 400;
}

h2::before {
	content: '~/';
	color: var(--glow);
}

.work {
	padding: 0;
	list-style: none;
}

.work a {
	position: relative;
	display: grid;
	grid-template-columns: 200px minmax(0, 1fr) auto;
	gap: 4px 16px;
	align-items: baseline;
	padding: 18px 0;
	border-top: 1px solid var(--line);
}

.work li:last-child a {
	border-bottom: 1px solid var(--line);
}

/* Hover: a lit edge draws along the row's top border. */
.work a::before {
	content: '';
	position: absolute;
	top: -1px;
	left: 0;
	width: 100%;
	height: 1px;
	background: linear-gradient(90deg, #e8f7ff, var(--glow) 40%, transparent);
	box-shadow: 0 0 14px 1px rgb(30 144 255 / 0.6);
	transform: scaleX(0);
	transform-origin: left;
	transition: transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.work a:is(:hover, :focus-visible)::before {
	transform: scaleX(1);
}

.work b {
	font-weight: 600;
}

.work span,
.work i {
	color: var(--muted);
	font-size: 0.9375rem;
	font-style: normal;
}

.products a {
	grid-template-columns: minmax(0, 1fr) auto;
	row-gap: 8px;
	padding-block: 24px;
}

.products b {
	font-size: 1.5rem;
	margin-left: -0.01em; /* bold capitals start closer to their edge */
	letter-spacing: -0.03em;
	line-height: 1.25;
}

.products span {
	grid-row: 2;
	grid-column: 1 / -1;
}

.work.products i {
	color: var(--accent);
}

footer {
	padding-block: 96px 64px;
}

footer nav {
	margin-inline: -12.5px; /* link padding, plus the space inside the first glyph */
}

@media (max-width: 640px) {
	footer nav {
		gap: 0;
		margin-inline: -8.5px;
	}

	footer nav a {
		padding-inline: 8px;
	}

	.work a {
		grid-template-columns: minmax(0, 1fr) auto;
	}

	.work span {
		grid-row: 2;
		grid-column: 1 / -1;
	}

	.about {
		padding-block: 48px 72px;
		font-size: 1.125rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}

	*,
	::before,
	::after {
		animation: none !important;
		transition: none !important;
	}
}
