/* ── PhotoCNX Public Gallery ─────────────────────────────────────── */

.pcnx-pub-gallery {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 3px;
	width: 100%;
	max-width: 1200px;
	margin: 0 auto;
}

/* ── Item ── */
.pcnx-pg-item {
	position: relative;
	aspect-ratio: 4 / 5;
	overflow: hidden;
	background: #ece8e0;
	cursor: pointer;
	-webkit-user-select: none;
	user-select: none;
}

/* fade-in on load */
.pcnx-pg-hidden  { opacity: 0; }
.pcnx-pg-visible { opacity: 1; transition: opacity .4s ease; }

.pcnx-pg-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	pointer-events: none;
	-webkit-user-drag: none;
	user-drag: none;
}

/* hover dim */
.pcnx-pg-item::after {
	content: '';
	position: absolute;
	inset: 0;
	background: rgba(0,0,0,0);
	transition: background .2s ease;
	pointer-events: none;
}
.pcnx-pg-item:hover::after { background: rgba(0,0,0,.12); }

/* ── Watermark overlay ── */
.pcnx-pg-wm {
	position: absolute;
	inset: 0;
	pointer-events: none;
	background-repeat: no-repeat;
	background-position: 96% 96%;
	background-size: 30%;
}

/* ── Skeleton loader ── */
.pcnx-pg-skeleton {
	aspect-ratio: 4 / 5;
	background: linear-gradient(
		90deg,
		#e2ddd6 25%,
		#ece8e0 50%,
		#e2ddd6 75%
	);
	background-size: 300% 100%;
	animation: pgShimmer 1.6s ease infinite;
}

@keyframes pgShimmer {
	0%   { background-position: 100% 0; }
	100% { background-position: -100% 0; }
}

/* ── Bottom spinner (แสดงระหว่างโหลด) ── */
.pcnx-pub-spinner {
	display: none; /* ซ่อนก่อน — JS เปิด */
	justify-content: center;
	align-items: center;
	gap: 10px;
	padding: 24px;
	color: #a09890;
	font-size: 13px;
}

.pcnx-pub-spinner svg {
	animation: pgSpin .9s linear infinite;
	flex-shrink: 0;
}

@keyframes pgSpin {
	to { transform: rotate(360deg); }
}

/* ── Sentinel ── */
.pcnx-pub-sentinel { height: 1px; }

/* ── End ── */
.pcnx-pub-end {
	text-align: center;
	color: #b0ada5;
	padding: 28px;
	font-size: 13px;
	grid-column: 1 / -1;
	letter-spacing: .5px;
}

/* ════════════════════════════════════════════════════════════════ */
/* ── Lightbox ── */
/* ════════════════════════════════════════════════════════════════ */

.pcnx-pub-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
}
.pcnx-pub-lightbox[aria-hidden="true"] { display: none; }

.pcnx-lb-overlay {
	position: absolute;
	inset: 0;
	background: rgba(0,0,0,.9);
}

.pcnx-lb-inner {
	position: relative;
	z-index: 1;
	max-height: 92dvh;
	display: flex;
	align-items: center;
	justify-content: center;
}

.pcnx-lb-img-wrap {
	position: relative;
	-webkit-user-select: none;
	user-select: none;
}

.pcnx-lb-img {
	display: block;
	max-height: 92dvh;
	max-width: 90vw;
	width: auto;
	height: auto;
	pointer-events: none;
	-webkit-user-drag: none;
	user-drag: none;
	border-radius: 4px;
	transition: opacity .25s ease;
}

/* Spinner inside lightbox */
.pcnx-lb-spinner {
	position: absolute;
	inset: 0;
	display: none;
	align-items: center;
	justify-content: center;
	z-index: 2;
}

.pcnx-lb-spinner svg {
	animation: pgSpin .9s linear infinite;
	opacity: .7;
}

.pcnx-lb-wm {
	position: absolute;
	inset: 0;
	pointer-events: none;
	background-repeat: no-repeat;
	background-position: 96% 96%;
	background-size: 30%;
}

/* ── Nav buttons ── */
.pcnx-lb-close,
.pcnx-lb-prev,
.pcnx-lb-next {
	position: absolute;
	z-index: 2;
	background: rgba(255,255,255,.15);
	backdrop-filter: blur(4px);
	color: #fff;
	border: none;
	border-radius: 50%;
	cursor: pointer;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background .15s, transform .15s;
}
.pcnx-lb-close:hover,
.pcnx-lb-prev:hover,
.pcnx-lb-next:hover { background: rgba(255,255,255,.28); transform: scale(1.08); }

.pcnx-lb-close { top:14px; right:14px; width:40px; height:40px; font-size:18px; }
.pcnx-lb-prev, .pcnx-lb-next { top:50%; transform:translateY(-50%); width:48px; height:48px; font-size:28px; }
.pcnx-lb-prev { left:12px; }
.pcnx-lb-next { right:12px; }
.pcnx-lb-prev:hover, .pcnx-lb-next:hover { transform:translateY(-50%) scale(1.08); }
.pcnx-lb-prev:disabled, .pcnx-lb-next:disabled { opacity:.25; cursor:default; transform:translateY(-50%); }

/* ── Responsive ── */
@media (max-width:640px) {
	.pcnx-pub-gallery {
		grid-template-columns: repeat(2, 1fr);
		gap: 2px;
	}
	.pcnx-lb-prev { left:4px; }
	.pcnx-lb-next { right:4px; }
}
