/**
 * STRATUSstaff Handbook homepage.
 * Tokens are local so the book can sit on a darker desk than inner pages.
 */

body.home {
	--hb-desk: #1b2838;
	--hb-paper: #f3eee4;
	--hb-paper-edge: #e7e0d2;
	--hb-rule: #cfc6b8;
	--hb-ink: #1c1916;
	--hb-muted: #5c564e;
	--hb-navy: #1f4b7a;
	--hb-policy: #5c4a2e;
	--hb-foundational: #7c2d2d;
	--hb-serif: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
	--hb-sans: var(--wp--preset--font-family--system-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
	--hb-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
}

body.home {
	background: var(--hb-desk);
	color: var(--hb-ink);
}

body.home .site-header {
	display: none;
}

body.home .site-main {
	padding: 0;
	flex: 1;
}

body.home .site-footer {
	padding: 0.85rem 1rem 1.25rem;
	color: color-mix(in srgb, #fff 55%, transparent);
	font-size: 0.75rem;
	letter-spacing: 0.04em;
}

body.home .site-footer .content-width {
	width: min(100% - 1.5rem, 72rem);
	text-align: center;
}

body.home .site-footer p {
	margin: 0;
}

/* --- Spread --- */

.handbook-home {
	padding: 0.75rem 0 1.5rem;
}

.handbook {
	position: relative;
	width: min(100% - 1.5rem, 72rem);
	margin: 0 auto;
}

.handbook-spread {
	display: flex;
	flex-direction: column;
	background: var(--hb-paper);
	color: var(--hb-ink);
	border: 1px solid color-mix(in srgb, #000 18%, var(--hb-paper-edge));
	box-shadow:
		0 1px 0 color-mix(in srgb, #fff 35%, transparent) inset,
		0 18px 50px color-mix(in srgb, #000 38%, transparent);
	background-image:
		linear-gradient(180deg, color-mix(in srgb, #fff 28%, transparent), transparent 5.5rem);
}

.handbook-leaf {
	position: relative;
	padding: 1.5rem 1.35rem 2.75rem;
}

.handbook-gutter {
	display: none;
}

.handbook-running {
	margin: 0 0 1.75rem;
	font-family: var(--hb-sans);
	font-size: 0.6875rem;
	font-weight: 600;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: var(--hb-muted);
}

.handbook-running--right {
	text-align: right;
}

.handbook-kicker {
	margin: 0 0 0.4rem;
	font-family: var(--hb-sans);
	font-size: 0.75rem;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--hb-navy);
}

.handbook-title {
	margin: 0 0 0.75rem;
	font-family: var(--hb-serif);
	font-size: clamp(2rem, 6vw, 3.15rem);
	font-weight: 400;
	line-height: 1.05;
	letter-spacing: -0.02em;
}

.handbook-promise {
	margin: 0 0 0.65rem;
	max-width: 22rem;
	font-family: var(--hb-serif);
	font-size: 1.2rem;
	line-height: 1.4;
	color: var(--hb-ink);
}

.handbook-purpose {
	margin: 0 0 1.75rem;
	padding-bottom: 1.5rem;
	border-bottom: 1px solid var(--hb-rule);
	font-size: 0.95rem;
	color: var(--hb-muted);
}

.handbook-folio {
	display: none;
	position: absolute;
	bottom: 1rem;
	margin: 0;
	font-family: var(--hb-serif);
	font-size: 0.8rem;
	font-style: italic;
	color: var(--hb-muted);
}

.handbook-folio--verso {
	left: 1.75rem;
}

.handbook-folio--recto {
	right: 1.75rem;
}

/* --- Legend --- */

.handbook-legend {
	margin-bottom: 1.75rem;
}

.handbook-legend__title,
.handbook-contents-title {
	margin: 0 0 0.85rem;
	font-family: var(--hb-sans);
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--hb-muted);
}

.handbook-legend__list {
	margin: 0;
}

.handbook-legend__item {
	display: grid;
	grid-template-columns: 7.5rem 1fr;
	gap: 0.75rem;
	padding: 0.7rem 0 0.7rem 0.85rem;
	border-left: 3px solid var(--hb-navy);
}

.handbook-legend__item--policy {
	border-left-color: var(--hb-policy);
}

.handbook-legend__item--foundational {
	border-left-color: var(--hb-foundational);
}

.handbook-legend__item dt {
	margin: 0;
	font-family: var(--hb-sans);
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.handbook-legend__item dd {
	margin: 0;
	font-size: 0.9rem;
	line-height: 1.45;
	color: var(--hb-muted);
}

/* --- Reader views --- */

.handbook-view[hidden] {
	display: none !important;
}

.handbook-live {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
}

.handbook-title--chapter {
	font-size: clamp(1.85rem, 5vw, 2.6rem);
}

.handbook-chapter-kinds {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
	margin: 0 0 0.85rem;
}

.handbook-section-nav {
	margin: 0 0 1.5rem;
	padding-top: 1.25rem;
	border-top: 1px solid var(--hb-rule);
}

.handbook-section-nav__title {
	margin: 0 0 0.6rem;
	font-family: var(--hb-sans);
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--hb-muted);
}

.handbook-section-nav__list {
	margin: 0;
	padding-left: 1.15rem;
}

.handbook-section-nav__list a {
	color: var(--hb-ink);
	text-decoration: none;
}

.handbook-section-nav__list a:hover,
.handbook-section-nav__list a:focus-visible {
	color: var(--hb-navy);
	text-decoration: underline;
}

.handbook-back {
	margin: 0 0 1.25rem;
	font-size: 0.8rem;
}

.handbook-back a {
	color: var(--hb-navy);
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	text-decoration: none;
}

.handbook-back a:hover,
.handbook-back a:focus-visible {
	text-decoration: underline;
}

.handbook-placeholder-note {
	margin: 0 0 1.25rem;
	font-family: var(--hb-sans);
	font-size: 0.6875rem;
	font-weight: 600;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--hb-muted);
}

.handbook-prose h2 {
	margin: 1.75rem 0 0.65rem;
	padding-top: 1.1rem;
	border-top: 1px solid var(--hb-rule);
	font-family: var(--hb-serif);
	font-size: 1.35rem;
	font-weight: 400;
}

.handbook-prose .handbook-section:first-child h2 {
	margin-top: 0;
	padding-top: 0;
	border-top: 0;
}

.handbook-prose h2 .handbook-kind {
	margin-left: 0.55rem;
	vertical-align: middle;
}

.handbook-prose p,
.handbook-intro p {
	max-width: 38em;
	margin: 0 0 1em;
	line-height: 1.65;
}

.handbook-intro {
	margin: 0 0 1.25rem;
}

.handbook-intro p:last-child {
	margin-bottom: 0;
}

.handbook-prose ul,
.handbook-prose ol {
	max-width: 38em;
	margin: 0 0 1em;
	padding-left: 1.25rem;
}

.handbook-prose li {
	margin-bottom: 0.35rem;
	line-height: 1.55;
}

.handbook-prose blockquote {
	max-width: 38em;
	margin: 0 0 1.25rem;
	padding: 0.15rem 0 0.15rem 1rem;
	border-left: 3px solid var(--hb-foundational);
	color: var(--hb-ink);
}

.handbook-prose blockquote p:last-child {
	margin-bottom: 0;
}

.handbook-prose a {
	color: var(--hb-navy);
	overflow-wrap: anywhere;
}

.handbook-pager {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	margin-top: 2.5rem;
	padding-top: 1.25rem;
	border-top: 1px solid var(--hb-rule);
}

.handbook-pager__link {
	display: flex;
	flex-direction: column;
	max-width: 48%;
	color: var(--hb-navy);
	text-decoration: none;
}

.handbook-pager__link--next {
	margin-left: auto;
	text-align: right;
}

.handbook-pager__dir {
	font-family: var(--hb-sans);
	font-size: 0.6875rem;
	font-weight: 600;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--hb-muted);
}

.handbook-pager__label {
	font-family: var(--hb-serif);
	font-size: 1rem;
}

.handbook-pager__link:hover .handbook-pager__label,
.handbook-pager__link:focus-visible .handbook-pager__label {
	text-decoration: underline;
}

/* --- Chapter index --- */

.handbook-index {
	display: flex;
	flex-direction: column;
	border-top: 1px solid var(--hb-rule);
}

.handbook-index__row {
	display: grid;
	grid-template-columns: 2.4rem 1fr;
	gap: 0.65rem 0.85rem;
	padding: 0.85rem 0.15rem;
	border-bottom: 1px solid var(--hb-rule);
	color: inherit;
	text-decoration: none;
}

.handbook-index__row:hover,
.handbook-index__row:focus-visible {
	background: color-mix(in srgb, #fff 42%, var(--hb-paper));
}

.handbook-index__num {
	font-family: var(--hb-mono);
	font-size: 0.8rem;
	line-height: 1.5;
	color: var(--hb-navy);
	font-variant-numeric: tabular-nums;
}

.handbook-index__title {
	display: block;
	font-family: var(--hb-serif);
	font-size: 1.15rem;
	line-height: 1.25;
}

.handbook-index__lede {
	display: block;
	margin-top: 0.2rem;
	font-size: 0.875rem;
	color: var(--hb-muted);
}

.handbook-index__kinds {
	grid-column: 2;
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
}

.handbook-kind {
	font-family: var(--hb-sans);
	font-size: 0.625rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--hb-navy);
}

.handbook-kind--policy {
	color: var(--hb-policy);
}

.handbook-kind--foundational {
	color: var(--hb-foundational);
}

/* --- Thumb tabs --- */

.handbook-top {
	position: fixed;
	right: 1rem;
	bottom: 1rem;
	z-index: 20;
	padding: 0.55rem 0.85rem;
	border: 1px solid var(--hb-rule);
	background: var(--hb-paper);
	color: var(--hb-ink);
	font-family: var(--hb-sans);
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	cursor: pointer;
	box-shadow: 0 8px 24px color-mix(in srgb, #000 28%, transparent);
}

.handbook-top[hidden] {
	display: none;
}

.handbook-top:hover,
.handbook-top:focus-visible {
	background: var(--hb-navy);
	border-color: var(--hb-navy);
	color: #fff;
}

.handbook-tabs {
	position: sticky;
	top: 0;
	z-index: 8;
	display: flex;
	flex-wrap: wrap;
	gap: 0.3rem;
	margin: 0 0 0.75rem;
	padding: 0.45rem 0 0.55rem;
	background: var(--hb-desk);
}

.handbook-tab {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-width: 2.4rem;
	padding: 0.35rem 0.4rem;
	background: var(--hb-paper);
	border: 1px solid var(--hb-rule);
	color: var(--hb-ink);
	text-decoration: none;
	font-family: var(--hb-mono);
	font-size: 0.7rem;
	line-height: 1.2;
}

.handbook-tab__title {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
}

.handbook-tab:hover,
.handbook-tab:focus-visible,
.handbook-tab.is-active {
	background: var(--hb-navy);
	border-color: var(--hb-navy);
	color: #fff;
}

.handbook-tab:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.handbook-tab--contents {
	font-family: var(--hb-serif);
}

/* --- Tablet+ : still a single practical index, wider measure --- */

@media (min-width: 40rem) {
	.handbook-leaf {
		padding: 2rem 2rem 3rem;
	}

	.handbook-index__row {
		grid-template-columns: 2.6rem 1fr auto;
		align-items: start;
	}

	.handbook-index__kinds {
		grid-column: auto;
		justify-content: end;
		padding-top: 0.3rem;
	}

	.handbook-index__title {
		font-size: 1.25rem;
	}
}

/* --- Desktop: open book --- */

@media (min-width: 64rem) {
	body.home,
	body.home .site {
		height: 100vh;
		overflow: hidden;
	}

	body.home .site {
		min-height: 0;
	}

	.handbook-home {
		display: flex;
		align-items: stretch;
		flex: 1;
		min-height: 0;
		padding: 1.25rem 3.5rem 0.75rem 1.25rem;
	}

	.handbook {
		display: flex;
		flex-direction: column;
		width: min(100%, 70rem);
		min-height: 0;
		height: 100%;
	}

	.handbook-view.is-active {
		flex: 1;
		min-height: 0;
	}

	.handbook-spread {
		display: grid;
		grid-template-columns: minmax(0, 1fr) 1.15rem minmax(0, 1fr);
		min-height: 0;
		height: 100%;
		overflow: hidden;
		background-image:
			linear-gradient(90deg, transparent 49.4%, color-mix(in srgb, #000 16%, transparent) 50%, transparent 50.6%),
			linear-gradient(180deg, color-mix(in srgb, #fff 30%, transparent), transparent 7rem);
	}

	.handbook-view[hidden] {
		display: none !important;
	}

	.handbook-leaf {
		min-height: 0;
		overflow: auto;
	}

	.handbook-gutter {
		display: block;
		background:
			linear-gradient(90deg, color-mix(in srgb, #000 10%, transparent), transparent 40%, color-mix(in srgb, #000 12%, transparent));
		box-shadow:
			inset 6px 0 10px color-mix(in srgb, #000 6%, transparent),
			inset -6px 0 10px color-mix(in srgb, #000 6%, transparent);
	}

	.handbook-leaf--verso {
		display: flex;
		flex-direction: column;
		padding: 1.75rem 2.4rem 3rem 2.6rem;
	}

	.handbook-legend {
		margin-top: auto;
	}

	.handbook-leaf--recto {
		padding: 1.75rem 2.6rem 3rem 2.1rem;
	}

	.handbook-folio {
		display: block;
	}

	.handbook-tabs {
		position: absolute;
		top: 12%;
		right: -2.55rem;
		flex-direction: column;
		flex-wrap: nowrap;
		gap: 0.2rem;
		margin: 0;
		padding: 0;
		background: transparent;
		z-index: 8;
	}

	.handbook-top {
		right: 1.25rem;
		bottom: 1.25rem;
	}

	.handbook-tab {
		min-width: 2.35rem;
		padding: 0.42rem 0.35rem 0.42rem 0.45rem;
		border-right: 0;
		border-radius: 3px 0 0 3px;
		box-shadow: 2px 1px 0 color-mix(in srgb, #000 12%, transparent);
	}

	.handbook-tab--contents {
		margin-bottom: 0.45rem;
	}

	.handbook-view--chapter .handbook-leaf--verso {
		display: flex;
		flex-direction: column;
	}

	.handbook-view--chapter .handbook-folio {
		display: none;
	}
}

@media (min-width: 80rem) {
	.handbook {
		width: min(100%, 76rem);
	}

	.handbook-title {
		font-size: 3.35rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}
}

@media (prefers-reduced-motion: no-preference) {
	html {
		scroll-behavior: smooth;
	}
}
