/* Imam & Science. — PDF book reader (page images, swipe or scroll, zoom) */
html, body.is-pdf { height: 100%; overflow: hidden; overscroll-behavior: none; }
body.is-pdf { background: var(--bg-alt); }
.pv { position: fixed; inset: 0; display: block; }
.pv__top, .pv__bot { position: absolute; left: 0; right: 0; z-index: 20; display: flex; align-items: center; gap: 4px; padding: 6px 8px; background: var(--bar); -webkit-backdrop-filter: saturate(1.8) blur(20px); backdrop-filter: saturate(1.8) blur(20px); transition: transform .45s var(--spring), opacity .3s; }
.pv__top { top: 0; padding-top: calc(6px + env(safe-area-inset-top)); border-bottom: .5px solid var(--hair-2); }
.pv__bot { bottom: 0; padding-bottom: calc(6px + env(safe-area-inset-bottom)); border-top: .5px solid var(--hair-2); }
.pv.is-bare .pv__top { transform: translateY(-110%); opacity: 0; }
.pv.is-bare .pv__bot { transform: translateY(110%); opacity: 0; }
.pv__title { flex: 1; min-width: 0; text-align: center; line-height: 1.2; }
.pv__title strong { display: block; font-size: 15px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv__title span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pv__aa { width: auto; padding: 0 12px; font-weight: 750; font-size: 16px; color: var(--ink); background: var(--fill); border-radius: 999px; height: 36px; }
.pv__scrub { flex: 1; display: flex; align-items: center; padding: 0 8px; }
.pv__scrub input { width: 100%; accent-color: var(--green); height: 28px; }
.pv__view { position: absolute; inset: 0; overflow: hidden; outline: none; touch-action: none; }

/* pages mode */
.pv__track { position: absolute; top: 0; bottom: 0; left: 0; display: flex; will-change: transform; }
.pv__track.is-anim { transition: transform .42s var(--spring); }
.slide { position: relative; flex: none; height: 100%; display: flex; align-items: center; justify-content: center; gap: 2px; padding: calc(58px + env(safe-area-inset-top)) 10px calc(58px + env(safe-area-inset-bottom)); overflow: hidden; }
.pv.is-bare .slide { padding-top: calc(10px + env(safe-area-inset-top)); padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.slide__z { display: flex; align-items: center; justify-content: center; gap: 2px; max-width: 100%; max-height: 100%; transform-origin: 0 0; will-change: transform; }
.pgx { position: relative; background: #fff; box-shadow: 0 0 0 .5px rgba(0,0,0,.08), 0 6px 24px -10px rgba(0,0,0,.3); flex: none; }
.pgx img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.pgx:has(img)::before { display: none; }
.pgx::before { content: attr(data-n); position: absolute; inset: 0; display: grid; place-items: center; color: #bbb; font-size: 13px; font-weight: 700; }

/* scroll mode */
.pv.is-scroll .pv__view { overflow: auto; touch-action: auto; -webkit-overflow-scrolling: touch; }
.pv__list { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: calc(64px + env(safe-area-inset-top)) 8px calc(72px + env(safe-area-inset-bottom)); width: max-content; min-width: 100%; }
.pv__list .pgx { width: var(--pw); }

/* themes for the page images */
[data-mode="paper"] .pgx { background: #f6ecd6; }
[data-mode="paper"] .pgx img { filter: sepia(.28) saturate(1.1) brightness(.97); mix-blend-mode: multiply; }
[data-mode="gray"] .pgx { background: #4a4a4c; }
[data-mode="gray"] .pgx img { filter: invert(.86) hue-rotate(180deg) contrast(.92); }
[data-mode="dark"] .pgx { background: #121212; }
[data-mode="dark"] .pgx img { filter: invert(.92) hue-rotate(180deg) contrast(.9) brightness(.92); }
.pv.no-invert .pgx img { filter: none !important; mix-blend-mode: normal !important; }

/* thumbnails & lists */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 12px 10px; padding: 4px 2px 10px; }
.thumbs button { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; font-weight: 650; color: var(--muted); font-variant-numeric: tabular-nums; }
.thumbs .t { width: 100%; background: #fff; border-radius: 4px; overflow: hidden; box-shadow: 0 0 0 .5px var(--hair-2); }
.thumbs .t img { width: 100%; height: 100%; object-fit: cover; }
.thumbs button.is-cur .t { box-shadow: 0 0 0 2.5px var(--green); }
.thumbs button.is-cur { color: var(--green-ink); }
.fbar--pdf { flex-wrap: wrap; top: calc(8px + env(safe-area-inset-top)); max-height: 70vh; }
.fbar__res { flex: 1 0 100%; max-height: 52vh; overflow-y: auto; padding: 0 2px 4px; }
.fbar__res:empty { display: none; }
.fbar__res button { display: block; width: 100%; text-align: left; padding: 10px; border-radius: 12px; font-size: 14px; color: var(--muted); }
.fbar__res button:hover { background: var(--fill); }
.fbar__res b { color: var(--ink); margin-right: 6px; }
.fbar__res mark { background: rgba(255,204,0,.45); color: inherit; border-radius: 3px; }
.fbar__res p { padding: 12px; color: var(--muted); font-size: 14px; }
[data-desktop-only] { display: none; }
@media (min-width: 900px) and (orientation: landscape) { [data-desktop-only] { display: flex; } }
.pv .toasts { top: calc(64px + env(safe-area-inset-top)); }
.pv .sheet { z-index: 96; }

/* Pages drawn live from the PDF: a soft shimmer until the page appears */
.pgx img.is-drawing, .thumbs img[data-thumb]:not([src]) { background: linear-gradient(100deg, #f4f4f2 30%, #ffffff 50%, #f4f4f2 70%) 0 0 / 300% 100%; animation: pgShimmer 1.4s linear infinite; }
.thumbs img[data-thumb] { display: block; width: 100%; height: 100%; object-fit: cover; }
@keyframes pgShimmer { to { background-position: -150% 0; } }
@media (prefers-reduced-motion: reduce) { .pgx img.is-drawing { animation: none; } }

/* PDF loading bar & center indicator ------------------------------------- */
.pv__bar {
	position: absolute;
	left: 0;
	right: 0;
	bottom: -2.5px;
	height: 3px;
	background: transparent;
	overflow: hidden;
	pointer-events: none;
	opacity: 0;
	transition: opacity .25s ease;
	z-index: 30;
}
.pv__bar.is-loading,
.pv:not(.is-ready) .pv__bar,
.pv.is-busy .pv__bar {
	opacity: 1;
}
.pv__bar span {
	display: block;
	height: 100%;
	width: 45%;
	background: linear-gradient(90deg, transparent, var(--green, #10b981) 35%, #34d399 70%, transparent);
	border-radius: 999px;
	box-shadow: 0 0 10px rgba(16, 185, 129, .65);
	animation: pvBarSlide 1.15s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes pvBarSlide {
	0% { transform: translateX(-100%) scaleX(0.6); }
	50% { transform: translateX(110%) scaleX(1.1); }
	100% { transform: translateX(280%) scaleX(0.6); }
}

.pv__loader {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 16px;
	z-index: 15;
	pointer-events: none;
	opacity: 1;
	transition: opacity .35s ease, transform .35s ease;
	background: var(--bg-alt);
}
.pv.is-ready .pv__loader {
	opacity: 0;
	transform: scale(0.96);
	pointer-events: none;
}
.pv__spinner {
	width: 44px;
	height: 44px;
	border: 3.5px solid var(--fill-2, rgba(0, 0, 0, .08));
	border-top-color: var(--green, #10b981);
	border-right-color: var(--green, #10b981);
	border-radius: 50%;
	animation: pvSpin .85s cubic-bezier(0.5, 0.1, 0.5, 0.9) infinite;
	box-shadow: 0 4px 20px -4px rgba(16, 185, 129, .25);
}
.pv__loader-t {
	font-size: 14px;
	font-weight: 650;
	color: var(--muted, #8e8e93);
	letter-spacing: -.01em;
	display: flex;
	align-items: center;
	gap: 6px;
}
@keyframes pvSpin {
	to { transform: rotate(360deg); }
}

/* Bottom bar: sleek minimalist floating reader pill ----------------------- */
.pv__bot {
	left: 50%;
	right: auto;
	bottom: calc(16px + env(safe-area-inset-bottom));
	width: auto;
	max-width: calc(100% - 24px);
	height: 48px;
	padding: 4px 6px;
	gap: 4px;
	background: var(--bar);
	-webkit-backdrop-filter: saturate(1.8) blur(24px);
	backdrop-filter: saturate(1.8) blur(24px);
	border: 0.5px solid var(--hair-2);
	border-radius: 999px;
	box-shadow: 0 12px 36px -10px rgba(0, 0, 0, .35), 0 2px 8px rgba(0, 0, 0, .08);
	transform: translateX(-50%);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	z-index: 25;
	transition: transform .4s var(--spring), opacity .3s ease;
}
.pv.is-bare .pv__bot {
	transform: translate(-50%, calc(100% + 36px));
	opacity: 0;
	pointer-events: none;
}
.pv__bot .iconbtn {
	flex: none;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	color: var(--ink);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background-color .15s ease, transform .12s ease, color .15s ease;
}
.pv__bot .iconbtn:hover {
	background: var(--fill);
}
.pv__bot .iconbtn:active {
	transform: scale(0.92);
}
.pv__bot .pvb__mark[aria-pressed="true"] {
	color: var(--green);
}
.pv__bot .pvb__nav {
	color: var(--ink);
}

.pv__pg {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 38px;
	padding: 0 16px;
	border-radius: 999px;
	background: var(--fill);
	color: var(--ink);
	font-size: 13.5px;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	line-height: 1;
	border: 0.5px solid var(--hair-2);
	cursor: pointer;
	user-select: none;
	white-space: nowrap;
	transition: background-color .15s ease, transform .12s ease, border-color .15s ease;
}
.pv__pg:hover {
	background: var(--fill-2);
	border-color: var(--hair-3);
}
.pv__pg:active {
	transform: scale(0.96);
}
.pv__pg span {
	display: inline-flex;
	align-items: center;
	font-weight: 700;
	color: var(--ink);
	line-height: 1;
}

/* Mobile adjustments (clean, spacious, thumb-friendly) */
@media (max-width: 600px) {
	.pv__bot {
		width: auto;
		max-width: calc(100% - 16px);
		bottom: calc(12px + env(safe-area-inset-bottom));
		height: 44px;
		padding: 3px 5px;
		gap: 3px;
	}
	.pv__bot .pvb__mark,
	.pv__bot .pvb__dl {
		display: none;
	}
	.pv__bot .iconbtn {
		width: 36px;
		height: 36px;
	}
	.pv__pg {
		height: 36px;
		padding: 0 14px;
		font-size: 13px;
	}
}

/* Custom page colour from Reader settings -------------------------------- */
.pv.is-custom .pgx { background: var(--page-bg); }
.pv.is-custom[data-custom="light"] .pgx img { filter: none; mix-blend-mode: multiply; }
.pv.is-custom[data-custom="dark"] .pgx img { filter: invert(1) hue-rotate(180deg); mix-blend-mode: screen; }
.pv.is-custom.no-invert .pgx img { filter: none !important; mix-blend-mode: normal !important; }
