/* ---------- tokens ---------- */
/* No webfont. System sans, black on white, hairline rules, no accent colour —
   the only colour on the page comes from photographs and project thumbnails. */
:root {
	--sans:
		-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
		Arial, sans-serif;
	--mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

	--bg: #ffffff;
	--surface: #f6f6f5; /* behind thumbnails while they load */
	--text: #111111;
	--muted: #6b6b6b; /* 5.4:1 on white */
	--line: #e6e6e6;

	--measure: 62rem;
	--prose: 38rem;
	--ease: cubic-bezier(0.2, 0.8, 0.25, 1);
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: var(--sans);
	font-size: 1.0625rem;
	line-height: 1.65;
	-webkit-font-smoothing: antialiased;
	/* Keeps the footer on the bottom edge of short pages (/blog/ is one post). */
	display: flex;
	flex-direction: column;
	min-height: 100dvh;
}
main {
	flex: 1;
}

.wrap {
	width: 100%;
	max-width: var(--measure);
	margin-inline: auto;
	padding-inline: 1.5rem;
}

a {
	color: inherit;
	text-decoration: none;
}
a:hover {
	text-decoration: underline;
	text-underline-offset: 0.2em;
	text-decoration-thickness: 1px;
}
:focus-visible {
	outline: 2px solid var(--text);
	outline-offset: 3px;
}

img {
	max-width: 100%;
	height: auto;
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

h1,
h2,
h3 {
	margin: 0;
	line-height: 1.2;
	font-weight: 500;
	letter-spacing: -0.02em;
}
h1 {
	font-size: clamp(1.9rem, 4.4vw, 2.9rem);
	font-weight: 400;
}
h2 {
	font-size: clamp(1.35rem, 2.4vw, 1.7rem);
}
h3 {
	font-size: 1.1rem;
}
p {
	margin: 0 0 1.1rem;
}
p:last-child {
	margin-bottom: 0;
}

.lede {
	font-size: 1.15rem;
	color: var(--muted);
	line-height: 1.6;
	max-width: var(--prose);
}
.meta {
	font-size: 0.85rem;
	color: var(--muted);
}
/* Tech lists and small labels. Plain text, not pills. */
.stack {
	font-size: 0.82rem;
	color: var(--muted);
}
.label {
	font-family: var(--mono);
	font-size: 0.72rem;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--muted);
}

/* ---------- brand + wordmark ---------- */
.brand {
	display: inline-flex;
	align-items: center;
	gap: 0.8rem;
}
/* In colour, deliberately — it's the one face on the site. */
.brand img {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	object-fit: cover;
	object-position: 50% 18%;
}
.masthead .brand span {
	font-size: 0.8rem;
	font-weight: 500;
	text-transform: uppercase;
	letter-spacing: 0.16em;
	white-space: nowrap;
}

/* The splash name. Two grid rows stretched to the width of the longer one, so
   flex space-between makes ANDREI and DRAGOMIR flush on both edges without a
   per-line tracking value. `gap` is the minimum tracking; the shorter line gets
   the leftover space added to it. */
.wordmark {
	position: relative;
	display: grid;
	font-size: clamp(1.85rem, 5.4vw, 3.4rem);
	font-weight: 300;
	line-height: 1.08;
	text-transform: uppercase;
}
.wm-line {
	display: flex;
	justify-content: space-between;
	gap: 0.18em;
}
.wm-line i {
	font-style: normal;
}
.brand-lg {
	gap: clamp(1rem, 2.6vw, 2rem);
}
.brand-lg img {
	width: clamp(72px, 10vw, 118px);
	height: clamp(72px, 10vw, 118px);
}

/* ---------- splash (first viewport of the home page) ---------- */
.splash {
	min-height: 100dvh;
	display: grid;
	grid-template-rows: 1fr auto;
	padding: 2rem 1.5rem 2.25rem;
}
.splash-main {
	align-self: center;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: clamp(2.5rem, 8vw, 6rem);
}
.splash-nav {
	display: flex;
	flex-direction: column;
	font-size: clamp(1.45rem, 3.4vw, 2rem);
	font-weight: 300;
	line-height: 1.5;
}
.splash-nav a {
	width: max-content;
	transition:
		transform 0.3s var(--ease),
		opacity 0.3s ease;
}
.splash-nav a:hover {
	text-decoration: none;
	transform: translateX(0.55rem);
	opacity: 0.5;
}
.splash-foot {
	display: grid;
	justify-items: center;
	gap: 1.5rem;
}
.splash-cue {
	font-family: var(--mono);
	font-size: 0.7rem;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--muted);
}
.splash-cue:hover {
	text-decoration: none;
	color: var(--text);
}
.splash-cue span {
	display: inline-block;
}

/* ---------- socials ---------- */
.socials {
	display: flex;
	justify-content: center;
	gap: 1.25rem;
}
.socials a {
	display: block;
	color: var(--muted);
	transition:
		color 0.2s ease,
		transform 0.2s var(--ease);
}
.socials a:hover {
	color: var(--text);
	transform: translateY(-3px);
}
.socials svg {
	display: block;
	width: 19px;
	height: 19px;
	fill: currentColor;
}

/* ---------- masthead ---------- */
.masthead {
	position: sticky;
	top: 0;
	z-index: 50;
	background: var(--bg);
	border-bottom: 1px solid var(--line);
}
/* On the home page the splash's own big nav is the masthead, so this one is out
   of flow (the splash gets the whole viewport) and only arrives on scroll. */
.home .masthead {
	position: fixed;
	inset: 0 0 auto;
}
.masthead .wrap {
	display: flex;
	align-items: center;
	gap: 1.5rem;
	padding-block: 1.1rem;
}
.masthead nav {
	margin-left: auto;
	display: flex;
	gap: 1.6rem;
	font-size: 0.95rem;
	color: var(--muted);
}
.masthead nav a {
	position: relative;
}
.masthead nav a:hover {
	color: var(--text);
	text-decoration: none;
}
.masthead nav a[aria-current] {
	color: var(--text);
}
.masthead nav a::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: -3px;
	height: 1px;
	background: currentColor;
	transform: scaleX(0);
	transform-origin: left;
	transition: transform 0.28s var(--ease);
}
.masthead nav a:hover::after,
.masthead nav a[aria-current]::after {
	transform: scaleX(1);
}
@media (max-width: 560px) {
	.masthead .wrap {
		gap: 1rem;
	}
	.masthead nav {
		gap: 1.05rem;
		font-size: 0.9rem;
	}
	.masthead .brand span {
		display: none;
	}
}

/* ---------- page structure ---------- */
main section {
	padding-bottom: clamp(3rem, 6vw, 4.5rem);
}
main section.splash {
	padding-bottom: 2.25rem;
}
/* Clears the fixed masthead when you jump to #about. */
#about {
	scroll-margin-top: 4.5rem;
}
.page-head {
	max-width: var(--prose);
	padding-block: clamp(1.5rem, 4vw, 3rem) clamp(2rem, 4vw, 3rem);
}
.page-head .lede {
	margin-top: 1.1rem;
}
.section-head {
	border-top: 1px solid var(--line);
	padding-top: 1.1rem;
	margin-bottom: 2.25rem;
}
.section-head h2 {
	margin-top: 0.35rem;
}
.section-head p {
	margin: 0.7rem 0 0;
	color: var(--muted);
	max-width: var(--prose);
}
.section-foot {
	margin-top: 2rem;
	font-size: 0.9rem;
}
.section-foot a {
	text-decoration: underline;
	text-underline-offset: 0.25em;
	text-decoration-thickness: 1px;
	text-decoration-color: var(--line);
	transition: text-decoration-color 0.2s ease;
}
.section-foot a:hover {
	text-decoration-color: currentColor;
}

/* ---------- list rows (projects, services, jobs, posts) ---------- */
.rows {
	list-style: none;
	margin: 0;
	padding: 0;
}
.rows > li {
	border-top: 1px solid var(--line);
	padding: 1.6rem 0;
	display: grid;
	grid-template-columns: minmax(0, 13rem) minmax(0, 1fr);
	gap: 0.35rem 2.5rem;
	align-items: baseline;
}
.rows > li:last-child {
	border-bottom: 1px solid var(--line);
}
.rows h3 {
	font-weight: 500;
}
.rows p {
	margin: 0;
	color: var(--muted);
	font-size: 0.98rem;
	max-width: 40rem;
}
.rows .stack,
.rows .meta {
	display: block;
	margin-top: 0.15rem;
}
.row-body {
	display: flex;
	flex-direction: column;
	gap: 0.55rem;
}
.row-links {
	display: flex;
	flex-wrap: wrap;
	gap: 1.1rem;
	font-size: 0.88rem;
}
.row-links a {
	text-decoration: underline;
	text-underline-offset: 0.25em;
	text-decoration-thickness: 1px;
	text-decoration-color: var(--line);
	transition: text-decoration-color 0.2s ease;
}
.row-links a:hover {
	text-decoration-color: currentColor;
}

/* Rows with a thumbnail: the image takes the left column instead of the label. */
.rows--media > li {
	grid-template-columns: minmax(0, 18rem) minmax(0, 1fr);
	align-items: start;
	gap: 1.25rem 2.5rem;
}
/* `--fig` comes from the project's `figure_height`: it shortens the box to where
   the schematic's content actually ends, and `cover` + a top-anchored
   object-position then crops off the decorative filler underneath. Screenshots
   have no --fig and stay 16:9. */
.thumb {
	display: block;
	aspect-ratio: var(--fig, 1200 / 675);
	overflow: hidden;
	border: 1px solid var(--line);
	background: var(--surface);
}
.thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: 50% 0;
	transform-origin: top center;
	transition: transform 0.5s var(--ease);
}
.rows--media > li:hover .thumb img {
	transform: scale(1.045);
}
.rows--media h3 {
	margin-top: -0.35rem;
}
@media (max-width: 640px) {
	.rows > li {
		grid-template-columns: 1fr;
		gap: 0.7rem;
	}
	.rows--media > li {
		grid-template-columns: 1fr;
	}
	.rows--media h3 {
		margin-top: 0;
	}
}

/* Numbered prose list (the three habits). Same rules, no boxes. */
.numbered {
	list-style: none;
	margin: 0;
	padding: 0;
	counter-reset: n;
}
.numbered > li {
	counter-increment: n;
	border-top: 1px solid var(--line);
	padding: 1.6rem 0;
	display: grid;
	grid-template-columns: 3.5rem minmax(0, 1fr);
	gap: 0.4rem 1.5rem;
	align-items: baseline;
}
.numbered > li::before {
	content: "0" counter(n);
	font-family: var(--mono);
	font-size: 0.78rem;
	color: var(--muted);
}
.numbered p {
	grid-column: 2;
	margin: 0;
	color: var(--muted);
}

/* ---------- about block (on the home page) ---------- */
.about-head {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: clamp(1.5rem, 5vw, 3.5rem);
	align-items: start;
	padding-block: clamp(2rem, 5vw, 3.5rem) clamp(2rem, 4vw, 3rem);
}
.portrait {
	width: clamp(9rem, 16vw, 13rem);
	aspect-ratio: 4 / 5;
	object-fit: cover;
	object-position: 50% 18%;
}
@media (max-width: 700px) {
	.about-head {
		grid-template-columns: 1fr;
	}
	.portrait {
		width: 8rem;
	}
}

.details {
	display: grid;
	grid-template-columns: minmax(0, 8rem) minmax(0, 1fr);
	gap: 0.15rem 2rem;
	margin: 0;
	max-width: 34rem;
}
.details dt {
	font-family: var(--mono);
	font-size: 0.72rem;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--muted);
	padding-top: 0.35rem;
}
.details dd {
	margin: 0 0 0.6rem;
	overflow-wrap: anywhere;
}
.details dd a {
	text-decoration: underline;
	text-underline-offset: 0.25em;
	text-decoration-thickness: 1px;
	text-decoration-color: var(--line);
}
@media (max-width: 460px) {
	.details {
		grid-template-columns: 1fr;
	}
	.details dt {
		padding-top: 0.8rem;
	}
}

/* ---------- post body ---------- */
.post,
.post-head {
	max-width: var(--prose);
}
.post-head {
	padding-block: clamp(1.5rem, 4vw, 3rem) 2.25rem;
}
.post-head .meta {
	display: block;
	margin-top: 0.9rem;
}
.post h2 {
	margin: 3rem 0 0.85rem;
	scroll-margin-top: 5rem;
}
.post h3 {
	margin: 2rem 0 0.5rem;
}
.post h2 + h3 {
	margin-top: 1.3rem;
}
/* Figures break out of the prose column to the full wrap width — the schematics
   need ~1000px for their BEFORE/AFTER labels to stay readable. `--measure - 3rem`
   IS the wrap's content width, so the figure's left edge lands on the text's. */
.post img {
	display: block;
	border: 1px solid var(--line);
	width: min(calc(var(--measure) - 3rem), calc(100vw - 3rem));
	max-width: none;
	margin: 1.75rem 0;
}
.post figure {
	margin: 1.75rem 0;
}
.post figure img {
	margin: 0;
}
.post figcaption {
	font-family: var(--mono);
	font-size: 0.74rem;
	color: var(--muted);
	margin-top: 0.6rem;
}
.post ul,
.post ol {
	padding-left: 1.3rem;
	margin: 0 0 1.1rem;
}
.post li {
	margin-bottom: 0.4rem;
}
.post p a,
.post li a {
	text-decoration: underline;
	text-underline-offset: 0.15em;
	text-decoration-thickness: 1px;
}
.post blockquote {
	margin: 1.75rem 0;
	padding-left: 1.15rem;
	border-left: 1px solid var(--line);
	color: var(--muted);
}
.post hr {
	border: 0;
	border-top: 1px solid var(--line);
	margin: 3rem 0;
}
/* Fact line under a case-study heading: stack and links, rules only. */
.facts {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem 1.5rem;
	align-items: baseline;
	padding: 0.7rem 0;
	margin: 0 0 1.4rem;
	border-block: 1px solid var(--line);
	font-size: 0.8rem;
	color: var(--muted);
}
.facts a {
	color: var(--text);
	text-decoration: underline;
	text-underline-offset: 0.25em;
	text-decoration-thickness: 1px;
	text-decoration-color: var(--line);
}

code,
pre {
	font-family: var(--mono);
	font-size: 0.85em;
}
pre {
	border: 1px solid var(--line);
	padding: 1rem 1.1rem;
	margin: 1.75rem 0;
	overflow-x: auto;
	line-height: 1.5;
}

/* ---------- footer ---------- */
footer {
	border-top: 1px solid var(--line);
	padding: 2rem 0 3rem;
}
footer .wrap {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 1rem 1.5rem;
}
footer .meta {
	margin-right: auto;
}
footer .socials {
	gap: 1.1rem;
}

/* ================= motion ================= */
@keyframes rise {
	from {
		opacity: 0;
		transform: translateY(1.1rem);
	}
}
@keyframes pop {
	from {
		opacity: 0;
		transform: scale(0.7);
	}
}
@keyframes bob {
	50% {
		transform: translateY(5px);
	}
}
@keyframes splash-out {
	to {
		opacity: 0;
		transform: translateY(-3.5rem) scale(0.94);
	}
}
@keyframes drop-in {
	from {
		opacity: 0;
		transform: translateY(-100%);
	}
}

@media (prefers-reduced-motion: no-preference) {
	html {
		scroll-behavior: smooth;
	}

	/* --- splash entrance: face, then the name letter by letter, then the nav --- */
	.brand-lg img {
		animation: pop 0.75s var(--ease) both;
	}
	.wm-line i {
		animation: rise 0.55s var(--ease) both;
		animation-delay: calc(0.2s + var(--i) * 0.045s);
	}
	.splash-nav a {
		animation: rise 0.6s var(--ease) both;
		animation-delay: calc(0.55s + var(--i) * 0.1s);
	}
	/* On the children, not .splash-foot itself — the scroll-morph rule below claims
	   that element's `animation` shorthand and would drop the entrance. */
	.splash-foot > * {
		animation: rise 0.7s var(--ease) both;
		animation-delay: 1s;
	}
	.splash-cue span {
		animation: bob 1.8s ease-in-out 2s infinite;
	}

	/* --- scroll morph: the splash dissolves upward as the compact masthead
	       drops in, so the home page turns into an ordinary page as you go.
	       One scroll(root) clock drives both halves. --- */
	@supports (animation-timeline: scroll()) {
		.home .masthead {
			animation: drop-in linear both;
			animation-timeline: scroll(root);
			animation-range: 15vh 55vh;
		}
		.splash-main,
		.splash-foot {
			animation: splash-out linear both;
			animation-timeline: scroll(root);
			animation-range: 0 68vh;
		}
	}

	/* --- scroll reveals on everything below the fold, no JS --- */
	@supports (animation-timeline: view()) {
		.about-head,
		.section-head,
		.rows > li,
		.numbered > li,
		.details {
			animation: rise linear both;
			animation-timeline: view();
			animation-range: entry 8% cover 26%;
		}
	}
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation: none !important;
		transition: none !important;
	}
}
