/* ==========================================================================
   Library — book cards + book details modal (2026-09-26)
   Loaded after page-library.bundle / unified-modal.css; every rule is scoped
   to #bookholder (library grid) or #bookModal so publications and other
   modals are untouched.

   Signature: books read as physical books on a shelf. Covers carry a spine
   shade on the inline-start edge (right on Arabic pages, where Arabic books
   are bound; left on English), and books without a cover image get a
   generated cloth-bound cover with the title stamped in gold.
   ========================================================================== */

#bookholder,
#bookModal {
	--bk-teal: var(--jinan-teal, #00846e);
	--bk-teal-deep: var(--jinan-teal-dark, #004d3f);
	--bk-gold: var(--jinan-gold, #f7b243);
	--bk-bronze: var(--jinan-gold-dark, #c77f2a);
	--bk-ink: var(--jinan-charcoal, #2b2d31);
	--bk-muted: #6b7076;
	--bk-line: rgba(43, 45, 49, 0.09);
	--bk-shelf: #eef2f0;
}

/* ---------- Grid ---------------------------------------------------------- */
#bookholder .books-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
	gap: 1.5rem;
}

/* ---------- Card ---------------------------------------------------------- */
#bookholder .book-card {
	display: flex;
	flex-direction: column;
	padding: 0; /* an older bundle rule padded the card, insetting the shelf */
	background: #fff;
	border: 1px solid var(--bk-line);
	border-radius: 14px;
	overflow: hidden;
	text-align: start;
	box-shadow: 0 1px 2px rgba(43, 45, 49, 0.04);
	transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
#bookholder .book-card:hover {
	transform: translateY(-3px);
	border-color: rgba(0, 132, 110, 0.18);
	box-shadow: 0 14px 30px -14px rgba(0, 77, 63, 0.35);
}

/* Shelf: the cover stands on a soft ledge */
#bookholder .book-cover {
	position: relative;
	display: flex;
	align-items: flex-end;
	justify-content: center;
	width: 100%;
	height: auto;
	padding: 1.5rem 1rem 1.25rem;
	background: linear-gradient(180deg, #f7f8f7 0%, var(--bk-shelf) 100%);
	border-bottom: 1px solid var(--bk-line);
	overflow: visible;
}
#bookholder .book-cover::after {
	/* contact shadow on the shelf */
	content: '';
	position: absolute;
	inset-inline: 22%;
	bottom: 1.05rem;
	height: 10px;
	border-radius: 50%;
	background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.22), transparent 70%);
	filter: blur(3px);
	z-index: 0;
}

/* Real covers (webp_picture → <picture><img>) */
#bookholder .book-cover picture,
#bookholder .book-cover > img {
	position: relative;
	z-index: 1;
	display: block;
	width: 128px;
	aspect-ratio: 2 / 3;
	border-start-start-radius: 3px;
	border-end-start-radius: 3px;
	border-start-end-radius: 6px;
	border-end-end-radius: 6px;
	overflow: hidden;
	box-shadow: 0 12px 20px -10px rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.08);
}
#bookholder .book-cover picture::after {
	/* spine shade on the binding edge */
	content: '';
	position: absolute;
	inset-block: 0;
	inset-inline-start: 0;
	width: 10px;
	background: linear-gradient(to right, rgba(0, 0, 0, 0.24), rgba(255, 255, 255, 0.14) 55%, transparent);
	pointer-events: none;
}
[dir="rtl"] #bookholder .book-cover picture::after {
	background: linear-gradient(to left, rgba(0, 0, 0, 0.24), rgba(255, 255, 255, 0.14) 55%, transparent);
}
#bookholder .book-cover picture img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transform: none;
	transition: none;
}

/* Generated cloth-bound cover (no cover image) */
#bookholder .book-cover .book-cloth,
#bookModal .bk-cover-cloth {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.55rem;
	width: 128px;
	aspect-ratio: 2 / 3;
	height: auto;
	padding: 1rem 0.8rem;
	padding-inline-start: 1.25rem;
	color: #f6c769;
	text-align: center;
	background:
		repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 4px),
		repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.035) 0 2px, transparent 2px 4px),
		linear-gradient(160deg, #0a8f78 0%, var(--bk-teal) 45%, #006a58 100%);
	border-start-start-radius: 3px;
	border-end-start-radius: 3px;
	border-start-end-radius: 6px;
	border-end-end-radius: 6px;
	box-shadow: 0 12px 20px -10px rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.08);
	overflow: hidden;
	font-size: inherit;
}
#bookholder .book-cover .book-cloth::before,
#bookModal .bk-cover-cloth::before {
	/* spine band */
	content: '';
	position: absolute;
	inset-block: 0;
	inset-inline-start: 0;
	width: 11px;
	background: linear-gradient(to right, rgba(0, 0, 0, 0.32), rgba(0, 0, 0, 0.12));
}
[dir="rtl"] #bookholder .book-cover .book-cloth::before,
[dir="rtl"] #bookModal .bk-cover-cloth::before {
	background: linear-gradient(to left, rgba(0, 0, 0, 0.32), rgba(0, 0, 0, 0.12));
}
#bookholder .book-cover .book-cloth::after,
#bookModal .bk-cover-cloth::after {
	/* gold-foil frame */
	content: '';
	position: absolute;
	inset: 7px;
	inset-inline-start: 17px;
	border: 1px solid rgba(247, 178, 67, 0.5);
	border-radius: 2px;
	pointer-events: none;
}
#bookholder .book-cloth-title {
	position: relative;
	font-weight: 700;
	font-size: 0.86rem;
	line-height: 1.55;
	display: -webkit-box;
	-webkit-line-clamp: 5;
	-webkit-box-orient: vertical;
	overflow: hidden;
	text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
#bookholder .book-cloth-author {
	position: relative;
	font-size: 0.7rem;
	line-height: 1.4;
	color: rgba(255, 255, 255, 0.78);
	padding-top: 0.45rem;
	border-top: 1px solid rgba(247, 178, 67, 0.4);
}

/* ---------- Card text ------------------------------------------------------ */
#bookholder .book-content {
	display: flex;
	flex-direction: column;
	flex: 1;
	gap: 0.4rem;
	padding: 1.1rem 1.25rem 1.25rem;
	text-align: start;
}
#bookholder .book-category {
	position: static;
	display: block;
	align-self: flex-start;
	margin: 0;
	padding: 0;
	background: none;
	border-radius: 0;
	box-shadow: none;
	color: var(--bk-bronze);
	font-size: 0.78rem;
	font-weight: 700;
	line-height: 1.4;
}
#bookholder .book-title {
	margin: 0;
	color: var(--bk-ink);
	font-size: 1.05rem;
	font-weight: 700;
	line-height: 1.55;
	text-align: start;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
#bookholder .book-author {
	display: flex;
	align-items: center;
	gap: 0.45rem;
	margin: 0;
	color: var(--bk-muted);
	font-size: 0.9rem;
}
#bookholder .book-author i {
	color: var(--bk-bronze);
	font-size: 0.78rem;
}
#bookholder .book-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 0.3rem 1rem;
	flex-grow: 0; /* legacy bundle grew this line, pushing the year to the card bottom */
	align-content: flex-start;
	margin: 0.15rem 0 0;
	padding: 0;
	background: none;
	color: #868b90;
	font-size: 0.82rem;
}
#bookholder .book-meta span {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0;
	background: none;
	border-radius: 0;
}
#bookholder .book-meta i {
	color: rgba(0, 132, 110, 0.55);
	font-size: 0.74rem;
}

/* ---------- Card actions (pinned to the bottom, equal widths) -------------- */
#bookholder .book-actions {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
	gap: 0.6rem;
	margin-top: auto;
	padding-top: 1rem;
	border-top: 1px solid var(--bk-line);
}
#bookholder .book-content > .book-meta + .book-actions,
#bookholder .book-content > .book-author + .book-actions {
	margin-top: auto;
}
#bookholder .book-btn,
#bookModal .bk-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.45rem;
	width: 100%;
	min-height: 42px;
	padding: 0.55rem 0.8rem;
	border: 1.5px solid transparent;
	border-radius: 10px;
	font-size: 0.9rem;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
#bookholder .book-btn-primary,
#bookModal .bk-btn-primary {
	background: var(--bk-teal);
	border-color: var(--bk-teal);
	color: #fff;
}
#bookholder .book-btn-primary:hover,
#bookModal .bk-btn-primary:hover {
	background: var(--jinan-teal-hover, #006b58);
	border-color: var(--jinan-teal-hover, #006b58);
	color: #fff;
}
#bookholder .book-btn-secondary,
#bookModal .bk-btn-secondary {
	background: #fff;
	border-color: rgba(0, 132, 110, 0.3);
	color: var(--bk-teal);
}
#bookholder .book-btn-secondary:hover,
#bookModal .bk-btn-secondary:hover {
	background: rgba(0, 132, 110, 0.07);
	border-color: var(--bk-teal);
	color: var(--bk-teal);
}
#bookholder .book-btn:focus-visible,
#bookModal .bk-btn:focus-visible,
#bookModal .unified-modal-close:focus-visible {
	outline: 2px solid var(--bk-gold);
	outline-offset: 2px;
}

/* ==========================================================================
   Book details modal
   ========================================================================== */
#bookModal .unified-modal-container {
	width: 100%; /* of the padded overlay — 94vw overflowed on phones */
	max-width: 640px;
}
#bookModal .unified-modal-header {
	background: var(--bk-teal);
	padding: 1rem 1.5rem;
}
#bookModal .unified-modal-title {
	color: #fff;
	font-size: 1.05rem;
	font-weight: 700;
	-webkit-text-fill-color: #fff;
	background: none;
}
#bookModal .unified-modal-close {
	background: rgba(255, 255, 255, 0.16);
	color: #fff;
	width: 38px;
	height: 38px;
}
#bookModal .unified-modal-close:hover {
	background: rgba(255, 255, 255, 0.28);
}
#bookModal .unified-modal-body {
	padding: 1.5rem;
}

/* Book header: cover + title + author */
#bookModal .bk-hero {
	display: flex;
	align-items: flex-start;
	gap: 1.25rem;
	padding-bottom: 1.25rem;
	margin-bottom: 1rem;
	border-bottom: 1px solid var(--bk-line);
}
#bookModal .bk-cover {
	flex: 0 0 96px;
}
#bookModal .bk-cover-img {
	display: block;
	width: 96px;
	aspect-ratio: 2 / 3;
	object-fit: cover;
	border-radius: 3px 6px 6px 3px;
	box-shadow: 0 12px 20px -10px rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.08);
}
#bookModal .bk-cover-cloth {
	width: 96px;
	padding: 0.7rem 0.5rem;
	padding-inline-start: 1rem;
}
#bookModal .bk-cover-cloth span {
	position: relative;
	font-weight: 700;
	font-size: 0.66rem;
	line-height: 1.5;
	display: -webkit-box;
	-webkit-line-clamp: 5;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
#bookModal .bk-hero-text {
	min-width: 0;
	padding-top: 0.2rem;
}
#bookModal .bk-eyebrow {
	color: var(--bk-bronze);
	font-size: 0.78rem;
	font-weight: 700;
	margin-bottom: 0.3rem;
}
#bookModal .bk-title {
	margin: 0 0 0.5rem;
	color: var(--bk-ink);
	font-size: 1.3rem;
	font-weight: 700;
	line-height: 1.45;
}
#bookModal .bk-author {
	display: flex;
	align-items: center;
	gap: 0.45rem;
	margin: 0;
	color: var(--bk-muted);
	font-size: 0.95rem;
}
#bookModal .bk-author i {
	color: var(--bk-bronze);
	font-size: 0.85rem;
}

/* Facts: label / value rows */
#bookModal .bk-facts {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	column-gap: 1.75rem;
	margin: 0 0 1.25rem;
}
#bookModal .bk-fact {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.6rem 0;
	border-bottom: 1px dashed rgba(43, 45, 49, 0.14);
}
#bookModal .bk-fact dt {
	margin: 0;
	color: #868b90;
	font-size: 0.85rem;
	font-weight: 500;
	white-space: nowrap;
}
#bookModal .bk-fact dd {
	margin: 0;
	color: var(--bk-ink);
	font-size: 0.92rem;
	font-weight: 600;
	text-align: end;
	overflow-wrap: anywhere;
}

/* About this book */
#bookModal .bk-about-title {
	margin: 0 0 0.6rem;
	color: var(--bk-teal);
	font-size: 0.95rem;
	font-weight: 700;
}
#bookModal .bk-about-body {
	color: #3d4046;
	font-size: 0.95rem;
	line-height: 1.85;
}
#bookModal .bk-about-body p {
	margin: 0.35rem 0;
	text-align: start !important;
}
#bookModal .bk-about-body img {
	display: block;
	max-width: 100%;
	height: auto;
	margin: 0.75rem auto;
	border-radius: 8px;
}

/* Footer: one row of actions */
#bookModal .unified-modal-footer {
	padding: 1rem 1.5rem;
	background: #fafbfa;
	border-top: 1px solid var(--bk-line);
}
#bookModal .bk-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.6rem;
}
#bookModal .bk-actions .bk-btn-primary,
#bookModal .bk-actions .bk-btn-secondary {
	flex: 1 1 180px;
	width: auto;
}
#bookModal .bk-btn-ghost {
	width: auto;
	flex: 0 0 auto;
	margin-inline-start: auto;
	background: none;
	border-color: transparent;
	color: var(--bk-muted);
}
#bookModal .bk-btn-ghost:hover {
	background: rgba(43, 45, 49, 0.06);
	color: var(--bk-ink);
}

/* ---------- Small screens ---------------------------------------------- */
@media (max-width: 575.98px) {
	#bookholder .books-grid {
		grid-template-columns: 1fr;
	}
	#bookModal .bk-facts {
		grid-template-columns: 1fr;
	}
	#bookModal .bk-hero {
		gap: 1rem;
	}
	#bookModal .bk-cover {
		flex-basis: 76px;
	}
	#bookModal .bk-cover-img,
	#bookModal .bk-cover-cloth {
		width: 76px;
	}
	#bookModal .bk-title {
		font-size: 1.12rem;
	}
	#bookModal .bk-btn-ghost {
		flex: 1 1 100%;
		margin-inline-start: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	#bookholder .book-card,
	#bookholder .book-btn,
	#bookModal .bk-btn {
		transition: none;
	}
	#bookholder .book-card:hover {
		transform: none;
	}
}
