:root {
	--bg: #14161b;
	--surface: #1b1e25;
	--border: #2a2e38;
	--text: #f4f1ea;
	--muted: #9aa0ab;
	--accent: #ff6a3d;
	--accent-soft: rgba(255, 106, 61, 0.12);
	--mono: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
	--sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
	--ease: cubic-bezier(0.2, 0.8, 0.2, 1);
	color-scheme: dark;
}

@media (prefers-color-scheme: light) {
	:root {
		--bg: #f4f1ea;
		--surface: #fbfaf6;
		--border: #e0dbd0;
		--text: #14161b;
		--muted: #5a606b;
		--accent: #e5532a;
		--accent-soft: rgba(229, 83, 42, 0.1);
		color-scheme: light;
	}
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
	margin: 0;
	overflow-x: hidden;
	background: var(--bg);
	color: var(--text);
	font: 16px/1.6 var(--sans);
	-webkit-font-smoothing: antialiased;
}

a { color: inherit; }

code { font-family: var(--mono); font-size: 0.92em; font-variant-ligatures: none; }

.wrap {
	max-width: 1080px;
	margin: 0 auto;
	padding: 0 24px;
}

/* Mark: the bright dot walks along the array, like an iteration cursor */
.mark { color: var(--text); flex: none; }
.mark circle { fill: var(--accent); animation: step 2.4s infinite; }
.mark .d2 { animation-delay: 0.8s; }
.mark .d3 { animation-delay: 1.6s; }

@keyframes step {
	0%, 30%, 100% { fill-opacity: 1; }
	36%, 94% { fill-opacity: 0.35; }
}

/* Scroll progress, filled like an XP bar */
.xp {
	position: fixed;
	inset: 0 0 auto;
	z-index: 10;
	height: 3px;
}
.xp span {
	display: block;
	height: 100%;
	background: linear-gradient(90deg, var(--accent), #ffb547);
	transform: scaleX(var(--progress, 0));
	transform-origin: left;
	box-shadow: 0 0 12px var(--accent);
}

/* Nav */
.nav {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding-top: 24px;
	padding-bottom: 24px;
}

.brand {
	display: flex;
	align-items: center;
	gap: 10px;
	text-decoration: none;
	font: 700 18px var(--mono);
	letter-spacing: -0.02em;
}
.brand .mark { width: 34px; height: 34px; transition: transform 0.4s var(--ease); }
.brand:hover .mark { transform: rotate(-8deg) scale(1.08); }
.brand b { color: var(--accent); }
.brand i { font-style: normal; font-weight: 400; color: var(--muted); }

.nav nav { display: flex; gap: 20px; }
.nav nav a {
	position: relative;
	color: var(--muted);
	text-decoration: none;
	font-size: 14px;
	font-weight: 500;
}
.nav nav a::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: -4px;
	height: 2px;
	background: var(--accent);
	transform: scaleX(0);
	transition: transform 0.25s var(--ease);
}
.nav nav a:hover { color: var(--text); }
.nav nav a:hover::after { transform: scaleX(1); }

/* Hero */
.hero {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1fr) 340px;
	column-gap: 48px;
	align-items: center;
	padding-top: 96px;
	padding-bottom: 112px;
}
.hero > * { grid-column: 1; }

.hero::before {
	content: "";
	position: absolute;
	inset: -40px 0 0;
	z-index: -1;
	background-image: radial-gradient(var(--border) 1px, transparent 1px);
	background-size: 28px 28px;
	mask-image: radial-gradient(ellipse at 70% 40%, #000 10%, transparent 65%);
	-webkit-mask-image: radial-gradient(ellipse at 70% 40%, #000 10%, transparent 65%);
}

.hero-mark {
	grid-column: 2;
	grid-row: 1 / span 5;
	width: 340px;
	height: 340px;
	color: var(--border);
	transform: translate(calc(var(--px, 0) * 18px), calc(var(--py, 0) * 18px)) rotate(calc(var(--px, 0) * 3deg));
	transition: transform 0.6s var(--ease);
	animation: float 7s ease-in-out infinite alternate;
}
.hero-mark circle { filter: drop-shadow(0 0 6px var(--accent)); }

@keyframes float {
	to { translate: 0 -14px; }
}

/* Easter egg: each click lights a dot; a full array starts the game */
.hero-mark { user-select: none; -webkit-tap-highlight-color: transparent; }
.hero-mark circle.lit { animation: none; fill-opacity: 1; }
.hero-mark.bump { animation: bump 0.25s var(--ease), float 7s ease-in-out infinite alternate; }
.hero-mark.charged circle { animation: none; fill-opacity: 1; filter: drop-shadow(0 0 14px var(--accent)); }

@keyframes bump {
	50% { scale: 0.94; }
}

.hero > :not(.game, .game-quit) { transition: opacity 0.5s var(--ease), filter 0.5s var(--ease); }
.hero.playing > :not(.game, .game-quit) { opacity: 0; filter: blur(6px); pointer-events: none; }
.hero.playing > .rise { animation: none; }
.hero.playing .hero-mark { transition-duration: 0.25s; scale: 0.3; }

.game {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	cursor: crosshair;
	touch-action: none;
	animation: fade-in 0.5s var(--ease);
}

.game-quit {
	position: absolute;
	top: 12px;
	right: 12px;
	padding: 4px 10px;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--surface);
	color: var(--muted);
	font: 12px var(--mono);
	cursor: pointer;
}
.game-quit:hover { color: var(--accent); border-color: var(--accent); }

@keyframes fade-in {
	from { opacity: 0; }
}

.kicker {
	min-height: 1.6em;
	margin: 0 0 20px;
	color: var(--accent);
	font-size: 15px;
}

.caret {
	display: inline-block;
	width: 0.55em;
	height: 1em;
	margin-left: 2px;
	vertical-align: -0.12em;
	background: var(--accent);
	animation: blink 1s steps(1) infinite;
}
h1 .caret { width: 0.08em; height: 0.85em; }

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

h1 {
	margin: 0;
	font: 700 clamp(38px, 7vw, 76px) / 1.08 var(--mono);
	letter-spacing: -0.04em;
}
.rot { color: var(--accent); }
.rot-wrap { white-space: nowrap; }

.lede {
	max-width: 600px;
	margin: 28px 0 0;
	color: var(--muted);
	font-size: 19px;
}
.lede em { color: var(--text); font-style: normal; }

.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 36px; }

.btn {
	display: inline-block;
	padding: 12px 20px;
	border-radius: 10px;
	background: var(--accent);
	color: #14161b;
	font-weight: 600;
	text-decoration: none;
	transition: transform 0.2s var(--ease), box-shadow 0.2s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px -8px var(--accent); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn.ghost {
	background: transparent;
	color: var(--text);
	box-shadow: inset 0 0 0 1px var(--border);
}
.btn.ghost:hover { box-shadow: inset 0 0 0 1px var(--accent); }

/* Entrance: hero words rise in order, sections reveal on scroll */
.js .rise {
	display: inline-block;
	opacity: 0;
	transform: translateY(0.6em);
	animation: rise 0.8s var(--ease) forwards;
	animation-delay: calc(var(--d) * 90ms + 150ms);
}
.js p.rise, .js div.rise { display: block; }
.js .cta.rise { display: flex; }

@keyframes rise {
	to { opacity: 1; transform: none; }
}

.js [data-reveal] {
	opacity: 0;
	transform: translateY(28px);
	filter: blur(4px);
	transition: opacity 0.7s var(--ease), transform 0.7s var(--ease), filter 0.7s var(--ease);
	transition-delay: var(--stagger, 0ms);
}
.js [data-reveal].in { opacity: 1; transform: none; filter: none; }

/* Sections */
.section-title {
	display: flex;
	align-items: baseline;
	gap: 14px;
	margin: 0 0 32px;
	font: 700 28px var(--mono);
	letter-spacing: -0.03em;
}
.section-title span { color: var(--accent); font-size: 14px; }

/* Project cards */
.grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 20px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.card {
	position: relative;
	display: flex;
	flex-direction: column;
	padding: 28px;
	border: 1px solid var(--border);
	border-radius: 16px;
	background: var(--surface);
	transform: perspective(900px) rotateX(var(--rx, 0)) rotateY(var(--ry, 0));
	transition: border-color 0.2s, transform 0.4s var(--ease), box-shadow 0.4s var(--ease);
}
.js .card[data-reveal].in { transform: perspective(900px) rotateX(var(--rx, 0)) rotateY(var(--ry, 0)); }
.js .card[data-reveal].done { transition: border-color 0.2s, transform 0.4s var(--ease), box-shadow 0.4s var(--ease); }
.card::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 50%), var(--accent-soft), transparent 60%);
	opacity: 0;
	transition: opacity 0.3s;
	pointer-events: none;
}
.card:hover { border-color: var(--accent); box-shadow: 0 24px 48px -24px rgba(0, 0, 0, 0.5); }
.card:hover::before { opacity: 1; }
.card.featured {
	grid-column: 1 / -1;
	background: linear-gradient(135deg, var(--accent-soft), transparent 60%), var(--surface);
}

.card-head {
	display: flex;
	align-items: center;
	gap: 14px;
}
.card h3 { margin: 0; font: 700 22px var(--mono); letter-spacing: -0.02em; }
.card .tag { margin-left: auto; }

.icon {
	flex: none;
	width: 48px;
	height: 48px;
	border-radius: 12px;
	box-shadow: 0 0 0 1px var(--border);
	transition: transform 0.4s var(--ease);
}
.featured .icon { width: 64px; height: 64px; border-radius: 16px; }
.card:hover .icon { animation: hop 0.6s var(--ease); }

@keyframes hop {
	40% { transform: translateY(-8px) rotate(-6deg); }
	70% { transform: translateY(1px) rotate(2deg); }
}

.tag {
	padding: 3px 9px;
	border-radius: 999px;
	background: var(--accent-soft);
	color: var(--accent);
	font: 500 12px var(--mono);
}

.tagline { margin: 8px 0 0; font-weight: 600; }
.card p { margin-top: 12px; margin-bottom: 0; color: var(--muted); }
.card .tagline { color: var(--text); }
.card .meta { font: 13px var(--mono); }

.links {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 16px;
	margin-top: auto;
	padding-top: 20px;
	font: 13px var(--mono);
}
.links a { position: relative; color: var(--accent); text-decoration: none; overflow-wrap: anywhere; }
.links a:hover { text-decoration: underline; }
.links .src { color: var(--muted); }

/* Why */
.why { padding-top: 128px; }

.why-lede {
	max-width: 720px;
	margin: 0 0 48px;
	font-size: 22px;
	line-height: 1.5;
}

.timeline {
	position: relative;
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	gap: 20px;
	margin: 0;
	padding: 0;
	list-style: none;
}
.timeline::before {
	content: "";
	position: absolute;
	top: 13px;
	left: 0;
	right: 0;
	height: 1px;
	background: linear-gradient(90deg, var(--accent), var(--border) 70%);
}
.timeline li { position: relative; padding-top: 40px; }
.timeline li::before {
	content: "";
	position: absolute;
	top: 6px;
	left: 0;
	width: 15px;
	height: 15px;
	border-radius: 50%;
	background: var(--bg);
	box-shadow: inset 0 0 0 3px var(--accent);
	transition: background 0.3s, box-shadow 0.3s;
}
.timeline li:hover::before { background: var(--accent); box-shadow: 0 0 0 6px var(--accent-soft); }
.timeline li:last-child::before { background: var(--accent); animation: pulse 2s infinite; }

@keyframes pulse {
	0% { box-shadow: 0 0 0 0 var(--accent); }
	100% { box-shadow: 0 0 0 14px transparent; }
}

.idx { color: var(--accent); font: 13px var(--mono); }
.timeline h3 { margin: 6px 0 8px; font: 700 18px var(--mono); letter-spacing: -0.02em; }
.timeline p { margin: 0; color: var(--muted); font-size: 15px; }
.timeline a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }

.stats {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 20px;
	margin: 64px 0 0;
}
.stats div {
	padding: 24px;
	border: 1px solid var(--border);
	border-radius: 16px;
	background: var(--surface);
}
.stats dt { font: 700 40px var(--mono); letter-spacing: -0.04em; color: var(--accent); }
.stats dd { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

/* About */
.about { padding-top: 128px; }

.about-body {
	display: flex;
	gap: 40px;
	align-items: flex-start;
	max-width: 820px;
}
.about-body p { margin: 0 0 16px; color: var(--muted); font-size: 17px; }
.about-body strong { color: var(--text); }

.avatar {
	flex: none;
	width: 160px;
	height: 160px;
	border-radius: 50%;
	box-shadow: 0 0 0 1px var(--border), 0 0 0 8px var(--accent-soft);
	transition: transform 0.6s var(--ease);
}
.avatar:hover { transform: rotate(-6deg) scale(1.04); }

.socials {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin: 24px 0 0;
	padding: 0;
	list-style: none;
}
.socials a {
	display: inline-block;
	padding: 6px 14px;
	border: 1px solid var(--border);
	border-radius: 999px;
	font-size: 14px;
	text-decoration: none;
	transition: transform 0.2s var(--ease), border-color 0.2s, color 0.2s;
}
.socials a:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }

/* Footer */
.footer {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
	margin-top: 128px;
	padding-top: 32px;
	padding-bottom: 48px;
	border-top: 1px solid var(--border);
	color: var(--muted);
	font-size: 14px;
}
.footer .mark { width: 24px; height: 24px; }
.hint {
	margin-left: auto;
	font: 12px var(--mono);
	letter-spacing: 0.1em;
	text-transform: uppercase;
	opacity: 0.5;
	animation: blink 1.6s steps(1) infinite;
	cursor: help;
}

/* Toast: achievements and easter eggs */
.toast {
	position: fixed;
	left: 50%;
	bottom: 24px;
	z-index: 20;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px 12px;
	width: max-content;
	max-width: calc(100vw - 32px);
	padding: 12px 18px;
	border: 1px solid var(--accent);
	border-radius: 12px;
	background: var(--surface);
	box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.5);
	font: 13px var(--mono);
	opacity: 0;
	transform: translate(-50%, 24px);
	transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
	pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast b { color: var(--accent); }
.toast:empty { display: none; }

.spark {
	position: fixed;
	z-index: 30;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--accent);
	pointer-events: none;
	animation: spark 1.1s var(--ease) forwards;
}

@keyframes spark {
	to { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

@media (max-width: 900px) {
	.timeline, .stats { grid-template-columns: repeat(2, 1fr); }
	.timeline li:last-child { grid-column: 1 / -1; }
	.timeline::before { display: none; }
	.hero { grid-template-columns: 1fr; }
	.hero-mark { display: none; }
}

@media (max-width: 640px) {
	.wrap { padding: 0 16px; }
	.nav nav a:not(:last-child) { display: none; }
	.hero { padding-top: 56px; padding-bottom: 72px; }
	.why, .about { padding-top: 88px; }
	.why-lede { font-size: 19px; }
	.timeline { grid-template-columns: 1fr; }
	.stats dt { font-size: 32px; }
	.about-body { flex-direction: column; gap: 24px; }
	.avatar { width: 112px; height: 112px; }
	.grid { grid-template-columns: 1fr; }
	.hint { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
	.mark .d1 { fill-opacity: 0.35; }
	.mark .d2 { fill-opacity: 0.65; }
	.js [data-reveal] { filter: none; transform: none; }
}
