/*
 * Educational Resources (/educational-resources/, #176, #187), redesign POC (soft editorial). The shared page
 * head, then the Educational Resources block (plugins/sacred-roots-site/blocks/resources): a bar of filter
 * buttons that stays at the top while scrolling, then each part (Books and Articles, Websites, Videos and
 * Podcasts) under a display heading, its topics in the left quarter behind a thin crimson rule, the resources
 * on the right with hairlines between. Filter buttons are bracketed links, like the blog's: the kinds in
 * spaced capitals, the topics in lowercase like the brand's captions, "(philosophy)". Phones stack.
 */
.sr-edu {
	--sr-edu-line: color-mix(in srgb, var(--wp--preset--color--ink) 14%, transparent);
	--sr-edu-quiet: color-mix(in srgb, var(--wp--preset--color--ink) 62%, var(--wp--preset--color--paper));
	--sr-edu-gap: 2vw;
	padding-block-end: 8vw;
	color: var(--wp--preset--color--ink);
	font-family: var(--wp--preset--font-family--label);
	font-weight: 300;
}

.wp-site-blocks > main:has(.sr-edu) {
	margin-block-start: 0;
}

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

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

.sr-edu a {
	color: inherit;
	text-decoration: none;
}

.sr-edu .sr-edu__head {
	padding-block-end: 2.4vw !important;
}

.sr-edu .sr-edu-resources {
	padding-inline: var(--sr-gutter);
}

/*
 * The filter bar: it stays at the top of the screen while the lists scroll under it (below the WordPress
 * admin bar when signed in); its paper (with the page's grain) reaches the window's sides. Each row is one line that scrolls sideways
 * when it doesn't fit (Books and Articles' ten topics), so the bar stays under 110px tall. The block's view.js
 * fades the side with more buttons and, for a mouse, adds an arrow there. Each row has 4px of room around its
 * buttons, so a keyboard focus ring isn't cut off.
 */
.sr-edu .sr-edu-filters {
	position: sticky;
	top: var(--wp-admin--admin-bar--height, 0px);
	z-index: 20;
	display: flex;
	flex-direction: column;
	gap: 0;
	margin-inline: calc(-1 * var(--sr-gutter));
	padding: 8px var(--sr-gutter) 10px;
	background-color: var(--wp--preset--color--paper);
	/* The line under the bar keeps to the page's gutters. */
	background-image: var(--sr-grain), linear-gradient(color-mix(in srgb, var(--wp--preset--color--ink) 45%, transparent), color-mix(in srgb, var(--wp--preset--color--ink) 45%, transparent));
	background-position: 0 0, var(--sr-gutter) 100%;
	background-size: auto, calc(100% - 2 * var(--sr-gutter)) 1px;
	background-repeat: repeat, no-repeat;
}

.sr-edu .sr-edu-filters__row {
	position: relative;
}

.sr-edu .sr-edu-filters ul {
	position: relative; /* The buttons' offsetLeft, for the script that scrolls the current one into view. */
	display: flex;
	flex-wrap: nowrap;
	align-items: baseline;
	gap: 2.2rem;
	margin: 0 -4px;
	padding: 4px;
	overflow-x: auto;
	list-style: none;
	scrollbar-width: none;
	overscroll-behavior-x: contain;
}

.sr-edu .sr-edu-filters ul::-webkit-scrollbar {
	display: none;
}

.sr-edu .sr-edu-filters li {
	flex: none;
	margin: 0;
}

.sr-edu .sr-edu-filters a {
	display: flex;
	align-items: baseline;
	padding-block: 6px;
	color: var(--wp--preset--color--ink);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.12em;
	line-height: 1.4;
	text-transform: uppercase;
	white-space: nowrap;
}

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

.sr-edu .sr-edu-filters a::before {
	content: "(";
	margin-right: 0.12em;
}

.sr-edu .sr-edu-filters a::after {
	content: ")";
	margin-left: 0.12em;
}

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

.sr-edu .sr-edu-filters a:hover,
.sr-edu .sr-edu-filters .is-current > a {
	color: var(--wp--preset--color--accent-1);
}

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

.sr-edu .sr-edu-filters a:focus-visible {
	outline: 2px solid var(--wp--preset--color--ink);
	outline-offset: 2px;
}

/* Topics: lowercase, like the brand's captions. */
.sr-edu .sr-edu-filters__topics {
	gap: 1.8rem;
}

.sr-edu .sr-edu-filters__topics a {
	padding-block: 4px;
	font-size: 14px;
	font-weight: 400;
	letter-spacing: 0.01em;
	text-transform: lowercase;
}

/* More buttons on one side or both: that side fades out. */
.sr-edu .sr-edu-filters__row.has-more-next ul {
	mask-image: linear-gradient(to right, #000 calc(100% - 64px), transparent);
}

.sr-edu .sr-edu-filters__row.has-more-back ul {
	mask-image: linear-gradient(to left, #000 calc(100% - 64px), transparent);
}

.sr-edu .sr-edu-filters__row.has-more-back.has-more-next ul {
	mask-image: linear-gradient(to right, transparent, #000 64px, #000 calc(100% - 64px), transparent);
}

/* The arrows: only with a mouse (fine pointer), on a side with more buttons. */
.sr-edu .sr-edu-filters__arrow {
	position: absolute;
	top: 50%;
	z-index: 1;
	display: none;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: 30px;
	height: 30px;
	margin: 0;
	padding: 0 0 3px;
	border: 1px solid color-mix(in srgb, var(--wp--preset--color--accent-1) 50%, transparent);
	border-radius: 50%;
	background: var(--wp--preset--color--paper);
	color: var(--wp--preset--color--accent-1);
	font-family: var(--wp--preset--font-family--heading);
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	transform: translateY(-50%);
}

.sr-edu .sr-edu-filters__arrow:hover {
	border-color: var(--wp--preset--color--accent-1);
}

.sr-edu .sr-edu-filters__arrow--back {
	left: -4px;
}

.sr-edu .sr-edu-filters__arrow--next {
	right: -4px;
}

@media (hover: hover) and (pointer: fine) {
	.sr-edu .sr-edu-filters__row.has-more-back > .sr-edu-filters__arrow--back,
	.sr-edu .sr-edu-filters__row.has-more-next > .sr-edu-filters__arrow--next {
		display: flex;
	}
}

/* A part of the page: a display heading, then its topics. Links to a part or topic land below the bar. */
.sr-edu .sr-edu__section {
	margin-block-start: 6vw;
}

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

/* Its real height comes from view.js; 110px without script. */
.sr-edu [id] {
	scroll-margin-block-start: calc(var(--sr-edu-bar, 110px) + 24px);
}

.sr-edu .sr-edu__kind {
	font-family: var(--wp--preset--font-family--heading);
	font-size: clamp(2.4rem, 4.6vw, 4.8rem);
	font-weight: 300;
	letter-spacing: 0;
	line-height: 0.95;
	text-transform: uppercase;
}

/* Links to each topic, under the part's heading (when every topic shows): lowercase, bracketed. */
.sr-edu .sr-resources__topics ul {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 2rem;
	margin: 1.6rem 0 0;
	padding: 0;
	list-style: none;
	font-size: 14px;
	font-weight: 400;
	line-height: 1.5;
	text-transform: lowercase;
}

.sr-edu .sr-resources__topics li {
	margin: 0;
}

.sr-edu .sr-resources__topics a::before,
.sr-edu .sr-resources__topics a::after {
	color: var(--wp--preset--color--accent-1);
}

.sr-edu .sr-resources__topics a::before {
	content: "(";
	margin-right: 0.1em;
}

.sr-edu .sr-resources__topics a::after {
	content: ")";
	margin-left: 0.1em;
}

.sr-edu .sr-resources__topics a:hover,
.sr-edu .sr-resources__topics a:focus-visible {
	color: var(--wp--preset--color--accent-1);
}

/*
 * A topic, on twelve columns: its name in the first three behind a thin crimson rule (it stays in view while
 * its resources scroll past), its resources in the rest.
 */
.sr-edu .sr-resources {
	margin-block-start: 2.4rem;
}

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

.sr-edu .sr-resources__group {
	display: grid;
	grid-template-columns: repeat(12, minmax(0, 1fr));
	column-gap: var(--sr-edu-gap);
	align-items: start;
	margin-block-start: 2.4rem;
	border-block-start: 1px solid color-mix(in srgb, var(--wp--preset--color--ink) 45%, transparent);
}

.sr-edu .sr-resources__topic {
	position: sticky;
	top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--sr-edu-bar, 110px) + 1.6rem);
	grid-column: 1 / 4;
	margin: 1.8rem 0 0;
	padding-inline-start: 1.1rem;
	border-inline-start: var(--sr-rule);
	font-family: var(--wp--preset--font-family--heading);
	font-size: clamp(1.4rem, 1.8vw, 1.9rem);
	font-weight: 400;
	line-height: 1.12;
}

.sr-edu .sr-resources__list {
	grid-column: 4 / -1;
	margin: 0;
	padding: 0;
	list-style: none;
}

.sr-edu .sr-resources__topic + .sr-resources__list {
	grid-column: 4 / -1;
}

.sr-edu .sr-resources__item {
	margin: 0;
	padding-block: 1.8rem 2rem;
}

.sr-edu .sr-resources__item + .sr-resources__item {
	border-block-start: 1px solid var(--sr-edu-line);
}

.sr-edu .sr-resources__item > * {
	max-width: 44rem;
	margin-block: 0;
}

.sr-edu .sr-resources__title {
	font-family: var(--wp--preset--font-family--heading);
	font-size: clamp(1.45rem, 1.9vw, 2rem);
	font-weight: 400;
	line-height: 1.12;
	overflow-wrap: anywhere;
}

.sr-edu .sr-resources__title a {
	transition: color 0.3s ease;
}

.sr-edu .sr-resources__title a:hover,
.sr-edu .sr-resources__title a:focus-visible {
	color: var(--wp--preset--color--accent-1);
}

/* Who and where: Inter, the author in ink, the site quieter. */
.sr-edu .sr-resources__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 0.2rem 1.4rem;
	margin-block-start: 0.7rem;
	font-size: 13px;
	font-weight: 400;
	line-height: 1.45;
}

.sr-edu .sr-resources__site {
	color: var(--sr-edu-quiet);
	letter-spacing: 0.02em;
}

.sr-edu .sr-resources__description {
	margin-block-start: 0.9rem;
	font-size: 16px;
	font-weight: 300;
	line-height: 1.6;
}

.sr-edu .sr-resources__description p {
	margin: 0;
}

.sr-edu .sr-resources__description p + p {
	margin-block-start: 0.7em;
}

.sr-edu .sr-resources__empty {
	margin-block-start: 2rem;
	color: var(--sr-edu-quiet);
}

@media (max-width: 781px) {
	.sr-edu .sr-edu__head {
		padding-block: 44px 24px !important;
	}

	/* A compact bar: its rows run from one side of the screen to the other. */
	.sr-edu .sr-edu-filters {
		padding: 6px 0 8px;
		background-position: 0 0, 0 100%;
		background-size: auto, 100% 1px;
	}

	.sr-edu .sr-edu-filters ul {
		gap: 1.4rem;
		margin-inline: 0;
		padding-inline: var(--sr-gutter);
	}

	/* A narrow window with a mouse: the arrows stay inside the screen (the rows reach its edges here). */
	.sr-edu .sr-edu-filters__arrow--back {
		left: 4px;
	}

	.sr-edu .sr-edu-filters__arrow--next {
		right: 4px;
	}

	/* Shorter fades. */
	.sr-edu .sr-edu-filters__row.has-more-next ul {
		mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent);
	}

	.sr-edu .sr-edu-filters__row.has-more-back ul {
		mask-image: linear-gradient(to left, #000 calc(100% - 40px), transparent);
	}

	.sr-edu .sr-edu-filters__row.has-more-back.has-more-next ul {
		mask-image: linear-gradient(to right, transparent, #000 40px, #000 calc(100% - 40px), transparent);
	}

	.sr-edu .sr-edu-filters a {
		font-size: 12px;
	}

	.sr-edu .sr-edu-filters__topics a {
		font-size: 13px;
	}

	.sr-edu .sr-edu__section {
		margin-block-start: 56px;
	}

	/* One topic link per line. */
	.sr-edu .sr-resources__topics ul {
		flex-direction: column;
	}

	.sr-edu .sr-resources__group {
		grid-template-columns: minmax(0, 1fr);
	}

	.sr-edu .sr-resources__topic,
	.sr-edu .sr-resources__list,
	.sr-edu .sr-resources__topic + .sr-resources__list {
		grid-column: 1;
	}

	.sr-edu .sr-resources__topic {
		position: static;
		margin-block-start: 1.6rem;
		font-size: 1.6rem;
	}

	.sr-edu .sr-resources__topic + .sr-resources__list > .sr-resources__item:first-child {
		padding-block-start: 1.2rem;
	}

	.sr-edu .sr-resources__item {
		padding-block: 1.5rem 1.7rem;
	}

	.sr-edu .sr-resources__title {
		font-size: 1.5rem;
	}

	.sr-edu .sr-resources__description {
		font-size: 15px;
	}
}

/* On small phones the WordPress admin bar scrolls away with the page, so the filter bar goes to the very top. */
@media (max-width: 600px) {
	.admin-bar .sr-edu .sr-edu-filters {
		top: 0;
	}

	.admin-bar .sr-edu .sr-resources__topic {
		top: auto;
	}
}
