/* Gallery positioning belongs to the original slide; loops use Kadence's link. */
.ai-image-labels-gallery-slide {
	position: relative;
}

.ai-image-labels-badge {
	position: absolute;
	left: 0.65rem;
	bottom: 0.65rem;
	z-index: 2;
	box-sizing: border-box;
	max-width: calc(100% - 1.3rem);
	padding: 0.3rem 0.5rem;
	border: 1px solid #d8ddda;
	border-radius: 0.25rem;
	background: #f5f5f3;
	color: #243138;
	font-size: 0.75rem;
	font-weight: 500;
	line-height: 1.35;
	white-space: normal;
	pointer-events: none;
}

/* Reserve Kadence's 32px thumbnail overlap plus the existing gallery inset. */
.ai-image-labels-gallery-slide--kadence .ai-image-labels-badge {
	bottom: calc(32px + 0.65rem);
}

@media (max-width: 480px) {
	.ai-image-labels-badge {
		left: 0.4rem;
		bottom: 0.4rem;
		max-width: calc(100% - 0.8rem);
		padding: 0.25rem 0.4rem;
	}
}

/* Content figures retain their native sizing, links and captions. */
.ai-image-labels-content-image {
	position: relative;
}

.ai-image-labels-content-image > .ai-image-labels-badge {
	top: 0.65rem;
	bottom: auto;
}

@media (max-width: 480px) {
	.ai-image-labels-content-image > .ai-image-labels-badge {
		top: 0.4rem;
	}
}

/* A text row is the safe fallback for tight gallery tiles and older browsers. */
.ai-image-labels-content-image--gallery > .ai-image-labels-badge {
	position: relative;
	top: auto;
	bottom: auto;
	left: auto;
	align-self: flex-start;
	flex: 0 0 auto;
	max-width: 100%;
	margin: 0 0 0.4rem;
}

@supports (container-type: inline-size) {
	.ai-image-labels-content-image--gallery {
		container-type: inline-size;
	}

	.ai-image-labels-content-image--gallery > .ai-image-labels-badge {
		position: absolute;
		top: 0.65rem;
		left: 0.65rem;
		max-width: calc(100% - 1.3rem);
		margin: 0;
	}

	@media (max-width: 480px) {
		.ai-image-labels-content-image--gallery > .ai-image-labels-badge {
			top: 0.4rem;
			left: 0.4rem;
			max-width: calc(100% - 0.8rem);
		}
	}

	@container (max-width: 22rem) {
		.ai-image-labels-content-image--gallery > .ai-image-labels-badge {
			position: relative;
			top: auto;
			left: auto;
			max-width: 100%;
			margin: 0 0 0.4rem;
		}
	}
}

/* WPC owns sizing and slider wrappers; only the active native slide is marked. */
.ai-image-labels-quick-view-slide {
	position: relative;
}

.ai-image-labels-quick-view-slide > .ai-image-labels-quick-view-badge {
	top: 0.65rem;
	bottom: auto;
}

@media (max-width: 480px) {
	.ai-image-labels-quick-view-slide > .ai-image-labels-quick-view-badge {
		top: 0.4rem;
	}
}

/* PhotoSwipe renders captions as text; preserve the separate AI-label line. */
.ai-image-labels-photoswipe .pswp__caption__center {
	white-space: pre-line;
	overflow-wrap: anywhere;
}
