/*
 * Library grid (gsc/library). The filter sits in a sticky side column from 1025px (like the
 * contents list on posts) and above the grid on smaller screens, where the types become chips.
 */
.gsc-library {
	--gsc-lib-navy: var(--wp--preset--color--navy, #0a3a7b);
	--gsc-lib-teal: var(--wp--preset--color--teal, #12b6b8);
	--gsc-lib-pale: var(--wp--preset--color--pale-blue, #f0f5fa);
	--gsc-lib-gold: var(--wp--preset--color--gold, #deab02);
	--gsc-lib-ink: var(--wp--preset--color--near-black, #111);
	--gsc-lib-line: rgba(10, 58, 123, 0.15);

	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 2.5rem;
	font-size: 1rem;
}

.gsc-library > * {
	margin-block: 0;
}

@media (min-width: 1025px) {
	.gsc-library {
		grid-template-columns: 280px minmax(0, 1fr);
		column-gap: clamp(2rem, 4vw, 3.5rem);
		align-items: start;
	}

	.gsc-library__filter {
		position: sticky;
		top: calc(var(--wp-admin--admin-bar--height, 0px) + 2rem);
	}
}

/* ---------- Filter ---------- */

.gsc-library__form {
	display: grid;
	gap: 1.25rem;
	margin: 0;
	padding: calc(12px + 1.25rem) 1.25rem 1.25rem;
	background: var(--gsc-lib-pale);
	clip-path: polygon(0 12px, 100% 0, 100% 100%, 0 100%);
}

.gsc-library .gsc-library__filter-title {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin: 0;
	color: var(--gsc-lib-navy);
	font-size: 0.875rem;
	font-weight: 700;
	letter-spacing: 0.12em;
	line-height: 1.4;
	text-transform: uppercase;
}

/* A short gold bar, like the contents list's. */
.gsc-library__filter-title::before {
	content: "";
	flex: 0 0 1.75rem;
	height: 6px;
	background: var(--gsc-lib-gold);
	clip-path: polygon(0 30%, 100% 0, 100% 70%, 0 100%);
}

.gsc-library__label {
	display: block;
	margin: 0 0 0.5rem;
	padding: 0;
	color: var(--gsc-lib-navy);
	font-size: 0.8rem;
	font-weight: 700;
}

.gsc-library__search-field {
	position: relative;
}

.gsc-library__search-icon {
	position: absolute;
	top: 50%;
	left: 0.8rem;
	width: 0.8rem;
	height: 0.8rem;
	fill: var(--gsc-lib-navy);
	transform: translateY(-50%);
	pointer-events: none;
}

.gsc-library .gsc-library__search input {
	width: 100%;
	margin: 0;
	padding: 0.6rem 0.75rem 0.6rem 2.2rem;
	border: 1px solid var(--gsc-lib-line);
	border-radius: 0;
	background: #fff;
	color: var(--gsc-lib-ink);
	font: inherit;
	font-size: 0.85rem;
	line-height: 1.4;
}

.gsc-library .gsc-library__search input:focus-visible {
	outline: 2px solid var(--gsc-lib-navy);
	outline-offset: 0;
	border-color: var(--gsc-lib-navy);
}

.gsc-library__types {
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.gsc-library__type-list {
	display: grid;
	gap: 2px;
}

.gsc-library__type {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	margin: 0;
	padding: 0.45rem 0.6rem;
	color: var(--gsc-lib-navy);
	font-size: 0.85rem;
	line-height: 1.3;
	cursor: pointer;
	transition: background-color 0.15s ease;
}

.gsc-library__type:hover,
.gsc-library__type:has(input:checked) {
	background: #fff;
}

.gsc-library__type:has(input:checked) .gsc-library__type-name {
	font-weight: 700;
}

.gsc-library__type input {
	flex: none;
	width: 1.05rem;
	height: 1.05rem;
	margin: 0;
	accent-color: var(--gsc-lib-teal);
	cursor: pointer;
}

.gsc-library__type input:focus-visible {
	outline: 2px solid var(--gsc-lib-navy);
	outline-offset: 2px;
}

.gsc-library__type-icon {
	flex: none;
	width: 1rem;
	height: 1rem;
	fill: var(--gsc-lib-teal);
}

.gsc-library__type-name {
	flex: 1;
}

.gsc-library__type-count {
	min-width: 1.6rem;
	padding: 0.1rem 0.4rem;
	background: rgba(10, 58, 123, 0.08);
	font-size: 0.7rem;
	font-weight: 700;
	text-align: center;
}

/* Phones and tablets: the types wrap as chips, so the filter stays short above the grid. */
@media (max-width: 1024px) {
	.gsc-library__type-list {
		display: flex;
		flex-wrap: wrap;
		gap: 0.5rem;
	}

	.gsc-library__type {
		max-width: 100%;
		padding: 0.4rem 0.7rem;
		background: #fff;
		border: 1px solid var(--gsc-lib-line);
	}

	.gsc-library__type:has(input:checked) {
		border-color: var(--gsc-lib-teal);
	}

	.gsc-library__type-name {
		flex: 0 1 auto;
		min-width: 0;
		overflow-wrap: anywhere;
	}
}

/* Phones: smaller chips, each as wide as its name, without the icons and counts, so two fit on a
   row and the filter stays short. (Equal columns were too narrow for "Document" with its icon.) */
@media (max-width: 599px) {
	.gsc-library__type-list {
		gap: 0.4rem;
	}

	.gsc-library__type {
		gap: 0.45rem;
		padding: 0.45rem 0.6rem;
		font-size: 0.8rem;
	}

	.gsc-library__type-icon,
	.gsc-library__type-count {
		display: none;
	}
}

.gsc-library__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.75rem 1.25rem;
}

.gsc-library__actions:not(:has(> :not([hidden]))) {
	display: none;
}

.gsc-library .gsc-library__apply {
	padding: 0.6rem 1.1rem;
	border: 0;
	border-radius: 0;
	background: var(--gsc-lib-navy);
	color: #fff;
	font: inherit;
	font-size: 0.85rem;
	font-weight: 600;
	cursor: pointer;
}

/* With JavaScript the results update as the filters change, so there's nothing to press. */
.gsc-library.is-enhanced .gsc-library__apply {
	display: none;
}

.gsc-library .gsc-library__clear,
.gsc-library .gsc-library__clear-link {
	color: var(--gsc-lib-navy);
	font-size: 0.85rem;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.gsc-library .gsc-library__clear[hidden] {
	display: none;
}

/* ---------- Results ---------- */

.gsc-library__main {
	min-width: 0;
}

.gsc-library__results {
	transition: opacity 0.2s ease;
}

.gsc-library.is-loading .gsc-library__results {
	opacity: 0.45;
}

.gsc-library .gsc-library__count {
	margin: 0 0 1rem;
	color: var(--gsc-lib-ink);
	font-size: 0.8rem;
	font-weight: 600;
	letter-spacing: 0.02em;
}

.gsc-library__count:focus {
	outline: none;
}

.gsc-library .gsc-library__grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 24px;
	margin: 0;
	padding: 0;
	list-style: none;
}

@media (min-width: 600px) {
	.gsc-library .gsc-library__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (min-width: 1025px) {
	.gsc-library .gsc-library__grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

.gsc-library .gsc-library__item {
	margin: 0;
	padding: 0;
}

.gsc-library .gsc-library__item::before {
	content: none;
}

.gsc-library__empty {
	padding: 1.5rem;
	background: var(--gsc-lib-pale);
}

.gsc-library__empty p {
	margin: 0;
}

/* ---------- Card ---------- */

.gsc-library-card {
	position: relative;
	display: flex;
	flex-direction: column;
	height: 100%;
	background: #fff;
	border: 1px solid var(--gsc-lib-line);
	transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.gsc-library-card:hover,
.gsc-library-card:focus-within {
	border-color: var(--gsc-lib-teal);
	box-shadow: -8px 8px 0 0 var(--gsc-lib-teal);
}

.gsc-library-card:has(.gsc-library-card__link:focus-visible) {
	outline: 3px solid var(--gsc-lib-navy);
	outline-offset: 3px;
}

.gsc-library-card__media {
	position: relative;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	background: var(--gsc-lib-pale);
}

.gsc-library .gsc-library-card__image {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	object-fit: cover;
	transition: transform 0.4s ease;
}

/* Logos and small or square pictures: shown whole on the pale panel, below the type label, and
   never stretched past their own size. */
.gsc-library-card__media.is-whole {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 2.6rem 1.25rem 0.9rem;
}

.gsc-library .gsc-library-card__media.is-whole .gsc-library-card__image {
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
}

/* A document's page or a book's cover: standing upright on the pale panel, below the type label, with its
   bottom half out of sight. */
.gsc-library-card__media.is-page {
	display: flex;
	justify-content: center;
	padding-top: 2.6rem;
}

.gsc-library .gsc-library-card__media.is-page .gsc-library-card__image {
	width: 58%;
	height: auto;
	align-self: flex-start;
	object-fit: initial;
	box-shadow: 0 4px 14px rgb(0 0 0 / 0.16);
}

@media not (prefers-reduced-motion) {
	.gsc-library-card:is(:hover, :focus-within) .gsc-library-card__media:not(.is-whole, .is-page) .gsc-library-card__image {
		transform: scale(1.06);
	}

	.gsc-library-card:is(:hover, :focus-within) .gsc-library-card__media.is-page .gsc-library-card__image {
		transform: translateY(-0.4rem);
	}
}

/* No image: the jigsaw piece and the type's icon on navy. */
.gsc-library-card__placeholder {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--gsc-lib-navy);
}

.gsc-library-card__placeholder::before {
	content: "";
	position: absolute;
	right: -12%;
	bottom: -38%;
	width: 75%;
	aspect-ratio: 1;
	background: var(--gsc-lib-teal);
	opacity: 0.9;
	-webkit-mask: url("../../assets/piece.svg") center / contain no-repeat;
	mask: url("../../assets/piece.svg") center / contain no-repeat;
	transform: rotate(-18deg);
}

.gsc-library-card__placeholder::after {
	content: "";
	position: absolute;
	top: -30%;
	left: -14%;
	width: 42%;
	aspect-ratio: 1;
	background: #fff;
	opacity: 0.08;
	-webkit-mask: url("../../assets/piece.svg") center / contain no-repeat;
	mask: url("../../assets/piece.svg") center / contain no-repeat;
	transform: rotate(24deg);
}

.gsc-library-card__placeholder-icon {
	position: relative;
	z-index: 1;
	width: 3rem;
	height: 3rem;
	fill: #fff;
}

/* Type label on the picture. */
.gsc-library-card__type {
	position: absolute;
	top: 10px;
	left: 10px;
	z-index: 1;
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	padding: 5px 10px 5px 8px;
	background: #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
	color: var(--gsc-lib-navy);
	font-size: 0.65rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	line-height: 1.2;
	text-transform: uppercase;
}

.gsc-library-card__type-icon {
	width: 0.8rem;
	height: 0.8rem;
	fill: var(--gsc-lib-teal);
}

.gsc-library-card__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 0.4rem;
	padding: 1rem 1.15rem 1.15rem;
}

.gsc-library .gsc-library-card__title {
	margin: 0;
	color: var(--gsc-lib-navy);
	font-size: 1.05rem;
	font-weight: 700;
	line-height: 1.25;
}

.gsc-library .gsc-library-card__link {
	color: inherit;
	text-decoration: none;
}

/* The whole card is the link. */
.gsc-library-card__link::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 2;
}

.gsc-library-card__link:focus-visible {
	outline: none;
}

.gsc-library .gsc-library-card__meta {
	margin: 0;
	color: var(--gsc-lib-ink);
	font-size: 0.8rem;
}

.gsc-library-card__button {
	position: relative;
	z-index: 1;
	display: inline-flex;
	align-items: center;
	align-self: flex-start;
	gap: 0.45rem;
	margin-top: auto;
	padding: 8px 14px;
	color: var(--gsc-lib-ink);
	font-size: 0.8rem;
	font-weight: 600;
	line-height: 1.2;
	translate: 0 0.35rem;
}

.gsc-library-card__button::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background: var(--gsc-lib-gold);
	clip-path: polygon(0 10%, 100% 0, 100% 90%, 0 100%);
	transition: clip-path 0.25s ease;
}

.gsc-library-card:is(:hover, :focus-within) .gsc-library-card__button::before {
	clip-path: polygon(0 0, 100% 10%, 100% 100%, 0 90%);
}

.gsc-library-card__button svg {
	width: 0.75rem;
	height: 0.75rem;
	fill: currentColor;
}

/* ---------- Page links ---------- */

.gsc-library__pagination {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	margin-top: 2.5rem;
}

.gsc-library .gsc-library__page {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.4rem;
	min-width: 44px;
	height: 44px;
	padding: 0 0.75rem;
	border: 1px solid var(--gsc-lib-line);
	color: var(--gsc-lib-navy);
	font-size: 0.85rem;
	font-weight: 600;
	text-decoration: none;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.gsc-library a.gsc-library__page:hover,
.gsc-library a.gsc-library__page:focus-visible {
	background: var(--gsc-lib-pale);
}

.gsc-library a.gsc-library__page:focus-visible {
	outline: 2px solid var(--gsc-lib-navy);
	outline-offset: 2px;
}

.gsc-library .gsc-library__page.is-current {
	border-color: var(--gsc-lib-navy);
	background: var(--gsc-lib-navy);
	color: #fff;
}

.gsc-library .gsc-library__page.is-gap {
	min-width: 0;
	padding: 0 0.25rem;
	border: 0;
}

.gsc-library__page svg {
	width: 0.6rem;
	height: 0.6rem;
	fill: currentColor;
}
