/* -------------------------------------------------------------------------
   Magazine Viewer - front-end styles (shelf + fullscreen reader).
------------------------------------------------------------------------- */

/* ---- Shelf ------------------------------------------------------------- */

.mv-shelf {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
	gap: 24px;
	margin: 0;
}

.mv-shelf__item {
	appearance: none;
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 0;
	margin: 0;
	border: 0;
	background: none;
	text-align: left;
	color: inherit;
	cursor: pointer;
	font-family: inherit;
}

.mv-shelf__cover {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 3 / 4;
	border-radius: 6px;
	overflow: hidden;
	background: #eef1f6;
	box-shadow: 0 8px 22px rgba(10, 14, 24, 0.16);
	transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.mv-shelf__cover img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: top center;
	display: block;
}

.mv-shelf__placeholder {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	font-size: 14px;
	letter-spacing: 0.08em;
	color: #6d7480;
	text-transform: uppercase;
}

.mv-shelf__badge {
	position: absolute;
	right: 8px;
	bottom: 8px;
	background: rgba(10, 12, 18, 0.82);
	color: #fff;
	font-size: 12px;
	line-height: 1;
	padding: 4px 7px;
	border-radius: 4px;
}

.mv-shelf__badge span {
	font-size: 10px;
	opacity: 0.75;
}

.mv-shelf__title {
	font-size: 15px;
	font-weight: 600;
	line-height: 1.3;
	-webkit-line-clamp: 2;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.mv-shelf__item:hover .mv-shelf__cover,
.mv-shelf__item:focus-visible .mv-shelf__cover {
	transform: translateY(-4px);
	box-shadow: 0 14px 30px rgba(10, 14, 24, 0.24);
}

.mv-shelf__item:focus-visible {
	outline: 2px solid var(--wp--preset--color--accent, #2271b1);
	outline-offset: 4px;
}

/* ---- Fullscreen reader overlay ---------------------------------------- */

.mv-viewer {
	position: fixed;
	inset: 0;
	z-index: 999999;
	background: #0d0d14;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.22s ease, visibility 0.22s ease;
}

.mv-viewer.is-open {
	opacity: 1;
	visibility: visible;
}

.mv-toolbar {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 16px;
	background: #16161f;
	color: #eef1f6;
	-webkit-user-select: none;
	user-select: none;
	flex: 0 0 auto;
}

.mv-toolbar__title {
	flex: 1 1 auto;
	font-size: 15px;
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.mv-toolbar__progress {
	flex: 0 0 auto;
	font-size: 12px;
	color: #9aa0ad;
	white-space: nowrap;
}

.mv-btn {
	appearance: none;
	font: inherit;
	line-height: 1;
	border: 1px solid #34344a;
	background: #232332;
	color: #f0f2f7;
	border-radius: 8px;
	cursor: pointer;
	padding: 9px 14px;
	font-size: 15px;
	transition: background 0.15s ease, border-color 0.15s ease;
}

.mv-btn:hover,
.mv-btn:focus-visible {
	background: #33334a;
	border-color: #4a4a68;
}

.mv-btn--close {
	font-size: 18px;
	padding: 7px 13px;
}

.mv-page-indicator {
	font-variant-numeric: tabular-nums;
	font-size: 13px;
	color: #b8bcc8;
	min-width: 60px;
	text-align: center;
}

.mv-stage {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

.mv-book {
	position: relative;
	margin: 0 auto;
}

.mv-book .flip-book-page,
.stf__parent {
	margin: 0 auto;
}

/* A single page. Initially empty, filled lazily as PDF.js renders */
.mv-page {
	position: relative;
	overflow: hidden;
	background: #fff;
}

/* Spinner shown on pages that are still being rendered */
.mv-page:empty::before {
	content: "";
	position: absolute;
	inset: 0;
	margin: auto;
	width: 26px;
	height: 26px;
	border: 2px solid rgba(0, 0, 0, 0.12);
	border-top-color: #2271b1;
	border-radius: 50%;
	animation: mv-spin 0.8s linear infinite;
}

.mv-page img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
	background: #fff;
}

.mv-loading {
	position: absolute;
	inset: 0;
	z-index: 6;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #dfe3ec;
	font-size: 14px;
	gap: 10px;
}

.mv-viewer.is-ready .mv-loading {
	display: none;
}

.mv-spinner {
	width: 18px;
	height: 18px;
	border: 2px solid rgba(255, 255, 255, 0.25);
	border-top-color: #fff;
	border-radius: 50%;
	animation: mv-spin 0.8s linear infinite;
}

@keyframes mv-spin {
	to {
		transform: rotate(360deg);
	}
}

/* ---- Responsive tweaks ------------------------------------------------ */

@media (max-width: 600px) {
	.mv-shelf {
		gap: 16px;
		grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
	}

	.mv-toolbar {
		padding: 8px 10px;
		gap: 8px;
	}

	.mv-btn {
		padding: 8px 11px;
	}
}