/* ============================================================
   Project Image Gallery – Frontend Shortcode Styles
   ============================================================ */

/* ── CSS custom properties ──────────────────────────────────── */
:root {
	--pig-radius: 3px;
	--pig-aspect: 3 / 2;          /* uniform cell aspect ratio */
	--pig-caption-bg: rgba(0, 0, 0, .55);
	--pig-caption-blur: 4px;
	--pig-modal-bg: rgba(10, 10, 12, .96);
	--pig-modal-radius: 4px;
	--pig-accent: #fff;
	--pig-nav-size: 48px;
	--pig-transition: 220ms cubic-bezier(.4, 0, .2, 1);
}

/* ── Wrapper ────────────────────────────────────────────────── */
.pig-sc-wrap {
	width: 100%;
}

/* ── Grid ───────────────────────────────────────────────────── */
.pig-sc-grid {
	display: grid;
	grid-template-columns: repeat( 2, 1fr ); /* fallback; overridden by inline style */
	width: 100%;
}

@media (max-width: 600px) {
	.pig-sc-grid {
		grid-template-columns: 1fr !important;
	}
}

/* ── Group header (group mode – project title above each grid) ── */
.pig-sc-group + .pig-sc-group {
	margin-top: 32px;
}

/* ── Image cell ─────────────────────────────────────────────── */
.pig-sc-cell {
	position: relative;
	aspect-ratio: var(--pig-aspect);
	overflow: hidden;
	border-radius: var(--pig-radius);
	cursor: pointer;
	margin: 0;         /* reset figure margin */
	background: #1a1a1a;

	/* Stagger fade-in on load */
	opacity: 0;
	animation: pig-cell-in var(--pig-transition) forwards;
}

/* Stagger up to 24 cells; JS resets for infinite pagination */
.pig-sc-cell:nth-child(1)  { animation-delay:   0ms; }
.pig-sc-cell:nth-child(2)  { animation-delay:  20ms; }
.pig-sc-cell:nth-child(3)  { animation-delay:  40ms; }
.pig-sc-cell:nth-child(4)  { animation-delay:  55ms; }
.pig-sc-cell:nth-child(5)  { animation-delay:  70ms; }
.pig-sc-cell:nth-child(6)  { animation-delay:  80ms; }
.pig-sc-cell:nth-child(7)  { animation-delay:  90ms; }
.pig-sc-cell:nth-child(8)  { animation-delay: 100ms; }
.pig-sc-cell:nth-child(9)  { animation-delay: 110ms; }
.pig-sc-cell:nth-child(10) { animation-delay: 120ms; }
.pig-sc-cell:nth-child(n+11) { animation-delay: 130ms; }

@keyframes pig-cell-in {
	from { opacity: 0; transform: scale(.97); }
	to   { opacity: 1; transform: scale(1);   }
}

.pig-sc-cell img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 400ms cubic-bezier(.25, .46, .45, .94);
	pointer-events: none;
	user-select: none;
}

.pig-sc-cell:hover img,
.pig-sc-cell:focus-visible img {
	transform: scale(1.055);
}

.pig-sc-cell:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

/* ── Caption (always visible, bottom-left box, fit-content width) ── */
.pig-sc-caption {
	position: absolute;
	bottom: 15px;
	left: 0;

	/* Shrink-wrap to text but enforce a minimum */
	display: inline-block;
	width: auto;
	min-width: 250px;
	max-width: 100%;

	padding: 5px 10px;
	background: rgba(0, 0, 0, 0.62);
	backdrop-filter: blur( 4px );
	-webkit-backdrop-filter: blur( 4px );
	border-radius: 2px;

	/* No hover transition needed — always visible */
	pointer-events: none;
}

.pig-sc-caption span {
	display: block;
	font-family: system-ui, sans-serif;
	font-size: clamp( 10px, 1.1vw, 13px );
	font-weight: 500;
	letter-spacing: .03em;
	color: #fff;
	text-shadow: 0 1px 2px rgba(0,0,0,.4);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ── Pagination ─────────────────────────────────────────────── */
.pig-sc-pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 20px;
	margin-top: 28px;
	padding: 4px 0;
}

.pig-sc-page-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	border: 2px solid currentColor;
	color: #333;
	text-decoration: none;
	font-size: 18px;
	line-height: 1;
	transition: background var(--pig-transition), color var(--pig-transition);
}

.pig-sc-page-btn:hover {
	background: #111;
	color: #fff;
}

.pig-sc-page-count {
	font-family: system-ui, sans-serif;
	font-size: 14px;
	letter-spacing: .05em;
	color: #555;
}

/* ── Empty state ────────────────────────────────────────────── */
.pig-sc-empty {
	color: #888;
	font-style: italic;
	text-align: center;
	padding: 40px 0;
}

/* ============================================================
   Lightbox Modal
   ============================================================ */

.pig-modal {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
}

.pig-modal[hidden] {
	display: none;
}

/* Backdrop */
.pig-modal__backdrop {
	position: absolute;
	inset: 0;
	background: var(--pig-modal-bg);
	cursor: pointer;
}

/* Inner layout */
.pig-modal__inner {
	position: relative;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	width: 100%;
	height: 100%;
	padding: 16px;
	box-sizing: border-box;
}

/* Stage */
.pig-modal__stage {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	flex: 1;
	max-width: min(90vw, 1200px);
	max-height: 90vh;
}

/* Main image */
.pig-modal__img {
	display: block;
	max-width: 100%;
	max-height: 84vh;
	object-fit: contain;
	border-radius: var(--pig-modal-radius);
	opacity: 0;
	transition: opacity 250ms ease;
	user-select: none;
	-webkit-user-drag: none;
}

.pig-modal__img.pig-is-loaded {
	opacity: 1;
}

/* Title */
.pig-modal__title {
	margin: 10px 0 0;
	font-family: system-ui, sans-serif;
	font-size: 13px;
	letter-spacing: .06em;
	color: rgba(255,255,255,.65);
	text-align: center;
	min-height: 1.4em;
	text-transform: uppercase;
}

/* Loader spinner */
.pig-modal__loader {
	position: absolute;
	width: 36px;
	height: 36px;
	border: 3px solid rgba(255,255,255,.15);
	border-top-color: rgba(255,255,255,.75);
	border-radius: 50%;
	animation: pig-spin 0.7s linear infinite;
	opacity: 0;
	transition: opacity 150ms;
}

.pig-modal__loader.pig-is-loading {
	opacity: 1;
}

@keyframes pig-spin {
	to { transform: rotate(360deg); }
}

/* Close button */
.pig-modal__close {
	position: absolute;
	top: 16px;
	right: 16px;
	z-index: 10;
	background: rgba(255,255,255,.08);
	border: none;
	border-radius: 50%;
	width: 40px;
	height: 40px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	color: #fff;
	transition: background var(--pig-transition), transform var(--pig-transition);
	padding: 0;
}

.pig-modal__close:hover {
	background: rgba(255,255,255,.18);
	transform: rotate(90deg);
}

.pig-modal__close svg {
	width: 18px;
	height: 18px;
}

/* Nav buttons */
.pig-modal__nav {
	flex-shrink: 0;
	background: rgba(255,255,255,.06);
	border: none;
	border-radius: 50%;
	width: var(--pig-nav-size);
	height: var(--pig-nav-size);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	color: #fff;
	transition: background var(--pig-transition), transform var(--pig-transition);
	padding: 0;
}

.pig-modal__nav:hover {
	background: rgba(255,255,255,.16);
}

.pig-modal__nav:active {
	transform: scale(.92);
}

.pig-modal__nav--prev:hover { transform: translateX(-2px); }
.pig-modal__nav--next:hover { transform: translateX(2px);  }

.pig-modal__nav svg {
	width: 24px;
	height: 24px;
}

.pig-modal__nav[disabled] {
	opacity: .25;
	cursor: default;
	pointer-events: none;
}

/* Modal open animation */
@keyframes pig-modal-in {
	from { opacity: 0; transform: scale(.96); }
	to   { opacity: 1; transform: scale(1); }
}

.pig-modal:not([hidden]) .pig-modal__inner {
	animation: pig-modal-in 180ms cubic-bezier(.4,0,.2,1) forwards;
}

/* ── Touch / small screen adjustments ──────────────────────── */
@media (max-width: 600px) {
	.pig-modal__nav {
		--pig-nav-size: 36px;
	}
	.pig-modal__inner {
		gap: 6px;
		padding: 10px;
	}
	.pig-modal__img {
		max-height: 76vh;
	}
}

/* ============================================================
   Gallery type  (type="gallery")
   ============================================================ */

/* ── Outer wrapper ──────────────────────────────────────────── */
.pig-sc-wrap--gallery {
	display: grid;
	grid-template-columns: 1fr 160px;  /* hero fluid | strip fixed */
	align-items: stretch;              /* both columns same height */
	gap: var(--pig-gallery-gap, 30px);
	height: 100%;
	max-height: 100%;
	overflow: hidden;
}

/* ── Hero column ────────────────────────────────────────────── */
.pig-gallery__hero {
	min-width: 0;
	min-height: 0;
	position: relative;
	overflow: hidden;
}

/* Inner wrapper is what we position the caption against */
.pig-gallery__hero-inner {
	position: relative;
	width: 100%;
	height: 100%;
	line-height: 0;
}

.pig-gallery__hero-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: opacity 250ms ease;
	cursor: pointer;
}

.pig-gallery__hero-img.pig-hero-loading {
	opacity: 0;
}

/* Hero caption – positioned inside .pig-gallery__hero-inner which is relative */
.pig-gallery__hero-caption {
	position: absolute;
	bottom: 15px;
	left: 0;
	display: inline-block;
	width: auto;
	min-width: 250px;
	max-width: 100%;
	padding: 5px 10px;
	background: rgba(0, 0, 0, 0.62);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	border-radius: 0 2px 2px 0;
	pointer-events: none;
	z-index: 2;
}

.pig-gallery__hero-caption span {
	display: block;
	line-height: 1.4;
	font-family: system-ui, sans-serif;
	font-size: clamp(11px, 1.2vw, 15px);
	font-weight: 500;
	letter-spacing: .03em;
	color: #fff;
	text-shadow: 0 1px 2px rgba(0,0,0,.4);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ── Thumbnail strip column ─────────────────────────────────── */
.pig-gallery__strip {
	/* Stretch to hero height via grid align-items:stretch */
	min-width: 0;
	overflow: hidden;   /* clip the scrollable inner */
}

/* Scrollable thumbs list — height driven by parent (hero) */
.pig-gallery__thumbs {
	display: flex;
	flex-direction: column;
	height: 100%;
	overflow-y: auto;
	scrollbar-width: thin;
	scrollbar-color: rgba(0,0,0,.2) transparent;
	gap: var(--pig-gallery-gap, 30px);
}

.pig-gallery__thumbs::-webkit-scrollbar {
	width: 4px;
}

.pig-gallery__thumbs::-webkit-scrollbar-thumb {
	background: rgba(0,0,0,.25);
	border-radius: 2px;
}

/* ── Individual thumbnail ────────────────────────────────────── */
.pig-gallery__thumb {
	position: relative;
	margin: 0;
	overflow: hidden;
	cursor: pointer;
	flex: 0 0 auto;   /* natural size, no stretching */
	line-height: 0;
	outline: 3px solid transparent;
	outline-offset: -3px;
	transition: outline-color 150ms ease, opacity 150ms ease;
}

.pig-gallery__thumb img {
	display: block;
	width: 160px;
	height: 100px;
	object-fit: cover;
	pointer-events: none;
	user-select: none;
}

.pig-gallery__thumb:hover {
	opacity: .82;
}

.pig-gallery__thumb.is-active {
	outline-color: #fff;
}

.pig-gallery__thumb:focus-visible {
	outline-color: #2271b1;
}

/* ── Mobile: stack thumbs below hero ────────────────────────── */
@media (max-width: 700px) {
	.pig-sc-wrap--gallery {
		grid-template-columns: 1fr;
		grid-template-rows: auto auto;
	}

	.pig-gallery__strip {
		width: 100%;
		height: 100px;
		overflow: hidden;
	}

	.pig-gallery__thumbs {
		flex-direction: row;
		height: 100%;
		overflow-x: auto;
		overflow-y: hidden;
	}

	.pig-gallery__thumb img {
		width: 140px;
		height: 100px;
	}
}
