/* Section library: the token contract, the reset and the shared primitives.

   Every section reads only the tokens below; a preset sets them. In the specimen a preset is a [data-preset]
   attribute on any element, so several presets can sit on one page. In a block theme build.py writes the same
   values to theme.json and to :root.

   Derived tokens (lines, tints, secondary inks) are computed with color-mix on the same selectors that set the
   base colours. A custom property computes where it is declared and inherits the result, so a band that flips
   to dark (.s--invert) must recompute them itself or it would inherit the light page's hairlines. The same holds
   for every alias (a token whose value is another token, like --heading-font): declared on :root alone it would be
   resolved against the root's fonts and a preset that sets only --font-display would never reach it. */

:root,
[data-preset],
.s--invert,
.s--brand,
.s--tint {
	/* secondary and tertiary inks; a dark preset raises --ink-2-mix, because the same mix reads weaker light-on-dark (APCA) */
	--ink-2: color-mix(in oklab, var(--ink) var(--ink-2-mix, 80%), var(--paper));
	--ink-3: color-mix(in oklab, var(--ink) 60%, var(--paper));
	--line: color-mix(in oklab, var(--ink) 15%, var(--paper));
	--line-strong: color-mix(in oklab, var(--ink) 80%, var(--paper));
	--paper-2: color-mix(in oklab, var(--ink) 4%, var(--paper));
	--paper-3: color-mix(in oklab, var(--ink) 8%, var(--paper));
	--brand-tint: color-mix(in oklab, var(--brand) 13%, var(--paper));
	/* brand as text: a bright brand (orange, coral) passes as a fill and fails as small text, so presets with one set
	   --brand-text-mix to darken it toward the ink (audit.py measures the result) */
	--brand-text: color-mix(in oklab, var(--brand) var(--brand-text-mix, 100%), var(--ink));
	--accent-tint: color-mix(in oklab, var(--accent) 35%, var(--paper));
	--card-bg: var(--paper);
	--card-line: var(--line);
	--chart-1: var(--brand);
	--chart-2: var(--accent);
	--chart-3: color-mix(in oklab, var(--brand) 45%, var(--paper));
	--chart-4: color-mix(in oklab, var(--ink) 35%, var(--paper));
	--heading-font: var(--font-display);
	--heading-weight: var(--display-weight);
	--num-family: var(--font-display);
	--btn-font: var(--font-body);
	--step-0: var(--body-size);
	color: var(--ink);
}

/* Frozen copies of the brand pair for .s--brand, which swaps them. They live only here: declared on the band
   itself they would read the band's own swapped values and form a cycle. */
:root,
[data-preset] {
	--_brand: var(--brand);
	--_brand-ink: var(--brand-ink);
}

:root {
	/* colour roles: a preset sets these eight and may override any derived one */
	--paper: #fbfaf7;
	--ink: #16161a;
	--brand: #2645c7;
	--brand-ink: #ffffff;
	--brand-on-invert: #9fb3ff;
	--accent: #f3c83f;
	--accent-ink: #16161a;
	--invert-bg: #16161a;
	--invert-fg: #f1efe9;
	--up: #1d7a4a;
	--down: #b3261e;

	/* type: three roles, at most three families (two is better) */
	--font-display: Georgia, "Times New Roman", serif;
	--font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--font-label: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
	--display-weight: 500;
	--display-tracking: -0.025em;
	--display-leading: 1;
	--display-case: none;
	--display-style: normal;
	--display-scale: 1;
	--display-stretch: normal;
	--heading-tracking: -0.015em;
	--em-style: italic;
	--em-color: currentColor;
	--em-family: inherit;
	--em-weight: inherit;
	--em-bg: none;
	--body-size: 1.0625rem;
	--body-leading: 1.62;
	--body-weight: 400;
	--measure: 66ch;
	--label-size: 0.75rem;
	--label-weight: 500;
	--label-tracking: 0.08em;
	--label-case: uppercase;
	--label-mark: "";
	--idx-prefix: "";
	--idx-style: decimal-leading-zero;

	/* shape */
	--radius-1: 3px;
	--radius-2: 6px;
	--radius-3: 10px;
	--radius-btn: 3px;
	--rule: 1px;
	--rule-strong: 2px;
	--shadow: none;
	--card-pad: clamp(20px, 2.4cqi, 32px);
	--card-shadow: none;
	--media-radius: 4px;
	--img-filter: none;

	/* buttons */
	--btn-size: 0.9375rem;
	--btn-weight: 600;
	--btn-case: none;
	--btn-tracking: 0;
	--btn-pad-y: 0.95em;
	--btn-pad-x: 1.45em;
	--btn-arrow: "\2192";

	/* space */
	--gutter: clamp(18px, 4.5vw, 44px);
	--section-y: clamp(64px, 9vw, 136px);
	--stack: 1.25rem;
	--wrap: 1240px;
	--wrap-narrow: 740px;
	--wrap-wide: 1440px;

	/* texture behind .s--textured; a preset may set one of the recipes at the end of this file */
	--texture: none;
	--texture-size: auto;
}

/* fluid scale, read against the nearest section (container query units), so a section shown in a narrow
   preview tile sizes its type to the tile, not to the window */
:root {
	--step--2: 0.75rem;
	--step--1: 0.875rem;
	--step-1: clamp(1.125rem, 1.02rem + 0.45cqi, 1.375rem);
	--step-2: clamp(1.35rem, 1.15rem + 0.9cqi, 1.85rem);
	--step-3: clamp(1.7rem, 1.35rem + 1.7cqi, 2.6rem);
	--step-4: clamp(2.1rem, 1.5rem + 3cqi, 3.9rem);
	--step-5: clamp(2.6rem, 1.6rem + 5cqi, 5.75rem);
	--step-6: clamp(3rem, 1.4rem + 8cqi, 8.75rem);
	--step-7: clamp(3.4rem, 0.8rem + 13cqi, 13.5rem);
}

/* ------------------------------------------------------------------------------------------------ reset */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font-family: var(--font-body);
	font-size: var(--body-size);
	font-weight: var(--body-weight);
	line-height: var(--body-leading);
	font-optical-sizing: auto;
	text-rendering: optimizeLegibility;
}
img, svg, video, canvas { display: block; max-width: 100%; height: auto; }
h1, h2, h3, h4, h5, h6, p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
ul[class], ol[class] { list-style: none; padding: 0; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
table { border-collapse: collapse; width: 100%; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
[hidden] { display: none !important; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ------------------------------------------------------------------------------------------------ section */

/* A section re-applies the body type itself: inherited font values are computed where they were declared (body),
   so a section inside a [data-preset] stage or a theme wrapper would otherwise keep the page's fonts. */
.s {
	position: relative;
	container: s / inline-size;
	padding-block: var(--section-y);
	background: var(--paper);
	color: var(--ink);
	font-family: var(--font-body);
	font-size: var(--body-size);
	font-weight: var(--body-weight);
	line-height: var(--body-leading);
}
.s--flush { padding-block: 0; }
.s--tight { padding-block: calc(var(--section-y) * 0.55); }
.s--top0 { padding-top: 0; }
.s--alt { background: var(--paper-2); }
.s--ruled { border-top: var(--rule) solid var(--line); }
.s--textured { background-image: var(--texture); background-size: var(--texture-size); }

.s--invert {
	--paper: var(--invert-bg);
	--ink: var(--invert-fg);
	--brand: var(--brand-on-invert);
	--brand-ink: var(--invert-bg);
	--ink-2-mix: 88%;
	/* a heading accent tuned for the light page would sink into a dark band */
	--em-color: var(--em-invert, var(--brand));
	--em-bg: none;
	--card-bg: color-mix(in oklab, var(--invert-fg) 6%, var(--invert-bg));
	background: var(--paper);
	color: var(--ink);
}
.s--brand {
	--paper: var(--_brand);
	--ink: var(--_brand-ink);
	--brand: var(--_brand-ink);
	--brand-ink: var(--_brand);
	/* a solid brand band leaves no room for a muted grey: secondary text keeps the full ink */
	--ink-2: var(--ink);
	--ink-3: color-mix(in oklab, var(--ink) 80%, var(--paper));
	--em-color: currentColor;
	--em-bg: none;
	--card-bg: color-mix(in oklab, var(--_brand-ink) 9%, var(--_brand));
	background: var(--paper);
	color: var(--ink);
}
.s--tint {
	--paper: var(--tint-bg, color-mix(in oklab, var(--brand) 9%, #fff));
	background: var(--paper);
}

.wrap { width: min(100% - 2 * var(--gutter), var(--wrap)); margin-inline: auto; }
.wrap--narrow { width: min(100% - 2 * var(--gutter), var(--wrap-narrow)); }
.wrap--wide { width: min(100% - 2 * var(--gutter), var(--wrap-wide)); }
.wrap--full { width: 100%; }

/* ------------------------------------------------------------------------------------------------ type */

.h-mega, .h-display, .h-1, .h-2, .h-3 {
	font-family: var(--font-display);
	font-weight: var(--display-weight);
	font-style: var(--display-style);
	font-stretch: var(--display-stretch);
	letter-spacing: var(--display-tracking);
	line-height: var(--display-leading);
	text-transform: var(--display-case);
	text-wrap: balance;
	color: var(--ink);
}
.h-mega { font-size: calc(var(--step-7) * var(--display-scale)); }
.h-display { font-size: calc(var(--step-6) * var(--display-scale)); }
.h-1 { font-size: calc(var(--step-5) * var(--display-scale)); }
.h-2 { font-size: calc(var(--step-4) * var(--display-scale)); line-height: calc(var(--display-leading) + 0.04); }
.h-3 { font-size: var(--step-3); line-height: calc(var(--display-leading) + 0.08); }
.h-4 {
	font-family: var(--heading-font);
	font-weight: var(--heading-weight);
	letter-spacing: var(--heading-tracking);
	font-size: var(--step-2);
	line-height: 1.18;
	text-wrap: balance;
}
.h-5 {
	font-family: var(--font-body);
	font-weight: 650;
	font-size: var(--step-1);
	line-height: 1.3;
	letter-spacing: -0.01em;
}
:is(.h-mega, .h-display, .h-1, .h-2, .h-3, .h-4) em {
	font-style: var(--em-style);
	font-family: var(--em-family);
	font-weight: var(--em-weight);
	color: var(--em-color);
	background: var(--em-bg);
	padding-inline: var(--em-pad, 0);
	-webkit-box-decoration-break: clone;
	box-decoration-break: clone;
}
:is(.h-mega, .h-display, .h-1, .h-2, .h-3) s { text-decoration-color: var(--down); text-decoration-thickness: 0.08em; color: var(--ink-3); }
.lede { font-size: var(--step-1); line-height: 1.5; color: var(--ink); max-width: 36em; text-wrap: pretty; }
.dek { font-size: var(--step-0); color: var(--ink-2); max-width: var(--measure); text-wrap: pretty; }
.prose { max-width: var(--measure); }
.prose > * + * { margin-top: var(--stack); }
.prose p, .prose li { text-wrap: pretty; }
.prose a { color: var(--brand-text); }
.prose h2 { font-family: var(--heading-font); font-weight: var(--heading-weight); font-size: var(--step-3); line-height: 1.12; letter-spacing: var(--heading-tracking); margin-top: 2.2em; }
.prose h3 { font-family: var(--font-body); font-weight: 650; font-size: var(--step-1); line-height: 1.3; margin-top: 1.8em; }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose li + li { margin-top: 0.45em; }
.prose li::marker { color: var(--ink-3); }
.small { font-size: var(--step--1); line-height: 1.5; }
.muted { color: var(--ink-2); }

.label {
	display: inline-flex;
	align-items: center;
	gap: 0.6em;
	font-family: var(--font-label);
	font-size: var(--label-size);
	font-weight: var(--label-weight);
	letter-spacing: var(--label-tracking);
	text-transform: var(--label-case);
	line-height: 1.2;
	color: var(--ink-2);
}
.label::before { content: var(--label-mark); color: var(--brand-text); }
.label--plain::before { content: none; }
.label--brand { color: var(--brand-text); }
.meta { font-family: var(--font-label); font-size: var(--step--2); letter-spacing: 0.04em; color: var(--ink-2); line-height: 1.4; }
.num { font-family: var(--num-family); font-variant-numeric: lining-nums; letter-spacing: -0.02em; }
.num--tab, td.num, th.num { font-variant-numeric: tabular-nums lining-nums; }
.idx { white-space: nowrap; }
.source { font-size: var(--step--2); color: var(--ink-2); line-height: 1.45; }
.source::before { content: "Source: "; font-weight: 600; }
.source--asof::before { content: "As of "; }
mark { background: var(--accent); color: var(--accent-ink); padding: 0 0.15em; }
code, kbd { font-family: var(--font-label); font-size: 0.9em; }
hr, .rule { border: 0; border-top: var(--rule) solid var(--line); margin: 0; }
.rule--strong { border-top: var(--rule-strong) solid var(--line-strong); }

/* ------------------------------------------------------------------------------------------------ section heads */

.s-head { display: grid; gap: 1rem; align-content: start; margin-bottom: clamp(32px, 5cqi, 64px); max-width: 52rem; }
.s-head .dek { margin-top: 0.25rem; }
.s-head--split { max-width: none; }
@container s (min-width: 860px) {
	.s-head--split { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); align-items: end; column-gap: 4cqi; }
	.s-head--split .label { grid-column: 1 / -1; }
	.s-head--split .dek { margin: 0; }
}
.s-head--num { counter-increment: none; }
.s-head--rule { padding-top: 1.1rem; border-top: var(--rule-strong) solid var(--line-strong); max-width: none; }
.s-head--rule .label { width: 100%; }
.s-head--rule .label > :last-child { margin-left: auto; }

/* index numbers (01, Nº 01, Sheet 1, Room I) are set by the preset */
.idx-list { counter-reset: idx; }
.idx-item { counter-increment: idx; }
.idx::before { content: var(--idx-prefix) counter(idx, var(--idx-style)); }

/* ------------------------------------------------------------------------------------------------ actions */

.btns { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; }
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.6em;
	padding: var(--btn-pad-y) var(--btn-pad-x);
	border: var(--rule) solid transparent;
	border-radius: var(--radius-btn);
	font-family: var(--btn-font);
	font-size: var(--btn-size);
	font-weight: var(--btn-weight);
	letter-spacing: var(--btn-tracking);
	text-transform: var(--btn-case);
	line-height: 1.1;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.btn::after { content: var(--btn-arrow); transition: transform 0.15s; }
.btn:hover::after { transform: translateX(3px); }
.btn--noarrow::after { content: none; }
.btn--primary { background: var(--brand); color: var(--brand-ink); }
.btn--primary:hover { background: color-mix(in oklab, var(--brand) 85%, var(--ink)); }
.btn--line { border-color: var(--line-strong); color: var(--ink); }
.btn--line:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn--accent { background: var(--accent); color: var(--accent-ink); }
.btn--link { padding: 0.2em 0; border-radius: 0; border-bottom: var(--rule) solid currentColor; }
.btn--link:hover { border-bottom-width: 2px; }

.chip {
	display: inline-flex;
	align-items: center;
	gap: 0.4em;
	padding: 0.38em 0.7em;
	border: var(--rule) solid var(--line);
	border-radius: var(--radius-1);
	font-family: var(--font-label);
	font-size: var(--step--2);
	letter-spacing: 0.03em;
	line-height: 1.2;
	color: var(--ink-2);
	background: var(--paper);
	white-space: nowrap;
}
.chip--fill { background: var(--paper-3); border-color: transparent; color: var(--ink); }
.chip--brand { background: var(--brand-tint); border-color: transparent; color: var(--ink); }
.chip--dot::before { content: ""; width: 0.5em; height: 0.5em; border-radius: 50%; background: var(--brand); }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ------------------------------------------------------------------------------------------------ boxes and media */

.card {
	background: var(--card-bg);
	border: var(--rule) solid var(--card-line);
	border-radius: var(--radius-2);
	box-shadow: var(--card-shadow);
	padding: var(--card-pad);
}
a.card { display: block; text-decoration: none; transition: border-color 0.15s, transform 0.15s; }
a.card:hover { border-color: var(--line-strong); }

.media { position: relative; overflow: hidden; border-radius: var(--media-radius); background: var(--paper-3); }
.media img, .media video { width: 100%; height: 100%; object-fit: cover; filter: var(--img-filter); }
.media--43 { aspect-ratio: 4 / 3; }
.media--32 { aspect-ratio: 3 / 2; }
.media--169 { aspect-ratio: 16 / 9; }
.media--45 { aspect-ratio: 4 / 5; }
.media--11 { aspect-ratio: 1; }
.media--tall { aspect-ratio: 3 / 4; }
.caption { margin-top: 0.7rem; font-size: var(--step--1); line-height: 1.45; color: var(--ink-2); max-width: 46em; }
.caption b { color: var(--ink); font-weight: 600; }

/* Placeholder for a photograph the site must supply. A flat field that names the shot it stands for, so a
   section is judged on layout and type, and nobody mistakes a placeholder for art direction. No gradients: a
   gradient blob is the first thing a reader takes for a template. */
.ph {
	position: relative;
	display: flex;
	align-items: flex-end;
	width: 100%;
	height: 100%;
	min-height: 140px;
	padding: 0.85rem 0.95rem;
	background: var(--ph-bg, color-mix(in oklab, var(--brand) 16%, var(--paper)));
	background-image: repeating-linear-gradient(135deg, color-mix(in oklab, var(--ink) 6%, transparent) 0 1px, transparent 1px 11px);
	color: var(--ink-2);
	font-family: var(--font-label);
	font-size: var(--step--2);
	letter-spacing: 0.05em;
	line-height: 1.35;
	text-transform: uppercase;
}
.ph::before { content: ""; position: absolute; inset: 0.6rem; border: var(--rule) dashed color-mix(in oklab, var(--ink) 22%, transparent); pointer-events: none; }
.ph--ink { --ph-bg: color-mix(in oklab, var(--brand) 22%, var(--invert-bg)); color: color-mix(in oklab, var(--invert-fg) 80%, transparent); }
.ph--ink::before { border-color: color-mix(in oklab, var(--invert-fg) 25%, transparent); }
.ph--accent { --ph-bg: var(--accent-tint); }
.ph--paper { --ph-bg: var(--paper-3); }

/* ------------------------------------------------------------------------------------------------ grids */

.grid { display: grid; gap: clamp(16px, 2.4cqi, 32px); }
.g-2, .g-3, .g-4, .g-5, .g-6 { display: grid; gap: clamp(16px, 2.4cqi, 32px); grid-template-columns: minmax(0, 1fr); }
@container s (min-width: 620px) {
	.g-2, .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.g-3, .g-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.g-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@container s (min-width: 960px) {
	.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
	.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
	.g-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
	.g-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
.split { display: grid; gap: clamp(28px, 5cqi, 80px); grid-template-columns: minmax(0, 1fr); }
@container s (min-width: 860px) {
	.split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
	.split--57 { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
	.split--75 { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
	.split--48 { grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); }
	.split--84 { grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); }
	.split--center { align-items: center; }
	.split--end { align-items: end; }
	.split--flip > :first-child { order: 2; }
}
.sticky { position: sticky; top: calc(var(--sticky-top, 88px)); align-self: start; }
.stack > * + * { margin-top: var(--stack); }
.stack-s > * + * { margin-top: 0.6rem; }
.stack-l > * + * { margin-top: 2rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; }
.between { justify-content: space-between; }

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ===== preset: orbit ===== */
:root {
	--paper: var(--wp--preset--color--paper);
	--ink: var(--wp--preset--color--ink);
	--brand: var(--wp--preset--color--brand);
	--brand-ink: var(--wp--preset--color--brand-ink);
	--brand-on-invert: var(--wp--preset--color--brand-on-invert);
	--accent: var(--wp--preset--color--accent);
	--accent-ink: var(--wp--preset--color--accent-ink);
	--invert-bg: var(--wp--preset--color--invert-bg);
	--invert-fg: var(--wp--preset--color--invert-fg);
	--font-display: var(--wp--preset--font-family--display);
	--font-body: var(--wp--preset--font-family--body);
	--font-label: var(--wp--preset--font-family--label);
	--display-weight: 700;
	--display-tracking: -0.03em;
	--display-leading: 1.0;
	--display-scale: 0.82;
	--heading-weight: 700;
	--em-style: normal;
	--em-color: var(--brand-text);
	--em-weight: 700;
	--em-invert: #8ab8e6;
	--body-size: 1.0625rem;
	--body-leading: 1.6;
	--label-size: 0.74rem;
	--label-weight: 600;
	--label-tracking: 0.08em;
	--label-mark: "\25A0";
	--brand-text-mix: 85%;
	--idx-style: decimal-leading-zero;
	--num-family: var(--font-display);
	--radius-1: 2px;
	--radius-2: 4px;
	--radius-3: 6px;
	--radius-btn: 3px;
	--media-radius: 4px;
	--btn-weight: 600;
}

/* ===== WordPress glue: template output styled with the library's primitives ===== */
.wp-site-blocks > * + * { margin-block-start: 0; }
.sl-single .wrap > * + * { margin-top: 1rem; }
.sl-single__date { margin-top: 0.6rem; }
.sl-single__body { margin-top: 2.4rem; }
.sl-list__title { margin-bottom: 2rem; }
.sl-list__items { list-style: none; padding: 0; margin: 0; border-top: var(--rule-strong) solid var(--line-strong); }
.sl-list__items > li { display: grid; gap: 0.35rem; padding: 1.2rem 0; border-bottom: var(--rule) solid var(--line); }
.wp-block-post-title a { text-decoration: none; }
.wp-block-post-title a:hover { text-decoration: underline; }
.sl-list__pages { display: flex; gap: 0.6rem; margin-top: 2rem; font-family: var(--font-label); font-size: var(--step--1); }
.wp-block-post-terms a { text-decoration: none; }
