/* Series blocks — Mormon Bandwagon
   Palette and type come from theme.json presets so the Site Editor stays in charge. */

:root {
	--mb-paper: var(--wp--preset--color--base);
	--mb-ink: var(--wp--preset--color--contrast);
	--mb-accent: var(--wp--preset--color--accent-1);
	--mb-paper-deep: var(--wp--preset--color--accent-2);
	--mb-ink-soft: var(--wp--preset--color--accent-4);
	--mb-rule: var(--wp--preset--color--accent-5);
	--mb-display: var(--wp--preset--font-family--cormorant-garamond);
	--mb-text: var(--wp--preset--font-family--source-serif-4);
	--mb-shadow: 12px 14px 30px rgba(38, 33, 27, 0.22);
	--mb-sticky-top: 0px;
}
body.admin-bar { --mb-sticky-top: 32px; }
@media (max-width: 782px) { body.admin-bar { --mb-sticky-top: 46px; } }

/* ---------- Buttons ---------- */
.mb-btn {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	font-family: var(--mb-text);
	font-size: 0.875rem;
	font-weight: 500;
	line-height: 1;
	padding: 0.65rem 0.95rem;
	border-radius: 2px;
	text-decoration: none;
	white-space: nowrap;
	transition: background-color .15s ease, color .15s ease;
}
.mb-btn--outline { border: 1px solid var(--mb-ink); color: var(--mb-ink); background: transparent; }
.mb-btn--outline:hover { background: var(--mb-ink); color: var(--mb-paper); }
.mb-btn--solid { background: var(--mb-ink); color: var(--mb-paper); border: 1px solid var(--mb-ink); }
.mb-btn--solid:hover { background: var(--mb-accent); border-color: var(--mb-accent); color: var(--mb-paper); }

/* ---------- Book cover (shared by shelf and series header) ---------- */
.mb-book__cover {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	box-sizing: border-box;
	padding: 30px 26px 26px 34px;
	border-radius: 2px 8px 8px 2px;
	color: var(--mb-paper);
	box-shadow: inset 6px 0 0 rgba(0,0,0,0.18), inset 8px 0 0 rgba(255,255,255,0.06), var(--mb-shadow);
	background-image: repeating-linear-gradient(0deg, rgba(0,0,0,0.025) 0 1px, transparent 1px 3px);
}
.mb-book__cover.has-image {
	background-size: cover;
	background-position: center;
	position: relative;
	isolation: isolate;
}
.mb-book__cover.has-image::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	background: linear-gradient(180deg, rgba(20,16,12,0.25) 0%, rgba(20,16,12,0.15) 45%, rgba(20,16,12,0.72) 100%);
	z-index: -1;
}
.mb-strip__spine.has-image { background-size: cover; background-position: center; }
.mb-book__count { font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.7; }
.mb-book__titling { display: flex; flex-direction: column; gap: 12px; }
.mb-book__title { font-family: var(--mb-display); font-size: clamp(1.5rem, 2vw, 2.125rem); font-weight: 600; line-height: 1.05; text-wrap: balance; }
.mb-book__rule { display: block; width: 36px; height: 1px; background: rgba(244,238,227,0.5); }
.mb-book__author { font-family: var(--mb-display); font-size: 1.125rem; font-style: italic; font-weight: 500; }

/* ---------- Shelf ---------- */
.mb-shelf { display: flex; flex-direction: column; gap: 28px; }
.mb-shelf__books {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: 40px;
	align-items: end;
}
.mb-book { display: flex; flex-direction: column; gap: 18px; text-decoration: none; color: inherit; transition: transform .25s ease; }
.mb-book:hover { transform: translateY(-4px); color: inherit; }
.mb-book__blurb { display: flex; flex-direction: column; gap: 6px; }
.mb-book__desc { font-size: 0.9375rem; line-height: 1.5; color: #3d3630; }
.mb-book__cta { font-size: 0.6875rem; }
.mb-book:hover .mb-book__cta { color: var(--mb-accent); }
.mb-shelf__plank {
	height: 10px;
	margin-top: -8px;
	border-radius: 1px;
	background: linear-gradient(var(--mb-rule), #c9bda6);
	box-shadow: 0 6px 12px rgba(38,33,27,0.12);
}
@media (max-width: 600px) {
	.mb-shelf__books {
		display: flex;
		overflow-x: auto;
		gap: 16px;
		padding: 8px 0 24px;
		scroll-snap-type: x mandatory;
		-webkit-overflow-scrolling: touch;
	}
	.mb-book { flex: 0 0 200px; scroll-snap-align: start; }
	.mb-book__cover { height: auto !important; min-height: 230px; padding: 18px 16px 16px 22px; }
	.mb-book__blurb { display: none; }
	.mb-shelf__plank { margin-top: -30px; }
}

/* ---------- Series strip (chapter pages) ---------- */
.mb-strip {
	position: sticky;
	top: var(--mb-sticky-top);
	z-index: 20;
	background: var(--mb-paper-deep);
	border-bottom: 1px solid var(--mb-rule);
	margin: 0 !important;
}
.mb-strip__inner {
	max-width: var(--wp--style--global--wide-size);
	margin: 0 auto;
	padding: 12px var(--wp--style--root--padding-right, 24px) 12px var(--wp--style--root--padding-left, 24px);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
}
.mb-strip__series { display: flex; align-items: center; gap: 14px; min-width: 0; }
.mb-strip__spine { flex: none; width: 22px; height: 30px; border-radius: 1px 3px 3px 1px; box-shadow: inset 3px 0 0 rgba(0,0,0,0.2); }
.mb-strip__names { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mb-strip__title { font-family: var(--mb-display); font-size: 1.25rem; font-weight: 600; line-height: 1; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mb-strip__meta { font-size: 0.8125rem; color: var(--mb-ink-soft); white-space: nowrap; }
.mb-strip__position { color: var(--mb-ink); white-space: nowrap; }
.mb-strip__nav { display: flex; gap: 10px; }
.mb-strip__progress { height: 3px; background: var(--mb-rule); display: flex; }
.mb-strip__progress span { display: block; height: 100%; background: var(--mb-accent); transition: width .3s ease; }
@media (max-width: 782px) {
	.mb-strip__position, .mb-strip__meta { display: none; }
	.mb-btn span { display: none; }
	.mb-btn { padding: 0.65rem; }
}

/* ---------- Reading layout ---------- */
.mb-reading-layout {
	display: grid;
	grid-template-columns: 280px minmax(0, 1fr);
	gap: 80px;
	align-items: start;
}
.mb-reading { max-width: 720px; }
.mb-reading .wp-block-post-title { margin-top: 0.5rem; margin-bottom: 1rem; }
.mb-reading .mb-byline { display: flex; gap: 10px; flex-wrap: wrap; font-size: 0.9375rem; color: var(--mb-ink-soft); padding-bottom: 1.6rem; border-bottom: 1px solid var(--mb-rule); margin-bottom: 2rem; }
@media (max-width: 1024px) {
	.mb-reading-layout { grid-template-columns: 1fr; gap: 32px; }
	.mb-toc { position: static !important; }
	.mb-toc__list { display: none; }
	.mb-toc.is-open .mb-toc__list { display: block; }
}

/* ---------- Table of contents sidebar ---------- */
.mb-toc {
	position: sticky;
	top: calc(var(--mb-sticky-top) + 88px);
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding-top: 6px;
	max-height: calc(100vh - var(--mb-sticky-top) - 100px);
	overflow-y: auto;
}
.mb-toc__heading, .mb-toc__toggle { margin: 0 0 8px; }
.mb-toc__toggle { background: none; border: 0; padding: 0; text-align: left; cursor: default; font: inherit; }
@media (max-width: 1024px) {
	.mb-toc__toggle { cursor: pointer; display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 12px 0; border-top: 1px solid var(--mb-rule); border-bottom: 1px solid var(--mb-rule); margin: 0; }
	.mb-toc__toggle::after { content: ""; width: 8px; height: 8px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); transition: transform .2s; }
	.mb-toc.is-open .mb-toc__toggle::after { transform: rotate(225deg); }
	.mb-toc__about { display: none; }
	.mb-toc.is-open .mb-toc__about { display: block; }
}
.mb-toc__list { list-style: none; margin: 0; padding: 0; }
.mb-toc__item a, .mb-toc__item > span {
	display: flex;
	gap: 12px;
	align-items: baseline;
	padding: 7px 0;
	font-size: 0.875rem;
	line-height: 1.35;
	color: var(--mb-ink-soft);
	text-decoration: none;
}
.mb-toc__item a:hover { color: var(--mb-ink); }
.mb-toc__n { flex: none; width: 20px; font-size: 0.75rem; font-variant-numeric: tabular-nums; color: #a89c86; }
.mb-toc__item.is-current > span { color: var(--mb-accent); font-weight: 600; }
.mb-toc__item.is-current .mb-toc__n { color: var(--mb-accent); }
.mb-toc__about { display: block; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--mb-rule); font-size: 0.8125rem; color: var(--mb-accent); text-decoration: none; }

/* ---------- Chapter label ---------- */
.mb-chapter-label { color: var(--mb-accent); margin: 0; }

/* ---------- Chapter navigation cards ---------- */
.mb-chapter-nav {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 24px;
	margin-top: 3rem;
	padding-top: 2rem;
	border-top: 1px solid var(--mb-ink);
}
.mb-chapter-nav__card {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 20px 22px;
	border: 1px solid var(--mb-rule);
	border-radius: 2px;
	text-decoration: none;
	color: var(--mb-ink);
	transition: border-color .15s ease, background-color .15s ease;
}
.mb-chapter-nav__card--prev:hover { border-color: var(--mb-ink); color: var(--mb-ink); }
.mb-chapter-nav__card--next { background: var(--mb-ink); color: var(--mb-paper); border-color: var(--mb-ink); align-items: flex-end; text-align: right; }
.mb-chapter-nav__card--next .mb-label { color: rgba(244,238,227,0.7); }
.mb-chapter-nav__card--next:hover { background: var(--mb-accent); border-color: var(--mb-accent); color: var(--mb-paper); }
.mb-chapter-nav__card--empty { border: 0; }
.mb-chapter-nav__title { font-family: var(--mb-display); font-size: 1.5rem; font-weight: 600; line-height: 1.15; }
@media (max-width: 600px) {
	.mb-chapter-nav { grid-template-columns: 1fr; }
	.mb-chapter-nav__card--empty { display: none; }
}

/* ---------- Series landing page ---------- */
.mb-series-header {
	display: grid;
	grid-template-columns: 300px minmax(0, 1fr);
	gap: 64px;
	align-items: start;
}
.mb-series-header__cover .mb-book__cover { height: 400px; }
.mb-series-header__text { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.mb-series-header__text > .mb-label { margin: 0; }
.mb-series-header__title { margin: 0; font-size: var(--wp--preset--font-size--xx-large); }
.mb-series-header__by { margin: 0; color: var(--mb-ink-soft); font-style: italic; }
.mb-series-header__desc { font-size: var(--wp--preset--font-size--reading); line-height: 1.6; color: #3d3630; }
.mb-series-header__desc p:last-child { margin-bottom: 0; }
@media (max-width: 782px) {
	.mb-series-header { grid-template-columns: 1fr; gap: 32px; }
	.mb-series-header__cover { max-width: 240px; }
	.mb-series-header__cover .mb-book__cover { height: 320px; }
}

.mb-chapters__heading { font-size: var(--wp--preset--font-size--x-large); margin: 0 0 1rem; }
.mb-chapters__list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--mb-ink); }
.mb-chapters__link {
	display: flex;
	gap: 28px;
	padding: 22px 0;
	border-bottom: 1px solid var(--mb-rule);
	text-decoration: none;
	color: inherit;
}
.mb-chapters__n { flex: none; width: 48px; font-family: var(--mb-display); font-size: 2rem; font-weight: 600; line-height: 1; color: #a89c86; font-variant-numeric: tabular-nums; }
.mb-chapters__link:hover .mb-chapters__n { color: var(--mb-accent); }
.mb-chapters__body { display: flex; flex-direction: column; gap: 6px; }
.mb-chapters__title { font-family: var(--mb-display); font-size: 1.625rem; font-weight: 600; line-height: 1.15; }
.mb-chapters__link:hover .mb-chapters__title { color: var(--mb-accent); }
.mb-chapters__excerpt { font-size: 0.9375rem; line-height: 1.5; color: #3d3630; }
.mb-chapters__meta { font-size: 0.8125rem; color: var(--mb-ink-soft); }

/* ---------- Comment form fields on paper ---------- */
.mb-reading .comment-form input[type="text"],
.mb-reading .comment-form input[type="email"],
.mb-reading .comment-form input[type="url"],
.mb-reading .comment-form textarea {
	background: #fbf8f2;
	border: 1px solid var(--mb-rule);
	border-radius: 2px;
}

/* Align the chapter list under the series header text (cover 300px + 64px gap). */
.mb-chapters.alignwide { max-width: 720px; margin-left: 364px; }
@media (max-width: 1100px) { .mb-chapters.alignwide { margin-left: auto; margin-right: auto; } }
@media (max-width: 1024px) {
	.mb-toc__about { display: none; }
	.mb-toc.is-open .mb-toc__about { display: block; }
}

/* ---------- Random essays grid ---------- */
.mb-essays__grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 40px 32px;
}
.mb-essay { display: flex; flex-direction: column; gap: 14px; text-decoration: none; color: inherit; }
.mb-essay:hover { color: inherit; }
.mb-essay__media {
	display: block;
	aspect-ratio: 3 / 2;
	overflow: hidden;
	border-radius: 2px;
	background: var(--mb-paper-deep);
	box-shadow: 0 1px 0 rgba(38,33,27,0.08);
}
.mb-essay__media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s ease; filter: saturate(0.9); }
.mb-essay:hover .mb-essay__media img { transform: scale(1.03); }
.mb-essay__placeholder { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; font-family: var(--mb-display); font-size: 4rem; font-weight: 600; color: #a89c86; }
.mb-essay__body { display: flex; flex-direction: column; gap: 6px; }
.mb-essay__title { font-family: var(--mb-display); font-size: 1.5rem; font-weight: 600; line-height: 1.15; text-wrap: pretty; }
.mb-essay:hover .mb-essay__title { color: var(--mb-accent); }
.mb-essay__meta { font-size: 0.875rem; color: var(--mb-ink-soft); }
@media (max-width: 900px) { .mb-essays__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px 24px; } }
@media (max-width: 520px) { .mb-essays__grid { grid-template-columns: 1fr; } }

/* ---------- Featured image on chapter / essay pages ---------- */
.mb-reading .wp-block-post-featured-image { margin: 0 0 2rem; }
.mb-reading .wp-block-post-featured-image img { border-radius: 2px; }

/* ---------- Thumbnails in the series chapter list ---------- */
.mb-chapters__thumb { flex: none; width: 120px; aspect-ratio: 3 / 2; overflow: hidden; border-radius: 2px; background: var(--mb-paper-deep); }
.mb-chapters__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 600px) { .mb-chapters__thumb { display: none; } }

/* ---------- Thumbnails in archive rows ---------- */
.mb-post-row.has-thumb { display: grid !important; grid-template-columns: 160px minmax(0, 1fr); gap: 24px; align-items: start; }
.mb-post-row .wp-block-post-featured-image { margin: 0; }
.mb-post-row .wp-block-post-featured-image img { border-radius: 2px; }
@media (max-width: 600px) { .mb-post-row.has-thumb { grid-template-columns: 1fr; } }

/* ---------- Author profile page ---------- */
.mb-author {
	display: grid;
	grid-template-columns: 160px minmax(0, 1fr);
	gap: 48px;
	align-items: start;
}
.mb-author__avatar { line-height: 0; }
.mb-author__img { width: 160px; height: 160px; border-radius: 50%; object-fit: cover; }
.mb-author__text { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.mb-author__text > .mb-label { margin: 0; }
.mb-author__name { margin: 0; font-size: var(--wp--preset--font-size--xx-large); }
.mb-author__count { margin: 0; color: var(--mb-ink-soft); font-style: italic; }
.mb-author__bio { font-size: var(--wp--preset--font-size--reading); line-height: 1.6; color: #3d3630; }
.mb-author__bio p:last-child { margin-bottom: 0; }
.mb-author__link { margin: 0; }
.mb-author__link a { border-bottom: 1px solid var(--mb-rule); }
@media (max-width: 782px) {
	.mb-author { grid-template-columns: 1fr; gap: 24px; }
	.mb-author__img { width: 112px; height: 112px; }
}
.mb-author-works { display: flex; flex-direction: column; gap: var(--wp--preset--spacing--70); }
.mb-author-works__section { display: flex; flex-direction: column; gap: 28px; }
.mb-author-works__heading { margin: 0; font-size: var(--wp--preset--font-size--x-large); }

/* ---------- Contributors grid ---------- */
.mb-contributors__grid {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	gap: 36px 24px;
}
.mb-contributor__link { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; text-decoration: none; color: inherit; }
.mb-contributor__img { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; transition: transform .2s ease; }
.mb-contributor__link:hover .mb-contributor__img { transform: translateY(-3px); }
.mb-contributor__name { font-family: var(--mb-display); font-size: 1.25rem; font-weight: 600; line-height: 1.15; }
.mb-contributor__link:hover .mb-contributor__name { color: var(--mb-accent); }
.mb-contributor__count { font-size: 0.8125rem; color: var(--mb-ink-soft); }

/* Keep a Comments Link (or comments count) in the reading byline the same
   size/colour as the author name and date, whatever block is used. */
.mb-reading .mb-byline .wp-block-post-comments-link,
.mb-reading .mb-byline .wp-block-post-comments-link a,
.mb-reading .wp-block-post-comments-link,
.mb-reading .wp-block-post-comments-link a,
.mb-reading .mb-byline .wp-block-post-comments-count {
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	color: var(--mb-ink-soft);
}
.mb-reading .wp-block-post-comments-link a:hover { color: var(--mb-accent); }
