/*
 * Sacred Ground Library — v1.0.2
 *
 * SPECIFICITY NOTE (see sacred-ground-upcoming-events plugin's CSS for the
 * full writeup): the theme injects an inline reset — `.sg-page * { margin:
 * 0; padding: 0; box-sizing: border-box; }` — on pages this plugin runs on.
 * A bare single-class selector has the same specificity as that reset and
 * can silently lose the cascade tie depending on injection order. Every
 * selector below is scoped under `.sg-lib-wrap` (doubled for the top-level
 * rule) to reliably out-rank it, without using !important anywhere.
 */

.sg-lib-wrap.sg-lib-wrap {
	width: 100%;
	padding: 48px 56px 56px;
	box-sizing: border-box;
	background-color: #1b0f3a;
}

.sg-lib-wrap * {
	box-sizing: border-box;
}

.sg-lib-wrap .sg-lib-heading {
	text-align: center;
	font-size: 2.4rem;
	font-weight: 700;
	margin: 0 0 8px;
	color: #f5d78e;
	letter-spacing: 0.01em;
}

.sg-lib-wrap .sg-lib-subheading {
	text-align: center;
	margin: 0 0 28px;
	color: #c9bde8;
	font-size: 1rem;
}

.sg-lib-wrap .sg-lib-search-row {
	display: flex;
	justify-content: center;
	margin: 0 0 20px;
}

.sg-lib-wrap .sg-lib-search {
	width: 100%;
	max-width: 480px;
	padding: 12px 18px;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.15);
	background: rgba(45, 27, 78, 0.6);
	color: #ffffff;
	font-size: 0.95rem;
}

.sg-lib-wrap .sg-lib-search::placeholder {
	color: #9d8fc2;
}

.sg-lib-wrap .sg-lib-search:focus {
	outline: none;
	border-color: rgba(212, 175, 55, 0.55);
}

.sg-lib-wrap .sg-lib-filters {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 10px;
	margin: 0 0 32px;
}

.sg-lib-wrap .sg-lib-chip {
	padding: 9px 20px;
	border-radius: 999px;
	border: 1px solid rgba(212, 175, 55, 0.4);
	background: transparent;
	color: #d4af37;
	font-size: 0.85rem;
	font-weight: 600;
	letter-spacing: 0.03em;
	cursor: pointer;
	transition: background 0.15s, color 0.15s;
}

.sg-lib-wrap .sg-lib-chip:hover {
	background: rgba(212, 175, 55, 0.12);
}

.sg-lib-wrap .sg-lib-chip.is-active {
	background: #d4af37;
	color: #1b0f3a;
}

.sg-lib-wrap .sg-lib-grid {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 20px;
}

.sg-lib-wrap .sg-lib-card {
	display: flex;
	flex-direction: column;
	background: rgba(45, 27, 78, 0.8);
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 14px;
	overflow: hidden;
	text-decoration: none;
	transition: border-color 0.2s;
}

/* The search/filter script (see shortcode markup below) toggles each
 * non-matching card's `hidden` attribute rather than removing it from the
 * DOM. The browser's built-in `[hidden] { display: none }` UA rule has
 * lower specificity than the `.sg-lib-card { display: flex }` rule above,
 * so without this override, cards marked hidden stayed visible — the
 * filter chips and search box looked broken (nothing happened on click)
 * even though the JS was correctly toggling the attribute the whole time. */
.sg-lib-wrap .sg-lib-card[hidden] {
	display: none;
}

.sg-lib-wrap .sg-lib-card:hover {
	border-color: rgba(212, 175, 55, 0.45);
}

.sg-lib-wrap .sg-lib-card__image {
	position: relative;
	aspect-ratio: 3 / 4;
	background-size: cover;
	background-position: center center;
	background-repeat: no-repeat;
	background-color: #2d1b4e;
}

.sg-lib-wrap .sg-lib-card__placeholder {
	position: absolute;
	inset: 0;
	background: linear-gradient(135deg, #2d1b4e 0%, #4a1942 50%, #6b46c1 100%);
}

.sg-lib-wrap .sg-lib-card__badge {
	position: absolute;
	top: 10px;
	left: 10px;
	background: rgba(0, 0, 0, 0.65);
	border: 1px solid rgba(212, 175, 55, 0.55);
	border-radius: 999px;
	padding: 4px 10px;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: #d4af37;
	backdrop-filter: blur(4px);
}

.sg-lib-wrap .sg-lib-card__body {
	padding: 14px 16px;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.sg-lib-wrap .sg-lib-card__title {
	margin: 0;
	font-size: 0.95rem;
	line-height: 1.3;
	font-weight: 600;
	color: #f5d78e;
}

.sg-lib-wrap .sg-lib-card:hover .sg-lib-card__title {
	color: #ffffff;
}

.sg-lib-wrap .sg-lib-card__excerpt {
	margin: 0;
	font-size: 0.85rem;
	color: #c9bde8;
	line-height: 1.5;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.sg-lib-wrap .sg-lib-empty,
.sg-lib-wrap .sg-lib-no-results {
	text-align: center;
	color: #c9bde8;
	padding: 24px 0;
}

@media (max-width: 900px) {
	.sg-lib-wrap .sg-lib-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 560px) {
	.sg-lib-wrap.sg-lib-wrap {
		padding: 20px 12px 28px;
	}
	.sg-lib-wrap .sg-lib-grid {
		grid-template-columns: 1fr;
	}
}

/* External-link warning modal (shown before Book/Movie/Podcast cards open
   Bookshop.org / IMDb / Apple Podcasts / etc). Not scoped under .sg-lib-wrap
   since it's rendered as a sibling of it, fixed to the viewport. */
.sg-lib-leave-modal[hidden] {
	display: none;
}

.sg-lib-leave-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
}

.sg-lib-leave-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(15, 8, 33, 0.75);
}

.sg-lib-leave-modal__box {
	position: relative;
	max-width: 420px;
	width: calc(100% - 40px);
	background: #1b0f3a;
	border: 1px solid rgba(212, 175, 55, 0.4);
	border-radius: 14px;
	padding: 28px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.sg-lib-leave-modal__title {
	margin: 0 0 12px;
	color: #f5d78e;
	font-size: 1.25rem;
	font-weight: 700;
}

.sg-lib-leave-modal__text {
	margin: 0 0 22px;
	color: #c9bde8;
	font-size: 0.95rem;
	line-height: 1.6;
}

.sg-lib-leave-modal__host {
	color: #f5d78e;
}

.sg-lib-leave-modal__actions {
	display: flex;
	gap: 12px;
	justify-content: flex-end;
}

.sg-lib-leave-modal__cancel {
	padding: 10px 18px;
	border-radius: 8px;
	border: 1px solid rgba(255, 255, 255, 0.2);
	background: transparent;
	color: #ffffff;
	font-size: 0.9rem;
	font-weight: 600;
	cursor: pointer;
}

.sg-lib-leave-modal__cancel:hover {
	background: rgba(255, 255, 255, 0.08);
}

.sg-lib-leave-modal__continue {
	padding: 10px 18px;
	border-radius: 8px;
	background: #d4af37;
	color: #1b0f3a;
	font-size: 0.9rem;
	font-weight: 700;
	text-decoration: none;
	cursor: pointer;
}

.sg-lib-leave-modal__continue:hover {
	background: #e0bf4e;
}
