﻿.pdf-viewer-wrap {
	margin: 24px 0;
}

.pdf-viewer-card {
	width: min( 100%, 460px );
	border: 0;
	padding: 0;
	background: none;
	border-radius: 0;
	cursor: pointer;
	text-align: left;
	perspective: 900px;
}

/* ── Book-open keyframes ──
   Each page fans out to a progressively wider angle, mimicking
   pages spreading from the spine as a book opens.
   Four separate keyframes so each page lands at its own angle.
   No z-index changes mid-animation = zero flicker. */


/* ── Book cover media container ── */
.pdf-viewer-card__media {
	display: block;
	position: relative;
	aspect-ratio: 4 / 4.8;
	background: linear-gradient( 135deg, #dbeafe, #e2e8f0 );
	border-radius: 3px 6px 6px 3px;
	overflow: visible;
	transform-origin: left center;
	transition: transform 400ms cubic-bezier( 0.23, 1, 0.32, 1 ),
	            box-shadow 400ms cubic-bezier( 0.23, 1, 0.32, 1 );
	width: 100%;
}

/* ── Animated page layers ── */
.pdf-viewer-card__page {
	position: absolute;
	inset: 2px;
	border-radius: 2px 5px 5px 2px;
	transform-origin: left center;
	will-change: transform, opacity;
	pointer-events: none;
	transition: transform 400ms cubic-bezier( 0.22, 1, 0.36, 1 ),
	            opacity   200ms ease;
}

/* Hidden at rest — only appear on hover */
.pdf-viewer-card__page--1 { background: #eef0f3; right: -4px;  box-shadow: 2px 0 3px rgba( 0,0,0,0.10 ); z-index: 4; opacity: 0; }
.pdf-viewer-card__page--2 { background: #e8eaee; right: -8px;  box-shadow: 2px 0 3px rgba( 0,0,0,0.08 ); z-index: 3; opacity: 0; }
.pdf-viewer-card__page--3 { background: #e2e4e9; right: -13px; box-shadow: 2px 0 3px rgba( 0,0,0,0.06 ); z-index: 2; opacity: 0; }

/* ── Cover image / placeholder — always on top of pages ── */
.pdf-viewer-card__media img,
.pdf-viewer-card__placeholder {
	position: relative;
	z-index: 5;
}

.pdf-viewer-card__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	border-radius: 3px 6px 6px 3px;
}

/* ── Hover title overlay ── */
.pdf-viewer-card__media-overlay {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	padding: 32px 12px 14px;
	background: linear-gradient( to top, rgba( 15, 23, 42, 0.75 ), transparent );
	color: #fff;
	font-size: 0.88rem;
	font-weight: 600;
	line-height: 1.3;
	border-radius: 0 0 6px 3px;
	opacity: 0;
	transition: opacity 300ms ease;
	pointer-events: none;
	word-break: break-word;
	z-index: 6;
}

/* ── Hover state: cover tilts open ── */
.pdf-viewer-card:hover .pdf-viewer-card__media,
.pdf-viewer-card:focus-visible .pdf-viewer-card__media {
	transform: rotateY( -16deg );
	box-shadow:
		6px  4px  12px rgba( 0, 0, 0, 0.28 ),
		14px 6px  12px rgba( 0, 0, 0, 0.14 ),
		20px 8px  12px rgba( 0, 0, 0, 0.08 ),
		26px 10px 12px rgba( 0, 0, 0, 0.04 );
}

/* Book-open: pages fan to their target angle and stay there while hovered */
.pdf-viewer-card:hover .pdf-viewer-card__page,
.pdf-viewer-card:focus-visible .pdf-viewer-card__page {
	opacity: 1;
	right: -12px;
}

.pdf-viewer-card:hover .pdf-viewer-card__page--1,
.pdf-viewer-card:focus-visible .pdf-viewer-card__page--1 {
	transform: rotateY(13deg) rotateZ(0);
    transition-delay: 60ms;
    right: -7px;
}
.pdf-viewer-card:hover .pdf-viewer-card__page--2,
.pdf-viewer-card:focus-visible .pdf-viewer-card__page--2 {
	transform: rotateY(-14deg) rotateZ(0);
    transition-delay: 120ms;
    right: -12px;
}

.pdf-viewer-card:hover .pdf-viewer-card__media-overlay,
.pdf-viewer-card:focus-visible .pdf-viewer-card__media-overlay {
	opacity: 1;
}

/* ── Placeholder (no thumbnail) ── */
.pdf-viewer-card__placeholder {
	display: grid;
	place-items: center;
	width: 100%;
	height: 100%;
	font-size: 2rem;
	font-weight: 700;
	color: #0f172a;
	border-radius: 3px 6px 6px 3px;
}

.pdf-viewer-card__content {
	display: block;
	padding: 10px 0 5px;
}

.pdf-viewer-card__title {
	display: block;
	font-size: 1rem;
	font-weight: 500;
	color: #0f172a;
	text-transform: capitalize;
}

.pdf-viewer-card__description {
	display: block;
	margin-top: 8px;
	color: #475569;
	line-height: 1.5;
}

.pdf-viewer-modal {
	position: fixed;
	inset: 0;
	z-index: 99999;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 220ms ease, visibility 0s linear 220ms;
}

.pdf-viewer-modal.is-visible,
.pdf-viewer-modal.is-closing {
	visibility: visible;
	transition-delay: 0s;
}

.pdf-viewer-modal.is-visible {
	opacity: 1;
	pointer-events: auto;
	z-index: 99999999;
}

.pdf-viewer-modal[hidden] {
	display: none;
}

.pdf-viewer-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba( 15, 23, 42, 0.56 );
	backdrop-filter: blur( 8px );
	opacity: 0;
	transition: opacity 220ms ease;
}

.pdf-viewer-modal__dialog {
	position: relative;
	width: min( 96vw, 1400px );
	height: min( 92vh, 1000px );
	margin: 4vh auto;
	background: #fff;
	border-radius: 18px;
	overflow: hidden;
	box-shadow: 0 30px 80px rgba( 15, 23, 42, 0.3 );
	opacity: 0;
	transform: translateY( 18px ) scale( 0.985 );
	transition: opacity 220ms ease, transform 220ms ease;
}

.pdf-viewer-modal.is-visible .pdf-viewer-modal__backdrop {
	opacity: 1;
}

.pdf-viewer-modal.is-visible .pdf-viewer-modal__dialog {
	opacity: 1;
	transform: translateY( 0 ) scale( 1 );
}

.pdf-viewer-modal__close {
	position: absolute;
	top: 9px;
	right: 14px;
	z-index: 5;
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background: #ffffff;
	color: #0f172a;
	font-size: 28px;
	cursor: pointer;
}

.pdf-viewer-modal__close svg {
	width: 18px;
	height: 18px;
}


.pdf-viewer {
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100%;
	background: #f8fafc;
	overflow: hidden;
}

.pdf-viewer__toolbar {
	display: flex;
	gap: 8px;
	align-items: center;
	flex-wrap: wrap;
	padding: 8px 68px 8px 12px;
	background: #ffffff;
	color: #0f172a;
	border-bottom: 1px solid #d9e2ec;
	position: sticky;
	top: 0;
	z-index: 4;
}

.pdf-viewer__page-nav {
	display: inline-flex;
	align-items: center;
	padding: 4px;
	border-radius: 16px;
	box-shadow: inset 0 1px 0 rgba( 255, 255, 255, 0.9 );
}

.pdf-viewer__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 36px;
	padding: 0 12px;
	border-radius: 10px;
	background: #ffffff;
	color: #0f172a;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.pdf-viewer__btn:hover,
.pdf-viewer__btn:focus-visible, .pdf-viewer-modal__close:hover,
.pdf-viewer-modal__close:focus-visible {
	background: #f8fafc;
	border-color: #b8c7d9;
	box-shadow: 0 0 0 3px rgba( 37, 99, 235, 0.08 );
	outline: none;
}

.pdf-viewer__btn--icon {
	width: 30px;
	padding: 0;
	border-radius: 12px;
}

.pdf-viewer__btn--icon svg {
	width: 18px;
	height: 18px;
}

.pdf-viewer__search {
	display: flex;
	flex-direction: column;
	gap: 6px;
	align-items: stretch;
	margin-left: auto;
}

.pdf-viewer__search-main {
	display: flex;
	align-items: center;
	justify-content: flex-end;
}

.pdf-viewer__search-field {
	position: relative;
	min-width: 360px;
	flex: 1;
}

.pdf-viewer__search-input {
	width: 100%;
	min-width: 0;
	padding: 8px 10px;
	padding-right: 160px;
	border: 1px solid #d9e2ec;
	border-radius: 10px;
	background: #ffffff;
	color: #0f172a;
}

.pdf-viewer__search-input::placeholder {
	color: #64748b;
}

.pdf-viewer__search-status,
.pdf-viewer__page-status {
	font-size: 0.9rem;
}

.pdf-viewer__page-status {
	display: inline-flex;
	align-items: baseline;
	gap: 6px;
	padding: 0 6px;
	font-weight: 700;
	letter-spacing: 0.02em;
	color: #0f172a;
}

.pdf-viewer__search-status {
	position: absolute;
	top: 50%;
	right: 92px;
	transform: translateY( -50% );
	color: #475569;
	font-size: 0.85rem;
	pointer-events: none;
}

.pdf-viewer__search-btn {
	position: absolute;
	top: 50%;
	transform: translateY( -50% );
	width: 32px;
	height: 32px;
	min-height: 32px;
	border-radius: 8px;
}

.pdf-viewer__search-btn[data-action="search-prev"] {
	right: 48px;
}

.pdf-viewer__search-btn[data-action="search-next"] {
	right: 10px;
}

.pdf-viewer__page-divider {
	color: #94a3b8;
}

.pdf-viewer__body {
	flex: 1;
	min-height: 0;
	overflow: auto;
	padding: 20px;
}

.pdf-viewer__pages {
	display: grid;
	gap: 20px;
	justify-items: center;
}

.pdf-viewer__page {
	position: relative;
	width: 100%;
	display: flex;
	justify-content: center;
}

.pdf-viewer__page-canvas-wrap {
	position: relative;
	box-shadow: 0 18px 40px rgba( 15, 23, 42, 0.12 );
	background: #fff;
	/*overflow: hidden;*/
}

.pdf-viewer__page canvas {
	display: block;
}

.pdf-viewer__text-layer,
.pdf-viewer__search-layer {
	position: absolute;
	inset: 0;
}

.pdf-viewer__text-layer {
	overflow: hidden;
	line-height: 1;
	text-size-adjust: none;
	transform-origin: 0 0;
	z-index: 2;
	forced-color-adjust: none;
	text-align: initial;
}

.pdf-viewer__text-layer :is( span, br ) {
	position: absolute;
	white-space: pre;
	transform-origin: 0 0;
	color: transparent;
	cursor: text;
	margin: 0;
}

.pdf-viewer__text-layer ::selection {
	background: rgba( 37, 99, 235, 0.28 );
}

.pdf-viewer__text-layer .markedContent {
	top: 0;
	height: 0;
}

.pdf-viewer__search-layer {
	z-index: 3;
	pointer-events: none;
}

.pdf-viewer__highlight {
	position: absolute;
	background: rgba( 250, 204, 21, 0.35 );
	pointer-events: none;
}

.pdf-viewer__loading {
	text-align: center;
	padding: 40px;
	color: #475569;
}

.pdf-viewer-modal-open {
	overflow: hidden;
}

@media ( max-width: 782px ) {
	.pdf-viewer-modal__dialog {
		width: 100vw;
		height: 100vh;
		margin: 0;
		border-radius: 0;
	}

	.pdf-viewer__toolbar {
		align-items: stretch;
	}

	.pdf-viewer__search {
		width: 100%;
		margin-left: 0;
	}

	.pdf-viewer__search-main {
		width: 100%;
	}

	.pdf-viewer__search-field {
		min-width: 0;
	}

	.pdf-viewer__search-input {
		padding-right: 144px;
	}
}

/* ==========================================================================
   Category grid  [pdf_viewer_category slug="..."]
   Fixed-width cards that wrap naturally — no column classes needed.
   ========================================================================== */

.pdf-viewer-category-grid {
	display: flex;
	flex-wrap: wrap;
	gap: 20px;
	margin: 24px 0;
}

/* Each card slot has a fixed width; the flex layout handles the rest */
.pdf-viewer-category-grid .pdf-viewer-wrap {
	margin: 0;
	flex: 0 0 var( --pv-card-width, 220px );   /* honour shortcode card_width attr */
	width: var( --pv-card-width, 220px );
	min-width: 0;
}

.pdf-viewer-category-grid .pdf-viewer-card {
	width: 100%;           /* fill the 220 px slot */
}

/* ── Responsive ── */

/* Narrow containers / phones: two cards per row minimum */
@media ( max-width: 540px ) {
	.pdf-viewer-category-grid .pdf-viewer-wrap {
		flex: 1 1 calc( 50% - 10px );   /* at least 2 per row */
		max-width: calc( 50% - 10px );
	}
}

/* Very small phones: single column */
@media ( max-width: 320px ) {
	.pdf-viewer-category-grid .pdf-viewer-wrap {
		flex: 1 1 100%;
		max-width: 100%;
	}
}

/* ── Book effect: respect reduced-motion preference ── */
@media ( prefers-reduced-motion: reduce ) {
	.pdf-viewer-card__media {
		transition: none;
	}
	.pdf-viewer-card:hover .pdf-viewer-card__media,
	.pdf-viewer-card:focus-visible .pdf-viewer-card__media {
		transform: none;
		box-shadow:
			3px 0 5px rgba( 0, 0, 0, 0.22 ),
			6px 0 5px rgba( 0, 0, 0, 0.10 );
	}
	.pdf-viewer-card__page {
		transition: none !important;
	}
	.pdf-viewer-card__media-overlay {
		transition: none;
	}
}