/*
 * site.css — the site's only stylesheet (loaded by src/layouts/BaseLayout.astro).
 *
 * Design adapted from mattrothenberg.com: a single narrow column, big
 * Instrument Sans paragraphs, small semi-condensed uppercase section labels,
 * pill "company badges" with a rotating colour glow on hover, and Paper Mono
 * list rows separated by hairlines.
 *
 * Classes are prefixed `ed-`; <body> carries `.ed`. Light/dark is driven by
 * the `data-theme` attribute on <html> (set before paint by BaseLayout and
 * toggled/saved by SiteFooter), falling back to the OS preference.
 */

/* ---------- Fonts (self-hosted, SIL OFL — licences in /fonts) ---------- */

@font-face {
	font-family: 'Instrument Sans';
	src: url('/fonts/instrument-sans-variable.woff') format('woff');
	font-weight: 400 700;
	font-stretch: 75% 100%;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: 'Paper Mono';
	src: url('/fonts/paper-mono-variable.woff2') format('woff2');
	font-weight: 100 800;
	font-style: normal;
	font-display: swap;
}

/* Lets the badge glow's conic gradient rotate smoothly. */
@property --ed-glow-angle {
	syntax: '<angle>';
	inherits: false;
	initial-value: 0deg;
}

/* ---------- Tokens (warm "stone" greys, as on the original) ---------- */

:root {
	--ed-gray-50: oklch(0.985 0.001 106.423);
	--ed-gray-100: oklch(0.97 0.001 106.424);
	--ed-gray-200: oklch(0.923 0.003 48.717);
	--ed-gray-300: oklch(0.869 0.005 56.366);
	--ed-gray-400: oklch(0.709 0.01 56.259);
	--ed-gray-500: oklch(0.553 0.013 58.071);
	--ed-gray-600: oklch(0.444 0.011 73.639);
	--ed-gray-700: oklch(0.374 0.01 67.558);
	--ed-gray-800: oklch(0.268 0.007 34.298);
	--ed-gray-900: oklch(0.216 0.006 56.043);
	--ed-gray-950: oklch(0.147 0.004 49.25);

	--ed-font-sans: 'Instrument Sans', system-ui, -apple-system, sans-serif;
	--ed-font-mono: 'Paper Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

	/* Light theme (default) */
	--ed-bg: #fff;
	--ed-fg: var(--ed-gray-900);
	--ed-heading: var(--ed-gray-900);
	--ed-muted: var(--ed-gray-500);
	--ed-rule: color-mix(in oklab, var(--ed-gray-950) 10%, transparent);
	--ed-hover: color-mix(in oklab, var(--ed-gray-100) 50%, transparent);
	--ed-ring: var(--ed-gray-300);
	--ed-badge-bg: #fff;
	--ed-badge-border: var(--ed-gray-200);
	--ed-badge-active-bg: var(--ed-gray-950);
	--ed-badge-active-fg: #fff;
	--ed-icon-outline: rgb(0 0 0 / 0.1);
}

:root[data-theme='dark'] {
	--ed-bg: var(--ed-gray-900);
	--ed-fg: var(--ed-gray-100);
	--ed-heading: #fff;
	--ed-muted: var(--ed-gray-400);
	--ed-rule: rgb(255 255 255 / 0.1);
	--ed-hover: color-mix(in oklab, var(--ed-gray-800) 20%, transparent);
	--ed-ring: var(--ed-gray-600);
	--ed-badge-bg: var(--ed-gray-900);
	--ed-badge-border: var(--ed-gray-700);
	--ed-badge-active-bg: #fff;
	--ed-badge-active-fg: var(--ed-gray-950);
	--ed-icon-outline: rgb(255 255 255 / 0.1);
}

/* No stored/assigned theme yet (e.g. JS disabled): follow the OS. */
@media (prefers-color-scheme: dark) {
	:root:not([data-theme]) {
		--ed-bg: var(--ed-gray-900);
		--ed-fg: var(--ed-gray-100);
		--ed-heading: #fff;
		--ed-muted: var(--ed-gray-400);
		--ed-rule: rgb(255 255 255 / 0.1);
		--ed-hover: color-mix(in oklab, var(--ed-gray-800) 20%, transparent);
		--ed-ring: var(--ed-gray-600);
		--ed-badge-bg: var(--ed-gray-900);
		--ed-badge-border: var(--ed-gray-700);
		--ed-badge-active-bg: #fff;
		--ed-badge-active-fg: var(--ed-gray-950);
		--ed-icon-outline: rgb(255 255 255 / 0.1);
	}
}

/* ---------- Base ---------- */

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

html {
	background-color: var(--ed-bg);
	color-scheme: light;
}

:root[data-theme='dark'] {
	color-scheme: dark;
}

body.ed {
	margin: 0;
	background-color: var(--ed-bg);
	color: var(--ed-fg);
	font-family: var(--ed-font-sans);
	font-size: 16px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	transition: background-color 0.2s ease-out, color 0.2s ease-out;
}

/* Resets are wrapped in :where() so they carry zero specificity and any
   component class (e.g. .ed-rows margins) overrides them. */
:where(.ed) :where(h1, h2, h3, p, ul) {
	margin: 0;
	padding: 0;
}

:where(.ed) ul {
	list-style: none;
}

:where(.ed) a {
	color: inherit;
	text-decoration: none;
}

:where(.ed) img {
	display: block;
	max-width: 100%;
}

.ed :focus-visible {
	outline: none;
	box-shadow: 0 0 0 2px var(--ed-ring);
}

/* ---------- Layout ---------- */

.ed-page {
	padding-top: 2rem;
	padding-bottom: 4rem;
}

.ed-content {
	max-width: 48rem;
	margin-inline: auto;
	padding-inline: 1.5rem;
	display: flex;
	flex-direction: column;
	gap: 3rem;
}

.ed-section {
	display: flex;
	flex-direction: column;
	gap: 1.5rem;
}

@media (min-width: 768px) {
	.ed-page {
		padding-top: 4rem;
	}

	.ed-content {
		gap: 4rem;
	}
}

/* ---------- Top bar: monogram + name, social icons ---------- */

.ed-topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: -0.5rem; /* 40px to the intro, like the original */
}

.ed-brand {
	display: inline-flex;
	align-items: center;
	gap: 0.75rem;
	min-width: 0;
	border-radius: 0.25rem;
}

.ed-brand-name {
	font-family: var(--ed-font-sans);
	font-size: 1rem;
	font-weight: 500;
	letter-spacing: 0.02em;
	line-height: 1;
	text-transform: uppercase;
	white-space: nowrap;
	color: var(--ed-heading);
}

.ed-monogram {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.75rem;
	height: 1.75rem;
	line-height: 0;
	font-family: var(--ed-font-sans);
	font-weight: 600;
	font-size: 17px;
	color: var(--ed-heading);
	corner-shape: squircle;
	border-radius: 28%;
	padding-bottom: 2px;
	box-shadow: inset 0 0 0 1.5px, inset 0 -3px;
	transition:
		transform 0.12s cubic-bezier(0.23, 1, 0.32, 1),
		box-shadow 0.12s cubic-bezier(0.23, 1, 0.32, 1),
		padding 0.12s cubic-bezier(0.23, 1, 0.32, 1);
}

.ed-brand:hover .ed-monogram {
	padding-bottom: 0;
	transform: translateY(1px);
	box-shadow: inset 0 0 0 1.5px, inset 0 -1.5px;
}

.ed-brand:active .ed-monogram {
	transform: translateY(2px) scale(0.97);
}

.ed-social {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.ed-social a {
	display: grid;
	place-items: center;
	width: 2rem;
	height: 2rem;
	border-radius: 0.375rem;
	color: var(--ed-muted);
	transition: color 0.15s ease-out, background-color 0.15s ease-out;
}

.ed-social a:hover,
.ed-social a:focus-visible {
	color: var(--ed-heading);
	background-color: var(--ed-hover);
}

.ed-social svg {
	width: 1.05rem;
	height: 1.05rem;
	fill: currentColor;
}

/* Tight phones: keep everything on one line. */
@media (max-width: 380px) {
	.ed-brand {
		gap: 0.5rem;
	}

	.ed-brand-name {
		font-size: 0.875rem;
	}

	.ed-social {
		gap: 0;
	}

	.ed-social a {
		width: 1.75rem;
	}
}

/* ---------- Type ---------- */

/* Big editorial paragraphs (h1 + body copy). */
.ed-lede {
	font-family: var(--ed-font-sans);
	font-size: 1.125rem;
	font-weight: 400;
	line-height: 1.375;
	text-wrap: pretty;
}

.ed-lede strong,
.ed-lede b {
	font-weight: 700;
}

@media (min-width: 768px) {
	.ed-lede {
		font-size: 1.625rem;
	}
}

/* Small uppercase section labels. */
.ed-label {
	font-family: var(--ed-font-sans);
	font-stretch: 87.5%; /* semi-condensed */
	font-weight: 600;
	font-size: 0.8125rem;
	line-height: 1;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--ed-heading);
}

@media (min-width: 768px) {
	.ed-label {
		font-size: 1.0625rem;
		letter-spacing: 0.02em;
	}
}

/* Underlined inline links. */
.ed .ed-link {
	text-decoration-line: underline;
	text-decoration-thickness: 2px;
	text-underline-offset: 0.15em;
	text-decoration-color: color-mix(in oklab, currentColor 60%, transparent);
	border-radius: 0.25rem;
	transition: text-decoration-color 0.15s ease-out;
}

.ed .ed-link:hover {
	text-decoration-color: currentColor;
}

/* ---------- Company badge pill ---------- */

.ed-badge {
	--ed-glow: var(--ed-muted); /* set per badge via inline style */
	position: relative;
	isolation: isolate;
	display: inline-flex;
	align-items: baseline;
	gap: 0.2em;
	margin-inline: 0.05em;
	padding-block: 0.05em;
	padding-inline: 0.35em;
	vertical-align: baseline;
	border: 1px solid transparent;
	border-radius: 9999px;
	background:
		linear-gradient(var(--ed-badge-bg), var(--ed-badge-bg)) padding-box,
		linear-gradient(var(--ed-badge-border), var(--ed-badge-border)) border-box;
	transition: box-shadow 0.3s ease-out, background 0.2s ease-out, color 0.2s ease-out;
	white-space: nowrap;
}

/* Rotating conic glow drawn only in the border ring. */
.ed-badge::before {
	content: '';
	position: absolute;
	inset: -1px;
	z-index: 0;
	pointer-events: none;
	border: 2px solid transparent;
	border-radius: inherit;
	background: conic-gradient(
			from var(--ed-glow-angle),
			transparent 0%,
			var(--ed-glow) 7%,
			var(--ed-glow) 21%,
			transparent 32%
		)
		border-box;
	-webkit-mask:
		linear-gradient(#000, #000) padding-box,
		linear-gradient(#000, #000) border-box;
	-webkit-mask-composite: xor;
	mask:
		linear-gradient(#000, #000) padding-box exclude,
		linear-gradient(#000, #000) border-box;
	opacity: 0;
	transition: opacity 0.3s ease-out;
	animation: ed-glow-rotate 4s linear infinite;
}

a.ed-badge:hover,
a.ed-badge:focus-visible {
	color: var(--ed-badge-active-fg);
	background:
		linear-gradient(var(--ed-badge-active-bg), var(--ed-badge-active-bg)) padding-box,
		linear-gradient(transparent, transparent) border-box;
	box-shadow: 0 0 8px color-mix(in srgb, var(--ed-glow) 18%, transparent);
}

a.ed-badge:hover::before,
a.ed-badge:focus-visible::before {
	opacity: 1;
}

.ed-badge-mark {
	position: relative;
	z-index: 1;
	align-self: center;
	display: inline-grid;
	place-items: center;
	width: 0.85em;
	height: 0.85em;
	border-radius: 0.2em;
	background: var(--ed-glow);
	color: #fff;
	font-family: var(--ed-font-sans);
	font-size: 0.85em;
	font-weight: 700;
	line-height: 1;
}

.ed-badge-mark span {
	font-size: 0.62em;
}

.ed-badge-name {
	position: relative;
	z-index: 1;
	font-family: var(--ed-font-sans);
	font-weight: 500;
	font-size: 0.9em;
}

/* Real logo instead of the coloured initial. */
.ed-badge-mark--logo {
	width: 1em;
	height: 1em;
	border-radius: 0;
	background: none;
}

.ed-badge-mark--logo img,
.ed-row-icon--logo img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

@keyframes ed-glow-rotate {
	to {
		--ed-glow-angle: 360deg;
	}
}

/* ---------- Mono rows list (work history) ---------- */

.ed-rows {
	margin-inline: -1rem;
	margin-top: 1rem; /* extra room above the list, on top of the section gap */
}

.ed-rows > li + li {
	border-top: 1px solid var(--ed-rule);
}

.ed-rows > li:last-child {
	border-bottom: 1px solid var(--ed-rule);
}

.ed-row {
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: 0.5rem 1rem;
	font-family: var(--ed-font-mono);
	font-size: 0.875rem;
	line-height: 1.5;
	text-transform: uppercase;
	-webkit-font-smoothing: subpixel-antialiased;
	transition: background-color 0.15s ease-out;
}

a.ed-row:hover,
a.ed-row:focus-visible {
	background-color: var(--ed-hover);
}

.ed-row-main {
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: center;
}

.ed-row-icon {
	flex-shrink: 0;
	display: grid;
	place-items: center;
	width: 1.25rem;
	height: 1.25rem;
	margin-right: 0.75rem;
	border-radius: 5px;
	outline: 1px solid var(--ed-icon-outline);
	outline-offset: -1px;
	background: var(--ed-glow, var(--ed-muted));
	color: #fff;
	font-family: var(--ed-font-sans);
	font-weight: 700;
	font-size: 0.6875rem;
	line-height: 1;
}

.ed-row-icon--logo {
	background: none;
	outline: none;
	border-radius: 0;
}

.ed-row-owner {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color: var(--ed-muted);
}

.ed-row-slash {
	flex-shrink: 0;
	margin-inline: 0.25rem;
	color: var(--ed-muted);
}

.ed-row-name {
	flex-shrink: 0;
	white-space: nowrap;
	font-weight: 700;
}

.ed-row-meta {
	flex-shrink: 0;
	font-variant-numeric: tabular-nums;
}

@media (min-width: 768px) {
	.ed-row {
		font-size: 1rem;
	}
}

/* On narrow screens let long role names wrap under the company. */
@media (max-width: 599px) {
	.ed-row-main {
		flex-wrap: wrap;
	}

	.ed-row-slash {
		display: none;
	}

	.ed-row-name {
		flex-basis: 100%;
		padding-left: 2rem; /* line up under the company, past the icon */
		white-space: normal;
	}

	.ed-row-meta {
		align-self: flex-start;
		font-size: 0.75rem;
		padding-top: 0.15rem;
	}
}

/* ---------- Call-to-action block ---------- */

.ed-cta {
	display: block;
	margin-inline: -1rem;
	padding: 2rem 1rem;
	border-top: 1px solid var(--ed-rule);
	border-bottom: 1px solid var(--ed-rule);
	transition: background-color 0.15s ease-out;
}

.ed-cta:hover,
.ed-cta:focus-visible {
	background-color: var(--ed-hover);
}

.ed-cta strong {
	font-weight: 700;
}

/* ---------- Figures / images ---------- */

.ed-figure {
	margin: 0;
	padding-top: 1.5rem;
	display: flex;
	justify-content: center;
}

.ed-figure img {
	height: auto;
}

/* Black artwork (e.g. the Packet32 logo) flips to white in dark mode. */
.ed-invert-dark {
	transition: filter 0.25s ease;
}

:root[data-theme='dark'] .ed-invert-dark {
	filter: invert(1);
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme]) .ed-invert-dark {
		filter: invert(1);
	}
}

/* Badge hover flips the pill to near-black (light theme) or white (dark
   theme), so flip single-colour logos along with it. */
:root:not([data-theme='dark']) a.ed-badge:hover .ed-invert-dark,
:root:not([data-theme='dark']) a.ed-badge:focus-visible .ed-invert-dark {
	filter: invert(1);
}

:root[data-theme='dark'] a.ed-badge:hover .ed-invert-dark,
:root[data-theme='dark'] a.ed-badge:focus-visible .ed-invert-dark {
	filter: none;
}

/* Logos with dark parts get a small light tile in dark mode. */
:root[data-theme='dark'] .ed-tile-dark {
	background: #fff;
	border-radius: 18%;
	padding: 6%;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme]) .ed-tile-dark {
		background: #fff;
		border-radius: 18%;
		padding: 6%;
	}
}

/* ---------- Footer ---------- */

.ed-footer {
	display: flex;
	flex-wrap: nowrap; /* pill stays beside the text, centered on it */
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding-top: 1.5rem;
	border-top: 1px solid var(--ed-rule);
	font-family: var(--ed-font-mono);
	font-size: 0.75rem;
	line-height: 1.6;
	text-transform: uppercase;
	color: var(--ed-muted);
}

.ed-footer > p {
	flex: 1;
	min-width: 0;
}

.ed-theme-switch {
	flex-shrink: 0;
}

.ed-footer a {
	color: var(--ed-fg);
	text-decoration: underline;
	text-decoration-color: var(--ed-rule);
	text-underline-offset: 0.2em;
}

.ed-footer a:hover {
	text-decoration-color: currentColor;
}

.ed-theme-switch {
	display: inline-flex;
	align-items: center;
	gap: 0.125rem;
	padding: 0.1875rem;
	border: 1px solid var(--ed-badge-border);
	border-radius: 9999px;
	background: var(--ed-badge-bg);
}

.ed-theme-switch button {
	display: grid;
	place-items: center;
	width: 1.75rem;
	height: 1.75rem;
	padding: 0;
	border: 0;
	border-radius: 9999px;
	background: none;
	color: var(--ed-muted);
	cursor: pointer;
	transition: color 0.15s ease-out, background-color 0.15s ease-out;
}

.ed-theme-switch button:hover {
	background-color: var(--ed-hover);
}

.ed-theme-switch button[aria-pressed='true'] {
	color: var(--ed-heading);
}

.ed-theme-switch svg {
	width: 1rem;
	height: 1rem;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* ---------- Motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
	.ed-monogram,
	.ed-social a,
	.ed-badge,
	.ed-badge::before,
	.ed-theme-switch button,
	body.ed {
		transition: none;
		animation: none;
	}
}
