/* np — one stylesheet for the whole site. Colors are the np Umbra palette. */

:root {
	--bg: #14161f;
	--deep: #0f1118;
	--ink: #c5cce0;
	--bright: #e8ecf6;
	--muted: #8b95b4;
	--rule: #262c3d;
	--blue: #a2cafe;
	--serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
	--mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
	--measure: 40rem;
}

* { box-sizing: border-box; }

html {
	background: var(--bg);
	color: var(--ink);
	font-family: var(--serif);
	font-size: 19px;
	line-height: 1.55;
	-webkit-font-smoothing: antialiased;
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0 auto;
	padding: 4rem 1.25rem 5rem;
	max-width: calc(var(--measure) + 2.5rem);
}

@media (max-width: 600px) {
	html { font-size: 17px; }
	body { padding-top: 2.5rem; }
}

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

a {
	color: inherit;
	text-decoration: underline;
	text-decoration-color: var(--muted);
	text-underline-offset: 0.18em;
	text-decoration-thickness: 1px;
}
a:hover { color: var(--bright); text-decoration-color: var(--bright); }

h1, h2, h3 { font-weight: 400; margin: 0; line-height: 1.2; color: var(--bright); }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; margin-top: 3rem; margin-bottom: 0.8rem; }
h3 { font-size: 1.05rem; font-style: italic; margin-top: 2rem; margin-bottom: 0.5rem; }
h2 + h3 { margin-top: 1rem; }

p { margin: 0 0 1.1em; }
ul, ol { padding-left: 1.4rem; margin: 0 0 1.1em; }
li { margin-bottom: 0.3em; }
strong { font-weight: 600; color: var(--bright); }

code {
	font-family: var(--mono);
	font-size: 0.82em;
	color: var(--bright);
}

.label, .eyebrow, figcaption, .crumbs, .output::before {
	font-family: var(--mono);
	font-size: 0.68rem;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--muted);
}
.eyebrow, figcaption, .crumbs { margin: 0 0 0.5rem; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

/* ── nav and footer ─────────────────────────────────────────── */
.nav {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	margin-bottom: 3.5rem;
}
.nav a { text-decoration: none; }
.nav a:hover { text-decoration: underline; }
.nav__name { font-family: var(--mono); color: var(--bright); }
.nav__links { display: flex; gap: 1.5rem; }
.nav__links a { color: var(--muted); }
.nav__links a[aria-current="page"] { color: var(--bright); }

.foot {
	margin-top: 5rem;
	padding-top: 1.25rem;
	border-top: 1px solid var(--rule);
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	flex-wrap: wrap;
	font-size: 0.85rem;
	color: var(--muted);
}
.foot a { color: var(--muted); }

/* ── code ───────────────────────────────────────────────────── */
pre {
	margin: 0;
	font-family: var(--mono);
	font-size: 0.72rem;
	line-height: 1.65;
	tab-size: 4;
	overflow-x: auto;
	white-space: pre;
}
pre code { font-size: inherit; color: inherit; }
.code {
	background: var(--deep);
	border: 1px solid var(--rule);
	padding: 1rem 1.1rem;
	margin: 1.2rem 0;
	color: var(--ink);
}
.output {
	position: relative;
	margin: -1.2rem 0 1.4rem;
	padding: 0.75rem 1.1rem 0.8rem 5.2rem;
	border: 1px solid var(--rule);
	border-top: 0;
	background: #12141c;
	color: #afe1ab;
}
.output::before {
	content: "prints";
	position: absolute;
	left: 1.1rem;
	top: 0.95rem;
}
.program { margin: 1.5rem 0 1.8rem; }
.program .code { margin-bottom: 0; }
.program .output { margin-top: 0; }

/* Umbra syntax colors, as in the editor theme. */
.t-comment { color: #7d93a8; font-style: italic; }
.t-keyword { color: #8391af; }
.t-type { color: #91dae9; }
.t-function { color: #a2cafe; }
.t-string { color: #afe1ab; }
.t-number { color: #feac9e; }
.t-own { color: #fe85a4; }
.t-spread { color: #ccb6fd; }
.t-punct { color: #657095; }
.t-operator { color: #7b86a6; }
.t-hole { color: #feb487; }
.t-module { color: #6d8bab; }
.t-constant { color: #ccb6fd; }

/* ── home ───────────────────────────────────────────────────── */
.intro { margin-bottom: 3.5rem; }
.showcase { margin: 0 0 3.5rem; }
.intro h1 { font-family: var(--mono); margin-bottom: 1rem; }
.section { margin-bottom: 3.5rem; }
.section > .label {
	display: block;
	padding-bottom: 0.6rem;
	margin-bottom: 1.2rem;
	border-bottom: 1px solid var(--rule);
}
.reading { list-style: none; padding: 0; }
.reading li { margin-bottom: 1.4rem; }
.reading li a { display: block; margin-bottom: 0.2rem; }
.reading li span { display: block; color: var(--muted); font-size: 0.95rem; }

/* ── examples: a scroller ───────────────────────────────────── */
.examples__list { list-style: none; padding: 0; margin: 0; counter-reset: ex; }
.examples__list li { display: grid; grid-template-columns: 2rem 1fr; gap: 0 0.4rem; padding: 0.55rem 0.5rem; counter-increment: ex; border-bottom: 1px solid var(--rule); }
.examples__list li::before { content: counter(ex); font-family: var(--mono); font-size: 0.7rem; color: var(--muted); padding-top: 0.3rem; }
.examples__list a { text-decoration: none; }
.examples__list a:hover { text-decoration: underline; }
/* Phones: the panel is hidden and a tapped row holds its program. */
.examples__panel, .examples__stage { display: none; }
.examples__list li.is-open a { color: var(--bright); }
.examples__list li .slide { grid-column: 1 / -1; margin: 0.7rem 0 0.4rem; visibility: visible; min-width: 0; }
@media (max-width: 899px) {
	pre { font-size: 0.66rem; }
	.code { padding: 0.8rem 0.9rem; }
	.output { padding-left: 4.6rem; }
	.output::before { left: 0.9rem; }
	.editor__pane { max-height: 70vh; }
}
.examples__title { margin: 0 0 1rem; }
.slide .program { margin: 0; }
@media (min-width: 900px) {
	body.wide { max-width: 76rem; padding-inline: 3rem; }
	body.wide .intro { max-width: var(--measure); }
	.intro__grid { display: grid; grid-template-columns: minmax(0, var(--measure)) minmax(0, 1fr); gap: 3rem; align-items: center; }
	.showcase { margin: 0; min-width: 0; }
	.showcase .program { margin: 0; }
	/* The section is tall: one screen plus a quarter screen of travel per
	   example. The scene inside it is pinned for the whole distance. */
	.examples { height: calc(100vh + var(--steps) * 25vh); margin-bottom: 0; }
	.examples__scene { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; justify-content: center; }
	.examples__scene > .label { position: absolute; top: 2rem; left: 0; right: 0; }
	.examples__grid { display: grid; grid-template-columns: 24rem minmax(0, 1fr); gap: 3rem; align-items: start; }
	.examples__title { line-height: 1.55; margin-top: 0.25rem; }
	.examples__list { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
	.examples__list li { cursor: pointer; }
	.examples__list a { transition: color 0.12s; }
	.examples__list li.is-shown { background: #1a1d28; }
	.examples__list li.is-shown a, .examples__list li.is-shown::before { color: var(--bright); }
	.examples__list li.is-locked { box-shadow: inset 3px 0 0 var(--blue); }
	.examples__list li.is-locked::before { color: var(--blue); }
	/* Every program occupies the same cell, so the panel is the size of the
	   tallest one and never moves. */
	.examples__list li { border-bottom: 0; padding: 0.25rem 0.5rem; border-radius: 3px; }
	.examples__list a { color: var(--muted); }
	.examples__panel { display: block; min-width: 0; }
	.examples__stage { display: grid; min-width: 0; max-height: calc(100vh - 9rem); overflow: auto; }
	.slide { grid-area: 1 / 1; align-self: start; visibility: hidden; min-width: 0; }
	.slide.is-shown { visibility: visible; }
}

.example h1 { margin-bottom: 0.4rem; }

.modules-inline { max-width: var(--measure); line-height: 1.9; }
.modules-inline a { text-decoration: none; margin-right: 1rem; white-space: nowrap; font-family: var(--mono); font-size: 0.85rem; }
.modules-inline a:hover { text-decoration: underline; }

/* ── the library, as an editor ──────────────────────────────── */
.editor { display: grid; grid-template-columns: 16rem minmax(0, 1fr); height: 85vh; border: 1px solid var(--rule); background: var(--deep); }
.editor__tree { overflow: auto; border-right: 1px solid var(--rule); background: #11131b; padding: 0.6rem 0; font-family: var(--mono); font-size: 0.72rem; line-height: 1.9; }
.editor__tree details { padding-left: 0; }
.editor__tree details details, .editor__tree details > a { margin-left: 0.9rem; }
.editor__tree summary { cursor: pointer; list-style: none; color: var(--muted); padding-left: 0.9rem; white-space: nowrap; }
.editor__tree summary::-webkit-details-marker { display: none; }
.editor__tree summary::before { content: "▸"; display: inline-block; width: 1rem; color: #4a5573; }
.editor__tree details[open] > summary::before { content: "▾"; }
.editor__tree a { display: block; color: var(--ink); text-decoration: none; padding-left: 1.9rem; white-space: nowrap; }
.editor__tree > a { padding-left: 1.9rem; }
.editor__tree a:hover { color: var(--bright); background: #161923; }
.editor__hidden { display: block; padding-left: 0.9rem; color: #4a5573; white-space: nowrap; cursor: default; }
.editor__hidden::before { content: "▸"; display: inline-block; width: 1rem; }
.editor__hidden em { font-style: normal; margin-left: 0.6rem; font-size: 0.65rem; letter-spacing: 0.06em; }
.editor__tree a.is-open { color: var(--bright); background: #1a1d28; }
.editor__pane { overflow: auto; display: flex; flex-direction: column; min-width: 0; }
.editor__bar { position: sticky; top: 0; background: #12141c; border-bottom: 1px solid var(--rule); padding: 0.5rem 1rem; font-family: var(--mono); font-size: 0.7rem; color: var(--muted); }
.editor__prose { padding: 1.5rem 2rem 3rem; max-width: 46rem; font-size: 0.95rem; }
.editor__prose h1 { font-size: 1.4rem; margin-bottom: 1rem; }
.editor__prose h2 { font-size: 1.15rem; margin-top: 2rem; }
.editor__prose h3 { margin-top: 1.4rem; }
.editor__prose .code { font-size: 0.72rem; }
.editor__code { padding: 1rem 1.25rem 3rem 0; font-size: 0.74rem; line-height: 1.6; counter-reset: line; }
.editor__code .line { display: block; counter-increment: line; padding-left: 4.2rem; position: relative; min-height: 1.6em; white-space: pre; }
.editor__code .line::before { content: counter(line); position: absolute; left: 0; width: 3rem; text-align: right; color: #4a5573; user-select: none; }
@media (max-width: 700px) {
	.editor { grid-template-columns: 1fr; height: auto; }
	.editor__tree { max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--rule); }
}

/* ── guide and book ─────────────────────────────────────────── */
.book-head { margin-bottom: 2.5rem; }
.book-head h1 { margin-bottom: 0.8rem; }
.book-head .byline { color: var(--muted); font-style: italic; }
.contents ol { padding-left: 1.6rem; }
.contents a { text-decoration: none; }
.contents a:hover { text-decoration: underline; }
.contents .sub { list-style: none; padding-left: 0; margin: 0.3em 0 0.8em; color: var(--muted); font-size: 0.9rem; }
.contents .sub a { color: var(--muted); }

.guide-section { margin-top: 4rem; padding-top: 2.5rem; border-top: 1px solid var(--rule); }
.guide-section:first-of-type { margin-top: 3rem; }
.guide-section h2 { margin-top: 0; }
.guide-example { margin: 1.4rem 0 1.6rem; }
.guide-example .code { margin: 0; }
.guide-callout { border-left: 1px solid var(--muted); padding: 0.1rem 0 0.1rem 1.1rem; margin: 1.5rem 0; color: var(--muted); }
.guide-callout strong { color: var(--ink); font-weight: 400; font-style: italic; }
.guide-table-wrap { overflow-x: auto; margin: 1.2rem 0 1.6rem; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { text-align: left; vertical-align: top; padding: 0.45rem 1rem 0.45rem 0; border-bottom: 1px solid var(--rule); }
th { font-weight: 400; color: var(--muted); font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; }
td code { font-size: 0.8em; }
.guide-list { list-style: none; padding: 0; }
.guide-list li { margin-bottom: 0.5em; padding-left: 1.1rem; text-indent: -1.1rem; }
.guide-list li::before { content: "–"; color: var(--muted); display: inline-block; width: 1.1rem; text-indent: 0; }

.book h1 { margin-bottom: 0.4rem; }
.book .chapter-number { display: block; margin-bottom: 0.4rem; }
.book h2 { margin-top: 3.5rem; }
.book h2 .num, .book h3 .num { color: var(--muted); margin-right: 0.5rem; }
.book blockquote { margin: 1.5rem 0; padding-left: 1.1rem; border-left: 1px solid var(--muted); color: var(--muted); font-style: italic; }
.book blockquote cite { display: block; font-style: normal; font-size: 0.85rem; margin-top: 0.3rem; }
.exercises { margin: 2rem 0 0; padding: 1.2rem 0 0; border-top: 1px solid var(--rule); }
.exercises .label { display: block; margin-bottom: 0.8rem; }
.exercises ol { padding-left: 1.6rem; }
.exercises li { margin-bottom: 0.7em; }
.exercises code { font-size: 0.8em; }
.pager {
	margin-top: 4rem;
	padding-top: 1.25rem;
	border-top: 1px solid var(--rule);
	display: flex;
	justify-content: space-between;
	gap: 1rem;
}
.pager a { text-decoration: none; color: var(--muted); }
.pager a:hover { color: var(--bright); text-decoration: underline; }
.pager__prev::before { content: "← "; }
.pager__next::after { content: " →"; }
.pager__next { text-align: right; }
