/* The book: a reading column, the contents beside it on a wide screen, and
   pages turned with the arrow keys. Tokens and the bar come from site.css. */

:root {
	--mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
	--measure: 720px;
}

/* The wallpaper, quieter: long text reads over it. */
body.book::before { opacity: .4; }

.bar-end button {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 6px 10px;
	border: 0;
	border-radius: var(--radius-pill);
	background: transparent;
	color: var(--text-2);
	font: inherit;
	font-size: 15px;
	cursor: pointer;
	transition: background .2s var(--effects);
}
.bar-end button:hover { background: var(--glass-hover); color: var(--text); }
.bar-end button svg { width: 18px; height: 18px; }
.pill[aria-current="page"] { box-shadow: 0 0 0 2px rgba(255, 255, 255, .85); }

/* How far through the chapters this page is. */
.progress {
	position: fixed;
	top: 0; left: 0;
	z-index: 11;
	height: 2px;
	width: calc(var(--p) * 100%);
	background: var(--tag-red);
}

.button {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 12px 22px;
	border-radius: 999px;
	border: 1px solid var(--glass-edge);
	background: var(--glass);
	color: var(--text);
	font-weight: 500;
	text-decoration: none;
	transition: background .2s var(--effects), transform .35s var(--spatial);
}
.button:hover { background: var(--glass-hover); transform: translateY(-2px); }
.button.primary { background: #fff; color: #0d3242; border-color: #fff; }
.button.primary:hover { background: #eef3f6; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 28px 0 0; }

.eyebrow {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 0 0 14px;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: var(--text-3);
}
.eyebrow::before {
	content: "";
	width: 10px; height: 10px;
	border-radius: 3px;
	background: var(--c, var(--tag-green));
}

/* --- The cover ------------------------------------------------------------ */

.cover-page { padding: 64px 0 32px; }
.cover-hero {
	display: grid;
	grid-template-columns: minmax(0, 4fr) minmax(0, 7fr);
	gap: 64px;
	align-items: center;
}
.cover {
	position: relative;
	aspect-ratio: 3 / 4;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	padding: 32px;
	border-radius: var(--radius-media);
	border: 1px solid var(--glass-edge);
	overflow: hidden;
	background:
		radial-gradient(110% 80% at 10% 10%, var(--wash-a) 0%, transparent 55%),
		radial-gradient(100% 90% at 90% 85%, var(--wash-b) 0%, transparent 60%),
		var(--desktop-base);
	box-shadow: var(--shadow), 0 40px 120px rgba(0, 0, 0, .3);
}
.cover svg { position: absolute; top: 32px; left: 32px; width: 72px; height: 72px; }
.cover-title { margin: 0; font-size: clamp(28px, 3vw, 38px); font-weight: 700; line-height: 1.05; letter-spacing: -.03em; }
.cover-sub { margin: 12px 0 0; color: var(--text-2); font-size: 15px; }
.cover-words h1 {
	margin: 0 0 12px;
	font-size: clamp(36px, 5vw, 60px);
	line-height: 1.04;
	letter-spacing: -.035em;
	text-wrap: balance;
}
.cover-words .subtitle { margin: 0 0 20px; color: var(--text); font-size: 21px; }
.cover-words p { color: var(--text-2); max-width: 36em; text-wrap: pretty; }
.cover-words .status { padding-left: 14px; border-left: 3px solid var(--tag-red); color: var(--text-2); font-size: 15.5px; }

.cover-contents { padding: 96px 0 0; max-width: 860px; }
.cover-contents h2 { margin: 0 0 20px; font-size: 32px; letter-spacing: -.02em; }

.chapter-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--glass-edge-soft); }
.chapter-list li { border-bottom: 1px solid var(--glass-edge-soft); }
.chapter-list a, .chapter-list .soon {
	display: grid;
	grid-template-columns: 48px minmax(0, 1fr) auto;
	gap: 16px;
	align-items: baseline;
	padding: 16px 8px;
	text-decoration: none;
}
.chapter-list .n { font-variant-numeric: tabular-nums; color: var(--text-3); font-size: 15px; }
.chapter-list .t { font-size: 19px; font-weight: 500; }
.chapter-list .meta { color: var(--text-3); font-size: 14px; }
.chapter-list a { border-radius: var(--radius-row); transition: background .2s var(--effects); }
.chapter-list a:hover { background: var(--glass); }
.chapter-list a .meta { color: var(--tag-red); }
.chapter-list .soon .t { color: var(--text-3); font-weight: 400; }

@media (max-width: 860px) {
	.cover-hero { grid-template-columns: minmax(0, 1fr); gap: 40px; }
	.cover { max-width: 300px; }
	.cover-contents { padding-top: 64px; }
}
@media (max-width: 520px) {
	.chapter-list a, .chapter-list .soon { grid-template-columns: 32px minmax(0, 1fr); }
	.chapter-list .meta { grid-column: 2; }
}

/* --- Reading --------------------------------------------------------------- */

.reader {
	display: grid;
	grid-template-columns: 280px minmax(0, var(--measure));
	justify-content: center;
	gap: 64px;
	padding: 40px var(--gutter) 0;
}
.side { position: relative; }
.side .toc {
	position: sticky;
	top: 72px;
	max-height: calc(100vh - 96px);
	overflow-y: auto;
	scrollbar-width: none;
	padding-bottom: 32px;
}
.contents-button { display: none !important; }
@media (max-width: 1180px) {
	.reader { grid-template-columns: minmax(0, var(--measure)); padding-top: 24px; }
	.side { display: none; }
	.contents-button { display: inline-flex !important; }
}

/* The contents, in the sidebar and in the sheet. */
.toc { font-size: 14.5px; }
.toc .toc-book { display: block; padding: 0 10px; margin: 0 0 14px; color: var(--text); font-weight: 600; text-decoration: none; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc a, .toc .soon {
	display: grid;
	grid-template-columns: 34px minmax(0, 1fr) auto;
	gap: 6px;
	padding: 6px 10px;
	border-radius: 10px;
	color: var(--text-2);
	text-decoration: none;
	line-height: 1.4;
}
.toc .n { color: var(--text-3); font-variant-numeric: tabular-nums; }
.toc a:hover { background: var(--glass); color: var(--text); }
.toc a[aria-current="page"] { background: rgba(255, 255, 255, .22); color: var(--text); font-weight: 500; }
.toc .soon { color: var(--text-3); }
.toc .tag { font-size: 12px; color: var(--text-3); }
.toc .open > a { color: var(--text); font-weight: 600; }
.toc .pages { margin: 2px 0 8px; }
.toc .pages a { grid-template-columns: 40px minmax(0, 1fr); font-size: 14px; }
.toc code { font-family: var(--mono); font-size: .9em; }

dialog.contents {
	width: min(440px, 100vw);
	max-width: none;
	height: 100vh;
	max-height: none;
	margin: 0 0 0 auto;
	padding: 56px 16px 24px;
	border: 0;
	border-left: 1px solid var(--glass-edge);
	background: var(--slate);
	color: var(--text);
	overflow-y: auto;
	scrollbar-width: none;
	-webkit-backdrop-filter: blur(24px);
	backdrop-filter: blur(24px);
}
dialog.contents[open] { animation: sheet .35s var(--spatial); }
dialog.contents::backdrop { background: rgba(4, 16, 22, .55); }
dialog.contents form button {
	position: absolute;
	top: 12px; right: 12px;
	width: 36px; height: 36px;
	border-radius: 50%;
	border: 1px solid var(--glass-edge-soft);
	background: var(--glass);
	color: var(--text);
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}
@keyframes sheet { from { transform: translateX(40px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { dialog.contents[open] { animation: none; } }

.crumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 32px; color: var(--text-3); font-size: 14.5px; }
.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { color: var(--text); text-decoration: underline; }

/* The text itself. */
.prose { font-size: 18px; line-height: 1.75; color: var(--text-2); }
.page-head { margin-bottom: 36px; }
.kicker { margin: 0 0 10px; color: var(--tag-red); font-size: 14px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.prose h1 { margin: 0; color: var(--text); font-size: clamp(32px, 4.6vw, 46px); line-height: 1.08; letter-spacing: -.03em; text-wrap: balance; }
.prose h2 { margin: 56px 0 16px; color: var(--text); font-size: 27px; line-height: 1.2; letter-spacing: -.02em; }
.prose h3 { margin: 40px 0 12px; color: var(--text); font-size: 21px; line-height: 1.3; }
.prose h4 { margin: 32px 0 10px; color: var(--text); font-size: 18px; }
.prose h2, .prose h3 { scroll-margin-top: 80px; }
.prose :is(h1, h2, h3, h4) code { font-size: .86em; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose .code, .prose .table { margin: 0 0 22px; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: 4px 0; }
.prose li::marker { color: var(--text-3); }
.prose strong { color: var(--text); font-weight: 600; }
.prose a { color: var(--text); text-decoration-color: var(--tag-red); text-underline-offset: 3px; }
.prose a:hover { text-decoration-thickness: 2px; }
.prose hr { height: 1px; margin: 44px 0; border: 0; background: var(--glass-edge-soft); }
.prose blockquote {
	padding: 4px 0 4px 20px;
	border-left: 3px solid var(--tag-red);
	color: var(--text);
}
.prose blockquote p:last-child { margin-bottom: 0; }

.header-anchor {
	margin-left: 10px;
	color: var(--text-3) !important;
	text-decoration: none !important;
	opacity: 0;
	transition: opacity .2s var(--effects);
}
:is(h2, h3):hover .header-anchor, .header-anchor:focus-visible { opacity: 1; }

.prose code {
	padding: .12em .38em;
	border-radius: 6px;
	background: rgba(0, 0, 0, .26);
	color: var(--text);
	font-family: var(--mono);
	font-size: .86em;
}
.prose .code {
	position: relative;
	border-radius: var(--radius-media);
	border: 1px solid var(--glass-edge-soft);
	background: rgba(4, 20, 28, .55);
}
.prose .code pre {
	margin: 0;
	padding: 16px 20px;
	overflow-x: auto;
	scrollbar-width: thin;
	font-size: 14.5px;
	line-height: 1.6;
}
.prose .code code { padding: 0; background: none; font-size: inherit; color: var(--text-2); }
/* What to type, apart from what was printed. */
.prose .code.copyable { background: rgba(0, 0, 0, .42); border-color: var(--glass-edge); }
.prose .code.copyable code { color: var(--text); }
.prose .code.copyable pre { padding-top: 40px; }
.prose .code.copyable::before {
	content: attr(data-lang);
	position: absolute;
	top: 10px; left: 20px;
	color: var(--text-3);
	font-size: 12px;
	font-weight: 600;
	letter-spacing: .06em;
	text-transform: uppercase;
}
.copy {
	position: absolute;
	top: 6px; right: 6px;
	padding: 4px 12px;
	border: 1px solid var(--glass-edge-soft);
	border-radius: 999px;
	background: var(--glass);
	color: var(--text-2);
	font: 500 13px/1.4 inherit;
	cursor: pointer;
}
.copy:hover { background: var(--glass-hover); color: var(--text); }

.prose .table { overflow-x: auto; }
.prose table { width: 100%; border-collapse: collapse; font-size: 16px; }
.prose th, .prose td { padding: 8px 12px; border-bottom: 1px solid var(--glass-edge-soft); text-align: left; vertical-align: top; }
.prose th { color: var(--text); font-weight: 600; }

/* A chapter's own page. */
.prose .index { list-style: none; padding: 0; border-top: 1px solid var(--glass-edge-soft); }
.prose .index li { margin: 0; border-bottom: 1px solid var(--glass-edge-soft); }
.prose .index a {
	display: grid;
	grid-template-columns: 48px minmax(0, 1fr);
	padding: 10px 6px;
	color: var(--text-2);
	text-decoration: none;
	border-radius: 10px;
}
.prose .index a:hover { background: var(--glass); color: var(--text); }
.prose .index .n { color: var(--text-3); font-variant-numeric: tabular-nums; }
.prose .button { text-decoration: none; }
.prose .button.primary { color: #0d3242; }

/* Turning the page. */
.turn {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px;
	margin: 64px 0 0;
	padding-top: 32px;
	border-top: 1px solid var(--glass-edge-soft);
}
.turn a {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 16px 18px;
	border-radius: var(--radius-row);
	border: 1px solid var(--glass-edge-soft);
	background: var(--glass);
	text-decoration: none;
	line-height: 1.35;
	transition: background .2s var(--effects), transform .35s var(--spatial);
}
.turn a:hover { background: var(--glass-hover); transform: translateY(-2px); }
.turn a.next { justify-content: flex-end; text-align: right; }
.turn small { display: block; margin-bottom: 4px; color: var(--text-3); font-size: 13px; }
.turn svg { flex: none; width: 20px; height: 20px; color: var(--text-3); }
@media (max-width: 600px) {
	.turn { grid-template-columns: minmax(0, 1fr); }
}

.book-foot { margin-top: 96px; padding: 32px 0 48px; border-top: 1px solid var(--glass-edge-soft); color: var(--text-3); font-size: 14px; }
.book-foot p { margin: 0 0 6px; max-width: 60em; }
.book-foot a { color: var(--text-2); }

/* On a phone the contents button is its icon alone. */
@media (max-width: 760px) {
	.bar-end button .label { display: none; }
}

/* Notes, tips and warnings: the manuscript's > [!TIP] and the like. */
.prose .alert {
	margin: 0 0 22px;
	padding: 16px 20px 2px;
	border-radius: var(--radius-media);
	border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
	border-left-width: 4px;
	background: color-mix(in srgb, var(--c) 9%, transparent);
	color: var(--text);
	--c: var(--tag-blue);
}
.prose .alert.tip { --c: var(--tag-green); }
.prose .alert.important { --c: var(--tag-purple); }
.prose .alert.warning { --c: var(--tag-yellow); }
.prose .alert.caution { --c: var(--tag-red); }
.prose .alert p { margin-bottom: 14px; }
.prose .alert-title {
	margin: 0 0 6px !important;
	color: var(--c);
	font-size: 13px;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
}

/* Figures, numbered in the manuscript's own captions. */
.prose figure { margin: 36px 0; }
.prose figure img { width: 100%; height: auto; border-radius: var(--radius-media); }
.prose figcaption { margin-top: 12px; color: var(--text-3); font-size: 15px; line-height: 1.5; }

/* Sections still being reviewed, listed by title. */
.toc .pages .soon { grid-template-columns: 40px minmax(0, 1fr); font-size: 14px; opacity: .6; }
.prose .index .soon {
	display: grid;
	grid-template-columns: 48px minmax(0, 1fr) auto;
	padding: 10px 6px;
	color: var(--text-3);
}
.prose .index .soon .tag { font-size: 13px; }
