/* helloloam.dev — the one stylesheet
 *
 * Type: General Sans (Indian Type Foundry, via Fontshare) under the ITF Free
 * Font License 2.0 — free to self-host for this site only. Unmodified files:
 * no subsetting, no conversion. Never into the loam core, the skeleton, the
 * wall or /edit, and never into a public repository.
 */

@font-face {
	font-family: "General Sans";
	src: url("/assets/fonts/GeneralSans-Variable.woff2") format("woff2");
	font-weight: 200 700;
	font-style: normal;
	font-display: swap;
}

:root {
	--orange: #FA500F;
	--paper:  #FBFBF8;
	--ink:    #252525;
	--ink-2:  #5c5c5a;

	/* Measured from the design at a 1640 px frame, fluid below it. */
	--gutter: clamp(1rem, 2.5vw, 2.5625rem);
	--step-hero: clamp(2.25rem, 1.2rem + 3vw, 3.75rem);   /* 58–60 px at 1640 */
	--step-h2:   clamp(2.25rem, 1.2rem + 3vw, 3.75rem);
	--step-body: clamp(1.125rem, .9rem + .6vw, 1.5rem);    /* 24 px from 1600 */

	color-scheme: light;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font-family: "General Sans", ui-sans-serif, system-ui, sans-serif;
	font-size: var(--step-body);
	line-height: 1.333;
	font-weight: 500;
	-webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul { margin: 0; }

a { color: inherit; }
a:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; border-radius: 2px; }

/* ── the orange ─────────────────────────────────────────────────────────── */

.hero {
	position: relative;
	isolation: isolate;
	overflow: hidden;
	background: var(--orange);
	color: var(--paper);
	padding: 0 var(--gutter) clamp(2.5rem, 4vw, 3.5rem);
	min-height: min(30.5rem, 92svh);
	display: flex;
	flex-direction: column;
}
.hero.is-page { min-height: 0; }

.bar {
	display: flex;
	align-items: center;
	gap: clamp(1rem, 1.6vw, 1.5rem);
	padding-block: 2.0625rem;
	font-size: 1.1875rem;
	font-weight: 600;
}
.bar-mark { display: inline-flex; color: inherit; }
.bar-mark svg { width: auto; height: 2rem; display: block; }
.bar-nav { display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; }
.bar-nav a { text-decoration: underline; text-underline-offset: .2em; text-decoration-thickness: 1.5px; }
.bar-nav a:hover,
.bar-nav a[aria-current="page"] { text-decoration-thickness: 3px; }

.hero-copy {
	margin-top: auto;
	padding-top: clamp(3rem, 7vw, 6.5rem);
	max-width: 42rem;
}
.hero-copy h1 {
	font-size: var(--step-hero);
	font-weight: 600;
	line-height: 1.12;
	letter-spacing: -.01em;
	text-wrap: balance;
}
.lede {
	margin-top: 1.75rem;
	max-width: 32rem;
	text-wrap: pretty;
}

/* The tiles: Truchet quarter-arcs on the orange (assets/js/tiles.js turns
 * them). The message comes first; the tiles are a band under it, full bleed,
 * whole rows, standing on the bottom edge of the orange. A tile carries two
 * rings centred on opposite corners, cut to quarter-arcs that meet the edge
 * midpoints, so neighbours join. */
.hero:has(.tiles) { padding-bottom: 0; }

.tiles {
	/* Whole pixels, or the joins between tiles show a hairline seam. */
	--tile: round(clamp(3rem, 4.4vw, 4.5rem), 2px);
	--stroke: round(calc(var(--tile) * .2), 1px);
	--whole: y;   /* tiles.js: whole rows; across, the edges of the orange cut the field */
	height: calc(var(--tile) * 4);
	margin: clamp(3rem, 6vw, 5.5rem) calc(var(--gutter) * -1) 0;
	display: grid;
	grid-template-columns: repeat(var(--cols, 12), var(--tile));
	grid-auto-rows: var(--tile);
	justify-content: center;
	align-content: start;
	overflow: hidden;
	pointer-events: none;
}
.tile {
	position: relative;
	clip-path: inset(-.5px);   /* half a pixel over the neighbour: no anti-aliased seam at the joins */
	transform: rotate(calc(var(--r, 0) * 90deg));
	transition: transform .8s cubic-bezier(.65, 0, .35, 1);
}
.tile::before,
.tile::after {
	content: "";
	position: absolute;
	width: calc(var(--tile) + var(--stroke));
	aspect-ratio: 1;
	border: var(--stroke) solid var(--paper);
	border-radius: 50%;
}
.tile::before { top: calc((var(--tile) + var(--stroke)) / -2); left: calc((var(--tile) + var(--stroke)) / -2); }
.tile::after  { bottom: calc((var(--tile) + var(--stroke)) / -2); right: calc((var(--tile) + var(--stroke)) / -2); }

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

/* ── the paper ─────────────────────────────────────────────────────────── */

main:not(.hero-copy) {
	padding: clamp(2.5rem, 3vw, 2.75rem) var(--gutter) 0;
}

/* The footer of every page: the principles. */
.principles {
	padding: clamp(2.5rem, 3vw, 2.75rem) var(--gutter) clamp(4rem, 8vw, 8rem);
}
main:not(.hero-copy) + .principles { margin-top: clamp(3rem, 6vw, 6rem); }

.principles h2 {
	font-size: var(--step-h2);
	font-weight: 600;
	line-height: 1.1;
	letter-spacing: -.015em;
}

.principles-grid {
	display: grid;
	grid-template-columns: 19fr 25fr 25fr 31fr;
	gap: 2rem 1.5rem;
	margin-top: clamp(1.5rem, 2.2vw, 2.25rem);
}
.principle-set h3 { font-size: 1em; font-weight: 600; }
.principle-set ul { list-style: none; padding: 0; }

@media (max-width: 80rem) {
	.principles-grid { grid-template-columns: 1fr 1fr; gap: 2rem 1.5rem; }
}
@media (max-width: 30rem) {
	.principles-grid { grid-template-columns: 1fr; }
}

/* ── prose (pages, principles, 404) ───────────────────────────────────── */

.kicker { margin-bottom: .75rem; font-weight: 600; }

.prose { max-width: 40rem; }
.prose > * + * { margin-top: 1em; }
.prose h2 { margin-top: 2.25em; font-size: 1em; font-weight: 600; }
.prose h2:first-child { margin-top: 0; }
.prose h2 + * { margin-top: .25em; }
.prose ul { padding-left: 1.1em; }
.prose li + li { margin-top: .5em; }
.prose strong { font-weight: 600; }
.prose em { font-style: normal; font-weight: 600; }   /* no italic file is loaded: emphasis is weight */
.prose code { font: inherit; font-weight: 600; }
.prose a, .next a { text-underline-offset: .2em; }

.next { max-width: 40rem; margin-top: 3em; font-weight: 600; }
.principles .next { margin-top: clamp(2rem, 3.5vw, 3rem); }
.next a::after { content: " \2192"; }

/* The footer's principles that have a page. */
.principle-set a { text-decoration: none; }
.principle-set a:hover,
.principle-set a[aria-current="page"] { text-decoration: underline; text-underline-offset: .2em; }

/* ── Bands: a page is a stack of strips (main > .band). A split band puts the
 * content on paper and an aside on white beside it, full height, that keeps
 * its inner block in view (.split-sticky) — for a form, a visual, code, an
 * example. Below 64rem the aside follows the content. ─────────────────── */

main:has(> .band) { padding: 0; }

.band.split {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(22rem, 34%);
}
.split-main {
	padding: clamp(2.5rem, 3vw, 2.75rem) clamp(1.5rem, 4vw, 4rem) clamp(3.5rem, 6vw, 5rem) var(--gutter);
	display: grid;
	gap: clamp(3.5rem, 7vw, 6rem);
	align-content: start;
}
.split-aside {
	background: #fff;
	font-size: .8em;   /* the aside speaks a step quieter than the content */
	padding: clamp(2.5rem, 3vw, 2.75rem) var(--gutter) clamp(3.5rem, 6vw, 5rem) clamp(1.5rem, 3vw, 2.5rem);
}
.split-sticky { position: sticky; top: var(--gutter); }
/* Sticky only where the block fits the screen; otherwise it simply scrolls. */
@media (max-height: 50rem) { .split-sticky { position: static; } }
@media (max-width: 64rem) {
	.band.split { grid-template-columns: 1fr; }
	.split-aside { padding-left: var(--gutter); }
	.split-sticky { position: static; }
}

.to-form { font-weight: 600; text-underline-offset: .2em; }
.to-form::after { content: " \2193"; }

.block h2,
.split-aside h2 {
	font-size: var(--step-h2);
	font-weight: 600;
	line-height: 1.1;
	letter-spacing: -.015em;
}
.split-aside h2 { font-size: clamp(2rem, 1.2rem + 2vw, 3rem); }
.block-lede { max-width: 40rem; margin-top: 1rem; }

.cards {
	list-style: none;
	padding: 0;
	margin-top: clamp(1.5rem, 2.2vw, 2.25rem);
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
	gap: 2rem 1.5rem;
}
.cards li { border-top: 2px solid var(--ink); padding-top: 1rem; }
.cards h3 { font-size: 1em; font-weight: 600; }
.cards p  { margin-top: .25em; }
.cards.is-coming li { border-top-style: dashed; }

.faq { margin-top: clamp(1.5rem, 2.2vw, 2.25rem); border-top: 2px solid var(--ink); }   /* fills its column: the paper, the page, or a split's aside */
.faq details { border-bottom: 1px solid color-mix(in srgb, var(--ink) 25%, var(--paper)); }
.faq summary {
	cursor: pointer;
	list-style: none;
	padding: 1rem 2rem 1rem 0;
	font-weight: 600;
	position: relative;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 0; top: 1rem; }
.faq details[open] summary::after { content: "\2212"; }
.faq details p { padding-bottom: 1.25rem; padding-right: 2rem; }

.interest {
	margin-top: 1.5rem;
	display: grid;
	gap: 1rem;
}
.interest label { display: grid; gap: .4rem; font-weight: 600; }
.interest label i { font-style: normal; font-weight: 500; color: var(--ink-2); }
.interest input,
.interest textarea {
	font: inherit;
	font-weight: 500;
	color: var(--ink);
	background: var(--paper);
	border: 2px solid var(--ink);
	border-radius: 0;
	padding: .6rem .75rem;
	width: 100%;
}
.interest input:focus-visible,
.interest textarea:focus-visible { outline: 3px solid var(--orange); outline-offset: 0; }
.interest .trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.interest .fine { font-size: .75em; color: var(--ink-2); }
.interest button {
	font: inherit;
	font-weight: 600;
	color: var(--paper);
	background: var(--orange);
	border: 0;
	padding: .75rem 1.5rem;
	cursor: pointer;
}
.interest button:disabled { opacity: .6; cursor: progress; }
.interest .status { margin-left: 1rem; }
.interest .status[data-state="err"] { color: #b3261e; }

/* A table in prose (BYOA: what works with which assistant). */
.prose table { width: 100%; border-collapse: collapse; margin-top: 1.5em; font-size: .85em; }
.prose th, .prose td { text-align: left; padding: .55rem .5rem .55rem 0; border-bottom: 1px solid color-mix(in srgb, var(--ink) 25%, var(--paper)); vertical-align: top; }
.prose thead th { border-bottom: 2px solid var(--ink); }
.prose tbody th { font-weight: 500; }
.prose .note { font-size: .8em; color: var(--ink-2); }
.prose { overflow-x: auto; }

/* ── The code band: a split whose aside is dark and carries an example. Bands
 * follow each other without a gap, so the dark column reads as one. ────── */

.band.split.is-code .split-aside {
	background: var(--ink);
	color: var(--paper);
	font-size: inherit;
	display: flex;
	align-items: center;
	min-width: 0;
}
.band.split.is-code .split-main { padding-bottom: clamp(2.5rem, 4vw, 3.5rem); }
.band.split.is-code + .band.split.is-code { border-top: 1px solid color-mix(in srgb, var(--ink) 14%, var(--paper)); }
.band.split.is-code + .band.split.is-code .split-aside { border-top: 1px solid color-mix(in srgb, var(--paper) 14%, var(--ink)); margin-top: -1px; }
.split-aside pre {
	margin: 0;
	width: 100%;
	overflow-x: auto;
	font: 500 .72em/1.6 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
	tab-size: 4;
	white-space: pre;
}
.code-name { font-size: clamp(1.75rem, 1.1rem + 1.6vw, 2.5rem) !important; }
.to-docs { font-weight: 600; text-underline-offset: .2em; }
.to-docs::after { content: " \2197"; }
@media (min-width: 64.0625rem) {
	.band.split.is-code { grid-template-columns: minmax(0, 1fr) minmax(0, 50%); }
}
