/* ==========================================================================
   kaijaks.co.uk — shared styles (2027 edition)
   Fonts: Merriweather & Inter, both SIL OFL 1.1 (see /assets/fonts/*-OFL.txt)
   ========================================================================== */

/* ---------- Fonts ----------
   One file per style, latin + latin-ext (includes Latvian), built by .build/build-fonts.js.
   Filenames carry a content hash, so they can be cached for a year: a changed font gets a new name. */
@font-face {
	font-family: "Merriweather";
	font-style: normal;
	font-weight: 400 900;
	font-display: optional;
	src: url(../fonts/merriweather-normal.7e87af9f.woff2) format("woff2");
}
@font-face {
	font-family: "Merriweather";
	font-style: italic;
	font-weight: 400 900;
	font-display: optional;
	src: url(../fonts/merriweather-italic.70cff6f1.woff2) format("woff2");
}
@font-face {
	font-family: "Inter";
	font-style: normal;
	font-weight: 400 700;
	font-display: optional;
	src: url(../fonts/inter-normal.327742b9.woff2) format("woff2");
}
@font-face {
	font-family: "Inter";
	font-style: italic;
	font-weight: 400 700;
	font-display: swap; /* not preloaded: let italic words swap in rather than stay in the system italic */
	src: url(../fonts/inter-italic.1fcc99fb.woff2) format("woff2");
}

/* ---------- Design tokens ---------- */
:root {
	color-scheme: light dark;

	/* Display face: Merriweather (variable, optical sizes) */
	--font-display: "Merriweather", Georgia, serif;
	--dw: 850;          /* headings */
	--dw-hero: 800;     /* big name */
	--dw-light: 500;    /* lede, pull quote */
	--ds: 0.9;          /* display size multiplier (Merriweather has a large x-height) */
	--d-track: -0.02em;
	--font-text: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

	/* Light: warm paper, copper accent (taken from the portrait backdrop) */
	--bg: #faf8f4;
	--surface: #ffffff;
	--ink: #1d1b18;
	--muted: #5f5a52;
	--rule: #e5e0d6;
	--accent: #a8481f;
	--accent-soft: #f3e3d8;

	/* Type scale (fluid) */
	--step--1: clamp(0.83rem, 0.8rem + 0.15vw, 0.9rem);
	--step-0: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
	--step-1: clamp(1.2rem, 1.1rem + 0.45vw, 1.4rem);
	--step-2: clamp(1.5rem, 1.3rem + 0.9vw, 2rem);
	--step-3: clamp(2rem, 1.6rem + 1.8vw, 3rem);
	--step-4: clamp(2.6rem, 1.9rem + 3.4vw, 4.75rem);

	--space-xs: 0.5rem;
	--space-s: 1rem;
	--space-m: 1.5rem;
	--space-l: clamp(2rem, 1.5rem + 2vw, 3rem);
	--space-xl: clamp(3.5rem, 2.5rem + 4vw, 6.5rem);

	--measure: 66ch;
	--wide: 72rem;
	--radius: 14px;
	--header-h: 4rem;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #131210;
		--surface: #1b1917;
		--ink: #ece8e1;
		--muted: #a59f95;
		--rule: #2e2b27;
		--accent: #f0915f;
		--accent-soft: #3a261b;

	}
}

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

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-padding-top: calc(var(--header-h) + 1rem);
}
@media (prefers-reduced-motion: no-preference) {
	html { scroll-behavior: smooth; }
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--ink);
	font-family: var(--font-text);
	font-size: var(--step-0);
	line-height: 1.65;
	font-optical-sizing: auto;
	text-rendering: optimizeLegibility;
	-webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
	font-family: var(--font-display);
	font-weight: var(--dw);
	font-synthesis: none;
	line-height: 1.12;
	letter-spacing: var(--d-track);
	margin: 0 0 0.5em;
	text-wrap: balance;
}

p, dd, li { text-wrap: pretty; }
p { margin: 0 0 1em; }

a {
	color: var(--accent);
	text-decoration-line: underline;
	text-decoration-thickness: 1px;
	text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
	text-underline-offset: 0.18em;
	transition: text-decoration-color 0.15s ease;
}
a:hover { text-decoration-color: currentColor; }

:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 3px;
	border-radius: 4px;
}

img { max-width: 100%; height: auto; display: block; }
abbr[title] { text-decoration: underline dotted; text-underline-offset: 0.2em; cursor: help; }
abbr a { text-decoration: none; }
small { font-size: var(--step--1); }

::selection { background: var(--accent-soft); color: var(--ink); }

.skip-link {
	position: absolute;
	left: 1rem;
	top: -3rem;
	padding: 0.5rem 1rem;
	background: var(--ink);
	color: var(--bg);
	border-radius: 8px;
	z-index: 100;
}
.skip-link:focus { top: 1rem; }

.visually-hidden {
	position: absolute !important;
	width: 1px; height: 1px;
	overflow: hidden; clip: rect(0 0 0 0);
	white-space: nowrap;
}

.wrap {
	width: min(100% - 2.5rem, var(--wide));
	margin-inline: auto;
}

.eyebrow {
	font-family: var(--font-text);
	font-size: var(--step--1);
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--accent);
	margin: 0 0 0.75rem;
}
.eyebrow .as-written { text-transform: none; letter-spacing: 0.02em; }

/* ==========================================================================
   Family picker (root)
   ========================================================================== */
.family {
	min-height: 100svh;
	display: grid;
	grid-template-rows: 1fr auto;
}
.family main {
	display: grid;
	align-content: center;
	padding-block: var(--space-xl) var(--space-l);
}
.family-intro { max-width: 40rem; margin-bottom: var(--space-l); }
.family-intro h1 {
	font-size: calc(var(--step-4) * var(--ds));
	font-weight: var(--dw-hero);
	margin-bottom: 0.25em;
}
.family-intro p { color: var(--muted); font-size: var(--step-1); margin: 0; }

.people {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: var(--space-s);
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
}
.person a {
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 1rem;
	padding: 1.1rem 1.25rem;
	background: var(--surface);
	border: 1px solid var(--rule);
	border-radius: var(--radius);
	color: var(--ink);
	text-decoration: none;
	transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.person a:hover {
	border-color: var(--accent);
	box-shadow: 0 8px 24px -16px color-mix(in srgb, var(--accent) 60%, transparent);
}
@media (prefers-reduced-motion: no-preference) {
	.person a:hover { transform: translateY(-2px); }
	.person a:hover .person-go { transform: translateX(3px); }
}
.person-mark {
	width: 3.25rem;
	aspect-ratio: 1;
	border-radius: 50%;
	overflow: hidden;
	display: grid;
	place-items: center;
	background: var(--accent-soft);
	color: var(--accent);
	font-family: var(--font-display);
	font-size: calc(1.4rem * var(--ds));
	font-weight: var(--dw);
}
.person-mark img { width: 100%; height: 100%; object-fit: cover; }
.person-name {
	display: block;
	font-family: var(--font-display);
	font-size: calc(var(--step-1) * var(--ds));
	font-weight: var(--dw);
	line-height: 1.2;
}
.person-role { display: block; font-size: var(--step--1); color: var(--muted); line-height: 1.4; text-wrap: balance; }
.person-go { color: var(--accent); font-size: 1.25rem; transition: transform 0.2s ease; }

.site-foot {
	border-top: 1px solid var(--rule);
	padding-block: var(--space-m);
	color: var(--muted);
	font-size: var(--step--1);
}
.site-foot .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 2rem; }
.site-foot p { margin: 0; }
.site-foot a { color: inherit; }

/* ==========================================================================
   Personal page
   ========================================================================== */

/* ---------- Header ---------- */
.top {
	position: sticky;
	top: 0;
	z-index: 50;
	background: color-mix(in srgb, var(--bg) 82%, transparent);
	backdrop-filter: saturate(1.4) blur(12px);
	-webkit-backdrop-filter: saturate(1.4) blur(12px);
	border-bottom: 1px solid var(--rule);
}
.top .wrap {
	min-height: var(--header-h);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
}
.top-home {
	font-family: var(--font-display);
	font-weight: var(--dw);
	font-size: calc(1.15rem * var(--ds));
	color: var(--ink);
	text-decoration: none;
	white-space: nowrap;
}
.top-home span { color: var(--muted); font-weight: 400; }
.top nav ul {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	gap: clamp(0.9rem, 2.5vw, 2rem);
}
.top nav a {
	color: var(--muted);
	text-decoration: none;
	font-size: var(--step--1);
	font-weight: 500;
	white-space: nowrap;
}
.top nav a:hover { color: var(--ink); }
.top nav a[aria-current="page"] {
	color: var(--ink);
	text-decoration: underline;
	text-decoration-color: var(--accent);
	text-decoration-thickness: 2px;
	text-underline-offset: 0.45em;
}

@media (max-width: 34rem) {
	.top .wrap { flex-direction: column; align-items: flex-start; gap: 0.25rem; padding-block: 0.6rem; }
	.top nav { width: 100%; overflow-x: auto; }
	:root { --header-h: 5.25rem; }
}

/* ---------- Hero ---------- */
.hero { padding-block: var(--space-l) var(--space-m); }
.hero .wrap {
	display: grid;
	gap: var(--space-l);
	align-items: center;
	grid-template-columns: 1fr;
}
@media (min-width: 48rem) {
	.hero .wrap { grid-template-columns: 1.5fr 1fr; }
}
.hero h1 {
	font-size: calc(var(--step-4) * var(--ds));
	font-weight: var(--dw-hero);
	margin-bottom: 0.3em;
}
.hero-say {
	margin-bottom: var(--space-m);
	font-size: var(--step-1);
	color: var(--muted);
}
.hero-say a { color: var(--muted); text-decoration: none; }
.hero-say a:hover { color: var(--accent); }
.hero-say svg { width: 1.15em; height: 1.15em; vertical-align: -0.15em; margin-right: 0.45em; }
.hero-lede {
	font-family: var(--font-display);
	font-size: calc(var(--step-2) * var(--ds));
	font-weight: var(--dw-light);
	line-height: 1.3;
	max-width: 24ch;
	margin-bottom: 0;
}
.flag-inline { display: inline-block; height: 0.8em; width: auto; vertical-align: baseline; margin-inline: 0.1em; border-radius: 2px; }

.portrait {
	position: relative;
	justify-self: center;
	width: min(100%, 22rem);
}
.portrait::before {
	content: "";
	position: absolute;
	inset: 1rem -1rem -1rem 1rem;
	border: 1px solid var(--accent);
	border-radius: calc(var(--radius) * 1.5);
}
.portrait img {
	position: relative;
	border-radius: calc(var(--radius) * 1.5);
	aspect-ratio: 1;
	object-fit: cover;
}
@media (max-width: 47.99rem) {
	.hero { padding-bottom: 0; }
	.portrait { order: -1; justify-self: start; width: 8.5rem; }
	.portrait::before { inset: 0.5rem -0.5rem -0.5rem 0.5rem; border-radius: var(--radius); }
	.portrait img { border-radius: var(--radius); }
}

/* ---------- Sections ---------- */
.section { padding-block: var(--space-l); }
.section + .section { border-top: 1px solid var(--rule); }
.section-head { margin-bottom: var(--space-l); }
.section-head h2 { font-size: calc(var(--step-3) * var(--ds)); }
.section-head h1:not(.pull) { font-size: calc(var(--step-4) * var(--ds) * 0.85); }

/* Standfirst: an introductory paragraph set in the display face, between heading and body */
.standfirst {
	font-family: var(--font-display);
	font-weight: 400;
	font-size: calc(var(--step-1) * var(--ds));
	line-height: 1.6;
	letter-spacing: -0.005em;
}
/* Page grid: every two-column layout uses equal halves with the same gap from 60rem,
   and the standfirst spans exactly one column so its edge lines up with the column below */
@media (min-width: 60rem) {
	.standfirst { max-width: calc((100% - var(--space-xl)) / 2); }
}
.standfirst p:last-child { margin-bottom: 0; }

/* Biography grid */
.bio-grid {
	display: grid;
	gap: var(--space-l) var(--space-xl);
	grid-template-columns: 1fr;
}
@media (min-width: 60rem) {
	.bio-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.bio-grid article h3 {
	font-size: calc(var(--step-1) * var(--ds));
	padding-top: 0.9rem;
	border-top: 2px solid var(--accent);
	display: inline-block;
}
.bio-grid article p { color: color-mix(in srgb, var(--ink) 88%, var(--bg)); }

/* Physics page */
.lattice {
	display: block;
	width: 100%;
	height: 132px;
	color: var(--accent);
	margin-bottom: var(--space-l);
}
.pull {
	font-family: var(--font-display);
	font-style: italic;
	font-weight: var(--dw-light);
	font-size: calc(var(--step-4) * var(--ds) * 0.85);
	line-height: 1.12;
	margin: 0 0 var(--space-m);
}
.physics-intro { margin-bottom: var(--space-xl); }
.physics-cols {
	display: grid;
	gap: var(--space-l) var(--space-xl);
	grid-template-columns: 1fr;
}
@media (min-width: 60rem) {
	.physics-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.physics-aside > div { position: sticky; top: calc(var(--header-h) + 2rem); }
}
.physics-body h3, .physics-aside h3 { font-size: calc(var(--step-2) * var(--ds)); }
.physics-body p { color: color-mix(in srgb, var(--ink) 88%, var(--bg)); }
.physics-aside > div {
	padding: var(--space-m);
	background: var(--surface);
	border: 1px solid var(--rule);
	border-top: 3px solid var(--accent);
	border-radius: var(--radius);
}
.physics-aside strong { font-weight: 600; }

/* Archive */
.archive-cols {
	display: grid;
	gap: var(--space-l) var(--space-xl);
	grid-template-columns: 1fr;
}
@media (min-width: 60rem) {
	.archive-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.archive-cols h3 { font-size: calc(var(--step-1) * var(--ds)); }
.files { margin: 0; }
.files > div {
	padding-block: 1.1rem;
	border-top: 1px solid var(--rule);
}
.files > div:last-child { border-bottom: 1px solid var(--rule); }
.files dt {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
	font-weight: 600;
	margin-bottom: 0.3rem;
}
.files dt a { text-decoration: none; }
.files dt a:hover { text-decoration: underline; }
.file-size {
	font-weight: 400;
	font-size: var(--step--1);
	color: var(--muted);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}
.files dd { margin: 0; color: var(--muted); font-size: 0.95em; }
.credits { margin-top: var(--space-l); color: var(--muted); max-width: var(--measure); }
.credits a { color: inherit; }

/* Contact / footer */
.contact { padding-block: var(--space-l); border-top: 1px solid var(--rule); }
.contact h2 { font-size: calc(var(--step-3) * var(--ds)); }
.links {
	list-style: none;
	margin: var(--space-m) 0 var(--space-l);
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
}
.links a {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.6rem 1.1rem;
	border: 1px solid var(--rule);
	border-radius: 999px;
	color: var(--ink);
	text-decoration: none;
	font-weight: 500;
	background: var(--surface);
	transition: border-color 0.15s ease, color 0.15s ease;
}
.links a:hover { border-color: var(--accent); color: var(--accent); }
.links svg { width: 1.1em; height: 1.1em; flex: none; }
.links svg.brand { width: 1em; height: 1em; }
/* Email pill only appears once email.js has given it an address */
.email-link:has(a:not([href])) { display: none; }
.email-fallback {
	display: inline-flex;
	padding: 0.6rem 1.1rem;
	border: 1px dashed var(--rule);
	border-radius: 999px;
	color: var(--muted);
}
.fineprint {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 0.5rem 2rem;
	padding-top: var(--space-m);
	border-top: 1px solid var(--rule);
	color: var(--muted);
	font-size: var(--step--1);
}
.fineprint p { margin: 0; }
.fineprint a { color: inherit; }
.dd-more { margin-top: 0.6em; }
.portrait { margin: 0; }

/* ---------- Print ---------- */
@media print {
	:root { --bg: #fff; --ink: #000; --muted: #444; --accent: #000; }
	.top, .lattice, .skip-link, .links svg { display: none; }
	.section, .hero, .contact { padding-block: 1.5rem; }
	a { color: #000; }
	.physics-body a[href^="http"]::after, .files a::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #444; }
	.physics-aside > div { position: static; }
}

/* Long-form text pages (privacy etc.) */
.prose { max-width: var(--measure); }
.prose h1 { font-size: calc(var(--step-3) * var(--ds)); }
.prose h2 { font-size: calc(var(--step-1) * var(--ds)); margin-top: 2em; }
.prose h3 { font-size: var(--step-0); font-family: var(--font-text); font-weight: 650; margin-top: 1.5em; }
.prose li { margin-bottom: 0.4em; }
.prose .updated { color: var(--muted); font-size: var(--step--1); margin-top: -0.5rem; }
.prose .summary {
	margin: var(--space-m) 0 var(--space-l);
	padding: var(--space-m);
	background: var(--surface);
	border: 1px solid var(--rule);
	border-left: 3px solid var(--accent);
	border-radius: var(--radius);
}
.prose .summary p { margin: 0; }
.prose ul { padding-left: 1.2em; }
