/*
 * Blog (redesign POC, soft editorial): the /posts/ list, category and tag pages (templates home, category and
 * tag, which share parts/posts-grid.html) and single posts (templates/single-post.html). Paper, ink, crimson.
 *
 * The list is still the owner's reading list (#163): posts grouped by year, with filter buttons for the
 * categories (inc/posts-list.php). Here the year is a large light serif numeral in the left quarter, each
 * post's text in the middle and its picture (warm, nearly monochrome until hovered) on the right, with
 * hairlines between. The filter buttons are bracketed links, "(Reflections 4)".
 *
 * A single post reads as an article: a kicker (category, date, author), a large light serif title in mixed
 * case (post titles run long), then the text set in a serif (EB Garamond) on a ~70-character measure,
 * because the posts are long reads and the brand guide gives Times as a body face too. Arabic and the
 * Qurʾān's words get a larger size and room around them; quoted verses get the brand's thin crimson rule.
 * Post bodies come from Squarespace (setup/data/posts.json); `sr-text-large`/`sr-text-small` are its
 * "large" and "small" paragraph styles.
 */
.sr-posts,
.sr-post {
	--sr-posts-line: color-mix(in srgb, var(--wp--preset--color--ink) 14%, transparent);
	--sr-posts-quiet: color-mix(in srgb, var(--wp--preset--color--ink) 62%, var(--wp--preset--color--paper));
	--sr-posts-gap: 2vw;
	--sr-arabic: "Geeza Pro", "Noto Naskh Arabic", "Amiri", "Arabic Typesetting", serif;
	color: var(--wp--preset--color--ink);
	font-family: var(--wp--preset--font-family--label);
	font-weight: 300;
}

/* The page runs straight on from the header, and the footer straight on from the page. */
.wp-site-blocks > .wp-block-template-part:has(> .sr-posts) {
	margin-block-start: 0;
}

.sr-posts :where(h1, h2, h3, h4, p),
.sr-post :where(h1, h2, h3, h4, p) {
	text-wrap: pretty;
}

.sr-posts a,
.sr-post a {
	color: inherit;
	text-decoration: none;
}

/* ---------- The list ---------- */

.sr-posts {
	padding-block-end: 8vw;
}

.sr-posts > * {
	margin-block: 0;
}

.sr-posts .sr-posts__head {
	padding-block-end: 2.4vw !important;
}

/* A category's name, the heading's italic second line, lowercase like the brand's (a tag keeps its own case). */
.sr-posts .sr-posts__page-title em:not(.sr-posts__page-tag) {
	text-transform: lowercase;
}

/* Filter buttons: bracketed links in spaced capitals, the count small after the name; the current one crimson. */
.sr-posts .sr-posts__filterbar {
	padding: 0 var(--sr-gutter) 4vw;
}

.sr-posts .sr-posts__filters {
	display: flex;
	flex-wrap: wrap;
	gap: 0.8rem 2.4rem;
	margin: 0;
	padding: 0;
	list-style: none;
	font-family: var(--wp--preset--font-family--label);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.12em;
	line-height: 1.4;
	text-transform: uppercase;
}

.sr-posts .sr-posts__filters li {
	margin: 0;
}

.sr-posts .sr-posts__filters a {
	display: inline-flex;
	align-items: baseline;
	gap: 0.12em;
	padding-block: 6px;
	color: var(--wp--preset--color--ink);
	white-space: nowrap;
}

.sr-posts .sr-posts__filters a::before,
.sr-posts .sr-posts__filters a::after {
	color: var(--wp--preset--color--accent-1);
	font-weight: 400;
}

.sr-posts .sr-posts__filters a::before {
	content: "(";
}

.sr-posts .sr-posts__filters a::after {
	content: ")";
}

.sr-posts .sr-posts__filters .sr-posts__count {
	margin-inline-start: 0.45em;
	color: var(--wp--preset--color--accent-1);
	font-size: 10px;
	font-weight: 500;
	letter-spacing: 0.06em;
	align-self: flex-start;
}

.sr-posts .sr-posts__filters a:hover,
.sr-posts .sr-posts__filters a:focus-visible,
.sr-posts .sr-posts__filters .current-cat > a {
	color: var(--wp--preset--color--accent-1);
}

.sr-posts .sr-posts__filters .current-cat > a {
	background: linear-gradient(var(--wp--preset--color--accent-1), var(--wp--preset--color--accent-1)) left bottom / 100% 1px no-repeat;
}

/*
 * Rows, on twelve columns: the year in the first three, the text in the next six, the picture in the last
 * three. A hairline above each post starts at the text; above a new year it runs the full width.
 */
.sr-posts .sr-posts__query {
	padding-inline: var(--sr-gutter);
}

.sr-posts .sr-posts__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.sr-posts .sr-posts__list > .wp-block-post {
	display: grid;
	grid-template-columns: repeat(12, minmax(0, 1fr));
	grid-template-rows: auto auto;
	column-gap: var(--sr-posts-gap);
	align-items: start;
	margin: 0;
}

.sr-posts .sr-posts__list > .wp-block-post::before {
	content: "";
	grid-column: 4 / -1;
	grid-row: 1;
	height: 1px;
	background: var(--sr-posts-line);
}

.sr-posts .sr-posts__list > .wp-block-post:has(> .sr-posts__year)::before {
	grid-column: 1 / -1;
	background: color-mix(in srgb, var(--wp--preset--color--ink) 45%, transparent);
}

.sr-posts .sr-posts__list > .wp-block-post > * {
	grid-row: 2;
	margin-block: 0;
}

.sr-posts .sr-posts__year {
	grid-column: 1 / 4;
	color: var(--wp--preset--color--ink);
	padding-block-start: 1.6rem;
	font-family: var(--wp--preset--font-family--heading);
	font-size: clamp(4rem, 7.6vw, 8.5rem);
	font-weight: 300;
	font-variant-numeric: lining-nums;
	letter-spacing: -0.02em;
	line-height: 0.8;
}

.sr-posts .sr-posts__text {
	grid-column: 4 / 10;
	padding-block: 2.2rem 2.6rem;
}

.sr-posts .sr-posts__text > * {
	margin-block: 0;
}

/* Category and date: small spaced capitals; the category crimson. */
.sr-posts .sr-posts__meta {
	gap: 0.4rem 1.6rem;
}

.sr-posts .sr-posts__meta > * {
	margin: 0;
	font-family: var(--wp--preset--font-family--label);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.16em;
	line-height: 1.5;
	text-transform: uppercase;
}

.sr-posts .sr-posts__category,
.sr-posts .sr-posts__category a {
	color: var(--wp--preset--color--accent-1);
}

.sr-posts .sr-posts__date {
	color: var(--sr-posts-quiet);
	font-weight: 500;
}

.sr-posts .sr-posts__title {
	margin-block-start: 0.9rem;
	font-family: var(--wp--preset--font-family--heading);
	font-size: clamp(1.75rem, 2.5vw, 2.6rem);
	font-weight: 400;
	letter-spacing: -0.005em;
	line-height: 1.06;
}

.sr-posts .sr-posts__title a {
	transition: color 0.3s ease;
}

.sr-posts .wp-block-post:hover .sr-posts__title a,
.sr-posts .sr-posts__title a:focus-visible {
	color: var(--wp--preset--color--accent-1);
}

.sr-posts .sr-posts__excerpt {
	margin-block-start: 1rem;
}

.sr-posts .sr-posts__excerpt p {
	display: -webkit-box;
	max-width: 36em;
	margin: 0;
	overflow: hidden;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	font-size: 16px;
	font-weight: 300;
	line-height: 1.6;
}

.sr-posts .sr-posts__author {
	display: block;
	margin-block-start: 1rem;
}

.sr-posts .sr-posts__author .wp-block-post-author__name {
	margin: 0;
	color: var(--sr-posts-quiet);
	font-size: 13px;
	font-weight: 400;
	line-height: 1.4;
}

.sr-posts .sr-posts__list > .wp-block-post > .sr-posts__image {
	grid-column: 10 / -1;
	margin-block: 2.2rem 2.6rem;
}

.sr-posts .sr-posts__image a {
	display: block;
	height: 100%;
}

.sr-posts .wp-block-post:hover .sr-posts__image img {
	filter: none;
	transform: scale(1.015);
}

.sr-posts .sr-posts__pagination {
	margin-block-start: 4vw;
	padding-block-start: 2rem;
	border-block-start: 1px solid var(--sr-posts-line);
}

.sr-posts .sr-posts__pagination a {
	color: var(--wp--preset--color--ink);
}

/* Phones: the year above its posts, the text beside a small picture, hairlines across the full width. */
@media (max-width: 781px) {
	.sr-posts .sr-posts__head {
		padding-block: 44px 20px !important;
	}

	.sr-posts .sr-posts__filterbar {
		padding-block-end: 36px;
	}

	.sr-posts .sr-posts__filters {
		gap: 0.2rem 1.4rem;
		font-size: 12px;
	}

	.sr-posts .sr-posts__list > .wp-block-post {
		grid-template-columns: minmax(0, 1fr) 96px;
		grid-template-rows: auto auto auto;
		column-gap: 16px;
	}

	.sr-posts .sr-posts__list > .wp-block-post::before,
	.sr-posts .sr-posts__list > .wp-block-post:has(> .sr-posts__year)::before {
		grid-column: 1 / -1;
	}

	.sr-posts .sr-posts__list > .wp-block-post > * {
		grid-row: 3;
	}

	.sr-posts .sr-posts__list > .wp-block-post > .sr-posts__year {
		grid-column: 1 / -1;
		grid-row: 2;
		padding-block-start: 1.4rem;
		font-size: 4.2rem;
	}

	.sr-posts .sr-posts__text {
		grid-column: 1;
		padding-block: 1.4rem 1.8rem;
	}

	.sr-posts .sr-posts__list > .wp-block-post > .sr-posts__image {
		grid-column: 2;
		margin-block: 1.4rem 1.8rem;
	}

	.sr-posts .sr-posts__title {
		margin-block-start: 0.6rem;
		font-size: 1.6rem;
		line-height: 1.1;
	}

	.sr-posts .sr-posts__excerpt p {
		-webkit-line-clamp: 3;
		line-clamp: 3;
		font-size: 15px;
	}

	.sr-posts .sr-posts__meta {
		gap: 0.2rem 1rem;
	}
}

/*
 * Rows fade in and slide 15px down into place over 1s as they come into view (as the cards did on
 * Squarespace's /posts). A year label is part of its first post's row, so it comes in with it.
 * assets/js/posts-reveal.js adds sr-reveal to <html> and is-revealed to each row, so without JavaScript the
 * rows are simply visible.
 */
@media (prefers-reduced-motion: no-preference) {
	.sr-reveal .sr-posts .sr-posts__list > .wp-block-post {
		opacity: 0;
		transform: translateY(-15px);
		transition: opacity 1s, transform 1s;
	}

	.sr-reveal .sr-posts .sr-posts__list > .wp-block-post.is-revealed {
		opacity: 1;
		transform: none;
	}
}

/* ---------- A single post ---------- */

.sr-post {
	--sr-post-text: clamp(19px, 18px + 0.25vw, 21px);
	padding-block-end: 2vw;
}

.sr-post .sr-post__article {
	display: grid;
	grid-template-columns: repeat(12, minmax(0, 1fr));
	column-gap: var(--sr-posts-gap);
	padding-inline: var(--sr-gutter);
}

.sr-post .sr-post__article > * {
	grid-column: 4 / -1;
	margin-block: 0;
}

/* Kicker and title. */
.sr-post .sr-post__head {
	grid-column: 1 / -1;
	padding-block: 4.5vw 4vw;
}

.sr-post .sr-post__head > * {
	margin-block: 0;
}

.sr-post .sr-post__meta {
	gap: 0.4rem 2rem;
}

.sr-post .sr-post__meta > * {
	margin: 0;
	font-family: var(--wp--preset--font-family--label);
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.16em;
	line-height: 1.5;
	text-transform: uppercase;
}

.sr-post .sr-post__category a {
	color: var(--wp--preset--color--accent-1);
}

.sr-post .sr-post__category a:hover,
.sr-post .sr-post__category a:focus-visible {
	text-decoration: underline;
	text-underline-offset: 0.3em;
}

.sr-post .sr-post__date {
	color: var(--wp--preset--color--ink);
}

/* "Written by Sacred Roots" on one line. */
.sr-post .sr-post__byline .wp-block-post-author__content,
.sr-post .sr-post__byline :is(.wp-block-post-author__byline, .wp-block-post-author__name) {
	display: inline;
	margin: 0;
	font-size: inherit;
}

.sr-post .sr-post__byline .wp-block-post-author__byline {
	color: var(--sr-posts-quiet);
}

.sr-post .sr-post__byline .wp-block-post-author__byline::after {
	content: " ";
}

/* Post titles run long, so mixed case in light serif rather than the display capitals. */
.sr-post .sr-post__title {
	max-width: 16em;
	margin-block-start: 1.8rem;
	font-family: var(--wp--preset--font-family--heading);
	font-size: clamp(2.6rem, 6.6vw, 7.5rem);
	font-weight: 300;
	letter-spacing: -0.015em;
	line-height: 1;
	text-wrap: balance;
}

/* The featured image, when the text doesn't already show it (inc/posts-list.php). */
.sr-post .sr-post__image {
	grid-column: 4 / 11;
	margin-block-end: 4vw;
}

.sr-post .sr-post__image img {
	max-height: 78vh;
}

/* The text: a serif for long reading, on a comfortable measure. */
.sr-post .sr-post__content {
	max-width: 33em;
	font-family: var(--wp--preset--font-family--text-serif);
	font-size: var(--sr-post-text);
	font-weight: 400;
	line-height: 1.62;
}

.sr-post .sr-post__content > * {
	margin-block: 0 1.05em;
}

.sr-post .sr-post__content > :first-child {
	margin-block-start: 0;
}

.sr-post .sr-post__content :is(p, h2, h3, h4) {
	white-space: pre-wrap; /* As on Squarespace: double spaces and tabs in the text show. */
}

.sr-post .sr-post__content p {
	font-size: 1em;
}

.sr-post .sr-post__content p.sr-text-large {
	font-size: 1.05em;
}

.sr-post .sr-post__content p.sr-text-small {
	font-size: 0.85em;
}

.sr-post .sr-post__content em {
	font-style: italic;
}

.sr-post .sr-post__content strong {
	font-weight: 600;
}

/* Headings in the text: light serif, mixed case. Squarespace posts use them for quoted verses, centred. */
.sr-post .sr-post__content :is(h2, h3, h4) {
	margin-block: 2.2em 1em;
	font-family: var(--wp--preset--font-family--heading);
	font-weight: 400;
	letter-spacing: 0;
	text-transform: none;
}

.sr-post .sr-post__content h2 {
	font-size: 1.8em;
	line-height: 1.2;
}

.sr-post .sr-post__content h3 {
	font-size: 1.5em;
	line-height: 1.25;
}

.sr-post .sr-post__content h4 {
	font-size: 1.25em;
	line-height: 1.35;
}

.sr-post .sr-post__content > :is(h2, h3, h4) + :is(h2, h3, h4) {
	margin-block-start: 0.4em;
}

.sr-post .sr-post__content > :is(h2, h3, h4):first-child {
	margin-block-start: 0;
}

.sr-post .sr-post__content :is(h2, h3, h4) em {
	color: var(--wp--preset--color--accent-1);
	font-size: 0.8em;
}

/*
 * Arabic, and the Qurʾān in it: a naskh face, larger, with tall lines so the vowel marks have room, and
 * space around each passage.
 */
.sr-post .sr-post__content [lang="ar"] {
	font-family: var(--sr-arabic);
	font-size: 1.35em;
	font-style: normal;
	font-weight: 400;
	line-height: 2;
	letter-spacing: 0;
}

.sr-post .sr-post__content :is(h2, h3, h4) [lang="ar"] {
	font-size: 0.95em;
	line-height: 2.1;
}

.sr-post .sr-post__content > p:has(> [lang="ar"]) {
	margin-block: 1.6em;
	line-height: 2;
}

/* Quoted verses and sayings: the brand's thin crimson rule on the left; verse numbers in crimson. */
.sr-post .sr-post__content .wp-block-quote {
	margin: 2em 0;
	padding: 0.2em 0 0.2em 1.4em;
	border: 0;
	border-inline-start: var(--sr-rule);
	font-size: 1em;
	font-style: normal;
}

.sr-post .sr-post__content .wp-block-quote > * {
	margin-block: 0 0.8em;
}

.sr-post .sr-post__content .wp-block-quote > :last-child {
	margin-block-end: 0;
}

.sr-post .sr-post__content .wp-block-quote strong {
	color: var(--wp--preset--color--accent-1);
	font-family: var(--wp--preset--font-family--label);
	font-size: 0.72em;
	font-weight: 600;
	letter-spacing: 0.06em;
}

.sr-post .sr-post__content :is(ul, ol) {
	margin-block: 0 1.05em;
	padding-inline-start: 1.3em;
}

.sr-post .sr-post__content li {
	margin-block: 0.4em;
	padding-inline-start: 0.2em;
}

.sr-post .sr-post__content li::marker {
	color: var(--wp--preset--color--accent-1);
}

/* A short crimson rule between parts of the text. */
.sr-post .sr-post__content .wp-block-separator {
	width: 3rem;
	margin: 2.6em 0;
	border: 0;
	border-top: var(--sr-rule);
	opacity: 1;
}

.sr-post .sr-post__content .wp-block-image {
	margin-block: 2em;
}

.sr-post .sr-post__content > .wp-block-image:first-child {
	margin-block-start: 0;
}

.sr-post .sr-post__content .wp-block-image img {
	display: block;
	width: 100%;
	height: auto;
}

.sr-post .sr-post__content a {
	color: var(--wp--preset--color--accent-1);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.18em;
}

/* Tags: bracketed links under the text, after a hairline. */
.sr-post .sr-post__tags {
	margin-block-start: 3.4rem;
	padding-block-start: 1.6rem;
	border-block-start: 1px solid var(--sr-posts-line);
}

.sr-post .sr-post__tags .wp-block-post-terms__separator {
	display: none;
}

.sr-post .sr-post__tags a {
	color: var(--wp--preset--color--ink);
}

/* "(Previous)" and "(Next)": bracketed labels over the other posts' titles, older on the left. */
.sr-post .sr-post__nav {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 2rem var(--sr-posts-gap);
	margin-block-start: 6vw;
	padding: 2.6rem var(--sr-gutter) 3vw;
	border-block-start: 1px solid var(--sr-posts-line);
}

.sr-post .sr-post__nav > * {
	margin: 0;
}

.sr-post .sr-post__newer {
	grid-column: 2;
	text-align: right;
}

.sr-post .sr-post__nav a {
	display: inline-flex;
	flex-direction: column;
	gap: 1rem;
}

.sr-post .sr-post__newer a {
	align-items: flex-end;
}

.sr-post .sr-post__nav .post-navigation-link__label {
	font-family: var(--wp--preset--font-family--label);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.12em;
	line-height: 1.4;
	text-transform: uppercase;
}

.sr-post .sr-post__nav .post-navigation-link__label::before,
.sr-post .sr-post__nav .post-navigation-link__label::after {
	color: var(--wp--preset--color--accent-1);
	font-weight: 400;
}

.sr-post .sr-post__nav .post-navigation-link__label::before {
	content: "(";
	margin-right: 0.12em;
}

.sr-post .sr-post__nav .post-navigation-link__label::after {
	content: ")";
	margin-left: 0.12em;
}

.sr-post .sr-post__nav .post-navigation-link__title {
	max-width: 18em;
	font-family: var(--wp--preset--font-family--heading);
	font-size: clamp(1.4rem, 2.2vw, 2.2rem);
	font-weight: 400;
	line-height: 1.1;
	text-wrap: balance;
	transition: color 0.3s ease;
}

.sr-post .sr-post__nav a:hover :is(.post-navigation-link__label, .post-navigation-link__title),
.sr-post .sr-post__nav a:focus-visible :is(.post-navigation-link__label, .post-navigation-link__title) {
	color: var(--wp--preset--color--accent-1);
}

@media (max-width: 781px) {
	.sr-post .sr-post__article {
		grid-template-columns: minmax(0, 1fr);
	}

	.sr-post .sr-post__article > *,
	.sr-post .sr-post__image {
		grid-column: 1;
	}

	.sr-post .sr-post__head {
		padding-block: 44px 32px;
	}

	.sr-post .sr-post__meta {
		gap: 0.2rem 1.2rem;
	}

	.sr-post .sr-post__meta > * {
		font-size: 11px;
	}

	.sr-post .sr-post__title {
		margin-block-start: 1.2rem;
		font-size: 2.6rem;
		line-height: 1.04;
	}

	.sr-post .sr-post__image {
		margin-block-end: 32px;
	}

	.sr-post .sr-post__content h2 {
		font-size: 1.55em;
	}

	.sr-post .sr-post__content h3 {
		font-size: 1.35em;
	}

	.sr-post .sr-post__content [lang="ar"] {
		font-size: 1.25em;
	}

	.sr-post .sr-post__nav {
		gap: 1.6rem 16px;
		padding-block: 2rem 32px;
	}

	.sr-post .sr-post__nav .post-navigation-link__label {
		font-size: 12px;
	}

	.sr-post .sr-post__nav .post-navigation-link__title {
		font-size: 1.3rem;
		overflow-wrap: anywhere;
	}
}
