/* Photo Gallery RB — lightbox (inside <pgrb-lightbox>'s shadow root). */

:host {
	position: fixed;
	inset: 0;
	z-index: 2147483000;
	opacity: 0;
	transition: opacity .25s ease;
	font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
:host(.open) { opacity: 1; }
:host(.closing) { opacity: 0; }
*, *::before, *::after { box-sizing: border-box; }

.lb {
	--bg: rgba(12, 12, 14, .96);
	--fg: #f5f5f7;
	--muted: rgba(245, 245, 247, .62);
	--btn: rgba(255, 255, 255, .08);
	--btn-hover: rgba(255, 255, 255, .18);
	--accent: #fff;
	position: absolute;
	inset: 0;
	display: grid;
	grid-template-rows: auto minmax(0, 1fr) auto auto;
	background: var(--bg);
	color: var(--fg);
	-webkit-user-select: none;
	user-select: none;
}
.lb.theme-light {
	--bg: rgba(250, 250, 252, .97);
	--fg: #1d1d1f;
	--muted: rgba(29, 29, 31, .6);
	--btn: rgba(0, 0, 0, .05);
	--btn-hover: rgba(0, 0, 0, .12);
	--accent: #1d1d1f;
}

/* toolbar */
.top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 12px 14px;
	position: relative;
	z-index: 5;
}
.counter { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; padding-left: 6px; }
.tools { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tool, .nav {
	display: inline-grid;
	place-items: center;
	width: 42px;
	height: 42px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--btn);
	color: var(--fg);
	cursor: pointer;
	text-decoration: none;
	transition: background-color .2s, transform .2s, opacity .2s;
}
.tool:hover, .nav:hover { background: var(--btn-hover); }
.tool:focus-visible, .nav:focus-visible, .thumbs button:focus-visible, .share-menu button:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}
.tool.on { background: var(--fg); color: var(--bg); }
.tool:disabled { opacity: .3; cursor: default; }
.tool[hidden] { display: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.share-menu {
	position: absolute;
	z-index: 6;
	top: 62px;
	right: 14px;
	display: flex;
	flex-direction: column;
	min-width: 190px;
	padding: 6px;
	border-radius: 12px;
	background: var(--fg);
	box-shadow: 0 16px 40px rgba(0, 0, 0, .35);
}
.share-menu[hidden] { display: none; }
.share-menu button {
	padding: 10px 14px;
	border: 0;
	border-radius: 8px;
	background: none;
	color: var(--bg);
	font: inherit;
	text-align: left;
	cursor: pointer;
}
.share-menu button:hover { background: rgba(127, 127, 127, .18); }

/* stage */
.stage {
	position: relative;
	min-height: 0;
	touch-action: none;
}
.slides { position: absolute; inset: 0 70px; }
.slide {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	opacity: 0;
	transition: opacity .35s ease, transform .35s ease;
}
.slide.from-right { transform: translate3d(60px, 0, 0); }
.slide.from-left { transform: translate3d(-60px, 0, 0); }
.slide.in { opacity: 1; transform: none; }
.slide.out { opacity: 0; pointer-events: none; }
.slide.out.to-left { transform: translate3d(-60px, 0, 0); }
.slide.out.to-right { transform: translate3d(60px, 0, 0); }
.slide img {
	grid-area: 1 / 1;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: 4px;
	cursor: zoom-in;
	transition: transform .3s ease, opacity .3s ease, filter .3s ease;
	-webkit-user-drag: none;
}
.slide img.ph {
	filter: blur(14px);
	opacity: .7;
}
.slide img.full { position: relative; opacity: 0; }
.slide.loaded img.full { opacity: 1; }
.slide.loaded img.ph { opacity: 0; }
.slide:not(.loaded)::after {
	content: "";
	grid-area: 1 / 1;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	border: 3px solid var(--btn-hover);
	border-top-color: var(--fg);
	animation: spin .8s linear infinite;
}
.slide.is-video::after { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.zoomed .slide img.full { cursor: grab; transition: transform .25s ease; }
.zoomed .slide img.full:active { cursor: grabbing; transition: none; }
.zoomed .nav, .zoomed .bottom, .zoomed .thumbs { opacity: 0; pointer-events: none; }

.frame {
	width: min(100%, calc((100vh - 220px) * 16 / 9));
	aspect-ratio: 16 / 9;
	background: #000;
	border-radius: 6px;
	overflow: hidden;
}
.frame iframe, .frame video { display: block; width: 100%; height: 100%; border: 0; }

.nav {
	position: absolute;
	z-index: 4;
	top: 50%;
	width: 50px;
	height: 50px;
	margin-top: -25px;
}
.nav.prev { left: 12px; }
.nav.next { right: 12px; }

/* caption */
.bottom {
	min-height: 18px;
	padding: 10px 24px 14px;
	text-align: center;
	transition: opacity .2s;
}
.no-text .bottom { padding: 0; min-height: 10px; }
.text { max-width: 780px; margin: 0 auto; -webkit-user-select: text; user-select: text; }
.title { font-weight: 600; font-size: 16px; }
.caption { color: var(--muted); margin-top: 2px; }
.caption:empty, .title:empty { display: none; }
.credit { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; text-decoration: none; }
.credit[href]:hover { color: var(--fg); text-decoration: underline; }
.credit[hidden] { display: none; }
.exif {
	margin-top: 8px;
	display: inline-block;
	padding: 5px 12px;
	border-radius: 999px;
	background: var(--btn);
	color: var(--muted);
	font-size: 13px;
	font-variant-numeric: tabular-nums;
}
.exif[hidden] { display: none; }

/* thumbnails */
.thumbs {
	display: flex;
	gap: 6px;
	padding: 0 14px 14px;
	overflow-x: auto;
	scrollbar-width: none;
	justify-content: safe center;
	transition: opacity .2s;
}
.thumbs::-webkit-scrollbar { display: none; }
.thumbs button {
	position: relative;
	flex: 0 0 auto;
	width: 64px;
	height: 46px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 6px;
	overflow: hidden;
	background: var(--btn);
	cursor: pointer;
	opacity: .5;
	transition: opacity .2s, border-color .2s;
}
.thumbs button:hover { opacity: .85; }
.thumbs button.on { opacity: 1; border-color: var(--accent); }
.thumbs img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumbs .v::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	margin: -6px 0 0 -4px;
	border-style: solid;
	border-width: 6px 0 6px 10px;
	border-color: transparent transparent transparent #fff;
	filter: drop-shadow(0 0 2px rgba(0, 0, 0, .6));
}

/* slideshow progress */
.progress { position: absolute; left: 0; right: 0; top: 0; height: 3px; pointer-events: none; }
.progress i { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: 0 50%; opacity: 0; }
.playing .progress i { opacity: .8; }

.toast {
	position: absolute;
	left: 50%;
	bottom: 90px;
	padding: 9px 16px;
	border-radius: 999px;
	background: var(--fg);
	color: var(--bg);
	font-size: 14px;
	opacity: 0;
	transform: translate(-50%, 10px);
	transition: opacity .2s, transform .2s;
	pointer-events: none;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 700px) {
	.slides { inset: 0; }
	.nav { display: none; }
	.tool { width: 38px; height: 38px; }
	.top { padding: 8px; }
	.tools { gap: 4px; }
	.frame { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after, :host { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}
