/* ══════════════════════════════════════════════════════════════════
   LETTERPRESS ARCHIVE — design layer

   theme.json owns the tokens; this file owns the idioms that block
   supports can't express: the title-page rule, the ruled index, the
   marginal apparatus, the contents rail, and the small-caps details.

   Dark mode works by redefining theme.json's generated preset custom
   properties rather than restyling components, so every core block
   follows along without knowing dark mode exists.
   ══════════════════════════════════════════════════════════════════ */

/* ── dark: lamplit leather ─────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
	:root {
		--wp--preset--color--paper:      oklch(0.203 0.013 55);
		--wp--preset--color--paper-deep: oklch(0.243 0.015 52);
		--wp--preset--color--ink:        oklch(0.906 0.010 84);
		--wp--preset--color--ink-soft:   oklch(0.730 0.015 78);
		--wp--preset--color--ink-faint:  oklch(0.630 0.015 72);
		--wp--preset--color--rule:       oklch(0.906 0.020 84 / 16%);
		--wp--preset--color--rule-soft:  oklch(0.906 0.020 84 / 9%);
		--wp--preset--color--gilt:       oklch(0.770 0.085 78);
	}
}
:root[data-theme="dark"] {
	--wp--preset--color--paper:      oklch(0.203 0.013 55);
	--wp--preset--color--paper-deep: oklch(0.243 0.015 52);
	--wp--preset--color--ink:        oklch(0.906 0.010 84);
	--wp--preset--color--ink-soft:   oklch(0.730 0.015 78);
	--wp--preset--color--ink-faint:  oklch(0.630 0.015 72);
	--wp--preset--color--rule:       oklch(0.906 0.020 84 / 16%);
	--wp--preset--color--rule-soft:  oklch(0.906 0.020 84 / 9%);
	--wp--preset--color--gilt:       oklch(0.770 0.085 78);
}
:root[data-theme="light"] {
	--wp--preset--color--paper:      oklch(0.971 0.007 100);
	--wp--preset--color--paper-deep: oklch(0.947 0.011 96);
	--wp--preset--color--ink:        oklch(0.235 0.014 55);
	--wp--preset--color--ink-soft:   oklch(0.470 0.013 60);
	--wp--preset--color--ink-faint:  oklch(0.540 0.013 62);
	--wp--preset--color--rule:       oklch(0.862 0.010 90);
	--wp--preset--color--rule-soft:  oklch(0.912 0.008 92);
	--wp--preset--color--gilt:       oklch(0.700 0.085 75);
}

:root {
	--wo-rail: 8.5rem;
	--wo-gap: 2.75rem;
	--wo-measure: 36rem;
}

/* ── base ──────────────────────────────────────────────────────── */

body {
	/* oldstyle figures in running text: 1851–1921 then sits on the
	   baseline the way it does in print, instead of standing up like
	   a row of fence posts */
	font-feature-settings: "onum" 1, "liga" 1, "kern" 1;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { text-wrap: balance; }
p, li, figcaption { text-wrap: pretty; }

/* Lining figures wherever digits must align in a column. */
.wo-index__meta,
.wo-index__date,
.wo-apparatus,
table {
	font-variant-numeric: tabular-nums;
}

a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
	outline: 2px solid var(--wp--preset--color--accent);
	outline-offset: 3px;
}

/* ── idiom: eyebrow ────────────────────────────────────────────── */
/* Archivo caps behind a short em-rule. The one motif shared with
   philgons.com and oikosaudio.com — what ties the network together. */
.wo-eyebrow {
	display: flex;
	align-items: center;
	gap: 0.7em;
	margin: 0;
	font-family: var(--wp--preset--font-family--archivo);
	font-size: 0.66rem;
	font-weight: 600;
	letter-spacing: 0.19em;
	text-transform: uppercase;
	color: var(--wp--preset--color--accent-ink);
}
.wo-eyebrow::before,
.wo-eyebrow.is-centered::after {
	content: "";
	flex: none;
	width: 1.6em;
	height: 1px;
	background: var(--wp--preset--color--accent);
}
.wo-eyebrow.is-centered { justify-content: center; }

/* ── idiom: true small caps ────────────────────────────────────── */
/* The real smcp feature, not browser-synthesized shrunken capitals. */
.wo-sc {
	font-feature-settings: "smcp" 1, "onum" 1, "kern" 1;
	letter-spacing: 0.05em;
	text-transform: none;
}

/* Headings that arrive already capitalised in the transcription. c2sc maps
   capitals to small caps, so ALL CAPS stops shouting without touching the
   source text. Tagged server-side in letterpress_anchor_headings(). */
.entry-content .wo-caps {
	font-feature-settings: "c2sc" 1, "smcp" 1, "onum" 1, "kern" 1;
	letter-spacing: 0.055em;
	font-size: 1.35rem;
	font-weight: 600;
	color: var(--wp--preset--color--ink);
}

/* ── idiom: the title-page rule ────────────────────────────────── */
/* Thick over thin — the printer's device from a title page. */
.wo-rule { border: 0; margin: 0; padding: 0; }
.wo-rule::before,
.wo-rule::after { content: ""; display: block; background: var(--wp--preset--color--ink); }
.wo-rule::before { height: 2px; }
.wo-rule::after { height: 1px; margin-top: 3px; opacity: 0.55; }

/* ── header ────────────────────────────────────────────────────── */
.wo-masthead .wp-block-site-title {
	font-size: 1.5rem;
	font-weight: 600;
	line-height: 1.1;
}
.wo-masthead .wp-block-site-title a { text-decoration: none; }
.wo-masthead .wp-block-site-tagline {
	font-size: 0.9rem;
	font-style: italic;
	color: var(--wp--preset--color--ink-faint);
}

.wo-nav .wp-block-navigation__container {
	gap: 1.65rem;
	font-family: var(--wp--preset--font-family--archivo);
	font-size: 0.7rem;
	font-weight: 600;
	letter-spacing: 0.15em;
	text-transform: uppercase;
}
.wo-nav .wp-block-navigation-item__content {
	text-decoration: none;
	padding-bottom: 0.2rem;
	border-bottom: 1px solid transparent;
	color: var(--wp--preset--color--ink-soft);
}
.wo-nav .wp-block-navigation-item__content:hover,
.wo-nav .current-menu-item > .wp-block-navigation-item__content {
	color: var(--wp--preset--color--accent-ink);
	border-bottom-color: var(--wp--preset--color--accent);
}

/* ── idiom: the ruled index ────────────────────────────────────── */
/* A bibliography is a ruled list. Cards would be the generic answer
   and the wrong one. */
.wo-index { list-style: none; margin: 0; padding: 0; }
.wo-index__item { border-bottom: 1px solid var(--wp--preset--color--rule-soft); }
.wo-index__item:first-child { border-top: 1px solid var(--wp--preset--color--rule-soft); }

.wo-index__link {
	display: grid;
	grid-template-columns: var(--wo-rail) 1fr auto;
	gap: 0 var(--wo-gap);
	align-items: baseline;
	padding: 1.05rem 0;
	text-decoration: none;
	transition: background-color 0.15s ease;
}
.wo-index__link:hover { background: var(--wp--preset--color--paper-deep); }
.wo-index__link:hover .wo-index__title { color: var(--wp--preset--color--accent-ink); }

/* the marginal column — where a catalogue puts the date */
.wo-index__date {
	font-family: var(--wp--preset--font-family--archivo);
	font-size: 0.68rem;
	font-weight: 600;
	letter-spacing: 0.1em;
	color: var(--wp--preset--color--ink-faint);
	text-align: right;
	padding-top: 0.3em;
}
.wo-index__title { display: block; font-size: 1.24rem; line-height: 1.32; }
.wo-index__note {
	display: block;
	margin-top: 0.22rem;
	font-size: 0.95rem;
	font-style: italic;
	color: var(--wp--preset--color--ink-soft);
}
.wo-index__meta {
	font-family: var(--wp--preset--font-family--archivo);
	font-size: 0.62rem;
	font-weight: 500;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--wp--preset--color--ink-faint);
	white-space: nowrap;
	padding-top: 0.45em;
}

/* ── idiom: the marginal apparatus ─────────────────────────────── */
.wo-apparatus {
	display: flex;
	flex-direction: column;
	font-family: var(--wp--preset--font-family--archivo);
	font-size: 0.62rem;
	font-weight: 500;
	line-height: 1.6;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--wp--preset--color--ink-faint);
	text-align: right;
}
.wo-apparatus__dinkus { letter-spacing: 0.4em; opacity: 0.7; }

/* ── idiom: the extract ────────────────────────────────────────── */
/* A quotation set as a printed extract — centred, opened by a dinkus —
   rather than as a bordered "testimonial". Used on the front pages. */
/* Specificity has to clear `.entry-content blockquote` below, which sets the
   left rule for pull quotes inside a work. An extract is not a pull quote. */
.wo-extract,
.entry-content blockquote.wo-extract {
	max-width: 40rem;
	margin: var(--wp--preset--spacing--50) auto 0;
	padding: 0;
	border: 0;
	text-align: center;
	font-style: italic;
	color: var(--wp--preset--color--ink);
	font-size: 1.5rem;
	line-height: 1.45;
}
.wo-extract::before {
	content: "* * *";
	display: block;
	margin-bottom: 1.4rem;
	color: var(--wp--preset--color--accent);
	font-style: normal;
	font-size: 1rem;
	letter-spacing: 0.75em;
	text-indent: 0.75em;
	line-height: 1;
}
.wo-extract p { margin: 0; }
.wo-extract cite {
	display: block;
	margin-top: 1.5rem;
	font-family: var(--wp--preset--font-family--archivo);
	font-size: 0.64rem;
	font-weight: 600;
	font-style: normal;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--wp--preset--color--ink-faint);
}

/* ── the reading view ──────────────────────────────────────────── */
/* Text column offset from centre, leaving a margin for the apparatus
   and the contents rail — the critical-edition signature. */
/* Two explicit children — a rail and a body — rather than relying on grid
   auto-placement, which gets fragile the moment the editor adds a block. */
.wo-reading {
	display: grid;
	grid-template-columns: var(--wo-rail) minmax(0, var(--wo-measure));
	gap: 0 var(--wo-gap);
	justify-content: center;
	align-items: start;
}
.wo-reading__rail { grid-column: 1; position: sticky; top: 2.5rem; }
.wo-reading__body { grid-column: 2; min-width: 0; }

.wo-runhead {
	grid-column: 1 / -1;
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 2.6rem;
	padding-bottom: 0.6rem;
	border-bottom: 1px solid var(--wp--preset--color--rule);
	font-feature-settings: "smcp" 1, "onum" 1;
	font-size: 0.86rem;
	letter-spacing: 0.08em;
	color: var(--wp--preset--color--ink-faint);
}

/* Drop cap on the real face, not core's synthesized one. Applied only via the
   wo-dropcap class, which letterpress_mark_dropcap() adds when the opening
   paragraph is actually prose — never to a pronunciation gloss or an epigraph. */
.wo-dropcap::first-letter {
	float: left;
	font-size: 3.9em;
	line-height: 0.82;
	margin-top: 0.04em;
	padding: 0.06em 0.09em 0 0;
	color: var(--wp--preset--color--accent-ink);
	font-weight: 500;
}

.wo-reading blockquote,
.entry-content blockquote {
	margin: 2.2rem 0;
	padding-left: 1.4rem;
	border-left: 2px solid var(--wp--preset--color--accent);
	font-style: italic;
	color: var(--wp--preset--color--ink-soft);
}

/* Footnotes: these transcriptions carry up to 128 of them. */
.entry-content .wp-block-footnotes,
.entry-content ol.footnotes {
	margin-top: 3rem;
	padding-top: 1.2rem;
	border-top: 1px solid var(--wp--preset--color--rule);
	font-size: 0.95rem;
	color: var(--wp--preset--color--ink-soft);
}

/* ── the contents rail ─────────────────────────────────────────── */
.wo-contents {
	display: block;
	text-align: right;
	max-height: calc(100vh - 5rem);
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
}
.wo-contents__label {
	display: block;
	margin-bottom: 0.8rem;
	font-family: var(--wp--preset--font-family--archivo);
	font-size: 0.6rem;
	font-weight: 600;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--wp--preset--color--ink-faint);
}
.wo-contents ol { list-style: none; margin: 0; padding: 0; }
.wo-contents li { margin: 0 0 0.55rem; }
.wo-contents a {
	display: block;
	padding-right: 0.7rem;
	border-right: 1px solid var(--wp--preset--color--rule);
	font-size: 0.86rem;
	line-height: 1.3;
	color: var(--wp--preset--color--ink-faint);
	text-decoration: none;
	/* headings here are full sentences — clamp so the rail stays
	   scannable; the full text is in the title attribute */
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.wo-contents a:hover,
.wo-contents a.is-current {
	color: var(--wp--preset--color--accent-ink);
	border-right-color: var(--wp--preset--color--accent);
}
.wo-contents__sub a { font-size: 0.78rem; padding-right: 1.4rem; }

/* reading progress hairline */
.wo-progress {
	position: fixed;
	top: 0;
	left: 0;
	height: 2px;
	width: 0;
	background: var(--wp--preset--color--accent);
	z-index: 9995;
	pointer-events: none;
}
body.admin-bar .wo-progress { top: 32px; }

/* Anchor landing: plain jumps plus scroll-margin. Deliberately no
   scroll-behavior:smooth — it breaks anchor jumps in this setup. */
.entry-content :is(h2, h3, h4)[id] { scroll-margin-top: 2rem; }

/* ── footer ────────────────────────────────────────────────────── */
.wo-colophon {
	border-top: 1px solid var(--wp--preset--color--rule);
	font-size: 1.02rem;
}
.wo-colophon a { text-decoration: none; color: var(--wp--preset--color--ink-soft); }
.wo-colophon a:hover { color: var(--wp--preset--color--accent-ink); }
.wo-colophon .wo-sister {
	font-style: italic;
	color: var(--wp--preset--color--ink-faint);
	font-size: 0.95rem;
}

/* ── narrow viewports ──────────────────────────────────────────── */
/* johnowen.org is currently unusable below ~1000px; this is the fix. */
@media (max-width: 46rem) {
	:root { --wo-rail: 0rem; --wo-gap: 0rem; }

	.wo-reading { grid-template-columns: minmax(0, 1fr); }
	.wo-reading__rail,
	.wo-reading__body { grid-column: 1; position: static; }
	.wo-contents { display: none; }

	.wo-apparatus {
		text-align: left;
		flex-direction: row;
		flex-wrap: wrap;
		gap: 0 0.9rem;
		margin-bottom: 1.6rem;
		padding-left: 0.8rem;
		border-left: 2px solid var(--wp--preset--color--accent);
	}
	.wo-apparatus__dinkus { display: none; }

	.wo-index__link { grid-template-columns: 1fr; gap: 0.3rem; padding: 0.95rem 0; }
	.wo-index__date { order: -1; text-align: left; padding-top: 0; }
	.wo-index__meta { padding-top: 0.2rem; }
}

/* Wide media in a work must not push the page sideways. */
.entry-content :is(table, pre) { display: block; max-width: 100%; overflow-x: auto; }
.entry-content img { max-width: 100%; height: auto; }

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

@media print {
	.wo-contents, .wo-progress, .wo-nav, .wo-colophon { display: none !important; }
	.wo-reading { display: block; }
}
