/* recipes.mattmoyles.com
 *
 * Plain CSS. No framework, no build step, no web fonts, no JavaScript — the
 * site has to keep working from inside the house when the WAN is down.
 *
 * The collection is mostly Slavic home cooking, so the palette comes from
 * enamelware and Gzhel pottery: cool enamel white, blue-black printing ink,
 * cobalt, and a beet red that earns its place in a book with this much borscht
 * in it.
 */

:root {
	--paper: #f5f4f0;
	--tint: #e9e7e1;
	--rule: #d5d2c9;
	--ink: #16181d;
	--ink-2: #5f646d;
	--cobalt: #1c4f8c;
	--beet: #99253f;

	--serif: "Charter", "Bitstream Charter", "Iowan Old Style", "Palatino Linotype",
		Palatino, "Book Antiqua", Georgia, serif;
	--sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

	--measure: 40rem;
	--wide: 64rem;
	--pad: 1.25rem;
}

@media (prefers-color-scheme: dark) {
	:root {
		--paper: #14161a;
		--tint: #1e2127;
		--rule: #2f343d;
		--ink: #e7e5df;
		--ink-2: #969ba5;
		--cobalt: #7fa9dd;
		--beet: #d97891;
	}
}

* { box-sizing: border-box; }

html {
	-webkit-text-size-adjust: 100%;
	overflow-wrap: break-word;
}

body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font: 1.0625rem/1.65 var(--serif);
	font-kerning: normal;
}

main {
	max-width: var(--wide);
	margin: 0 auto;
	padding: 1.75rem var(--pad) 4rem;
}

img { max-width: 100%; }

a { color: var(--cobalt); text-underline-offset: 2px; }
a:hover { color: var(--beet); }

:focus-visible { outline: 2px solid var(--beet); outline-offset: 2px; }

/* ------------------------------------------------------------ masthead -- */
.top {
	max-width: var(--wide);
	margin: 0 auto;
	padding: 1.25rem var(--pad) 0;
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.5rem 1rem;
	flex-wrap: wrap;
}

.brand {
	font-size: 1.05rem;
	font-weight: 600;
	color: var(--ink);
	text-decoration: none;
	letter-spacing: -0.01em;
}

.top nav {
	display: flex;
	flex-wrap: wrap;
	gap: 0 1.25rem;
}
.top nav a {
	font-family: var(--sans);
	font-size: 0.8125rem;
	color: var(--ink-2);
	text-decoration: none;
	white-space: nowrap;
}
.top nav a:hover { color: var(--beet); text-decoration: underline; }

.bot {
	max-width: var(--wide);
	margin: 0 auto;
	padding: 1.5rem var(--pad) 2.5rem;
	border-top: 1px solid var(--rule);
	font-family: var(--sans);
	font-size: 0.8125rem;
	color: var(--ink-2);
}
.bot p { margin: 0; display: flex; flex-wrap: wrap; gap: 0 1.25rem; }
.bot a { color: var(--ink-2); }

/* ---------------------------------------------------------------- titles -- */
.sitetitle {
	font-size: clamp(2rem, 6vw, 3rem);
	line-height: 1.05;
	letter-spacing: -0.025em;
	font-weight: 600;
	margin: 0.25rem 0 0;
}

.sitetitle + .lede {
	margin-top: 0.8rem;
	padding-top: 0.8rem;
	border-top: 3px solid var(--cobalt);
}

.lede {
	color: var(--ink-2);
	max-width: var(--measure);
	margin: 0 0 1.5rem;
}

/* Tag rows must be able to wrap. The links are emitted one per line so the
   browser has a break opportunity between them; nowrap keeps a single tag
   from splitting mid-name but never spans the whole row. */
.alltags {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem 0.5rem;
	margin: 0 0 1.75rem;
}

.tag {
	display: inline-block;
	padding: 0.15rem 0.6rem;
	border: 1px solid var(--rule);
	border-radius: 999px;
	font-family: var(--sans);
	font-size: 0.8125rem;
	line-height: 1.5;
	text-decoration: none;
	color: var(--ink);
	white-space: nowrap;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
}
.tag:hover { border-color: var(--cobalt); color: var(--cobalt); }
.tag .n { color: var(--ink-2); font-size: 0.6875rem; margin-left: 0.35em; }
.tag:hover .n { color: inherit; }

/* ------------------------------------------------------------- the mosaic -- */
.mosaic {
	list-style: none;
	margin: 0 0 1.5rem;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
	grid-auto-flow: dense;
	gap: 0.5rem;
}

.mosaic a {
	position: relative;
	display: block;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	background: var(--tint);
	text-decoration: none;
	border-radius: 2px;
}

.mosaic img,
.mosaic .noimg {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* No photo yet: the recipe's initial on a quiet ruled panel, which reads as a
   deliberate plate rather than a broken image. */
.mosaic .noimg {
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 2.75rem;
	font-weight: 600;
	color: color-mix(in srgb, var(--ink) 22%, transparent);
	background:
		repeating-linear-gradient(
			45deg, transparent, transparent 7px,
			color-mix(in srgb, var(--ink) 6%, transparent) 7px,
			color-mix(in srgb, var(--ink) 6%, transparent) 8px);
}

.mosaic .cap {
	position: absolute;
	inset: auto 0 0 0;
	padding: 2rem 0.6rem 0.55rem;
	color: #fff;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.5) 42%, transparent);
}

.mosaic .ct {
	display: block;
	font-size: 0.9rem;
	line-height: 1.25;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.mosaic .cm {
	display: block;
	margin-top: 0.15rem;
	font-family: var(--sans);
	font-size: 0.6875rem;
	opacity: 0.85;
	font-variant-numeric: tabular-nums;
}

.mosaic a:hover { outline: 2px solid var(--cobalt); outline-offset: -2px; }
.mosaic a:hover .cap { background: linear-gradient(to top, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.6) 50%, transparent); }

/* Give the grid some rhythm once there are enough columns for a double tile
   to not swallow the whole row. */
@media (min-width: 34rem) {
	.mosaic li:nth-child(11n + 1) a { aspect-ratio: auto; height: 100%; }
	.mosaic li:nth-child(11n + 1) { grid-column: span 2; grid-row: span 2; }
	.mosaic li:nth-child(11n + 1) .ct { font-size: 1.15rem; }
}

.count {
	font-family: var(--sans);
	font-size: 0.8125rem;
	color: var(--ink-2);
	margin: 1.25rem 0 0;
}

/* ------------------------------------------------------- the A-Z ledger -- */
.index { list-style: none; margin: 0; padding: 0; }
.index li { border-top: 1px solid var(--rule); }
.index li:last-child { border-bottom: 1px solid var(--rule); }

.index a {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.4rem 0;
	text-decoration: none;
	color: var(--ink);
}
.index a:hover { color: var(--beet); }

.thumb {
	flex: 0 0 auto;
	width: 42px;
	height: 42px;
	object-fit: cover;
	display: block;
	background: var(--tint);
	border-radius: 2px;
}

.index .t { flex: 1 1 auto; min-width: 0; }
.index .leader {
	flex: 1 1 auto;
	min-width: 1.5rem;
	border-bottom: 1px dotted var(--rule);
	transform: translateY(-0.3em);
}
.index .d {
	flex: 0 0 auto;
	font-family: var(--sans);
	font-size: 0.75rem;
	color: var(--ink-2);
	font-variant-numeric: tabular-nums;
}

.taglist { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 2.5rem; }
.taglist li { margin: 0 0 0.5rem; break-inside: avoid; }
.taglist .n { font-family: var(--sans); font-size: 0.75rem; color: var(--ink-2); }

/* --------------------------------------------------------- recipe page -- */
.recipe { max-width: var(--wide); }

.recipe h1 {
	font-size: clamp(1.8rem, 4.5vw, 2.6rem);
	line-height: 1.1;
	letter-spacing: -0.022em;
	font-weight: 600;
	margin: 0.25rem 0 0.6rem;
	max-width: 24ch;
}

.tags { display: flex; flex-wrap: wrap; gap: 0.4rem 0.5rem; margin: 0 0 1rem; }

.meta {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1.75rem;
	margin: 0 0 1.5rem;
	padding: 0.7rem 0;
	border-top: 1px solid var(--rule);
	border-bottom: 1px solid var(--rule);
	font-family: var(--sans);
	font-size: 0.8125rem;
}
.meta b {
	display: block;
	font-weight: 500;
	color: var(--ink-2);
	font-size: 0.75rem;
}

.summary { max-width: var(--measure); color: var(--ink-2); }

/* Photo credit, shown only where a licence requires it. */
.credit {
	margin: -1.6rem 0 2rem;
	font-family: var(--sans);
	font-size: 0.7rem;
	color: var(--ink-2);
}

img.hero {
	width: 100%;
	max-height: 22rem;
	object-fit: cover;
	display: block;
	margin: 0 0 2rem;
	border-radius: 2px;
}

.cook {
	display: grid;
	grid-template-columns: minmax(13rem, 18rem) minmax(0, 1fr);
	gap: 2.5rem;
	align-items: start;
}

.ingredients { position: sticky; top: 1.25rem; }

.ingredients h2, .method h2, .notes h2, .nutrition h2 {
	font-size: 0.9375rem;
	font-weight: 600;
	margin: 0 0 0.75rem;
	padding-bottom: 0.4rem;
	border-bottom: 2px solid var(--beet);
}

.ingredients ul { list-style: none; margin: 0; padding: 0; font-size: 0.9375rem; }
.ingredients li { padding: 0.3rem 0; border-bottom: 1px solid var(--rule); line-height: 1.45; }
.ingredients h3, .method h3 {
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--beet);
	margin: 1.25rem 0 0.4rem;
}

.method ol { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.method ol li {
	counter-increment: step;
	position: relative;
	padding: 0 0 1.1rem 2.75rem;
	max-width: var(--measure);
}
.method ol li::before {
	content: counter(step);
	position: absolute;
	left: 0;
	top: -0.1em;
	font-family: var(--sans);
	font-size: 1.25rem;
	font-weight: 500;
	color: var(--cobalt);
	font-variant-numeric: tabular-nums;
}

/* pandoc emits loose lists (<li><p>…</p></li>), lowdown emits tight ones.
   Normalise both so the hanging step number lines up with the first line. */
.method ol li > :first-child,
.ingredients li > :first-child { margin-top: 0; }
.method ol li > :last-child,
.ingredients li > :last-child { margin-bottom: 0; }

.notes { margin-top: 2.5rem; max-width: var(--measure); }
.notes p:first-of-type { margin-top: 0; }

/* Nutrition arrives as "Calories: 320 kcal" pairs and is set as a real
   definition list, not a run-on line of escaped markdown. */
.nutrition { margin-top: 2.5rem; max-width: var(--measure); }
.nutrition dl {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
	gap: 0.6rem 1.25rem;
	margin: 0;
	font-family: var(--sans);
}
.nutrition dl > div {
	border-top: 1px solid var(--rule);
	padding-top: 0.4rem;
}
.nutrition dt { font-size: 0.7rem; color: var(--ink-2); }
.nutrition dd { margin: 0.1rem 0 0; font-size: 0.9375rem; font-variant-numeric: tabular-nums; }

.source {
	max-width: var(--measure);
	color: var(--ink-2);
	font-size: 0.875rem;
	font-family: var(--sans);
	overflow-wrap: anywhere;
}

.back {
	margin-top: 3rem;
	padding-top: 1rem;
	border-top: 1px solid var(--rule);
	font-family: var(--sans);
	font-size: 0.8125rem;
	display: flex;
	flex-wrap: wrap;
	gap: 0 1.25rem;
}

/* ---------------------------------------------------------------- tablet -- */
@media (max-width: 52rem) {
	.cook { grid-template-columns: 1fr; gap: 1.75rem; }
	.ingredients { position: static; }
	.ingredients ul { font-size: 1rem; }
}

/* ----------------------------------------------------------------- phone -- */
@media (max-width: 34rem) {
	:root { --pad: 1rem; }
	body { font-size: 1rem; }
	.mosaic { gap: 0.35rem; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); }
	.mosaic .ct { font-size: 0.8125rem; }
	.mosaic .cap { padding: 1.6rem 0.5rem 0.45rem; }
	.taglist { columns: 1; }
	.method ol li { padding-left: 2.25rem; }
	/* The dotted leader has no room to do its job on a phone. */
	.index .leader { display: none; }
	.index .t { flex: 1 1 auto; }
	.index a { gap: 0.6rem; }
	img.hero { max-height: 14rem; }
}

@media (prefers-reduced-motion: reduce) {
	* { animation: none !important; transition: none !important; }
}

/* ----------------------------------------------------------------- print -- */
@media print {
	:root {
		--paper: #fff; --tint: #fff; --rule: #bbb;
		--ink: #000; --ink-2: #444; --cobalt: #000; --beet: #000;
	}
	.top nav, .bot, .alltags, .back, img.hero, .thumb, .mosaic { display: none; }
	main { max-width: none; padding: 0; }
	.cook { grid-template-columns: 1fr; gap: 1.25rem; }
	.ingredients { position: static; }
	.method ol li { padding-bottom: 0.5rem; }
	a { color: #000; text-decoration: none; }
}
