/**
 * Book Gallery styles.
 *
 * Fonts, text colours and heading styles are inherited from the theme. The accent colour follows
 * the theme automatically (Elementor, Astra, Divi 5, block themes) and can be overridden in
 * Books > Settings or with the --book-gallery-theme-accent custom property.
 */

.book-gallery {
	--book-gallery-accent: var(--book-gallery-theme-accent, var(--e-global-color-accent, var(--ast-global-color-0, var(--gcid-primary-color, var(--wp--preset--color--primary, var(--wp--preset--color--contrast, #2271b1))))));
	--book-gallery-accent-text: #fff;
	--book-gallery-star: #f5a623;
	--book-gallery-star-empty: rgba(128, 128, 128, 0.35);
	--book-gallery-sale: #c62828;
	--book-gallery-radius: 6px;
	--book-gallery-gap: 1.5rem;
	--book-gallery-border: color-mix(in srgb, currentColor 15%, transparent);
	--book-gallery-surface: color-mix(in srgb, currentColor 5%, transparent);
	--book-gallery-muted: color-mix(in srgb, currentColor 70%, transparent);

	box-sizing: border-box;
	width: 100%;
	margin-block: 0 2rem;
	container: book-gallery / inline-size;
}

.book-gallery *,
.book-gallery *::before,
.book-gallery *::after {
	box-sizing: inherit;
}

.book-gallery .book-gallery-card__authors,
.book-gallery .book-gallery-single__authors,
.book-gallery .book-gallery-author__count,
.book-gallery .book-gallery__empty,
.book-gallery .book-gallery-card__meta > div {
	margin: 0;
}

.book-gallery .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
	word-wrap: normal !important;
}

.book-gallery__title {
	margin: 0 0 1.25rem;
}

/* Themes often underline content links with high-specificity selectors; UI elements stay clean. */
.book-gallery .book-gallery-button,
.book-gallery .book-gallery-chip,
.book-gallery .book-gallery-card__media,
.book-gallery .book-gallery-card__title a,
.book-gallery .book-gallery-slide__media,
.book-gallery .book-gallery-slide__title a,
.book-gallery .book-gallery-section__more,
.book-gallery .book-gallery-author__name a,
.book-gallery .book-gallery-pagination .page-numbers {
	text-decoration: none !important;
}

.book-gallery__empty {
	padding: 1.5rem;
	border: 1px dashed var(--book-gallery-border);
	border-radius: var(--book-gallery-radius);
	text-align: center;
}

/* Page wrappers */

.book-gallery-main--contained {
	box-sizing: border-box;
	width: 100%;
	max-width: var(--wp--style--global--wide-size, 1200px);
	margin-inline: auto;
	padding: 2.5rem 1.25rem 3.5rem;
}

.book-gallery-main--block-theme {
	padding-block: var(--wp--preset--spacing--50, 2.5rem) var(--wp--preset--spacing--60, 3.5rem);
}

/* Buttons */

.book-gallery .book-gallery-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.4em;
	margin: 0;
	padding: 0.65em 1.15em;
	border: 1px solid var(--book-gallery-accent);
	border-radius: var(--book-gallery-radius);
	background: var(--book-gallery-accent);
	color: var(--book-gallery-accent-text);
	font-family: inherit;
	font-size: 0.9rem;
	font-weight: 600;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	text-transform: none;
	letter-spacing: normal;
	box-shadow: none;
	cursor: pointer;
	transition: filter 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.book-gallery .book-gallery-button:hover,
.book-gallery .book-gallery-button:focus {
	background: var(--book-gallery-accent);
	color: var(--book-gallery-accent-text);
	text-decoration: none;
	filter: brightness(0.9);
}

.book-gallery .book-gallery-button--secondary,
.book-gallery .book-gallery-button--download {
	background: transparent;
	color: inherit;
	border-color: var(--book-gallery-border);
}

.book-gallery .book-gallery-button--download {
	color: var(--book-gallery-accent);
	border-color: currentColor;
}

.book-gallery .book-gallery-button--secondary:hover,
.book-gallery .book-gallery-button--secondary:focus,
.book-gallery .book-gallery-button--download:hover,
.book-gallery .book-gallery-button--download:focus {
	background: var(--book-gallery-surface);
	color: inherit;
	filter: none;
}

.book-gallery a:focus-visible,
.book-gallery button:focus-visible,
.book-gallery input:focus-visible,
.book-gallery select:focus-visible,
.book-gallery-slider__track:focus-visible {
	outline: 2px solid var(--book-gallery-accent);
	outline-offset: 2px;
}

.book-gallery-buttons {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

/* Chips, price, rating */

.book-gallery-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
}

.book-gallery .book-gallery-chip {
	display: inline-block;
	padding: 0.2em 0.65em;
	border-radius: 999px;
	background: var(--book-gallery-surface);
	border: 1px solid var(--book-gallery-border);
	color: inherit;
	font-size: 0.78rem;
	line-height: 1.5;
	text-decoration: none;
}

.book-gallery a.book-gallery-chip:hover,
.book-gallery a.book-gallery-chip:focus {
	border-color: var(--book-gallery-accent);
	color: inherit;
	text-decoration: none;
}

.book-gallery-price {
	font-weight: 700;
}

.book-gallery .book-gallery-price del {
	opacity: 0.6;
	font-weight: 400;
}

.book-gallery .book-gallery-price ins {
	background: none;
	color: var(--book-gallery-sale);
	text-decoration: none;
}

.book-gallery-rating {
	--book-gallery-rating-percent: calc(var(--book-gallery-rating, 0) / 5 * 100%);
	display: inline-block;
	font-size: 1.1em;
	line-height: 1;
	letter-spacing: 0.1em;
}

.book-gallery-rating::before {
	content: "\2605\2605\2605\2605\2605";
	background: linear-gradient(90deg, var(--book-gallery-star) var(--book-gallery-rating-percent), var(--book-gallery-star-empty) var(--book-gallery-rating-percent));
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
}

/* Covers */

.book-gallery .book-gallery-cover {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	border-radius: var(--book-gallery-radius);
	object-fit: cover;
	box-shadow: none;
}

.book-gallery-cover--placeholder {
	display: flex !important;
	align-items: center;
	justify-content: center;
	aspect-ratio: 2 / 3;
	background: var(--book-gallery-surface);
	border: 1px solid var(--book-gallery-border);
	color: var(--book-gallery-muted);
}

/* Search and sorting form */

.book-gallery-filter {
	display: grid;
	gap: 1rem;
	margin: 0 0 var(--book-gallery-gap);
	padding: 1.25rem;
	border: 1px solid var(--book-gallery-border);
	border-radius: var(--book-gallery-radius);
	background: var(--book-gallery-surface);
}

.book-gallery-filter__fields {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr));
	gap: 0.75rem;
}

.book-gallery-filter__field input,
.book-gallery-filter__field select,
.book-gallery-filter__sorting select {
	width: 100%;
	max-width: 100%;
	min-height: 2.6rem;
	margin: 0;
	font-family: inherit;
	font-size: 0.9rem;
}

.book-gallery-filter__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.75rem 1rem;
}

.book-gallery-filter__reset {
	font-size: 0.9rem;
}

.book-gallery-filter__sorting {
	display: flex;
	gap: 0.5rem;
	margin-inline-start: auto;
}

.book-gallery-filter__sorting select {
	width: auto;
}

/* Grid view and cards */

.book-gallery-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr));
	gap: var(--book-gallery-gap);
}

.book-gallery-grid--fixed {
	grid-template-columns: repeat(var(--book-gallery-columns, 4), minmax(0, 1fr));
}

.book-gallery-grid--compact {
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr));
}

.book-gallery-list {
	display: grid;
	gap: var(--book-gallery-gap);
}

.book-gallery-card {
	display: flex;
	flex-direction: column;
	min-width: 0;
	overflow: hidden;
	border: 1px solid var(--book-gallery-border);
	border-radius: var(--book-gallery-radius);
	transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.book-gallery-card:hover {
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.book-gallery .book-gallery-card__media {
	display: block;
	color: inherit;
	aspect-ratio: 2 / 3;
	overflow: hidden;
	background: var(--book-gallery-surface);
}

.book-gallery-card__media .book-gallery-cover {
	border-radius: 0;
	transition: transform 0.3s ease;
}

.book-gallery-card:hover .book-gallery-card__media .book-gallery-cover {
	transform: scale(1.03);
}

.book-gallery-card__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 0.6rem;
	padding: 1rem;
}

.book-gallery .book-gallery-card__title {
	margin: 0;
	font-size: 1.05rem;
	line-height: 1.3;
}

.book-gallery .book-gallery-card__title a {
	color: inherit;
	text-decoration: none;
}

.book-gallery .book-gallery-card__title a:hover,
.book-gallery .book-gallery-card__title a:focus {
	color: var(--book-gallery-accent);
}

.book-gallery-card__authors,
.book-gallery-card__meta,
.book-gallery-card__excerpt {
	color: var(--book-gallery-muted);
	font-size: 0.875rem;
}

.book-gallery-card__meta {
	display: grid;
	gap: 0.2rem;
}

.book-gallery-card__label {
	font-weight: 600;
}

.book-gallery-card__excerpt p:not(:last-child) {
	margin-bottom: 0.5em;
}

.book-gallery-card__footer {
	display: grid;
	gap: 0.75rem;
	margin-top: auto;
}

.book-gallery-card--grid .book-gallery-buttons > * {
	flex: 1 1 auto;
}

.book-gallery-card--list {
	display: grid;
	grid-template-columns: minmax(0, 9rem) minmax(0, 1fr);
	gap: 1.25rem;
	padding: 1rem;
}

.book-gallery-card--list .book-gallery-card__media {
	border-radius: var(--book-gallery-radius);
}

.book-gallery-card--list .book-gallery-card__body {
	padding: 0;
}

.book-gallery-card--list .book-gallery-card__title {
	font-size: 1.2rem;
}

/* Pagination */

.book-gallery-pagination {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.35rem;
	margin-top: 2rem;
}

.book-gallery .book-gallery-pagination .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2.4rem;
	height: 2.4rem;
	padding: 0 0.6rem;
	border: 1px solid var(--book-gallery-border);
	border-radius: var(--book-gallery-radius);
	color: inherit;
	text-decoration: none;
	line-height: 1;
}

.book-gallery .book-gallery-pagination a.page-numbers:hover,
.book-gallery .book-gallery-pagination a.page-numbers:focus {
	border-color: var(--book-gallery-accent);
}

.book-gallery .book-gallery-pagination .page-numbers.current {
	border-color: var(--book-gallery-accent);
	background: var(--book-gallery-accent);
	color: var(--book-gallery-accent-text);
}

.book-gallery .book-gallery-pagination .page-numbers.dots {
	border-color: transparent;
}

/* Slider */

.book-gallery-slider {
	position: relative;
}

.book-gallery-slider__track {
	position: relative;
	display: flex;
	gap: var(--book-gallery-gap);
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	padding-bottom: 0.5rem;
}

.book-gallery-slider.is-enhanced .book-gallery-slider__track {
	scrollbar-width: none;
}

.book-gallery-slider.is-enhanced .book-gallery-slider__track::-webkit-scrollbar {
	display: none;
}

.book-gallery-slide {
	display: grid;
	flex: 0 0 100%;
	grid-template-columns: minmax(0, 16rem) minmax(0, 1fr);
	gap: 2rem;
	align-items: center;
	padding: 1.5rem;
	border: 1px solid var(--book-gallery-border);
	border-radius: var(--book-gallery-radius);
	background: var(--book-gallery-surface);
	scroll-snap-align: start;
}

.book-gallery .book-gallery-slide__media {
	display: block;
	color: inherit;
	aspect-ratio: 2 / 3;
}

.book-gallery-slide__body {
	display: grid;
	gap: 0.85rem;
	align-content: center;
}

.book-gallery .book-gallery-slide__title {
	margin: 0;
	font-size: 1.6rem;
	line-height: 1.25;
}

.book-gallery .book-gallery-slide__title a {
	color: inherit;
	text-decoration: none;
}

.book-gallery-slider__controls {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	margin-top: 1rem;
}

.book-gallery-slider__controls[hidden] {
	display: none;
}

.book-gallery .book-gallery-slider__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.75rem;
	height: 2.75rem;
	margin: 0;
	padding: 0;
	border: 1px solid var(--book-gallery-border);
	border-radius: 50%;
	background: transparent;
	color: inherit;
	font-size: 1.6rem;
	line-height: 1;
	box-shadow: none;
	cursor: pointer;
}

.book-gallery .book-gallery-slider__button:hover,
.book-gallery .book-gallery-slider__button:focus {
	border-color: var(--book-gallery-accent);
	background: transparent;
	color: var(--book-gallery-accent);
}

.book-gallery-slider__status {
	min-width: 6rem;
	color: var(--book-gallery-muted);
	font-size: 0.875rem;
	text-align: center;
}

/* Category view */

.book-gallery-section + .book-gallery-section {
	margin-top: 2.5rem;
	padding-top: 2rem;
	border-top: 1px solid var(--book-gallery-border);
}

.book-gallery-section__header {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.5rem 1rem;
	margin-bottom: 1.25rem;
}

.book-gallery .book-gallery-section__title {
	margin: 0;
}

.book-gallery .book-gallery-section__more {
	font-size: 0.9rem;
	font-weight: 600;
	text-decoration: none;
}

/* Author panel */

.book-gallery-authors {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
	gap: var(--book-gallery-gap);
}

.book-gallery-author {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.6rem;
	padding: 1.5rem;
	border: 1px solid var(--book-gallery-border);
	border-radius: var(--book-gallery-radius);
	text-align: center;
}

.book-gallery-author__image {
	width: 7.5rem;
	height: 7.5rem;
	margin-bottom: 0.5rem;
	overflow: hidden;
	border-radius: 50%;
	background: var(--book-gallery-surface);
	border: 4px solid var(--book-gallery-border);
}

.book-gallery .book-gallery-author__image img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
}

.book-gallery-author__initial {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	color: var(--book-gallery-muted);
	font-size: 2.5rem;
	font-weight: 600;
	text-transform: uppercase;
}

.book-gallery .book-gallery-author__name {
	margin: 0;
	font-size: 1.15rem;
}

.book-gallery .book-gallery-author__name a {
	color: inherit;
	text-decoration: none;
}

.book-gallery-author__count,
.book-gallery-author__bio {
	color: var(--book-gallery-muted);
	font-size: 0.875rem;
}

.book-gallery-author__bio {
	display: -webkit-box;
	-webkit-line-clamp: 4;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.book-gallery-author .book-gallery-button {
	margin-top: auto;
}

/* Single book */

.book-gallery-single {
	margin-block: 0;
}

.book-gallery-single__header {
	margin-bottom: 2rem;
}

.book-gallery .book-gallery-single__title {
	margin: 0 0 0.35rem;
	font-size: clamp(1.75rem, 1.2rem + 2vw, 2.5rem);
	line-height: 1.2;
}

.book-gallery-single__authors {
	color: var(--book-gallery-muted);
	font-size: 1.1rem;
}

.book-gallery-single__layout {
	display: grid;
	grid-template-columns: minmax(0, 18rem) minmax(0, 1fr);
	gap: 2.5rem;
	align-items: start;
}

.book-gallery-single__layout--no-cover {
	grid-template-columns: minmax(0, 1fr);
}

.book-gallery-single__aside,
.book-gallery-single__main {
	display: grid;
	gap: 1.25rem;
	min-width: 0;
}

.book-gallery-single__cover .book-gallery-cover {
	height: auto;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.book-gallery-single__aside .book-gallery-price {
	font-size: 1.35rem;
	text-align: center;
}

.book-gallery-single__aside .book-gallery-buttons {
	flex-direction: column;
}

.book-gallery-single__main > .book-gallery-price {
	font-size: 1.35rem;
}

.book-gallery .book-gallery-single__section-title {
	margin: 0 0 1rem;
	padding-bottom: 0.5rem;
	border-bottom: 1px solid var(--book-gallery-border);
	font-size: 1.35rem;
	font-weight: 600;
}

.book-gallery-details {
	margin: 0;
}

.book-gallery-details__row {
	display: grid;
	grid-template-columns: minmax(7rem, 11rem) minmax(0, 1fr);
	gap: 1rem;
	padding: 0.6rem 0;
	border-bottom: 1px solid var(--book-gallery-border);
}

.book-gallery .book-gallery-details dt {
	margin: 0;
	font-weight: 600;
}

.book-gallery .book-gallery-details dd {
	margin: 0;
	overflow-wrap: anywhere;
}

.book-gallery-single__description > :first-child {
	margin-top: 0;
}

.book-gallery-single__terms {
	display: grid;
	gap: 0.75rem;
}

/* Responsive: adapt to the width of the column the gallery is placed in. */

@container book-gallery (max-width: 720px) {
	.book-gallery-single__layout {
		grid-template-columns: minmax(0, 1fr);
	}

	.book-gallery-single__aside {
		width: 100%;
		max-width: 20rem;
		margin-inline: auto;
	}

	.book-gallery-grid--fixed {
		grid-template-columns: repeat(min(var(--book-gallery-columns, 4), 3), minmax(0, 1fr));
	}

	.book-gallery-slide {
		grid-template-columns: minmax(0, 1fr);
		gap: 1.25rem;
	}

	.book-gallery .book-gallery-slide__media {
		width: min(100%, 14rem);
		margin-inline: auto;
	}

	.book-gallery .book-gallery-slide__title {
		font-size: 1.3rem;
	}
}

@container book-gallery (max-width: 480px) {
	.book-gallery-grid--fixed {
		grid-template-columns: repeat(min(var(--book-gallery-columns, 4), 2), minmax(0, 1fr));
	}

	.book-gallery-card--list {
		grid-template-columns: minmax(0, 6rem) minmax(0, 1fr);
		gap: 1rem;
	}

	.book-gallery-details__row {
		grid-template-columns: minmax(0, 1fr);
		gap: 0.15rem;
	}

	.book-gallery-filter__sorting,
	.book-gallery-filter__sorting select,
	.book-gallery-filter__actions .book-gallery-button {
		width: 100%;
		margin-inline-start: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.book-gallery *,
	.book-gallery *::before,
	.book-gallery *::after {
		transition: none !important;
		scroll-behavior: auto !important;
	}
}
