/* Public home page. Dark, full-screen scenes drawn in SVG by home.js.
   By default the page is a plain readable column. Inside the "scripting + motion allowed" block at the
   end, each scene becomes several screens tall with a sticky stage, and home.js animates it on scroll. */

:root {
	color-scheme: dark;
	--bg: #05080f;
	--bg-glow: #0c1a33;
	--text: #e9eef8;
	--muted: #8a97ad;
	--line: rgb(255 255 255 / 0.1);
	--cyan: #7ee8fa;
	--blue: #3d7bff;
	--amber: #ffb547;
	--mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
	--gutter: clamp(1rem, 4vw, 2.5rem);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 17px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	-webkit-font-smoothing: antialiased;
	overflow-x: clip;
}
a { color: inherit; text-underline-offset: 0.2em; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--blue); color: #fff; }

.mono { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

/* ---- Header ---- */
.top {
	position: fixed; inset: 0 0 auto; z-index: 20;
	display: flex; align-items: center; justify-content: space-between;
	padding: 1rem var(--gutter);
	background: linear-gradient(var(--bg), rgb(5 8 15 / 0));
}
.mark { font-weight: 750; letter-spacing: 0.06em; text-decoration: none; font-size: 0.95rem; }
.top nav { display: flex; align-items: center; gap: clamp(1rem, 3vw, 2rem); }
.top nav a { color: var(--muted); text-decoration: none; font-size: 0.9rem; transition: color 0.2s; }
.top nav a:hover { color: var(--text); }
/* "Sign in" leaves the page for the private hub, so it is drawn as a quiet pill, apart from the section links. */
.top nav a.sign-in { color: var(--text); border: 1px solid rgb(255 255 255 / 0.22); border-radius: 999px; padding: 0.2rem 0.8rem; margin: -0.2rem 0; }
.top nav a.sign-in:hover { border-color: var(--cyan); }
/* The smallest phones (320px wide): tighter gaps, so the menu keeps clear of the "ZW" mark. */
@media (max-width: 360px) { .top nav { gap: 0.8rem; } .top nav a.sign-in { padding-inline: 0.6rem; } }

/* ---- Section rail (right edge) ---- */
.rail { position: fixed; right: var(--gutter); top: 50%; translate: 0 -50%; z-index: 20; display: grid; gap: 1.4rem; justify-items: end; }
.rail::before { content: ""; position: absolute; right: 4px; top: 4px; bottom: 4px; width: 1px; background: var(--line); }
.rail a {
	position: relative; display: flex; align-items: center; gap: 0.75rem; text-decoration: none;
	font: 0.68rem/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}
.rail a::after { content: ""; width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--muted); background: var(--bg); transition: background 0.3s, border-color 0.3s, box-shadow 0.3s; }
.rail span { opacity: 0; translate: 6px 0; transition: opacity 0.3s, translate 0.3s; }
.rail a:hover span, .rail a:focus-visible span, .rail a[aria-current="true"] span { opacity: 1; translate: 0 0; }
.rail a[aria-current="true"] { color: var(--text); }
.rail a[aria-current="true"]::after { background: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 14px var(--cyan); }
@media (max-width: 720px) { .rail { display: none; } }

/* ---- Scenes ---- */
.scene { position: relative; }
.stage {
	position: relative; min-height: 100vh; min-height: 100svh;
	display: grid; place-items: center; align-content: center;
	padding: 6rem var(--gutter) 4.5rem; overflow: hidden;
}
.art { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.caption { position: absolute; left: var(--gutter); bottom: 1.4rem; margin: 0; max-width: calc(100% - 2 * var(--gutter)); }
.eyebrow { margin: 0 0 1.2rem; }

/* 1. Hero */
.hero .stage { background: radial-gradient(ellipse 70% 60% at 50% 50%, var(--bg-glow), var(--bg) 75%); }
.bonds line { stroke: var(--cyan); stroke-linecap: round; }
.hero-text {
	position: relative; z-index: 1; text-align: center; padding: 2rem 3rem;
	background: radial-gradient(closest-side, rgb(5 8 15 / 0.7), rgb(5 8 15 / 0));
	opacity: calc(1 - var(--fade, 0));
	transform: scale(calc(1 + var(--fade, 0) * 0.25));
	filter: blur(calc(var(--fade, 0) * 8px));
}
h1 {
	margin: 0; font-size: clamp(3.2rem, 12vw, 10rem); line-height: 0.92; letter-spacing: -0.05em; font-weight: 760;
	text-shadow: 0 0 30px var(--bg), 0 0 60px var(--bg);
}
.headline { margin: 1.1rem 0 0; color: var(--muted); font-size: clamp(1rem, 2.2vw, 1.3rem); text-shadow: 0 0 20px var(--bg); }
.hint { display: none; }

/* 2. About */
.about .stage { justify-items: center; }
.about-copy { position: relative; z-index: 1; width: min(100%, 52rem); }
.about-text { margin: 0; font-size: clamp(1.45rem, 3.4vw, 2.6rem); line-height: 1.22; letter-spacing: -0.025em; font-weight: 620; text-wrap: balance; }
.about-text .w { transition: opacity 0.35s, color 0.35s; }
.wave { position: relative; inset: auto; width: min(100%, 72rem); height: auto; margin-top: clamp(1.5rem, 5vh, 3rem); }
.wave .axis { stroke: var(--line); }
.wave .barrier-top { stroke: var(--amber); stroke-width: 2; }
.wave .label { fill: var(--amber); font: 15px var(--mono); }
.wave .density { fill: var(--blue); opacity: 0.28; }
.wave .envelope { fill: none; stroke: var(--muted); stroke-dasharray: 3 6; opacity: 0.55; }
.wave .psi { fill: none; stroke: var(--cyan); stroke-width: 2.2; stroke-linejoin: round; }

/* 3. Projects */
.work .stage { display: block; padding-top: 7rem; }
.work .eyebrow { position: relative; z-index: 1; }
.ghost {
	position: absolute; left: var(--gutter); top: 50%; translate: 0 -50%; margin: 0;
	font-size: clamp(6rem, 24vw, 22rem); font-weight: 800; letter-spacing: -0.06em; line-height: 1;
	color: transparent; -webkit-text-stroke: 1px rgb(255 255 255 / 0.08);
	white-space: nowrap; pointer-events: none; user-select: none;
}
.track { position: relative; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); gap: 1.25rem; }
.card {
	position: relative; display: flex; flex-direction: column; gap: 0.6rem; padding: 1.5rem;
	border: 1px solid var(--line); border-radius: 20px;
	background: linear-gradient(160deg, rgb(255 255 255 / 0.07), rgb(255 255 255 / 0.015));
	backdrop-filter: blur(8px);
}
.card h3 { margin: 0; font-size: 1.35rem; letter-spacing: -0.02em; line-height: 1.25; }
.card p { margin: 0; color: var(--muted); }
.card .tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: auto; padding-top: 0.6rem; }
.tags span { font: 0.7rem var(--mono); letter-spacing: 0.06em; color: var(--cyan); border: 1px solid rgb(126 232 250 / 0.25); border-radius: 999px; padding: 0.15rem 0.6rem; }
.glyph { width: 100%; height: auto; aspect-ratio: 200 / 120; margin-bottom: 0.4rem; fill: none; stroke: var(--cyan); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.glyph :is(path, line, circle, ellipse) { stroke-dasharray: 1px 1px; stroke-dashoffset: calc((1 - var(--draw, 1)) * 1px); }
.glyph .faint { stroke: var(--muted); opacity: 0.4; }

/* 4. Contact */
.contact .stage { background: radial-gradient(circle at 50% 50%, var(--bg-glow), var(--bg) 70%); }
.pattern { inset: auto; left: 50%; top: 50%; translate: -50% -50%; width: min(96vw, 96vh); height: min(96vw, 96vh); }
.pattern .ring { fill: none; stroke: var(--cyan); stroke-opacity: 0.18; stroke-dasharray: 1px 1px; }
.pattern .spot { fill: #dff9ff; }
.pattern .beam { fill: #ffffff; }
/* home.js focuses the section after a jump to it; the section itself needs no outline. */
.scene:focus { outline: none; }
.contact-copy { position: relative; z-index: 1; text-align: center; opacity: var(--show, 1); translate: 0 calc((1 - var(--show, 1)) * 2rem); }
h2 { margin: 0 0 1.75rem; font-size: clamp(2.6rem, 8vw, 6rem); line-height: 1; letter-spacing: -0.05em; font-weight: 760; text-shadow: 0 0 30px var(--bg); }
.links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; }
.links a {
	display: inline-block; padding: 0.6rem 1.3rem; border: 1px solid var(--line); border-radius: 999px;
	background: rgb(5 8 15 / 0.7); text-decoration: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.links a:hover { border-color: var(--cyan); box-shadow: 0 0 20px rgb(126 232 250 / 0.25); }
.data { margin: 2rem 0 0; text-transform: none; letter-spacing: 0.02em; }
.data a { color: var(--cyan); }
.colophon { position: absolute; right: var(--gutter); bottom: 1.4rem; margin: 0; }
@media (max-width: 720px) { .colophon { display: none; } }

/* ---- Scroll-driven layout (JavaScript on, motion allowed) ---- */
@media (scripting: enabled) and (prefers-reduced-motion: no-preference) {
	html { scroll-behavior: smooth; }
	.hero { height: 360vh; }
	.about { height: 280vh; }
	.contact { height: 240vh; }
	.stage { position: sticky; top: 0; height: 100vh; height: 100svh; min-height: 0; }

	.hint {
		display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
		position: absolute; bottom: 1.4rem; left: 50%; translate: -50% 0;
		opacity: calc(1 - var(--p, 0) * 14);
	}
	.hint::after {
		content: ""; width: 1px; height: 2.6rem; transform-origin: top;
		background: linear-gradient(var(--cyan), rgb(126 232 250 / 0));
		animation: drip 2s ease-in-out infinite;
	}
	@keyframes drip {
		0% { transform: scaleY(0); opacity: 1; }
		70% { transform: scaleY(1); opacity: 1; }
		100% { transform: scaleY(1); opacity: 0; }
	}

	.about-text .w { opacity: 0.16; }
	.about-text .w.lit { opacity: 1; }

	/* flex-start, not centre: a centred track wider than the screen would start off to the left. */
	.work .stage { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding-top: 5rem; }
	.track {
		display: flex; width: max-content; gap: 1.5rem;
		padding-inline: max(var(--gutter), calc(50vw - min(40vw, 13rem)));
		transform: translate3d(var(--x, 0px), 0, 0);
	}
	.card {
		width: min(80vw, 26rem); flex: none;
		opacity: calc(0.3 + 0.7 * var(--draw, 1));
		transform: perspective(1000px) rotateY(var(--tilt, 0deg)) scale(calc(0.9 + 0.1 * var(--draw, 1)));
	}
	.ghost { transform: translateX(calc(var(--x, 0px) * 0.3)); }
}
