/* ==========================================================================
   Bonzer 3D Flipbook — Frontend Styles
   Author: Bonzer Web Solutions
   ========================================================================== */

.bonzer-fb-wrapper {
	--bfb-accent: #8a4fff;
	--bfb-accent-2: #3b82f6;
	--bfb-radius: 14px;
	--bfb-ink: #1a1a2e;
	box-sizing: border-box;
	font-family: inherit;
}
.bonzer-fb-wrapper *, .bonzer-fb-wrapper *::before, .bonzer-fb-wrapper *::after,
.bonzer-fb-overlay, .bonzer-fb-overlay *, .bonzer-fb-overlay *::before, .bonzer-fb-overlay *::after {
	box-sizing: border-box;
}

/* ---------- Toolbar (search + category filter) ---------- */
.bonzer-fb-toolbar {
	display: flex;
	gap: 14px;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 22px;
}

.bonzer-fb-search {
	position: relative;
	flex: 1 1 260px;
	max-width: 360px;
}
.bonzer-fb-search .dashicons {
	position: absolute;
	left: 12px;
	top: 50%;
	transform: translateY(-50%);
	color: #9a9aab;
	font-size: 18px;
}
.bonzer-fb-search-input,
.bonzer-fb-filter-select {
	width: 100%;
	padding: 10px 14px 10px 36px;
	border: 1px solid #e2e2ea;
	border-radius: 999px;
	font-size: 14px;
	background: #fff;
	transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.bonzer-fb-filter-select {
	padding-left: 16px;
	max-width: 220px;
}
.bonzer-fb-search-input:focus,
.bonzer-fb-filter-select:focus {
	outline: none;
	border-color: var(--bfb-accent);
	box-shadow: 0 0 0 3px rgba(138, 79, 255, 0.15);
}

/* ---------- Grid ---------- */
.bonzer-fb-grid {
	display: grid;
	gap: 30px;
}
.bonzer-fb-grid--single {
	max-width: 340px;
}

.bonzer-fb-no-results {
	text-align: center;
	color: #888;
	padding: 30px 0;
}

.bonzer-fb-empty {
	color: #888;
}

/* ---------- Card ---------- */
.bonzer-fb-card {
	display: block;
}

.bonzer-fb-card-open {
	all: unset;
	display: flex;
	flex-direction: column;
	width: 100%;
	cursor: pointer;
	border-radius: var(--bfb-radius);
	transition: transform 0.35s cubic-bezier(.2,.8,.2,1), box-shadow 0.35s ease;
	will-change: transform;
}

.bonzer-fb-card-open:hover {
	transform: translateY(-8px);
	box-shadow: 0 22px 40px -12px rgba(30, 20, 70, 0.28);
}
.bonzer-fb-card-open:focus-visible {
	outline: 3px solid var(--bfb-accent);
	outline-offset: 4px;
}

.bonzer-fb-cover {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 3 / 4;
	overflow: hidden;
	border-radius: var(--bfb-radius);
	background: #eef0f5;
	box-shadow:
		0 1px 0 #fff inset,
		0 10px 24px -10px rgba(20, 15, 50, 0.35),
		-6px 0 14px -8px rgba(0,0,0,0.18);
}

.bonzer-fb-cover::after {
	content: "";
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: 14%;
	background: linear-gradient(90deg, rgba(0,0,0,0.28), rgba(0,0,0,0));
	pointer-events: none;
	z-index: 2;
}

.bonzer-fb-cover img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.5s ease;
}
.bonzer-fb-card-open:hover .bonzer-fb-cover img {
	transform: scale(1.05);
}

.bonzer-fb-cover-placeholder {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, var(--bfb-accent), var(--bfb-accent-2));
}
.bonzer-fb-cover-placeholder .dashicons {
	font-size: 52px;
	width: 52px;
	height: 52px;
	color: rgba(255,255,255,0.85);
}

.bonzer-fb-cover-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	background: linear-gradient(180deg, rgba(20,10,50,0) 40%, rgba(15,8,40,0.78) 100%);
	opacity: 0;
	transition: opacity 0.3s ease;
	color: #fff;
	z-index: 3;
}
.bonzer-fb-card-open:hover .bonzer-fb-cover-overlay,
.bonzer-fb-card-open:focus-visible .bonzer-fb-cover-overlay {
	opacity: 1;
}
.bonzer-fb-open-icon {
	width: 52px;
	height: 52px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(255,255,255,0.16);
	backdrop-filter: blur(6px);
	border: 1px solid rgba(255,255,255,0.5);
	transform: translateY(10px);
	transition: transform 0.3s ease;
}
.bonzer-fb-card-open:hover .bonzer-fb-open-icon {
	transform: translateY(0);
}
.bonzer-fb-open-text {
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.03em;
	text-transform: uppercase;
}

.bonzer-fb-title {
	margin-top: 14px;
	font-size: 15px;
	font-weight: 600;
	color: var(--bfb-ink);
	line-height: 1.4;
	text-align: left;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* ==========================================================================
   Reader modal
   ========================================================================== */

.bonzer-fb-overlay {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	flex-direction: column;
	background: radial-gradient(ellipse at center, #241a3d 0%, #100a1f 100%);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.3s ease;
	font-family: inherit;
}
.bonzer-fb-overlay.is-open {
	opacity: 1;
	visibility: visible;
}

.bonzer-fb-overlay-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 18px;
	color: #fff;
	flex-wrap: wrap;
	gap: 10px;
}

.bonzer-fb-book-title {
	font-size: 15px;
	font-weight: 600;
	opacity: 0.9;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 40vw;
}

.bonzer-fb-toolbar-group {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
}

.bonzer-fb-icon-btn {
	all: unset;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	color: #fff;
	cursor: pointer;
	background: rgba(255,255,255,0.08);
	transition: background 0.2s ease, transform 0.15s ease;
}
.bonzer-fb-icon-btn:hover {
	background: rgba(255,255,255,0.2);
}
.bonzer-fb-icon-btn:active {
	transform: scale(0.92);
}
.bonzer-fb-icon-btn svg {
	width: 19px;
	height: 19px;
}
.bonzer-fb-icon-btn.is-muted svg .bfb-sound-wave {
	display: none;
}
.bonzer-fb-icon-btn[disabled] {
	opacity: 0.35;
	cursor: not-allowed;
}

.bonzer-fb-close-btn {
	background: rgba(255,255,255,0.08);
}
.bonzer-fb-close-btn:hover {
	background: #e5484d;
}

/* Stage: where the flipbook lives */
.bonzer-fb-stage {
	flex: 1;
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	padding: 10px 70px 0;
	min-height: 0;
}

.bonzer-fb-zoom-pan {
	transform-origin: center center;
	transition: transform 0.25s ease;
	display: flex;
	align-items: center;
	justify-content: center;
	touch-action: none;
	position: relative;
}
.bonzer-fb-zoom-pan.is-zoomed {
	cursor: grab;
	width: 100%;
	height: 100%;
}
.bonzer-fb-zoom-pan.is-panning {
	cursor: grabbing;
	transition: none;
}
/*
 * The page-flip library draws pages onto a <canvas> that is only ever as
 * many physical pixels as its CSS display size — it does not gain detail
 * from a higher-resolution source image, and CSS-scaling it while zoomed
 * just stretches that same fixed bitmap (hence blurry/unreadable text).
 *
 * So instead of zooming the canvas book itself, we hide it while zoomed
 * and show a plain, separately-rendered high-resolution <img> of just the
 * current page in its place. A real <img> element has no such resolution
 * ceiling, so it stays sharp at any zoom level.
 */
.bonzer-fb-zoom-pan.is-zoomed .bonzer-fb-book {
	opacity: 0;
	pointer-events: none;
}

.bonzer-fb-book {
	box-shadow: 0 40px 80px -20px rgba(0,0,0,0.6);
}

.bonzer-fb-zoom-view {
	display: none;
	position: absolute;
	inset: 0;
	align-items: center;
	justify-content: center;
	gap: 2px;
}
.bonzer-fb-zoom-pan.is-zoomed .bonzer-fb-zoom-view {
	display: flex;
}
.bfb-zoom-img {
	max-width: 100%;
	max-height: 100%;
	height: 100%;
	width: auto;
	object-fit: contain;
	background: #fff;
	box-shadow: 0 40px 80px -20px rgba(0,0,0,0.6);
	/* Prevent the browser's native "drag this image" gesture from
	   hijacking our own pan-while-zoomed dragging after a few pixels. */
	-webkit-user-drag: none;
	user-drag: none;
	-webkit-user-select: none;
	user-select: none;
	pointer-events: none;
}

/* Prev/Next arrows: fixed to the left/right edges of the stage, not below */
.bonzer-fb-side-nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 6;
	width: 46px;
	height: 46px;
}
.bonzer-fb-side-nav.bfb-prev {
	left: 12px;
}
.bonzer-fb-side-nav.bfb-next {
	right: 12px;
}
.bonzer-fb-side-nav {
	background: rgba(255,255,255,0.1);
}
.bonzer-fb-side-nav:hover {
	background: rgba(255,255,255,0.22);
}
.bonzer-fb-side-nav svg {
	width: 22px;
	height: 22px;
}
.bonzer-fb-side-nav[disabled] {
	opacity: 0.25;
	cursor: not-allowed;
}
/* .bonzer-fb-icon-btn:active sets transform:scale(0.92) for a press
   effect, which — being the same CSS property — was completely replacing
   this button's translateY(-50%) vertical-centering transform (not
   combining with it). That caused the button to visibly snap down by
   half its own height on every press, and very likely also caused the
   unreliable clicks: the button's actual position moving under the
   cursor mid-click. Restoring the centering alongside the press-scale
   fixes both. (Using ".bonzer-fb-icon-btn.bonzer-fb-side-nav:active"
   for specificity — plain ".bonzer-fb-side-nav:active" would tie with
   ".bonzer-fb-icon-btn:active" and the winner would depend on source
   order, which is fragile.) */
.bonzer-fb-icon-btn.bonzer-fb-side-nav:active {
	transform: translateY(-50%) scale(0.92);
}

.bonzer-fb-page-img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	background: #fff;
	display: block;
}

.bonzer-fb-page-shadow {
	background: #fdfdfb;
}

/* Loading state */
.bonzer-fb-loading {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 16px;
	color: #fff;
	background: rgba(16, 10, 31, 0.6);
	z-index: 5;
}
.bonzer-fb-spinner {
	width: 46px;
	height: 46px;
	border-radius: 50%;
	border: 3px solid rgba(255,255,255,0.2);
	border-top-color: var(--bfb-accent, #8a4fff);
	animation: bfb-spin 0.9s linear infinite;
}
@keyframes bfb-spin {
	to { transform: rotate(360deg); }
}
.bonzer-fb-loading-text {
	font-size: 14px;
	opacity: 0.85;
}
.bonzer-fb-progress-track {
	width: 220px;
	height: 5px;
	border-radius: 4px;
	background: rgba(255,255,255,0.15);
	overflow: hidden;
}
.bonzer-fb-progress-bar {
	height: 100%;
	width: 0%;
	background: linear-gradient(90deg, var(--bfb-accent, #8a4fff), var(--bfb-accent-2, #3b82f6));
	transition: width 0.2s ease;
}

.bonzer-fb-error {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	text-align: center;
	padding: 20px;
}

/* Bottom bar: nav arrows + page indicator + thumbnails */
.bonzer-fb-overlay-bottom {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 10px 18px 16px;
}

.bonzer-fb-page-indicator-row {
	display: flex;
	align-items: center;
	justify-content: center;
}

.bonzer-fb-page-indicator {
	color: #fff;
	font-size: 13px;
	min-width: 92px;
	text-align: center;
	font-variant-numeric: tabular-nums;
}
.bonzer-fb-page-indicator input {
	width: 40px;
	text-align: center;
	background: rgba(255,255,255,0.1);
	border: 1px solid rgba(255,255,255,0.25);
	border-radius: 4px;
	color: #fff;
	font-size: 13px;
	padding: 2px 4px;
}

.bonzer-fb-thumbs {
	display: flex;
	gap: 8px;
	overflow-x: auto;
	padding: 6px 4px;
	scrollbar-width: thin;
}
.bonzer-fb-thumbs::-webkit-scrollbar {
	height: 6px;
}
.bonzer-fb-thumbs::-webkit-scrollbar-thumb {
	background: rgba(255,255,255,0.25);
	border-radius: 4px;
}
.bonzer-fb-thumb {
	flex: 0 0 auto;
	width: 42px;
	height: 56px;
	border-radius: 4px;
	overflow: hidden;
	cursor: pointer;
	opacity: 0.55;
	border: 2px solid transparent;
	transition: opacity 0.2s ease, border-color 0.2s ease;
	background: #fff;
}
.bonzer-fb-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
.bonzer-fb-thumb.is-active,
.bonzer-fb-thumb:hover {
	opacity: 1;
	border-color: var(--bfb-accent, #8a4fff);
}

/* Fullscreen tweaks */
.bonzer-fb-overlay:fullscreen,
.bonzer-fb-overlay:-webkit-full-screen {
	background: #100a1f;
}

/* Body lock while reader open */
body.bonzer-fb-lock {
	overflow: hidden;
}

/* ---------- Responsive ---------- */
@media (max-width: 782px) {
	.bonzer-fb-book-title {
		max-width: 50vw;
		font-size: 13px;
	}
	.bonzer-fb-icon-btn {
		width: 34px;
		height: 34px;
	}
	.bonzer-fb-side-nav {
		width: 38px;
		height: 38px;
	}
	.bonzer-fb-side-nav.bfb-prev {
		left: 6px;
	}
	.bonzer-fb-side-nav.bfb-next {
		right: 6px;
	}
}

@media (max-width: 480px) {
	.bonzer-fb-stage {
		padding: 10px 46px 0;
	}
}

@media (max-width: 480px) {
	.bonzer-fb-grid {
		gap: 20px;
	}
	.bonzer-fb-toolbar {
		flex-direction: column;
		align-items: stretch;
	}
	.bonzer-fb-search,
	.bonzer-fb-filter-select {
		max-width: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.bonzer-fb-card-open,
	.bonzer-fb-cover img,
	.bonzer-fb-zoom-pan,
	.bonzer-fb-open-icon {
		transition: none !important;
	}
}
