/* ==========================================================================
   paulclarke.nz
   One stylesheet: tokens, base elements, layout, components, print.
   ========================================================================== */

/* Tokens
   -------------------------------------------------------------------------- */
:root {
	/* Colour */
	--color-page: #f8f4ed;
	--color-surface: #ffffff;
	--color-text: #202a24;
	--color-ink: #202a24;
	--color-muted: #666666;
	--color-focus: #202a24;
	--color-highlight: #7c942e; /* olive green, 3.1:1 on the page colour */
	--color-mark: color-mix(in srgb, var(--color-highlight) 30%, var(--color-page)); /* highlighter tint behind key words */
	--color-strong: #000000;

	/* Chart series, darkest to lightest */
	--color-series-1: #1e202b;
	--color-series-2: #666666;
	--color-series-3: #8c8c8c;
	--color-series-4: #ffffff;
	--color-series-stroke: #666666;

	/* Type */
	--font-sans: "DM Sans", system-ui, sans-serif;
	--font-display: "Fraunces", Georgia, serif;
	--font-mono: "DM Mono", ui-monospace, monospace;

	--text-body: 1rem;
	--leading-body: 1.444;
	--text-small: 0.9rem;
	--text-label: 1.111rem;
	--leading-label: 1.4;
	--text-nav: 0.833rem;
	--text-h1: clamp(1.8rem, 1.1rem + 2.4vw, 3rem);
	--leading-h1: 1.27;
	--text-h3: clamp(1.5rem, 1.25rem + 0.9vw, 1.889rem);
	--leading-h3: 1.235;

	/* Space */
	--space-2xs: 0.25rem;
	--space-xs: 0.5rem;
	--space-s: 1rem;
	--space-m: 1.667rem;
	--space-l: 3rem;
	--space-xl: 4.444rem;
	--space-hero: 4rem;

	/* Layout */
	--page-max: 1500px;
	--gutter: 1.111rem;
	--measure: 38rem;
	--header-height: 70px;
}

@media (min-width: 768px) {
	:root {
		--gutter: 1.667rem;
	}
}

/* Dark theme
   Follows the system setting unless the visitor picks a theme with the header toggle,
   which sets data-theme on <html>. The two blocks below hold the same values: keep them in step.
   Screen only, so printing always uses the light colours. */
:root {
	color-scheme: light;
}

@media screen and (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		color-scheme: dark;
		--color-page: #161a17;
		--color-surface: #1f2420;
		--color-text: #ebe5d9;
		--color-ink: #ebe5d9;
		--color-muted: #a5a69c;
		--color-focus: #ebe5d9;
		--color-highlight: #9fb54a;
		--color-mark: color-mix(in srgb, #9fb54a 28%, #161a17);
		--color-strong: #ffffff;
		--color-series-1: #ebe5d9;
		--color-series-2: #a5a69c;
		--color-series-3: #6b6f69;
		--color-series-4: #161a17;
		--color-series-stroke: #a5a69c;
	}
}

@media screen {
	:root[data-theme="dark"] {
		color-scheme: dark;
		--color-page: #161a17;
		--color-surface: #1f2420;
		--color-text: #ebe5d9;
		--color-ink: #ebe5d9;
		--color-muted: #a5a69c;
		--color-focus: #ebe5d9;
		--color-highlight: #9fb54a;
		--color-mark: color-mix(in srgb, #9fb54a 28%, #161a17);
		--color-strong: #ffffff;
		--color-series-1: #ebe5d9;
		--color-series-2: #a5a69c;
		--color-series-3: #6b6f69;
		--color-series-4: #161a17;
		--color-series-stroke: #a5a69c;
	}
}

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

html {
	font-size: 112.5%; /* 18px by default, and follows the reader's own setting */
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	background: var(--color-page);
	color: var(--color-text);
	font-family: var(--font-sans);
	font-size: var(--text-body);
	line-height: var(--leading-body);
	-webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
	margin: 0 0 var(--space-m);
	font-family: var(--font-display);
	font-weight: 500;
}

h1 {
	font-size: var(--text-h1);
	line-height: var(--leading-h1);
}

h3 {
	font-size: var(--text-h3);
	line-height: var(--leading-h3);
}

p,
ul {
	margin: 0 0 1.444em;
}

ul {
	padding-left: 1.25em;
}

li + li {
	margin-top: var(--space-xs);
}

a {
	color: var(--color-ink);
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

a:hover {
	color: var(--color-muted);
}

a:focus-visible {
	outline: 2px solid var(--color-focus);
	outline-offset: 3px;
}

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

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

/* Each section sits inside the page width, with its content column centred */
.section {
	max-width: var(--page-max);
	margin: var(--space-l) auto 0;
	padding-inline: var(--gutter);
}

main > .section:first-child {
	margin-top: var(--space-xl);
}

main > .section:last-child {
	margin-bottom: var(--space-xl);
}

.section__inner {
	margin-inline: auto;
}

.section--prose .section__inner {
	max-width: var(--measure);
}

@media (min-width: 768px) {
	.section__inner {
		max-width: calc(100% * 8 / 12);
	}
}

/* Components
   -------------------------------------------------------------------------- */

/* Icons (Lucide, via the icon shortcode): sized to the text, coloured by it */
.icon {
	display: inline-block;
	flex-shrink: 0;
	width: 1.1em;
	height: 1.1em;
	vertical-align: -0.2em;
}

/* Hidden visually, still read by screen readers */
.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* Skip link */
.skip-link {
	position: absolute;
	left: -9999px;
	top: 0;
	z-index: 100;
	padding: var(--space-xs) var(--space-s);
	background: var(--color-page);
	color: var(--color-ink);
}

.skip-link:focus {
	left: var(--space-s);
	top: var(--space-s);
}

/* Site header */
.site-header {
	position: sticky;
	top: 0;
	z-index: 10;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-xs) var(--space-l);
	min-height: var(--header-height);
	padding: var(--space-s) var(--gutter);
	background: var(--color-page);
	font-family: var(--font-sans);
}

.site-header__name {
	color: var(--color-ink);
	font-size: var(--text-label);
	line-height: 1;
	text-decoration: none;
}

.site-nav ul {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-2xs) var(--space-m);
	margin: 0;
	padding: 0;
	list-style: none;
}

.site-nav li + li {
	margin-top: 0;
}

.site-nav a {
	position: relative;
	isolation: isolate;
	color: var(--color-muted);
	font-size: var(--text-nav);
	text-decoration: none;
}

/* A thin line under the label, starting to its left; it grows on hover and stays on the current page */
.site-nav a::before {
	content: "";
	position: absolute;
	z-index: -1;
	left: -0.9em;
	bottom: -0.2em;
	width: 0;
	height: 0.2em;
	background: var(--color-highlight);
	transition: width 0.3s ease;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
	color: var(--color-ink);
}

.site-nav a[aria-current="page"] {
	color: var(--color-strong);
}

.site-nav a:hover::before,
.site-nav a[aria-current="page"]::before {
	width: calc(100% + 0.9em);
}

@media (prefers-reduced-motion: reduce) {
	.site-nav a::before {
		transition: none;
	}
}

@media (min-width: 768px) {
	.site-nav ul {
		gap: var(--space-l);
	}
}

/* Theme toggle: shown by theme.js, so visitors without JavaScript just follow their system setting */
.site-header__end {
	display: flex;
	align-items: center;
	gap: var(--space-m);
}

.theme-toggle {
	display: inline-grid;
	place-items: center;
	width: 2.25rem;
	height: 2.25rem;
	margin: -0.5rem -0.5rem -0.5rem 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: var(--color-muted);
	cursor: pointer;
}

.theme-toggle[hidden] {
	display: none;
}

.theme-toggle:hover {
	color: var(--color-ink);
}

.theme-toggle:focus-visible {
	outline: 2px solid var(--color-focus);
	outline-offset: 2px;
}

.theme-toggle .icon {
	width: 1.1rem;
	height: 1.1rem;
}

/* Moon offers dark; sun offers light */
.theme-toggle[aria-pressed="true"] .icon--moon,
.theme-toggle[aria-pressed="false"] .icon--sun {
	display: none;
}

@media (min-width: 768px) {
	.site-header__end {
		gap: var(--space-l);
	}
}

/* Mono label: section titles, dates, breadcrumbs */
.label,
.section h2:not(.card__title) {
	margin: var(--space-l) 0 var(--space-m);
	color: var(--color-muted);
	font-family: var(--font-mono);
	font-size: var(--text-label);
	font-weight: 400;
	line-height: var(--leading-label);
}

.section__inner > .label:first-child {
	margin-top: 0;
}

/* Meta line under a heading, such as a role's dates: small body text in the muted colour */
.label--meta {
	margin: 0 0 var(--space-xs);
	font-family: var(--font-sans);
	font-size: var(--text-small);
	line-height: var(--leading-body);
}

/* Hero: heading beside the portrait from tablet up, stacked above it on small screens */
.hero {
	display: grid;
	max-width: var(--page-max);
	margin: var(--space-xl) auto 0;
	padding-inline: var(--gutter);
}

.hero__text {
	position: relative;
	z-index: 1;
	margin-bottom: var(--space-m);
}

/* Key words in the hero: a highlighter stroke behind the lower part of the word, in a tint of the
   highlight colour. Upright and the same colour as the heading, so it does not read as a link. */
.hero__mark {
	font-style: normal;
	background-image: linear-gradient(transparent 58%, var(--color-mark) 58%, var(--color-mark) 92%, transparent 92%);
	-webkit-box-decoration-break: clone;
	box-decoration-break: clone;
	padding-inline: 0.06em;
}

.hero__image img {
	border-radius: 12px;
}

@media (min-width: 768px) {
	.hero {
		grid-template-columns: repeat(12, 1fr);
	}

	.hero__text {
		grid-column: 2 / span 6; /* stops at the portrait's edge, so the heading never sits on the photo */
		grid-row: 1;
		margin-bottom: 0;
		padding-top: 1.2rem;
	}

	.hero__image {
		grid-column: 8 / span 4;
		grid-row: 1;
		padding-inline: 10px;
	}
}

@media (min-width: 992px) {
	.hero__text {
		padding-top: var(--space-hero);
	}
}

/* Cards and highlights: more space between items than between a title and its text */
.card,
.highlight {
	margin-bottom: var(--space-l);
}

.card__title {
	font-family: var(--font-display);
	font-size: var(--text-h3);
	font-weight: 500;
	line-height: var(--leading-h3);
}

.card__title,
.highlight h3 {
	margin: 0 0 var(--space-xs);
}

/* Case study */
.case-study .section__inner > h2 {
	margin-top: var(--space-l);
}

/* Chart: a single stacked bar with a text legend */
.chart {
	margin: var(--space-m) 0;
}

.chart__bar {
	display: block;
	width: 100%;
	height: auto;
}

.chart__segment {
	stroke: var(--color-series-stroke);
	stroke-width: 1;
}

.chart__segment--1 { fill: var(--color-series-1); }
.chart__segment--2 { fill: var(--color-series-2); }
.chart__segment--3 { fill: var(--color-series-3); }
.chart__segment--4 { fill: var(--color-series-4); }

.chart__legend {
	margin: var(--space-s) 0;
	padding: 0;
	list-style: none;
}

.chart__legend li {
	margin: 0;
}

.chart__swatch {
	display: inline-block;
	width: 14px;
	height: 14px;
	margin-right: 0.4rem;
	vertical-align: -1px;
	border: 1px solid var(--color-series-stroke);
}

.chart__swatch--1 { background: var(--color-series-1); }
.chart__swatch--2 { background: var(--color-series-2); }
.chart__swatch--3 { background: var(--color-series-3); }
.chart__swatch--4 { background: var(--color-series-4); }

.chart figcaption {
	color: var(--color-muted);
	font-size: var(--text-small);
}

/* Maturity label: a design's label as designers apply it, with a five-step meter of how settled it is */
.maturity {
	display: inline-flex;
	align-items: center;
	gap: 0.5em;
	padding: 0.15em 0.6em;
	border: 1.5px solid currentColor;
	border-radius: 3px;
	font-family: var(--font-mono);
	font-size: 0.75rem;
	letter-spacing: 0.06em;
	line-height: 1.4;
	text-transform: uppercase;
	white-space: nowrap;
	vertical-align: 0.1em;
}

.maturity__meter {
	display: inline-flex;
	gap: 2px;
}

.maturity__meter span {
	width: 0.45em;
	height: 0.8em;
	border: 1px solid var(--color-muted);
}

.maturity__meter .is-on {
	border-color: var(--color-highlight);
	background: var(--color-highlight);
}

/* Terms defined in a short list: each term in the display face, its meaning below */
.term-list {
	margin: 0 0 1.444em;
}

.term-list div {
	padding: var(--space-s) 0;
	border-top: 1px solid var(--color-muted);
}

.term-list dt {
	font-family: var(--font-display);
	font-size: 1.25rem;
}

.term-list dd {
	margin: 0;
	color: var(--color-muted);
}

/* A numbered sequence of stages, joined by a line down the left */
.stage-list {
	margin: 0 0 1.444em;
	padding: 0;
	list-style: none;
}

.stage-list > li {
	margin: 0;
	padding: 0 0 var(--space-m) var(--space-m);
	border-left: 2px solid var(--color-highlight);
}

.stage-list > li:last-child {
	padding-bottom: 0;
}

.stage-list ul {
	margin: 0 0 var(--space-xs);
}

.stage-list ul li + li {
	margin-top: var(--space-2xs);
}

.stage-list__title {
	margin: var(--space-xs) 0 var(--space-2xs);
	font-size: 1.25rem;
}

.stage-list p {
	margin: 0 0 var(--space-2xs);
}

.stage-list__feedback {
	color: var(--color-muted);
}

/* Example: a small framed illustration of something in use, with a mono caption above */
.example {
	margin: 0 0 var(--space-m);
}

.example figcaption {
	margin-bottom: var(--space-xs);
	color: var(--color-muted);
	font-family: var(--font-mono);
	font-size: var(--text-small);
}

.example__frame,
.example__cover {
	padding: var(--space-s);
	border: 1px solid var(--color-muted);
	border-radius: 6px;
	background: var(--color-surface);
}

.example__frame p:last-child {
	margin-bottom: 0;
}

.example__frame--mono {
	font-family: var(--font-mono);
	font-size: var(--text-small);
	overflow-wrap: anywhere;
}

.example__frame--mono p {
	margin-bottom: var(--space-2xs);
}

.example__cover {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	align-items: flex-start;
	max-width: 22rem;
	aspect-ratio: 16 / 9;
}

.example__cover-title {
	font-family: var(--font-display);
	font-size: 1.25rem;
}

.note {
	color: var(--color-muted);
	font-size: var(--text-small);
}

/* Data table: scrolls sideways on its own on narrow screens rather than widening the page */
.table-scroll {
	margin: 0 0 1.444em;
	overflow-x: auto;
}

.table-scroll:focus-visible {
	outline: 2px solid var(--color-focus);
	outline-offset: 3px;
}

.data-table {
	width: 100%;
	min-width: 32rem;
	border-collapse: collapse;
	font-size: var(--text-small);
}

.data-table th,
.data-table td {
	padding: var(--space-xs) var(--space-s) var(--space-xs) 0;
	border-bottom: 1px solid var(--color-muted);
	text-align: left;
	vertical-align: top;
}

.data-table thead th {
	color: var(--color-muted);
	font-family: var(--font-mono);
	font-weight: 400;
}

.data-table tbody th {
	font-weight: 500;
	white-space: nowrap;
}

/* Contact links */
.link-list {
	padding: 0;
	list-style: none;
}

.link-list li {
	margin: 0;
}

/* Print
   The Résumé page prints as a one-page CV; other pages print without navigation.
   -------------------------------------------------------------------------- */
@media print {
	@page {
		size: A4;
		margin: 15mm 18mm;
	}

	html {
		font-size: 10pt;
	}

	body {
		background: #ffffff;
	}

	.site-header,
	.skip-link,
	.no-print {
		display: none !important;
	}

	.section,
	main > .section:first-child,
	main > .section:last-child,
	.hero {
		margin: 0;
		padding: 0;
	}

	.section__inner,
	.section--prose .section__inner {
		max-width: none;
		margin-left: 0;
	}

	body,
	a {
		color: #000000;
	}

	a {
		text-decoration: none;
	}

	h1 {
		font-size: 2.2rem;
		margin-bottom: 0.5rem;
	}

	h3 {
		font-size: 1.3rem;
		margin: 1rem 0 0.2rem;
	}

	.section h2:not(.card__title) {
		margin: 1.4rem 0 0.6rem;
	}

	p,
	ul {
		margin-bottom: 0.5em;
	}

	li + li {
		margin-top: 0.15em;
	}

	.label--meta {
		margin-bottom: 0.4em;
	}

	h2,
	h3 {
		break-after: avoid;
	}

	p,
	li {
		break-inside: avoid;
	}
}
