/* RetroTube Photo Viewer */
:root { --rtpv-accent: #ff3d3d; }

html.rtpv-lock,
html.rtpv-lock body { overflow: hidden !important; }

.rtpv-enabled img:not(.no-viewer):not(.emoji):not(.wp-smiley) { cursor: zoom-in; }

/* ------------------------------------------------------------ overlay */
.rtpv {
	position: fixed;
	inset: 0;
	z-index: 2147483000;
	display: flex;
	flex-direction: column;
	background: rgba(0, 0, 0, var(--rtpv-bg, .96));
	color: #fff;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	opacity: 0;
	transition: opacity .2s ease;
	outline: none;
	-webkit-tap-highlight-color: transparent;
	-webkit-user-select: none;
	user-select: none;
	overscroll-behavior: contain;
}
.rtpv[hidden] { display: none; }
.rtpv.is-open { opacity: 1; }
.rtpv *, .rtpv *::before, .rtpv *::after { box-sizing: border-box; }

/* ------------------------------------------------------------ top bar */
.rtpv-top {
	position: absolute;
	top: 0; left: 0; right: 0;
	z-index: 5;
	display: flex;
	align-items: center;
	gap: 2px;
	padding: calc(env(safe-area-inset-top, 0px) + 8px) 8px 28px;
	background: linear-gradient(rgba(0, 0, 0, .7), transparent);
	pointer-events: none;
	transition: opacity .2s ease, transform .2s ease;
}
.rtpv-top .rtpv-btn { pointer-events: auto; }
.rtpv-count {
	margin-right: auto;
	padding-left: 8px;
	font-size: 14px;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	text-shadow: 0 1px 3px rgba(0, 0, 0, .6);
}
.rtpv--single .rtpv-count { visibility: hidden; }

.rtpv-btn {
	width: 42px;
	height: 42px;
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #fff;
	cursor: pointer;
	transition: background .15s ease, color .15s ease;
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .5));
}
.rtpv-btn svg { width: 22px; height: 22px; display: block; }
.rtpv-btn:hover { background: rgba(255, 255, 255, .16); }
.rtpv-btn:focus-visible { outline: 2px solid var(--rtpv-accent); outline-offset: 1px; }
.rtpv-btn.is-on { color: var(--rtpv-accent); }

.rtpv.hide-ui .rtpv-top { opacity: 0; transform: translateY(-12px); }
.rtpv.hide-ui .rtpv-top .rtpv-btn { pointer-events: none; }
.rtpv.hide-ui .rtpv-bottom { opacity: 0; pointer-events: none; }

/* -------------------------------------------------------------- stage */
.rtpv-stage {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	overflow: hidden;
	touch-action: none;
}
.rtpv-track {
	display: flex;
	width: 100%;
	height: 100%;
	transform: translate3d(-100%, 0, 0);
	transition: transform .3s cubic-bezier(.22, .61, .36, 1);
	will-change: transform;
}
.rtpv.is-dragging .rtpv-track,
.rtpv.is-dragging .rtpv-img,
.rtpv.is-dragging .rtpv-slide { transition: none; }

.rtpv-slide {
	position: relative;
	flex: 0 0 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform .2s ease;
}
.rtpv-img {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	transform-origin: 50% 50%;
	transition: transform .22s ease;
	-webkit-user-drag: none;
	user-select: none;
	pointer-events: auto;
}
.rtpv.is-zoomed .rtpv-img { cursor: grab; }

.rtpv-slide.is-loading::after {
	content: "";
	position: absolute;
	top: 50%; left: 50%;
	width: 34px; height: 34px;
	margin: -17px 0 0 -17px;
	border: 3px solid rgba(255, 255, 255, .25);
	border-top-color: var(--rtpv-accent);
	border-radius: 50%;
	animation: rtpv-spin .8s linear infinite;
	pointer-events: none;
}
@keyframes rtpv-spin { to { transform: rotate(360deg); } }

.rtpv-nav {
	position: absolute;
	top: 50%;
	z-index: 3;
	width: 48px; height: 48px;
	margin-top: -24px;
	background: rgba(0, 0, 0, .45);
}
.rtpv-nav[hidden] { display: none; }
.rtpv-prev { left: 12px; }
.rtpv-next { right: 12px; }
.rtpv--single .rtpv-nav,
.rtpv.is-zoomed .rtpv-nav,
.rtpv.hide-ui .rtpv-nav { display: none; }
@media (pointer: coarse) { .rtpv-nav { display: none; } }
@media (pointer: coarse) { .rtpv-zoom { display: none; } }

/* ------------------------------------------------------------- bottom */
.rtpv-bottom {
	position: relative;
	z-index: 4;
	flex: 0 0 auto;
	background: linear-gradient(transparent, rgba(0, 0, 0, .7) 40%);
	transition: opacity .2s ease;
}
.rtpv-caption {
	max-height: 4.4em;
	overflow: auto;
	padding: 6px 18px 4px;
	text-align: center;
	font-size: 14px;
	line-height: 1.4;
	text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
}
.rtpv-caption[hidden] { display: none; }

.rtpv-thumbs {
	position: relative;
	display: flex;
	gap: 6px;
	overflow-x: auto;
	padding: 8px 10px calc(env(safe-area-inset-bottom, 0px) + 10px);
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
}
.rtpv-thumbs::-webkit-scrollbar { display: none; }
.rtpv-thumbs[hidden] { display: none; }
.rtpv--single .rtpv-thumbs { display: none; }

.rtpv-thumb {
	flex: 0 0 auto;
	width: 56px;
	height: 56px;
	margin: 0;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 7px;
	background: #1c1c1c;
	overflow: hidden;
	opacity: .55;
	cursor: pointer;
	transition: opacity .15s ease, border-color .15s ease, transform .15s ease;
}
.rtpv-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.rtpv-thumb:hover { opacity: .85; }
.rtpv-thumb.is-active { opacity: 1; border-color: var(--rtpv-accent); transform: scale(1.06); }
.rtpv-thumb:focus-visible { outline: 2px solid #fff; }

@media (min-width: 768px) {
	.rtpv-thumb { width: 68px; height: 68px; }
}

/* ---------------------------------------------------------- grid view */
.rtpv-gridview {
	position: absolute;
	inset: 0;
	z-index: 4;
	display: none;
	background: #0b0b0b;
	overflow: auto;
	padding: calc(env(safe-area-inset-top, 0px) + 64px) 6px calc(env(safe-area-inset-bottom, 0px) + 16px);
}
.rtpv.show-grid .rtpv-gridview {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
	gap: 4px;
	align-content: start;
}
.rtpv-gitem {
	position: relative;
	aspect-ratio: 1;
	margin: 0;
	padding: 0;
	border: 2px solid transparent;
	background: #1c1c1c;
	overflow: hidden;
	cursor: pointer;
}
.rtpv-gitem img { display: block; width: 100%; height: 100%; object-fit: cover; }
.rtpv-gitem.is-active { border-color: var(--rtpv-accent); }
.rtpv-gitem:focus-visible { outline: 2px solid #fff; }

/* -------------------------------------------------------------- toast */
.rtpv-toast {
	position: absolute;
	left: 50%;
	bottom: 120px;
	z-index: 8;
	max-width: 80%;
	padding: 8px 16px;
	border-radius: 999px;
	background: rgba(30, 30, 30, .95);
	font-size: 13px;
	opacity: 0;
	transform: translateX(-50%) translateY(8px);
	transition: opacity .2s ease, transform .2s ease;
	pointer-events: none;
	word-break: break-all;
}
.rtpv-toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ----------------------------------------- [rtpv_gallery] square grid */
.rtpv-gallery {
	display: grid;
	grid-template-columns: repeat(var(--rtpv-cols, 4), 1fr);
	gap: 6px;
	margin: 1.2em 0;
}
.rtpv-gallery .rtpv-gi {
	display: block;
	aspect-ratio: 1;
	overflow: hidden;
	border-radius: 6px;
	background: #1c1c1c;
}
.rtpv-gallery .rtpv-gi img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform .25s ease;
}
.rtpv-gallery .rtpv-gi:hover img { transform: scale(1.05); }
@media (max-width: 600px) {
	.rtpv-gallery { grid-template-columns: repeat(var(--rtpv-cols-m, 3), 1fr); gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
	.rtpv, .rtpv-track, .rtpv-img, .rtpv-slide, .rtpv-top, .rtpv-bottom, .rtpv-toast { transition: none !important; }
	.rtpv-slide.is-loading::after { animation-duration: 2s; }
}

/* ------------------------------------------------------- pagination */
.rtpv-hide { display: none !important; }

.rtpv-pager {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 6px;
	margin: 24px 0;
	clear: both;
}
.rtpv-pg {
	min-width: 40px;
	height: 40px;
	margin: 0;
	padding: 0 14px;
	border: 1px solid rgba(128, 128, 128, .45);
	border-radius: 8px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
	transition: border-color .15s ease, background .15s ease;
}
.rtpv-pg:hover:not([disabled]) { border-color: var(--rtpv-accent); }
.rtpv-pg.is-active { background: var(--rtpv-accent); border-color: var(--rtpv-accent); color: #fff; cursor: default; }
.rtpv-pg[disabled] { opacity: .4; cursor: default; }
.rtpv-pg:focus-visible { outline: 2px solid var(--rtpv-accent); outline-offset: 2px; }
.rtpv-pg-gap { padding: 0 2px; opacity: .7; }
.rtpv-pg-info { flex-basis: 100%; text-align: center; font-size: 13px; opacity: .75; }
.rtpv-more { padding: 0 22px; }
