/*
Theme Name: DOAC Reference
Theme URI: https://example.org/
Author: Recovery pipeline
Description: A reading and navigation theme for the recovered Biographical Dictionary of Architects in Canada. Built for a text-only reference work: A–Z browsing, fast search, and long-form biographical prose with citations.
Version: 1.1
License: GPL-2.0-or-later
Text Domain: doac
*/

/* ==========================================================================
   The whole design rests on typography. This corpus has no images at all —
   3,000 biographies of dense prose, dates, place names and citations — so
   what makes it usable is measure, rhythm and restraint, not decoration.

   SPACING: every margin, padding and gap in this file comes from the scale
   below, which is Material's 4/8dp grid. Nothing is eyeballed. That is what
   makes the vertical rhythm consistent between a nav row, a list item and a
   paragraph, and it is why the reference nav no longer has rows 1.6px apart.
   ========================================================================== */

:root {
	/* Spacing scale — multiples of 8, with 4 for fine adjustment only. */
	--sp-1: 0.25rem;   /*  4px */
	--sp-2: 0.5rem;    /*  8px */
	--sp-3: 0.75rem;   /* 12px */
	--sp-4: 1rem;      /* 16px */
	--sp-5: 1.5rem;    /* 24px */
	--sp-6: 2rem;      /* 32px */
	--sp-7: 3rem;      /* 48px */
	--sp-8: 4rem;      /* 64px */

	/* Smallest comfortable hit area for a dense interface. */
	--target: 2.5rem;  /* 40px */

	/* Warm paper, dark ink, oxblood accent: the palette of the printed
	   reference works this descends from. */
	--paper:        #fbf9f5;
	--surface:      #ffffff;
	--surface-sunk: #f3efe7;
	--ink:          #1c1a17;
	--ink-soft:     #4a453d;
	--ink-faint:    #6f685c;
	--rule:         #e0d9cb;
	--rule-strong:  #c9c0ad;
	--accent:       #8a3324;
	--accent-soft:  #a9503f;
	--focus:        #2f5d62;

	--serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
	         "Times New Roman", serif;
	--sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
	        Arial, sans-serif;

	--measure: 34rem;      /* ~68 characters — the readable limit for prose */
	--gutter: clamp(var(--sp-4), 4vw, var(--sp-6));
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--paper:        #171614;
		--surface:      #1d1c19;
		--surface-sunk: #232120;
		--ink:          #e9e4da;
		--ink-soft:     #b8b0a2;
		--ink-faint:    #8e8677;
		--rule:         #333029;
		--rule-strong:  #4a463c;
		--accent:       #e0937f;
		--accent-soft:  #c9765f;
		--focus:        #7fb2b8;
	}
}

:root[data-theme="dark"] {
	--paper:        #171614;
	--surface:      #1d1c19;
	--surface-sunk: #232120;
	--ink:          #e9e4da;
	--ink-soft:     #b8b0a2;
	--ink-faint:    #8e8677;
	--rule:         #333029;
	--rule-strong:  #4a463c;
	--accent:       #e0937f;
	--accent-soft:  #c9765f;
	--focus:        #7fb2b8;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font-family: var(--serif);
	font-size: 1.0625rem;
	line-height: 1.6;
	text-rendering: optimizeLegibility;
	-webkit-font-smoothing: antialiased;
}

/* --- shared -------------------------------------------------------------- */

.wrap {
	max-width: 62rem;
	margin: 0 auto;
	/* Longhand deliberately. The `padding: 0 var(--gutter)` shorthand also sets
	   top and bottom to zero, and because a class outranks an element selector
	   it silently wiped the vertical padding on <main class="wrap">, leaving
	   headings touching the rule above them and the previous/next links sitting
	   directly on the footer border. */
	padding-left: var(--gutter);
	padding-right: var(--gutter);
}

.wrap--prose { max-width: calc(var(--measure) + 2 * var(--gutter)); }

/* Any wrap that is also a landmark region carries its own vertical rhythm. */
main.wrap { padding-top: var(--sp-7); padding-bottom: var(--sp-8); }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-soft); }

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

.screen-reader-text {
	position: absolute; width: 1px; height: 1px;
	overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
	white-space: nowrap;
}

.skip-link {
	position: absolute; left: -9999px; top: 0;
	background: var(--surface); color: var(--ink);
	padding: var(--sp-3) var(--sp-4); z-index: 100;
}
.skip-link:focus { left: 0; }

/* --- masthead ------------------------------------------------------------ */

.masthead {
	border-bottom: 1px solid var(--rule);
	background: var(--surface);
}

.masthead__inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--sp-3) var(--sp-5);
	padding-top: var(--sp-5);
	padding-bottom: var(--sp-5);
}

.masthead__title {
	font-size: clamp(1.15rem, 2.4vw, 1.5rem);
	font-weight: 600;
	letter-spacing: .01em;
	margin: 0;
	line-height: 1.3;
}
.masthead__title a { color: inherit; text-decoration: none; }
.masthead__title a:hover { color: var(--accent); }

.masthead__dates {
	font-family: var(--sans);
	font-size: .72rem;
	letter-spacing: .1em;
	text-transform: uppercase;
	color: var(--ink-faint);
	white-space: nowrap;
}

.masthead__search { margin-left: auto; }

/* --- search form --------------------------------------------------------- */

.searchform { display: flex; gap: var(--sp-2); }

.searchform input[type="search"] {
	font: inherit;
	font-family: var(--sans);
	font-size: .9rem;
	min-height: var(--target);
	padding: var(--sp-2) var(--sp-3);
	min-width: 15.5rem;
	color: var(--ink);
	background: var(--paper);
	border: 1px solid var(--rule-strong);
	border-radius: 3px;
}
.searchform input[type="search"]::placeholder { color: var(--ink-faint); }

.searchform button {
	font-family: var(--sans);
	font-size: .85rem;
	min-height: var(--target);
	padding: var(--sp-2) var(--sp-4);
	color: var(--surface);
	background: var(--ink);
	border: 1px solid var(--ink);
	border-radius: 3px;
	cursor: pointer;
}
.searchform button:hover { background: var(--accent); border-color: var(--accent); }

/* --- reference nav (front matter) ---------------------------------------- */

.refnav {
	border-bottom: 1px solid var(--rule);
	background: var(--surface-sunk);
	font-family: var(--sans);
	font-size: .82rem;
}
.refnav ul {
	display: flex; flex-wrap: wrap;
	/* This list wraps to three rows on a site with a full set of front matter.
	   The row gap has to be a real gap, or the rows sit on top of each other. */
	gap: var(--sp-2) var(--sp-5);
	list-style: none;
	margin: 0;
	padding: var(--sp-3) 0;
}
.refnav li { display: flex; }
.refnav a {
	display: inline-block;
	padding: var(--sp-1) 0;
	color: var(--ink-soft);
	text-decoration: none;
	line-height: 1.4;
}
.refnav a:hover, .refnav .is-current a { color: var(--accent); text-decoration: underline; }
.refnav .is-current a { font-weight: 600; }

/* A full set of front matter is fourteen links, which on a phone stacks four
   rows deep and pushes the entries most of a screen down. Scrolling it
   sideways keeps every link reachable in one row, matching the letter bar. */
@media (max-width: 40rem) {
	.refnav ul {
		flex-wrap: nowrap;
		overflow-x: auto;
		scrollbar-width: none;
		-webkit-overflow-scrolling: touch;
	}
	.refnav ul::-webkit-scrollbar { display: none; }
	.refnav li { flex: 0 0 auto; }
	.refnav a { white-space: nowrap; }
}

/* --- letter bar ---------------------------------------------------------- */

.letterbar {
	position: sticky; top: 0; z-index: 20;
	background: var(--paper);
	border-bottom: 1px solid var(--rule);
	padding: var(--sp-2) 0;
}
.letterbar__list {
	display: flex; flex-wrap: wrap;
	gap: var(--sp-1);
	list-style: none; margin: 0; padding: 0;
	font-family: var(--sans);
}
.letterbar__list a,
.letterbar__list span {
	display: flex;
	align-items: center;
	justify-content: center;
	/* Narrow enough that all 26 letters hold a single row inside the 62rem
	   column, but full height so the hit area stays comfortable. A dictionary's
	   alphabet wrapping to two rows makes it read as a menu rather than an
	   index — and the bar is sticky, so a second row follows the reader. */
	min-width: 1.75rem;
	min-height: var(--target);
	font-size: .88rem;
	font-weight: 600;
	letter-spacing: .02em;
	text-decoration: none;
	border-radius: 3px;
	color: var(--ink-soft);
}
.letterbar__list a:hover { background: var(--surface-sunk); color: var(--accent); }
.letterbar__list .is-current a { background: var(--ink); color: var(--paper); }
.letterbar__list .is-empty span { color: var(--rule-strong); }

/* On a phone the alphabet wraps to three rows, and because the bar is sticky
   those rows follow the reader down the page eating a third of the screen.
   One horizontally scrollable row keeps it to a single line. */
@media (max-width: 40rem) {
	.letterbar__list {
		flex-wrap: nowrap;
		overflow-x: auto;
		scrollbar-width: none;
		-webkit-overflow-scrolling: touch;
	}
	.letterbar__list::-webkit-scrollbar { display: none; }
	.letterbar__list li { flex: 0 0 auto; }
	/* Scrolling already frees the bar from fitting, so touch gets full targets. */
	.letterbar__list a,
	.letterbar__list span { min-width: var(--target); }
}

/* --- page furniture ------------------------------------------------------ */

main { padding: var(--sp-7) 0 var(--sp-8); }

.pagetitle {
	font-size: clamp(1.5rem, 3.5vw, 2.1rem);
	font-weight: 600;
	line-height: 1.2;
	margin: 0 0 var(--sp-2);
	letter-spacing: -.01em;
}

.pagemeta {
	font-family: var(--sans);
	font-size: .82rem;
	color: var(--ink-faint);
	margin: 0 0 var(--sp-6);
}

.lede {
	font-size: 1.15rem;
	line-height: 1.55;
	color: var(--ink-soft);
	max-width: var(--measure);
	margin: 0 0 var(--sp-6);
}

/* --- A–Z index (archive landing) ----------------------------------------- */

.azgrid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
	gap: var(--sp-2);
	list-style: none; margin: 0 0 var(--sp-7); padding: 0;
}
.azgrid a,
.azgrid .is-empty {
	display: block;
	padding: var(--sp-4) var(--sp-2);
	text-align: center;
	text-decoration: none;
	background: var(--surface);
	border: 1px solid var(--rule);
	border-radius: 4px;
	color: var(--ink);
	transition: border-color .12s, transform .12s;
}
.azgrid a:hover {
	border-color: var(--accent);
	transform: translateY(-1px);
}
.azgrid__letter {
	display: block;
	font-size: 1.5rem;
	font-weight: 600;
	line-height: 1;
}
.azgrid__count {
	display: block;
	margin-top: var(--sp-2);
	font-family: var(--sans);
	font-size: .7rem;
	letter-spacing: .06em;
	color: var(--ink-faint);
}
.azgrid .is-empty {
	background: transparent;
	border-style: dashed;
	opacity: .5;
	pointer-events: none;
}

/* --- entry list (letter pages, search) ----------------------------------- */

.filterbar {
	display: flex; flex-wrap: wrap; align-items: center;
	gap: var(--sp-4);
	margin: 0 0 var(--sp-5);
	padding-bottom: var(--sp-5);
	border-bottom: 1px solid var(--rule);
}
.filterbar input {
	font-family: var(--sans);
	font-size: .92rem;
	min-height: var(--target);
	padding: var(--sp-2) var(--sp-3);
	min-width: min(20rem, 100%);
	color: var(--ink);
	background: var(--surface);
	border: 1px solid var(--rule-strong);
	border-radius: 3px;
}
.filterbar__count {
	font-family: var(--sans);
	font-size: .82rem;
	color: var(--ink-faint);
}

.entrylist {
	columns: 2;
	column-gap: var(--sp-7);
	list-style: none;
	margin: 0; padding: 0;
}
@media (min-width: 60rem) { .entrylist { columns: 3; } }
@media (max-width: 34rem) { .entrylist { columns: 1; } }

.entrylist li {
	break-inside: avoid;
	margin: 0 0 var(--sp-2);
	line-height: 1.45;
}
.entrylist a {
	display: inline-block;
	padding: var(--sp-1) 0;
	text-decoration: none;
	color: var(--ink);
}
.entrylist a:hover { color: var(--accent); text-decoration: underline; }
.entrylist li[hidden] { display: none; }

/* A name rendered as SURNAME, Given — the surname carried in small caps,
   which is how the printed dictionary distinguished it. */
.name__surname {
	font-variant: small-caps;
	letter-spacing: .02em;
}
.name__given { color: var(--ink-soft); }

.emptystate {
	font-family: var(--sans);
	font-size: .92rem;
	color: var(--ink-faint);
	padding: var(--sp-5) 0;
}

/* --- single entry -------------------------------------------------------- */

.entry__header {
	max-width: var(--measure);
	margin-right: auto;
	margin-bottom: var(--sp-6);
	padding-bottom: var(--sp-5);
	border-bottom: 2px solid var(--ink);
}
.entry__title {
	font-size: clamp(1.6rem, 4vw, 2.25rem);
	font-weight: 600;
	line-height: 1.2;
	margin: 0;
	letter-spacing: -.01em;
}
.entry__title .name__surname { letter-spacing: .01em; }

/* A two-column grid whose first track is the reading measure: prose stays
   readable and flush with the heading, while a wide appendix table spans the
   whole column. Constraining the container instead would squeeze a
   five-column table into 34rem, which is how tables end up clipped. */
.entry__body,
.page__body {
	display: grid;
	grid-template-columns: min(var(--measure), 100%) 1fr;
	max-width: none;
}
.entry__body > *,
.page__body > * { grid-column: 1; min-width: 0; }

.entry__body > .tablewrap,
.page__body > .tablewrap { grid-column: 1 / -1; width: 100%; }

.entry__body { font-size: 1.075rem; }
.entry__body p { margin: 0 0 var(--sp-5); }
.entry__body p:last-child { margin-bottom: 0; }

.entry__body strong { font-weight: 600; }

.entry__body ul, .entry__body ol { padding-left: var(--sp-5); margin: 0 0 var(--sp-5); }
.entry__body li { margin-bottom: var(--sp-2); }

.entry__body blockquote {
	margin: var(--sp-5) 0;
	padding-left: var(--sp-4);
	border-left: 2px solid var(--rule-strong);
	color: var(--ink-soft);
}

/* The citation block that closes most entries. Set smaller and quieter than
   the biography, the way a printed reference sets its apparatus. */
.entry__sources {
	max-width: var(--measure);
	margin-right: auto;
	margin-top: var(--sp-7);
	padding-top: var(--sp-5);
	border-top: 1px solid var(--rule);
	font-size: .94rem;
	line-height: 1.55;
	color: var(--ink-soft);
}
.entry__sources h2 {
	font-family: var(--sans);
	font-size: .72rem;
	font-weight: 700;
	letter-spacing: .12em;
	text-transform: uppercase;
	color: var(--ink-faint);
	margin: 0 0 var(--sp-3);
}
.entry__sources p { margin: 0 0 var(--sp-4); }
.entry__sources p:last-child { margin-bottom: 0; }

/* Cross-references. A link to an entry that survived reads as an ordinary
   link; one that only exists in the archive is marked, so a reader knows
   before clicking that they are leaving for the Internet Archive. */
.entry__body a[href^="http"]:not(.doac-archived-link) { text-decoration: underline; }

a.doac-archived-link {
	color: var(--ink-soft);
	text-decoration: underline dotted;
	text-underline-offset: 3px;
}
a.doac-archived-link:hover { color: var(--accent); }
a.doac-archived-link::after {
	content: "↗ archive";
	font-family: var(--sans);
	font-size: .62em;
	letter-spacing: .04em;
	text-transform: uppercase;
	vertical-align: .35em;
	margin-left: var(--sp-1);
	color: var(--ink-faint);
	text-decoration: none;
}

/* --- prev / next --------------------------------------------------------- */

.adjacent {
	display: flex; flex-wrap: wrap; gap: var(--sp-4);
	justify-content: space-between;
	max-width: var(--measure);
	margin-right: auto;
	margin-top: var(--sp-7);
	padding-top: var(--sp-5);
	border-top: 1px solid var(--rule);
	font-family: var(--sans);
	font-size: .86rem;
}
.adjacent__label {
	display: block;
	font-size: .68rem;
	letter-spacing: .1em;
	text-transform: uppercase;
	color: var(--ink-faint);
	margin-bottom: var(--sp-1);
}
.adjacent a {
	display: inline-block;
	padding: var(--sp-1) 0;
	text-decoration: none;
	color: var(--ink);
}
.adjacent a:hover { color: var(--accent); }
.adjacent__next { text-align: right; margin-left: auto; }

/* --- static pages (front matter, appendices) ----------------------------- */

.page__body h2 {
	font-size: 1.3rem;
	margin: var(--sp-7) 0 var(--sp-3);
	line-height: 1.25;
}
.page__body h3 { font-size: 1.1rem; margin: var(--sp-6) 0 var(--sp-2); }
.page__body p { margin: 0 0 var(--sp-5); }
.page__body ul, .page__body ol { padding-left: var(--sp-5); margin: 0 0 var(--sp-5); }
.page__body li { margin-bottom: var(--sp-2); }

/* The appendices are wide tables. They must scroll inside their own box,
   never widen the page. */
.tablewrap {
	overflow-x: auto;
	margin: var(--sp-6) 0;
	border: 1px solid var(--rule);
	border-radius: 4px;
	background: var(--surface);
}

table {
	border-collapse: collapse;
	width: 100%;
	font-size: .92rem;
	font-family: var(--sans);
}
th, td {
	padding: var(--sp-3) var(--sp-4);
	text-align: left;
	vertical-align: top;
	white-space: nowrap;
	border-bottom: 1px solid var(--rule);
}
th {
	font-weight: 600;
	font-size: .78rem;
	letter-spacing: .05em;
	text-transform: uppercase;
	color: var(--ink-faint);
	background: var(--surface-sunk);
	position: sticky; top: 0;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-sunk); }
/* The first column holds names, which may legitimately wrap; everything else
   is short enough that wrapping only makes it harder to read. */
td:first-child, th:first-child { white-space: normal; min-width: 12rem; }

/* --- search results ------------------------------------------------------ */

.result {
	max-width: var(--measure);
	margin: 0 0 var(--sp-5);
	padding-bottom: var(--sp-5);
	border-bottom: 1px solid var(--rule);
}
.result:last-of-type { border-bottom: 0; }
.result__title { font-size: 1.15rem; margin: 0 0 var(--sp-2); line-height: 1.3; }
.result__title a { text-decoration: none; color: var(--ink); }
.result__title a:hover { color: var(--accent); }
.result__excerpt { margin: 0; color: var(--ink-soft); font-size: .97rem; }
.result__kind {
	display: inline-block;
	margin-left: var(--sp-2);
	font-family: var(--sans);
	font-size: .68rem;
	letter-spacing: .09em;
	text-transform: uppercase;
	color: var(--ink-faint);
}
mark {
	background: color-mix(in srgb, var(--accent) 18%, transparent);
	color: inherit;
	padding: 0 .1em;
	border-radius: 2px;
}

/* --- pagination ---------------------------------------------------------- */

.pagination {
	display: flex; gap: var(--sp-2); flex-wrap: wrap;
	margin-top: var(--sp-6);
	font-family: var(--sans);
	font-size: .88rem;
}
.pagination .page-numbers {
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: var(--target);
	min-height: var(--target);
	padding: 0 var(--sp-3);
	border: 1px solid var(--rule);
	border-radius: 3px;
	text-decoration: none;
	color: var(--ink-soft);
}
.pagination .page-numbers:hover { border-color: var(--accent); color: var(--accent); }
.pagination .current {
	background: var(--ink);
	border-color: var(--ink);
	color: var(--paper);
}

/* --- footer -------------------------------------------------------------- */

.sitefooter {
	border-top: 1px solid var(--rule);
	background: var(--surface);
	padding: var(--sp-7) 0;
	font-size: .88rem;
	color: var(--ink-soft);
}
.sitefooter p { margin: 0 0 var(--sp-2); max-width: var(--measure); }
.sitefooter p:last-child { margin-bottom: 0; }
.sitefooter .fine {
	font-family: var(--sans);
	font-size: .76rem;
	color: var(--ink-faint);
}

@media print {
	.masthead__search, .letterbar, .refnav, .adjacent, .filterbar { display: none; }
	body { background: #fff; color: #000; font-size: 11pt; }
	.entry__body, .entry__sources { max-width: none; }
}
