/* ═══════════════════════════════════════════════════════════════════
 * WP E-Newspaper Pro — Viewer  v1.2.3
 * Clean white background, full-height scrollable paper, title label band
 * ═══════════════════════════════════════════════════════════════════ */

/* ── Design tokens ────────────────────────────────────────────────── */
:root {
	--wenp-dark-bg: #1a1a2e;
	--wenp-dark-card: #16213e;
	--wenp-dark-nav: #0f3460;
	--wenp-accent: #e94560;
	--wenp-text: #eaeaea;
	--wenp-transition: .25s ease;
	--wenp-thumb-w: 150px;
	/* thumbnail sidebar */
	--flip-ms: 480ms;
	/* flip animation    */
}

/* ── Full-width wrapper ───────────────────────────────────────────── */
.wenp-fullwidth-wrap {
	width: 100%;
	box-sizing: border-box;
}

/* ── Outer viewer ────────────────────────────────────────────────── */
.wenp-viewer-wrapper {
	display: flex;
	flex-direction: column;
	width: 100%;
	font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
	box-shadow: 0 4px 24px rgba(0, 0, 0, .15);
	background: #fff;
	color: #222;
	overflow: visible;
}

/* Both themes now use white / light background */
.wenp-theme-dark,
.wenp-theme-light {
	background: #fff;
	color: #222;
}

/* ── Navigation bar ──────────────────────────────────────────────── */
.wenp-nav {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
	padding: 8px 16px;
	background: #0f3460;
}

.wenp-btn {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 6px 14px;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	font-size: .85rem;
	font-weight: 600;
	text-decoration: none;
	background: rgba(255, 255, 255, .14);
	color: #fff;
	transition: background var(--wenp-transition), transform var(--wenp-transition);
}

.wenp-btn:hover:not(:disabled) {
	background: var(--wenp-accent);
	transform: translateY(-1px);
}

.wenp-btn:disabled {
	opacity: .4;
	cursor: not-allowed;
}

.wenp-page-indicator {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: .88rem;
	color: #fff;
}

.wenp-page-input {
	width: 52px;
	text-align: center;
	background: rgba(255, 255, 255, .15);
	border: 1px solid rgba(255, 255, 255, .3);
	border-radius: 4px;
	color: #fff;
	padding: 4px;
	font-size: .88rem;
}

.wenp-zoom-controls {
	display: flex;
	gap: 4px;
}

.wenp-fullscreen {
	margin-left: 6px;
}

.wenp-download {
	color: #fff !important;
}

/* ── Newspaper title inside nav bar (right side) ────────────────── */
.wenp-nav-title {
	margin-left: auto;
	display: flex;
	align-items: center;
	gap: 4px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 340px;
	font-size: .82rem;
	font-weight: 600;
	color: #f0c040;
	letter-spacing: .01em;
}

.wenp-nav-title-text {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.wenp-nav-title-page {
	white-space: nowrap;
	font-weight: 700;
	color: #fff;
	background: rgba(255, 255, 255, .15);
	padding: 2px 7px;
	border-radius: 10px;
	font-size: .78rem;
}

/* ── Page title label band ───────────────────────────────────────── */
/*  Sits between the nav bar and the newspaper body.
    Shows "Newspaper Title — Page N" and optional date + DL link.     */
.wenp-page-label {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 12px;
	padding: 7px 18px;
	background: #ffd700;
	/* golden yellow — distinct label   */
	border-bottom: 2px solid #e6c000;
	font-size: .88rem;
	font-weight: 700;
	color: #111;
	line-height: 1.3;
}

.wenp-page-label-text {
	flex: 1;
	min-width: 0;
}

.wenp-page-label-date {
	font-weight: 600;
	font-size: .8rem;
	color: #555;
	white-space: nowrap;
}

.wenp-label-dl-btn {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 4px 12px;
	background: #0f3460;
	color: #fff !important;
	border-radius: 4px;
	text-decoration: none;
	font-size: .78rem;
	font-weight: 700;
	white-space: nowrap;
	transition: background var(--wenp-transition);
}

.wenp-label-dl-btn:hover {
	background: var(--wenp-accent);
}

/* ═══════════════════════════════════════════════════════════════════
 * Main body — 2-column grid
 *   col 1: thumbnails (--wenp-thumb-w)
 *   col 2: newspaper page (fills remaining space)
 * ═══════════════════════════════════════════════════════════════════ */
.wenp-viewer-body {
	display: grid;
	grid-template-columns: var(--wenp-thumb-w) 1fr;
	align-items: start;
	/* columns start at top, not stretched */
}

/* ── Thumbnail sidebar — limited to viewport height, scrolls ────── */
.wenp-sidebar {
	overflow-y: auto;
	overflow-x: hidden;
	background: #f5f5f5;
	border-right: 1px solid #e0e0e0;
	/* Limit height to the viewport; remaining pages scroll within */
	max-height: 100vh;
	position: sticky;
	top: 0;
	align-self: start;
}

.wenp-sidebar-heading {
	padding: 10px 12px 6px;
	font-size: .73rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .08em;
	color: #888;
}

/* ── Thumbnail strip ─────────────────────────────────────────────── */
.wenp-thumbnails {
	padding: 6px;
}

.wenp-thumb {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 5px 3px;
	cursor: pointer;
	border-radius: 4px;
	transition: background var(--wenp-transition);
	margin-bottom: 3px;
}

.wenp-thumb:hover,
.wenp-thumb-active {
	background: rgba(15, 52, 96, .12);
}

.wenp-thumb img {
	width: 100%;
	max-width: 126px;
	border-radius: 2px;
	display: block;
	border: 1px solid #ddd;
}

.wenp-thumb-num {
	font-size: .68rem;
	color: #888;
	margin-top: 3px;
}

/* ═══════════════════════════════════════════════════════════════════
 * Flipbook stage (centre column)
 *
 * White background. No height constraint — the newspaper image
 * displays at its full natural height and the browser page scrolls.
 * ═══════════════════════════════════════════════════════════════════ */
.wenp-flipbook-stage {
	display: block;
	/* block so content flows naturally  */
	position: relative;
	background: #fff;
	padding: 16px 20px 24px;
	box-sizing: border-box;
	width: 100%;
}

.wenp-side-nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	height: 30mm;
	width: 14mm;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 0;
	background: rgba(15, 52, 96, 0.06);
	color: rgba(15, 52, 96, 0.55);
	cursor: pointer;
	transition: background .2s ease, color .2s ease;
	z-index: 3;
	border-radius: 999px;
}

.wenp-side-nav:hover {
	background: rgba(15, 52, 96, 0.14);
	color: rgba(15, 52, 96, 0.95);
}

.wenp-side-nav .dashicons {
	font-size: 32px;
	width: 32px;
	height: 32px;
}

.wenp-side-nav-prev {
	left: 0;
}

.wenp-side-nav-next {
	right: 0;
}

/* Container wraps the img; no perspective needed for simple scroll mode */
.wenp-single-page {
	width: 100%;
}

/* The newspaper page image — full width, natural (tall) height */
.wenp-page-img {
	display: block;
	width: 100%;
	max-width: 100%;
	height: auto;
	/* Paper-like drop shadow */
	box-shadow: 0 2px 20px rgba(0, 0, 0, .18), 0 1px 4px rgba(0, 0, 0, .08);
	backface-visibility: hidden;
	-webkit-backface-visibility: hidden;
	user-select: none;
	-webkit-user-drag: none;
	transform-origin: center top;
	transition: box-shadow .2s ease;
}

/* Overlay layer */
.wenp-flip-overlay {
	position: absolute;
	inset: 0;
	pointer-events: none;
}

/* ── Under-page ad ────────────────────────────────────────── */
.wenp-under-page-ad {
	max-width: 100%;
	overflow: visible;
}

.wenp-under-page-ad img,
.wenp-under-page-ad iframe,
.wenp-under-page-ad video {
	max-width: 100%;
	height: auto;
	display: block;
	margin: 0 auto;
}

/* ── Footer ad wrappers — allow full-size creatives ────────── */
.wenp-bottom-ad {
	max-width: 100%;
	overflow: visible;
}

/* Ad code wrapper — overflow visible so ads can self-size */
.wenp-ad-code-wrap {
	width: 100%;
	max-width: 100%;
	overflow: visible;
}

.wenp-ad-code-wrap iframe,
.wenp-ad-code-wrap img,
.wenp-ad-code-wrap video,
.wenp-ad-code-wrap embed,
.wenp-ad-code-wrap object,
.wenp-ad-code-wrap ins {
	max-width: none; /* let ad network set its own width */
}

/* Footer slot — allow inline-sizing for fixed ad creatives */
.wenp-bottom-ad .wenp-ad-slot {
	display: inline-block;
	min-width: 0;
	max-width: none;
	overflow: visible;
}

.wenp-bottom-ad .wenp-ad-slot-footer {
	display: inline-block;
	width: max-content;
	max-width: none;
	overflow: visible;
}

.wenp-bottom-ad .wenp-ad-slot-footer .wenp-ad-code-wrap {
	width: max-content;
	max-width: none;
	overflow: visible;
}

.wenp-bottom-ad .wenp-ad-slot-footer iframe,
.wenp-bottom-ad .wenp-ad-slot-footer ins,
.wenp-bottom-ad .wenp-ad-slot-footer object,
.wenp-bottom-ad .wenp-ad-slot-footer embed {
	max-width: none;
	width: auto;
}

/* ═══════════════════════════════════════════════════════════════════
 * Page-turn animations (kept for JS flip effect)
 * ═══════════════════════════════════════════════════════════════════ */
@keyframes wenp-flip-fwd {
	0% {
		transform: rotateY(0deg) skewY(0deg);
		transform-origin: left center;
		opacity: 1;
	}

	20% {
		transform: rotateY(-25deg) skewY(-1.5deg);
		transform-origin: left center;
	}

	50% {
		transform: rotateY(-90deg) skewY(0deg);
		transform-origin: left center;
		opacity: .85;
	}

	80% {
		transform: rotateY(-155deg) skewY(1.5deg);
		transform-origin: left center;
	}

	100% {
		transform: rotateY(-180deg) skewY(0deg);
		transform-origin: left center;
		opacity: 1;
	}
}

@keyframes wenp-flip-bwd {
	0% {
		transform: rotateY(0deg) skewY(0deg);
		transform-origin: right center;
		opacity: 1;
	}

	20% {
		transform: rotateY(25deg) skewY(1.5deg);
		transform-origin: right center;
	}

	50% {
		transform: rotateY(90deg) skewY(0deg);
		transform-origin: right center;
		opacity: .85;
	}

	80% {
		transform: rotateY(155deg) skewY(-1.5deg);
		transform-origin: right center;
	}

	100% {
		transform: rotateY(180deg) skewY(0deg);
		transform-origin: right center;
		opacity: 1;
	}
}

.wenp-flip-fwd {
	animation: wenp-flip-fwd var(--flip-ms) cubic-bezier(.45, 0, .55, 1) forwards;
}

.wenp-flip-bwd {
	animation: wenp-flip-bwd var(--flip-ms) cubic-bezier(.45, 0, .55, 1) forwards;
}

/* ── Zoom levels ─────────────────────────────────────────────────── */
.wenp-viewer-wrapper.wenp-zoomed .wenp-page-img {
	cursor: move;
}

.wenp-zoom-1 .wenp-page-img {
	transform: scale(1);
}

.wenp-zoom-2 .wenp-page-img {
	transform: scale(1.5);
}

.wenp-zoom-3 .wenp-page-img {
	transform: scale(2);
}

.wenp-zoom-4 .wenp-page-img {
	transform: scale(2.5);
}

/* ── Fullscreen — scrollable so user can read the full paper ───── */
.wenp-viewer-wrapper:-webkit-full-screen {
	width: 100vw;
	height: 100vh;
	overflow-y: auto;
	background: #fff;
}

.wenp-viewer-wrapper:-moz-full-screen {
	width: 100vw;
	height: 100vh;
	overflow-y: auto;
	background: #fff;
}

.wenp-viewer-wrapper:fullscreen {
	width: 100vw;
	height: 100vh;
	overflow-y: auto;
	background: #fff;
}

/* In fullscreen the viewer body and stage should NOT restrict height */
.wenp-viewer-wrapper:-webkit-full-screen .wenp-viewer-body,
.wenp-viewer-wrapper:-moz-full-screen .wenp-viewer-body,
.wenp-viewer-wrapper:fullscreen .wenp-viewer-body {
	align-items: start;
}

.wenp-viewer-wrapper:-webkit-full-screen .wenp-flipbook-stage,
.wenp-viewer-wrapper:-moz-full-screen .wenp-flipbook-stage,
.wenp-viewer-wrapper:fullscreen .wenp-flipbook-stage {
	min-height: auto;
	height: auto;
}

/* ── Empty state ─────────────────────────────────────────────────── */
.wenp-no-pages {
	padding: 40px;
	text-align: center;
	opacity: .6;
	font-size: 1.1rem;
}

/* ═══════════════════════════════════════════════════════════════════
 * Theme container overrides — force full width in any WP theme
 * ═══════════════════════════════════════════════════════════════════ */
body.wenp-issue-page .entry-content,
body.wenp-issue-page .post-content,
body.wenp-issue-page .post-body,
body.wenp-issue-page .site-content,
body.wenp-issue-page .site-main,
body.wenp-issue-page .content-area,
body.wenp-issue-page #content,
body.wenp-issue-page #main,
body.wenp-issue-page #primary,
body.wenp-issue-page article,
body.wenp-issue-page article.hentry,
body.wenp-issue-page article.post,
body.wenp-issue-page .container,
body.wenp-issue-page .td-pb-span8,
body.wenp-issue-page .td-ss-main-content,
body.wenp-issue-page .td-container,
body.wenp-issue-page .wp-block-post-content {
	max-width: none !important;
	width: 100% !important;
	padding-left: 0 !important;
	padding-right: 0 !important;
	margin-left: 0 !important;
	margin-right: 0 !important;
	float: none !important;
	box-sizing: border-box !important;
}

/* ═══════════════════════════════════════════════════════════════════
 * Responsive — collapse on narrow screens
 * ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
	.wenp-side-nav {
		height: 24mm;
		width: 12mm;
	}

	.wenp-viewer-body {
		grid-template-columns: 1fr;
	}

	.wenp-sidebar {
		display: none;
	}

	.wenp-nav {
		justify-content: center;
	}

	.wenp-nav-title {
		display: none;
		/* hide on mobile — too narrow */
	}

	.wenp-flipbook-stage {
		padding: 10px 12px 16px;
	}
}

/* ── ePaper Display Page Ad Layout ────────────────────────────────── */
.wenp-display-layout {
	display: flex;
	gap: 16px;
	align-items: flex-start;
}

.wenp-display-main {
	flex: 1;
	min-width: 0;
}

/* Under-page horizontal ad */
.wenp-under-page-ad {
	max-width: 1008px;
	margin: 16px auto;
	text-align: center;
}

.wenp-display-bottom-ads {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 16px;
	margin-top: 20px;
	align-items: flex-start;
	overflow: visible;
}

.wenp-display-bottom-ads .wenp-bottom-ad {
	flex: 0 0 auto;
	min-width: 0; /* let ad creative dictate its own width */
	max-width: none;
	text-align: center;
	overflow: visible;
}

@media (max-width: 900px) {
	.wenp-display-layout {
		flex-direction: column;
	}

	.wenp-display-bottom-ads {
		flex-direction: column;
		align-items: center;
		overflow-x: auto;
	}

	.wenp-display-bottom-ads .wenp-bottom-ad {
		min-width: 0;
		max-width: 100%;
		overflow-x: auto;
	}

	.wenp-bottom-ad .wenp-ad-slot {
		min-width: 0;
		max-width: 100%;
	}

	.wenp-bottom-ad .wenp-ad-code-wrap {
		max-width: 100%;
		overflow-x: auto;
	}

	.wenp-bottom-ad .wenp-ad-slot-footer {
		max-width: 100%;
		overflow-x: auto;
	}

	.wenp-bottom-ad .wenp-ad-slot-footer .wenp-ad-code-wrap {
		max-width: 100%;
		overflow-x: auto;
	}
}

/* ── Ad device visibility ────────────────────────────────────────── */
/* Desktop: > 1024px */
@media (min-width: 1025px) {
	.wenp-hide-desktop {
		display: none !important;
	}
}

/* Tablet: 768–1024px */
@media (min-width: 768px) and (max-width: 1024px) {
	.wenp-hide-tablet {
		display: none !important;
	}
}

/* Mobile: < 768px */
@media (max-width: 767px) {
	.wenp-side-nav {
		height: 20mm;
		width: 10mm;
	}

	.wenp-side-nav .dashicons {
		font-size: 24px;
		width: 24px;
		height: 24px;
	}

	.wenp-hide-mobile {
		display: none !important;
	}
}

/* ═══════════════════════════════════════════════════════════════════
   PAGE LIGHTBOX / ZOOM MODAL
   ═══════════════════════════════════════════════════════════════════ */

/* Make the viewer page image appear clickable */
.wenp-page-img {
	cursor: zoom-in;
}

/* ── Overlay backdrop ─────────────────────────────────────────────── */
.wenp-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	/* Shown/hidden via JS — initial display:none is set inline */
}

.wenp-lightbox-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.88);
	cursor: pointer;
}

/* ── Window ───────────────────────────────────────────────────────── */
.wenp-lightbox-window {
	position: relative;
	z-index: 1;
	width: 94vw;
	height: 94vh;
	max-width: 1400px;
	display: flex;
	flex-direction: column;
	background: #1a1a2e;
	border-radius: 8px;
	overflow: hidden;
	box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
	animation: wenp-lb-pop 0.18s ease-out;
}

@keyframes wenp-lb-pop {
	from { opacity: 0; transform: scale(0.94); }
	to   { opacity: 1; transform: scale(1); }
}

/* ── Header ───────────────────────────────────────────────────────── */
.wenp-lightbox-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 8px 14px;
	background: #12122a;
	border-bottom: 1px solid rgba(255,255,255,.08);
	flex-shrink: 0;
	gap: 12px;
}

.wenp-lb-title {
	font-size: 13px;
	font-weight: 600;
	color: #c8c8e8;
	white-space: nowrap;
}

.wenp-lb-header-controls {
	display: flex;
	align-items: center;
	gap: 4px;
}

.wenp-lb-zoom-pct {
	font-size: 12px;
	color: #a8a8c8;
	min-width: 44px;
	text-align: center;
	font-family: monospace;
}

/* ── Buttons ──────────────────────────────────────────────────────── */
.wenp-lb-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
	background: rgba(255,255,255,.07);
	border: 1px solid rgba(255,255,255,.12);
	border-radius: 6px;
	color: #d0d0f0;
	padding: 5px 9px;
	cursor: pointer;
	font-size: 13px;
	line-height: 1;
	transition: background 0.15s, transform 0.1s;
}

.wenp-lb-btn:hover {
	background: rgba(255,255,255,.16);
	color: #fff;
}

.wenp-lb-btn:active {
	transform: scale(0.93);
}

.wenp-lb-btn.wenp-lb-close {
	background: rgba(220, 50, 50, .2);
	border-color: rgba(220, 50, 50, .35);
	color: #f87171;
}

.wenp-lb-btn.wenp-lb-close:hover {
	background: rgba(220, 50, 50, .4);
	color: #fff;
}

.wenp-lb-btn.wenp-lb-nav {
	padding: 6px 14px;
	gap: 6px;
}

.wenp-lb-btn.wenp-lb-nav:disabled {
	opacity: 0.3;
	cursor: not-allowed;
}

/* ── Scrollable pan canvas ────────────────────────────────────────── */
.wenp-lightbox-canvas {
	flex: 1;
	overflow: auto; /* native scrollbars appear when image is larger than canvas */
	position: relative;
	background: #0f0f20;
	display: flex;
	align-items: flex-start;
	justify-content: flex-start;
	/* Always show scrollbars so user sees pan affordance */
	scrollbar-width: thin;
	scrollbar-color: rgba(255,255,255,.2) transparent;
}

.wenp-lightbox-canvas::-webkit-scrollbar {
	width: 10px;
	height: 10px;
}

.wenp-lightbox-canvas::-webkit-scrollbar-track {
	background: rgba(0,0,0,.3);
}

.wenp-lightbox-canvas::-webkit-scrollbar-thumb {
	background: rgba(255,255,255,.2);
	border-radius: 4px;
}

.wenp-lightbox-canvas::-webkit-scrollbar-corner {
	background: rgba(0,0,0,.3);
}

.wenp-lb-img-wrap {
	display: inline-block; /* shrink-wrap to image so canvas shows scrollbars */
	transition: none;
	cursor: grab;
	padding: 16px;
	box-sizing: content-box;
}

.wenp-lb-img-wrap.wenp-lb-dragging {
	cursor: grabbing;
}

#wenp-lb-img {
	display: block;
	/* Width is set dynamically in JS based on zoom */
	height: auto;
	user-select: none;
	border-radius: 2px;
	box-shadow: 0 4px 24px rgba(0,0,0,.5);
}

/* ── Footer ───────────────────────────────────────────────────────── */
.wenp-lightbox-footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 8px 14px;
	background: #12122a;
	border-top: 1px solid rgba(255,255,255,.08);
	flex-shrink: 0;
}

.wenp-lb-page-counter {
	font-size: 13px;
	color: #a8a8c8;
	font-weight: 600;
}

/* ── Mobile ───────────────────────────────────────────────────────── */
@media (max-width: 600px) {
	.wenp-lightbox-window {
		width: 100vw;
		height: 100vh;
		border-radius: 0;
	}

	.wenp-lb-btn.wenp-lb-nav span:not(.dashicons) {
		display: none;
	}
}

/* ── Viewer page click-to-zoom cursor ───────────────────────── */
/* .wenp-flip-overlay sits on top of the page image and is the
   actual click target. Show zoom-in cursor to signal it's clickable. */
.wenp-flip-overlay {
	cursor: zoom-in;
}
