/*
 * Poems: the gallery (/poems/), the daily poem (/daily/) and the writing page
 * (/write/). Book-like and quiet: one narrow serif column on warm paper,
 * metadata in small letterspaced sans. System fonts only.
 */

:root {
	color-scheme: light dark;
	--paper: #f7f3ec;
	--ink: #1f1c18;
	--muted: #6b635a;
	--rule: #ddd5c8;
	--accent: #8c2f1f;
	--focus: #1f5fbf;
	--serif: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, "Book Antiqua", Georgia, serif;
	--sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--measure: 36rem;
}

@media (prefers-color-scheme: dark) {
	:root {
		--paper: #161412;
		--ink: #ebe5da;
		--muted: #a39a8e;
		--rule: #38332d;
		--accent: #e08a70;
		--focus: #8ab4ff;
	}
}

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

[hidden] {
	display: none !important;
}

html {
	background: var(--paper);
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0 auto;
	max-width: calc(var(--measure) + 3rem);
	padding: max(1.25rem, env(safe-area-inset-top)) 1.5rem 5rem;
	background: var(--paper);
	color: var(--ink);
	font-family: var(--serif);
	font-size: 1.1875rem;
	line-height: 1.65;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

a {
	color: inherit;
	text-decoration-color: var(--rule);
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
}

a:hover {
	color: var(--accent);
	text-decoration-color: currentColor;
}

:focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: 3px;
	border-radius: 2px;
}

/* ── Site header ───────────────────────────────────────────────────── */

.site-header {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
	padding-bottom: 0.75rem;
	margin-bottom: clamp(2.5rem, 9vw, 4.5rem);
	border-bottom: 1px solid var(--rule);
	font-family: var(--sans);
	font-size: 0.8125rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.site-name {
	font-weight: 600;
	text-decoration: none;
}

.site-nav {
	display: flex;
	gap: 1.25rem;
}

.site-nav a {
	color: var(--muted);
	text-decoration: none;
}

.site-nav a[aria-current="page"] {
	color: var(--ink);
	text-decoration: underline;
	text-decoration-color: var(--accent);
	text-underline-offset: 0.45em;
}

/* ── Page headers ──────────────────────────────────────────────────── */

.page-header {
	margin-bottom: 2.5rem;
}

.page-title {
	margin: 0;
	font-size: clamp(2rem, 7vw, 2.75rem);
	font-weight: 400;
	line-height: 1.1;
	letter-spacing: -0.01em;
}

.page-links {
	display: flex;
	gap: 1.25rem;
	margin: 0.75rem 0 0;
	font-family: var(--sans);
	font-size: 0.875rem;
	color: var(--muted);
}

.empty {
	color: var(--muted);
	font-style: italic;
}

/* ── A poem ────────────────────────────────────────────────────────── */

.poem-date {
	margin: 0 0 0.5rem;
	font-family: var(--sans);
	font-size: 0.8125rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--muted);
}

.poem-title {
	margin: 0 0 2rem;
	font-size: clamp(1.75rem, 6vw, 2.375rem);
	font-weight: 400;
	line-height: 1.15;
	letter-spacing: -0.005em;
	text-wrap: balance;
}

.stanza {
	margin: 0 0 1.4em;
	white-space: pre-wrap; /* keeps the poet's indentation */
}

.line {
	display: block;
	padding-left: 1.5em; /* wrapped lines hang, so line breaks stay legible */
	text-indent: -1.5em;
}

.poem-credit {
	margin: 2.5rem 0 0;
	padding-top: 1rem;
	border-top: 1px solid var(--rule);
	max-width: 20rem;
	font-size: 0.9375rem;
	font-style: italic;
	color: var(--muted);
}

.poem-nav {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: 0.75rem 1.5rem;
	margin-top: 3.5rem;
	font-family: var(--sans);
	font-size: 0.875rem;
	color: var(--muted);
}

.poem-nav a {
	text-decoration: none;
}

.poem-nav-archive {
	margin: 0 auto;
}

.poem-nav-older:only-of-type,
.poem-nav-archive:first-child {
	margin-left: 0;
}

/* ── Gallery index ─────────────────────────────────────────────────── */

.gallery {
	list-style: none;
	margin: 0;
	padding: 0;
	counter-reset: poem;
}

.gallery-item {
	counter-increment: poem;
	padding: 1.1rem 0;
	border-top: 1px solid var(--rule);
}

.gallery-item:last-child {
	border-bottom: 1px solid var(--rule);
}

.gallery-link {
	display: block;
	text-decoration: none;
}

.gallery-title {
	display: block;
	font-size: 1.375rem;
	line-height: 1.3;
}

.gallery-title::before {
	content: none;
}

.gallery-first-line,
.gallery-credit {
	display: block;
	color: var(--muted);
}

.gallery-first-line {
	margin-top: 0.15rem;
	font-size: 0.98rem;
}

.gallery-link:hover .gallery-title {
	color: var(--accent);
}

.gallery-credit {
	margin-top: 0.25rem;
	font-family: var(--sans);
	font-size: 0.8125rem;
}

/* ── Daily archive ─────────────────────────────────────────────────── */

.archive-month + .archive-month {
	margin-top: 2.25rem;
}

.archive-month-title {
	margin: 0 0 0.5rem;
	font-family: var(--sans);
	font-size: 0.8125rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--muted);
}

.archive-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.archive-list a {
	display: flex;
	gap: 1rem;
	padding: 0.4rem 0;
	text-decoration: none;
	border-bottom: 1px solid var(--rule);
}

.archive-list time {
	flex: 0 0 6.5rem;
	font-family: var(--sans);
	font-size: 0.875rem;
	line-height: 1.9;
	color: var(--muted);
	font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation: none !important;
		transition: none !important;
		scroll-behavior: auto !important;
	}
}
