@font-face {
	font-family: "Latin Modern Roman";
	font-style: normal;
	font-weight: 400;
	font-display: swap;
	src: url("/fonts/lmroman10-regular.woff2") format("woff2");
}
@font-face {
	font-family: "Latin Modern Roman";
	font-style: italic;
	font-weight: 400;
	font-display: swap;
	src: url("/fonts/lmroman10-italic.woff2") format("woff2");
}
@font-face {
	font-family: "Latin Modern Roman";
	font-style: normal;
	font-weight: 700;
	font-display: swap;
	src: url("/fonts/lmroman10-bold.woff2") format("woff2");
}

:root {
	--bg: #f6f4ee;
	--fg: #0b1020;
	--muted: #5d5d66;
	--rule: #dcd9d0;
	--accent: #2f6bff;
	--gold: #e8b04b;
	--serif: "Latin Modern Roman", "CMU Serif", "Computer Modern", "STIX Two Text", Georgia, "Times New Roman", serif;
	color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0b1020;
		--fg: #f6f4ee;
		--muted: #a2a4b3;
		--rule: #24293d;
		--accent: #7ea1ff;
	}
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

/* A touch larger than the browser default, so every rem size grows with it. */
html { font-size: 106.25%; }

body {
	background: var(--bg);
	color: var(--fg);
	font-family: var(--serif);
	line-height: 1.5;
	text-rendering: optimizeLegibility;
	/* Latin Modern is a light face on screen. A hairline stroke in the text colour
	   thickens it slightly without switching to a synthetic bold. */
	-webkit-text-stroke: 0.22px currentColor;
}

pre, code, kbd, samp { -webkit-text-stroke: 0; }

/* Animated conformal map, behind everything. */
.plane {
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	z-index: -1;
	pointer-events: none;
}

.page {
	min-height: 100vh;
	min-height: 100dvh;
	display: flex;
	flex-direction: column;
	max-width: 72rem;
	margin: 0 auto;
	padding: 1.25rem 1rem;
}

/* Header and nav */
.top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	/* Keep the header, and the mobile menu that drops out of it, above everything else on the page. */
	position: relative;
	z-index: 1000;
}

.brand {
	display: inline-flex;
	align-items: center;
	gap: 1.4rem;
	color: inherit;
	text-decoration: none;
	font-size: 1.35rem;
	letter-spacing: 0.01em;
}

.brand svg { width: 2.1rem; height: 2.1rem; flex: none; }

.nav {
	display: flex;
	align-items: center;
	gap: 1.4rem;
	font-size: 1.15rem;
}

.nav a {
	color: inherit;
	text-decoration: none;
	padding: 0.2rem 0.1rem;
	border-bottom: 1px solid transparent;
}

.nav a:hover, .nav a:focus-visible, .nav a[aria-current="page"] {
	border-bottom-color: var(--accent);
}

.nav functorial-account { margin-left: 0.8rem; }

/* The sign-in control arrives with a script from id.functorial.inc. Until it does, hold
   the room a "Sign in" takes, so the links beside it never move. The control keeps it
   from there (infra: gateway/public/account.js, HOLD). */
.nav functorial-account:not(:defined) { display: inline-block; padding: 0.2rem 0.1rem; white-space: nowrap; visibility: hidden; }
.nav functorial-account:not(:defined)::before { content: "Sign in"; }

/* Hero */
.hero {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	padding: 3rem 0 6rem;
}

.hero h1 {
	margin: 0 0 1rem;
	font-weight: 400;
	font-size: clamp(2.4rem, 7vw, 4.75rem);
	line-height: 1.05;
	letter-spacing: -0.005em;
	text-wrap: balance;
}

.hero .tagline {
	margin: 0 0 2.25rem;
	max-width: 60ch;
	font-size: clamp(1.2rem, 2.6vw, 1.65rem);
	font-style: italic;
	color: var(--muted);
	text-wrap: balance;
}

.cta {
	display: inline-block;
	padding: 0.75rem 1.6rem;
	border: 1.5px solid var(--fg);
	border-radius: 999px;
	color: var(--fg);
	background: color-mix(in srgb, var(--bg) 80%, transparent);
	backdrop-filter: blur(4px);
	text-decoration: none;
	font-size: 1.2rem;
	transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

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

/* About page */
.prose {
	flex: 1;
	max-width: 46rem;
	width: 100%;
	margin: 0 auto;
	padding: 3rem 0 4rem;
}

.prose h1 { margin: 0 0 1rem; font-weight: 400; font-size: clamp(2rem, 5vw, 3rem); line-height: 1.1; }

.lede {
	margin: 0 0 2rem;
	font-size: 1.25rem;
	color: var(--muted);
}

.card {
	border: 1.5px solid color-mix(in srgb, var(--muted) 45%, transparent);
	border-radius: 18px;
	padding: 1.25rem 1.5rem 1.25rem;
	background: color-mix(in srgb, var(--bg) 85%, transparent);
	backdrop-filter: blur(6px);
}

.card + .card { margin-top: 1.5rem; }

.card-head {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 1rem;
	margin: 0 0 1.25rem;
}

.card-title { margin: 0; font-size: 1.05rem; color: var(--muted); }

.open { color: var(--accent); text-decoration: none; }
.open:hover { text-decoration: underline; }

.diagram {
	display: block;
	width: 100%;
	max-width: 36rem;
	height: auto;
	margin: 0 auto;
	overflow: visible;
}

.diagram .word { font-family: var(--serif); font-size: 72px; fill: var(--fg); }
.diagram .label { font-family: var(--serif); font-size: 18px; fill: var(--muted); }
.diagram .arrow, .diagram .head { fill: none; stroke: var(--accent); stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.diagram .node { fill: none; stroke: var(--rule); stroke-width: 1.5; }
.diagram .glyph { fill: none; stroke: var(--fg); stroke-width: 1.75; stroke-linejoin: round; }
.diagram .dot { fill: var(--fg); }

.cards .flash { fill: var(--bg); stroke: color-mix(in srgb, var(--muted) 60%, transparent); stroke-width: 1.5; }
.cards .flash.front { stroke: var(--accent); stroke-width: 2; }
.cards .corner { font-family: var(--serif); font-size: 16px; fill: var(--muted); }
.cards .keyword { font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace; font-size: 30px; fill: var(--fg); }

.how {
	list-style: none;
	margin: 1.5rem 0 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
	gap: 1.5rem;
}

.how li { display: flex; gap: 0.75rem; }
.n { color: var(--accent); padding-top: 0.15rem; }
.how h2 { margin: 0 0 0.25rem; font-size: 1.15rem; font-weight: 700; }
.how p { margin: 0; color: var(--muted); }

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

/* Terms and contact pages */
.legal { font-size: 1.1rem; }
.legal h2 { margin: 2rem 0 0.5rem; font-size: 1.3rem; font-weight: 700; scroll-margin-top: 1rem; }
.legal h2:first-child, .legal .toc + h2 { margin-top: 0.5rem; }
.legal p { margin: 0 0 0.85rem; }
.legal ul { margin: 0 0 0.85rem; padding-left: 1.25rem; }
.legal li { margin: 0 0 0.4rem; }
.legal a { color: var(--accent); }
.legal .email { margin: 0 0 1rem; font-size: 1.5rem; }

.toc { margin: 0 0 1.75rem; padding: 0 0 1.25rem; border-bottom: 1px solid var(--rule); }
.toc ol { margin: 0; padding-left: 1.5rem; columns: 2 14rem; column-gap: 2rem; }
.toc li { margin: 0 0 0.2rem; }

footer {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	column-gap: 1rem;
	font-size: 0.95rem;
	color: var(--muted);
}

footer p { margin: 0.5rem 0; }
footer a { color: inherit; }
footer .links { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; }

@media (max-width: 480px) {
	.hero { padding: 2rem 0 4rem; }
	.brand span { font-size: 1.15rem; }
	.nav { gap: 0.9rem; font-size: 1rem; }
}

@media (max-width: 360px) {
	.brand span { display: none; }
}

/* About: team, and Principles: slogan */
.team { list-style: none; padding: 0 !important; display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1.5rem; }
.team p { margin: 0 0 0.25rem; }
.team .who { font-size: 1.25rem; font-weight: 700; }
.team .role { color: var(--accent); }
.slogan { font-size: 1.4rem; margin: 0.5rem 0 1rem !important; }

/* Mobile menu. nav.js adds the button and .has-toggle; without it the links stay inline. */
.nav-toggle { display: none; }

@media (max-width: 640px) {
	.top.has-toggle { position: relative; }
	.top.has-toggle .brand span { display: inline; font-size: 1.2rem; }
	.top.has-toggle .nav-toggle {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 2.75rem;
		height: 2.75rem;
		margin-right: -0.5rem;
		padding: 0;
		border: 0;
		border-radius: 10px;
		background: none;
		color: inherit;
		cursor: pointer;
	}
	.nav-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
	.nav-toggle svg { width: 1.6rem; height: 1.6rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
	.nav-toggle path { transform-box: view-box; transform-origin: center; transition: transform 0.18s ease, opacity 0.18s ease; }
	.nav-open .nav-toggle .l1 { transform: translateY(5px) rotate(45deg); }
	.nav-open .nav-toggle .l2 { opacity: 0; }
	.nav-open .nav-toggle .l3 { transform: translateY(-5px) rotate(-45deg); }

	.top.has-toggle .nav {
		display: none;
		position: absolute;
		top: calc(100% + 0.6rem);
		left: 0;
		right: 0;
		z-index: 20;
		flex-direction: column;
		align-items: stretch;
		gap: 0;
		padding: 0.4rem 1rem 0.7rem;
		font-size: 1.15rem;
		background: var(--bg);
		border: 1px solid color-mix(in srgb, var(--muted) 35%, transparent);
		border-radius: 14px;
		box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
	}
	.top.has-toggle.nav-open .nav { display: flex; }
	.top.has-toggle .nav a {
		padding: 0.8rem 0.1rem;
		border-bottom: 1px solid color-mix(in srgb, var(--muted) 20%, transparent);
	}
	.top.has-toggle .nav a[aria-current="page"] { color: var(--accent); }
	.top.has-toggle .nav functorial-account { margin: 0.7rem 0 0; }
}

@media (prefers-reduced-motion: reduce) {
	.nav-toggle path { transition: none; }
}

/* Front page: a mostly opaque, full-width bar behind the header, so the
   lattice background (lattice.js) never runs under the nav. */
.home { overflow-x: clip; }
.home .top { position: relative; isolation: isolate; }
.home .top::before {
	content: "";
	position: absolute;
	z-index: -1;
	inset: -1.25rem calc(50% - 50vw) -0.9rem;
	background: color-mix(in srgb, var(--bg) 90%, transparent);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
	border-bottom: 1px solid color-mix(in srgb, var(--muted) 18%, transparent);
}

/* Principles popup (principles-popup.js). A centred card on wide screens,
   a sheet from the bottom on phones. */
.principles-pop {
	width: min(38rem, calc(100vw - 2rem));
	max-height: min(85vh, 44rem);
	max-height: min(85dvh, 44rem);
	padding: 0;
	border: 1px solid var(--rule);
	border-radius: 16px;
	background: var(--bg);
	color: var(--fg);
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
	overflow: hidden;
	flex-direction: column;
}
.principles-pop[open] { display: flex; }
.principles-pop::backdrop { background: rgba(11, 16, 32, 0.45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.principles-pop .pp-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 1rem 1rem 0.75rem 1.5rem;
	border-bottom: 1px solid var(--rule);
}
.principles-pop .pp-head h2 { margin: 0; font-size: 1.3rem; font-weight: 700; }
.principles-pop .pp-close {
	flex: none;
	width: 2.5rem;
	height: 2.5rem;
	border: 1px solid var(--rule);
	border-radius: 999px;
	background: transparent;
	color: var(--fg);
	font: inherit;
	font-size: 1.6rem;
	line-height: 1;
	cursor: pointer;
}
.principles-pop .pp-close:hover, .principles-pop .pp-close:focus-visible { border-color: var(--accent); color: var(--accent); }
.principles-pop .pp-body { padding: 0.25rem 1.5rem 0.5rem; overflow-y: auto; overscroll-behavior: contain; }
.principles-pop .pp-body h3 { margin: 1.25rem 0 0.35rem; font-size: 1.15rem; font-weight: 700; }
.principles-pop .pp-body p { margin: 0 0 0.5rem; font-size: 1.05rem; line-height: 1.5; }
.principles-pop .pp-loading { color: var(--muted); }
.principles-pop .pp-more { margin: 0; padding: 0.75rem 1.5rem 1rem; border-top: 1px solid var(--rule); font-size: 1rem; }
.principles-pop .pp-more a { color: var(--accent); }

@media (max-width: 640px) {
	.principles-pop {
		width: 100vw;
		max-width: 100vw;
		margin: auto 0 0;
		border-radius: 18px 18px 0 0;
		border-bottom: 0;
	}
	.principles-pop .pp-head { padding-left: 1.25rem; }
	.principles-pop .pp-body, .principles-pop .pp-more { padding-left: 1.25rem; padding-right: 1.25rem; }
}
