/**
 * AI Image Marking - theme-specific label placement.
 *
 * Only applies when an image is marked (the .ai-image-inline wrapper exists only then).
 */

/* Text bg image: the wrapper carries .text-bg-image-thumbnail (flex order, size); the image just fills it. */
.text-bg-image > .ai-image-inline > .text-bg-image-thumbnail {
	width: 100%;
	margin: 0;
	order: 0;
}

/*
 * Text block image right: the image is absolutely positioned inside .image-bg.
 * The wrapper takes over that position (same offsets as the block styles), so the label
 * sits on the image corner instead of the .image-bg box.
 */
.text-block-image-right .image-bg > .ai-image-inline {
	position: absolute;
	top: 24px;
	left: 0;
	height: 100%;
	display: block;
}

.text-block-image-right .image-bg > .ai-image-inline > img {
	position: static;
	height: 100%;
}

@media only screen and (min-width: 768px) {
	.text-block-image-right .image-bg > .ai-image-inline {
		top: -40px;
		left: 50px;
	}
}

@media only screen and (min-width: 1024px) {
	.text-block-image-right .image-bg > .ai-image-inline {
		top: 0;
		left: 80px;
	}
}

@media only screen and (min-width: 1440px) {
	.text-block-image-right .image-bg > .ai-image-inline {
		top: -30px;
		left: 50px;
	}
}

@media only screen and (min-width: 1920px) {
	.text-block-image-right .image-bg > .ai-image-inline {
		top: -110px;
		left: 100px;
	}
}

/*
 * Images with a bottom margin: the margin moves to the wrapper so the label sits on the image,
 * not below it (values mirror the block styles).
 */
.сompared-item .ai-image-inline > .сompared-item-img,
.img-text-cta-outer .ai-image-inline > img {
	margin-bottom: 0;
}

.сompared-item .ai-image-inline {
	margin-bottom: 22px;
}

.img-text-cta-outer .ai-image-inline {
	margin-bottom: 64px;
}

@media only screen and (min-width: 768px) {
	.сompared-item .ai-image-inline {
		margin-bottom: 46px;
	}

	.img-text-cta-outer .ai-image-inline {
		margin-bottom: 72px;
	}
}

@media only screen and (min-width: 1024px) {
	.img-text-cta-outer .ai-image-inline {
		margin-bottom: 64px;
	}
}

/* Dark slider: the image is a circle (border-radius + overflow hidden), so a corner label would be clipped. */
.dark-slider__face-image > .ai-label {
	right: 50%;
	bottom: 8%;
	transform: translateX(50%);
}

@media only screen and (max-width: 767px) {
	/* Image right: on mobile the image is static inside the padded section (.content-width, 24px). */
	.image-right > .ai-label {
		right: 28px;
		bottom: 11px;
	}

	/* Image title slogan: the block sets position: static on mobile, which detaches the label. */
	.image-title-slogan-bg.ai-generated,
	.image-title-slogan-bg.ai-edited {
		position: relative;
	}
}

/* Bg text columns: when marked, the wrapper carries the absolute background-image layout and the image only fills it. */
.bg-text-columns-outer .bg-text-columns-image.ai-image-inline {
	display: block;
}

.bg-text-columns-outer .ai-image-inline > .bg-text-columns-image {
	position: static;
	display: block;
	height: 100%;
	max-width: none;
	transform: none;
}

/*
 * The background image sticks out of .content-width on the right by --ai-bleed (its negative "right" offset).
 * On narrow screens that part is cut by the viewport, on wide screens the whole image is visible.
 * The label goes to the image's own corner, moved left only by the part that is off-screen:
 * off-screen part = bleed - free space right of .content-width = bleed - (viewport - max content width) / 2.
 * The extra 10px covers the desktop scrollbar, which 100vw includes.
 */
.bg-text-columns-outer .bg-text-columns-image.ai-image-inline {
	--ai-bleed: 170px;
	--ai-content-max: 1440px;
}

.bg-text-columns-outer .bg-text-columns-image.ai-image-inline > .ai-label {
	right: max(8px, calc(var(--ai-bleed) + 8px - max(0px, (100vw - var(--ai-content-max)) / 2 - 10px)));
}

@media only screen and (min-width: 768px) {
	.bg-text-columns-outer .bg-text-columns-image.ai-image-inline {
		--ai-bleed: 310px;
	}
}

@media only screen and (min-width: 1440px) {
	.bg-text-columns-outer .bg-text-columns-image.ai-image-inline {
		--ai-bleed: 360px;
	}
}

@media only screen and (min-width: 1920px) {
	.bg-text-columns-outer .bg-text-columns-image.ai-image-inline {
		--ai-bleed: 290px;
		--ai-content-max: 1920px;
	}
}

/* Text logo: the wrapper carries the image classes (width, top padding, mobile/desktop visibility); the image only fills it. */
.text-logo .ai-image-inline > .text-logo-image {
	width: 100%;
	padding-top: 0;
}

/* Barcode block mockup: the wrapper carries the absolute position and height; the image only fills it. */
.barcode-block-outer .barcode-block-images .barcode-block-mockup-image.ai-image-inline {
	display: block;
}

.barcode-block-outer .barcode-block-images .ai-image-inline > .barcode-block-mockup-image {
	position: static;
	display: block;
	height: 100%;
	max-width: none;
}

/*
 * Barcode block code: the small image is centered in the round badge. When marked, the wrapper
 * takes over that centering and the label sits on the image itself. The image is tiny, so the
 * label may use most of its width to stay readable.
 */
.barcode-block-outer .barcode-block-images .barcode-block-code-image > .ai-image-inline {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 70px;
	transform: translate(-50%, -50%);
}

.barcode-block-outer .barcode-block-images .barcode-block-code-image .ai-image-inline > img {
	position: static;
	display: block;
	width: 100%;
	transform: none;
}

.barcode-block-outer .barcode-block-images .barcode-block-code-image .ai-image-inline > .ai-label {
	right: 3px;
	bottom: 3px;
	max-width: 90%;
}

@media only screen and (min-width: 1440px) {
	.barcode-block-outer .barcode-block-images .barcode-block-code-image > .ai-image-inline {
		width: 84px;
	}
}
