/* Reading List page: shelves of 3D hardcovers. Loaded only by page-reading-list.hbs */
/* Cloth colours for books without cover art, cycled by position. */
.shelf > li:nth-child(6n + 1) .book { --cloth: #c8553d; }
.shelf > li:nth-child(6n + 2) .book { --cloth: #e9dfc4; --cloth-fg: #2b2414; }
.shelf > li:nth-child(6n + 3) .book { --cloth: #5b6b2e; }
.shelf > li:nth-child(6n + 4) .book { --cloth: #a8c8e8; --cloth-fg: #0f2338; }
.shelf > li:nth-child(6n + 5) .book { --cloth: #4a2545; }
.shelf > li:nth-child(6n + 6) .book { --cloth: #1c1d21; }

.reading-list-head .reading-list-intro {
	max-width: 42rem;
	margin: 1.5rem auto 0;
	text-align: center;
}
.reading-list-all-wrap {
	margin: 1.25rem 0 0;
}
.reading-list-all {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	font-size: 0.95rem;
	font-weight: 500;
	text-underline-offset: 4px;
}
.reading-list-all:hover {
	text-decoration: underline;
}
.reading-list-all svg {
	width: 1rem;
	height: 1rem;
}

/* ---- shelves: each wrapped row of books gets its own plank (repeating gradient sized to the row) */
.shelf {
	--book-w: 7.4rem;
	--book-h: calc(var(--book-w) * 1.5);
	--book-d: 1.5rem;
	--shelf-row: calc(var(--book-h) + 2.25rem);
	--shelf-thickness: 0.85rem;
	--shelf-color: color-mix(in oklab, var(--text-color-main) 24%, var(--body-background-color));
	--shelf-edge: color-mix(in oklab, var(--text-color-main) 40%, var(--body-background-color));
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: center;
	gap: var(--shelf-thickness) 1.1rem;
	margin: 1.5rem 0 4rem;
	padding: 0 1.5rem var(--shelf-thickness);
	list-style: none;
	background: repeating-linear-gradient(
		to bottom,
		transparent 0,
		transparent var(--shelf-row),
		var(--shelf-edge) var(--shelf-row),
		var(--shelf-edge) calc(var(--shelf-row) + 2px),
		var(--shelf-color) calc(var(--shelf-row) + 2px),
		var(--shelf-color) calc(var(--shelf-row) + var(--shelf-thickness))
	);
}
.shelf > li {
	display: flex;
	align-items: flex-end;
	height: var(--shelf-row);
}
.shelf:has(> li:hover) > li:not(:hover) .book {
	opacity: 0.75;
}

/* ---- one book */
.book {
	--cloth-fg: #f4efe6;
	position: relative;
	display: block;
	width: var(--book-w);
	height: var(--book-h);
	perspective: 1100px;
	text-decoration: none;
	color: inherit;
	transition: opacity 0.3s;
}
.book-body {
	position: relative;
	display: block;
	width: 100%;
	height: 100%;
	transform-style: preserve-3d;
	transform: rotateY(-32deg);
	transform-origin: center;
	transition: transform 0.55s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.book:hover .book-body,
.book:focus-visible .book-body {
	transform: rotateY(-8deg) translateY(-0.6rem) translateZ(0.5rem);
}
.book:focus-visible {
	outline: 2px solid var(--ghost-accent-color);
	outline-offset: 4px;
}
.book-front,
.book-back,
.book-spine,
.book-pages {
	position: absolute;
	display: block;
	backface-visibility: hidden;
}
.book-front {
	inset: 0;
	border-radius: 2px 5px 5px 2px;
	overflow: hidden;
	background: var(--cloth);
	transform: translateZ(calc(var(--book-d) / 2));
	box-shadow:
		inset 4px 0 6px -4px rgb(0 0 0 / 0.55),
		inset 0 0 0 1px rgb(255 255 255 / 0.08);
}
.book-front img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.book-front::after {
	/* hinge groove + a soft sheen, like a real hardcover */
	content: "";
	position: absolute;
	inset: 0;
	background:
		linear-gradient(90deg, rgb(0 0 0 / 0.28) 0, rgb(0 0 0 / 0.08) 5%, transparent 9%),
		linear-gradient(115deg, rgb(255 255 255 / 0.16) 0, rgb(255 255 255 / 0) 35%);
	pointer-events: none;
}
.book-front-title {
	position: absolute;
	inset: 12% 10%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0.5rem;
	border: 1px solid color-mix(in oklab, var(--cloth-fg) 50%, transparent);
	color: var(--cloth-fg);
	font-size: 0.8rem;
	font-weight: 600;
	line-height: 1.2;
	text-align: center;
	text-wrap: balance;
}
.book-back {
	inset: 0;
	border-radius: 2px 5px 5px 2px;
	background: var(--cloth, #2a2a2e);
	transform: rotateY(180deg) translateZ(calc(var(--book-d) / 2));
}
.book-spine {
	top: 0;
	left: calc(var(--book-d) / -2);
	width: var(--book-d);
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 2px 0 0 2px;
	background-color: var(--cloth, #2a2a2e);
	background-image: linear-gradient(90deg, rgb(0 0 0 / 0.35) 0, rgb(255 255 255 / 0.14) 18%, rgb(0 0 0 / 0.05) 50%, rgb(0 0 0 / 0.4) 100%), var(--cover);
	background-size: cover, auto 100%;
	background-position: left center;
	transform: rotateY(-90deg);
	box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.06);
	backface-visibility: visible;
}
.book.no-cover .book-spine {
	background-image: linear-gradient(90deg, rgb(0 0 0 / 0.35) 0, rgb(255 255 255 / 0.14) 18%, rgb(0 0 0 / 0.05) 50%, rgb(0 0 0 / 0.4) 100%);
}
.book-spine-title {
	max-height: 92%;
	overflow: hidden;
	writing-mode: vertical-rl;
	white-space: nowrap;
	text-overflow: ellipsis;
	color: #fff;
	font-size: 0.62rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-shadow: 0 0 2px rgb(0 0 0 / 0.9), 0 0 6px rgb(0 0 0 / 0.6);
}
.book-pages {
	top: 2px;
	bottom: 2px;
	left: calc(var(--book-w) - var(--book-d) / 2);
	width: calc(var(--book-d) - 3px);
	background: repeating-linear-gradient(90deg, #f3eee4 0 1px, #d9d2c3 1px 2px);
	transform: rotateY(90deg);
	backface-visibility: visible;
}
/* shadow on the plank */
.book::after {
	content: "";
	position: absolute;
	left: 8%;
	right: -12%;
	bottom: -0.35rem;
	height: 0.9rem;
	border-radius: 50%;
	background: rgb(0 0 0 / 0.45);
	filter: blur(6px);
	transition: transform 0.55s, opacity 0.55s;
	z-index: -1;
}
.book:hover::after {
	transform: translateY(0.4rem) scaleX(0.9);
	opacity: 0.6;
}

.reading-list-empty {
	text-align: center;
	opacity: 0.7;
}
@media (max-width: 767px) {
	.shelf {
		--book-w: 5rem;
		--book-d: 1.1rem;
		gap: var(--shelf-thickness) 0.75rem;
		padding: 0 0.5rem var(--shelf-thickness);
	}
	.book-spine-title {
		font-size: 0.5rem;
	}
}
@media (prefers-reduced-motion: reduce) {
	.book,
	.book-body,
	.book::after {
		transition: none;
	}
	.book:hover .book-body {
		transform: rotateY(-32deg);
	}
}
