/* ==========================================================================
   Gallery — Before/After Masonry Grid + Lightbox Comparison
   FliserRent 1.2.0
   ========================================================================== */

/* ---------- Masonry Grid ---------- */

.gallery-masonry {
	columns: 3 320px;
	column-gap: 1.25rem;
}

.gallery-card {
	break-inside: avoid;
	margin-bottom: 1.25rem;
	border-radius: 8px;
	overflow: hidden;
	background: var(--card-bg, #fff);
	box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
	cursor: pointer;
	transition: transform .2s ease, box-shadow .2s ease;
	position: relative;
}

.gallery-card:hover,
.gallery-card:focus-within {
	transform: translateY(-3px);
	box-shadow: 0 6px 20px rgba(0, 0, 0, .12);
}

.gallery-card:focus {
	outline: 3px solid var(--primary, hsl(171, 100%, 41%));
	outline-offset: 2px;
}

/* Thumbnail container — show the "after" image with a before/after badge */
.gallery-card__thumb {
	position: relative;
	overflow: hidden;
	aspect-ratio: 4 / 3;
	background: var(--skeleton-bg, #f0f0f0);
}

.gallery-card__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: opacity .3s ease;
}

.gallery-card__thumb img[data-src] {
	opacity: 0;
}

.gallery-card__thumb img.loaded {
	opacity: 1;
}

/* Hover: reveal the "before" image */
.gallery-card__before-overlay {
	position: absolute;
	inset: 0;
	opacity: 0;
	transition: opacity .35s ease;
}

.gallery-card__before-overlay img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.gallery-card:hover .gallery-card__before-overlay {
	opacity: 1;
}

/* Badge */
.gallery-card__badge {
	position: absolute;
	top: .75rem;
	left: .75rem;
	display: flex;
	gap: .35rem;
	z-index: 2;
	pointer-events: none;
}

.gallery-card__badge .tag {
	font-size: .7rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .03em;
}

/* Hover hint */
.gallery-card__hint {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	padding: .5rem;
	background: linear-gradient(transparent, rgba(0,0,0,.6));
	color: #fff;
	font-size: .75rem;
	text-align: center;
	opacity: 0;
	transition: opacity .25s ease;
	pointer-events: none;
}

.gallery-card:hover .gallery-card__hint {
	opacity: 1;
}

/* Card info */
.gallery-card__info {
	padding: .75rem 1rem;
}

.gallery-card__caption {
	font-weight: 600;
	font-size: .95rem;
	margin-bottom: .25rem;
	color: var(--text-color, #363636);
}

.gallery-card__meta {
	font-size: .8rem;
	color: var(--text-muted, #7a7a7a);
}

/* ---------- Filters ---------- */

.gallery-filters .button.gallery-filter {
	margin-bottom: .5rem;
}

.gallery-filters .button.gallery-filter:not(.is-active) {
	background: var(--card-bg, #fff);
	color: var(--text-color, #363636);
	border-color: var(--border-color, #dbdbdb);
}

/* ---------- Lightbox ---------- */

.gallery-lightbox {
	position: fixed;
	inset: 0;
	z-index: 9999;
	background: rgba(0, 0, 0, .92);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 2rem;
	animation: gallery-fade-in .25s ease;
}

@keyframes gallery-fade-in {
	from { opacity: 0; }
	to   { opacity: 1; }
}

.gallery-lightbox__close {
	position: absolute;
	top: 1rem;
	right: 1rem;
	background: none;
	border: none;
	color: #fff;
	cursor: pointer;
	z-index: 10;
	opacity: .7;
	transition: opacity .2s;
}

.gallery-lightbox__close:hover { opacity: 1; }

.gallery-lightbox__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	background: none;
	border: none;
	color: #fff;
	cursor: pointer;
	z-index: 10;
	opacity: .6;
	transition: opacity .2s;
	padding: 1rem;
}

.gallery-lightbox__nav:hover { opacity: 1; }
.gallery-lightbox__prev { left: .5rem; }
.gallery-lightbox__next { right: .5rem; }

.gallery-lightbox__content {
	max-width: 900px;
	width: 100%;
}

/* ---------- Comparison Slider ---------- */

.gallery-comparison {
	position: relative;
	user-select: none;
	-webkit-user-select: none;
}

.gallery-comparison__wrapper {
	position: relative;
	overflow: hidden;
	border-radius: 8px;
	background: #111;
	aspect-ratio: 4 / 3;
}

.gallery-comparison__after {
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
}

.gallery-comparison__before-clip {
	position: absolute;
	inset: 0;
	width: 50%;
	overflow: hidden;
}

.gallery-comparison__before {
	width: 100%;
	height: 100%;
	object-fit: contain;
	/* Match the after image dimensions exactly */
	position: absolute;
	top: 0;
	left: 0;
}

/* Make before image fill same size as wrapper, not the clip */
.gallery-comparison__before-clip img {
	width: var(--comparison-width, 100%);
	min-width: var(--comparison-width, 100%);
	max-width: none;
}

.gallery-comparison__slider {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 50%;
	width: 4px;
	background: #fff;
	cursor: ew-resize;
	z-index: 5;
	transform: translateX(-50%);
}

.gallery-comparison__handle {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
	color: var(--primary, hsl(171, 100%, 41%));
	font-size: 1rem;
}

.gallery-comparison__labels {
	display: flex;
	justify-content: space-between;
	margin-top: .75rem;
}

/* ---------- Dark Mode ---------- */

[data-theme="dark"] .gallery-card,
.dark-mode .gallery-card {
	--card-bg: #1e1e1e;
	--text-color: #e0e0e0;
	--text-muted: #999;
	--border-color: #444;
	--skeleton-bg: #2a2a2a;
	box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
}

[data-theme="dark"] .gallery-card:hover,
.dark-mode .gallery-card:hover {
	box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
}

[data-theme="dark"] .gallery-filters .button.gallery-filter:not(.is-active),
.dark-mode .gallery-filters .button.gallery-filter:not(.is-active) {
	--card-bg: #2a2a2a;
	--text-color: #e0e0e0;
	--border-color: #555;
}

/* ---------- Responsive ---------- */

@media (max-width: 768px) {
	.gallery-masonry {
		columns: 1;
	}

	.gallery-lightbox {
		padding: 1rem;
	}

	.gallery-lightbox__nav {
		padding: .5rem;
	}

	.gallery-comparison__wrapper {
		aspect-ratio: auto;
	}
}

@media (min-width: 769px) and (max-width: 1023px) {
	.gallery-masonry {
		columns: 2;
	}
}

/* ---------- Skeleton Loader ---------- */

.gallery-card--skeleton .gallery-card__thumb {
	background: linear-gradient(90deg, var(--skeleton-bg, #f0f0f0) 25%, #e0e0e0 50%, var(--skeleton-bg, #f0f0f0) 75%);
	background-size: 200% 100%;
	animation: skeleton-shimmer 1.5s infinite;
}

@keyframes skeleton-shimmer {
	0%   { background-position: 200% 0; }
	100% { background-position: -200% 0; }
}

.gallery-card--skeleton .gallery-card__info {
	padding: 1rem;
}

.gallery-card--skeleton .skeleton-line {
	height: .8rem;
	border-radius: 4px;
	background: var(--skeleton-bg, #f0f0f0);
	margin-bottom: .5rem;
}

.gallery-card--skeleton .skeleton-line:last-child {
	width: 60%;
}
