/* Blob Image - [uaf_blob_image]
   All values arrive as unitless CSS variables on .uaf-blob (see blob_image_shortcode.php) -
   the builder's live sliders write the raw slider number into those same variables, so units
   are added here with calc(). Fallbacks match the builder defaults.

   Blob shape: 4 points, one per edge, each 0-100 = how far along that edge the point sits.
   Expanding them into an 8-value border-radius always produces a valid, smooth shape, for any
   slider combination (the "fancy border radius" technique). */

.uaf-blob {
	width: 100%;
	max-width: 400px;
}

.uaf-blob--align-center { margin-left: auto; margin-right: auto; }
.uaf-blob--align-left   { margin-right: auto; }
.uaf-blob--align-right  { margin-left: auto; }

/* Square stage, so the blob never distorts at different column widths. */
.uaf-blob .uaf-blob-stage {
	position: relative;
	aspect-ratio: 1 / 1;
	overflow: hidden;
}

/* Clipped by default: big offsets would otherwise cause horizontal scroll on mobile. */
.uaf-blob--overflow .uaf-blob-stage {
	overflow: visible;
}

.uaf-blob .uaf-blob-shape {
	position: absolute;
	left: calc(50% + var(--uaf-blob-x, -5) * 1%);
	top: calc(50% + var(--uaf-blob-y, -3) * 1%);
	width: calc(var(--uaf-blob-size, 88) * 1%);
	height: calc(var(--uaf-blob-size, 88) * 1%);
	translate: -50% -50%;
	rotate: calc(var(--uaf-blob-rotate, 0) * 1deg);
	background: var(--uaf-blob-color, #e6e4fa);
	opacity: calc(var(--uaf-blob-opacity, 100) / 100);
	border-radius:
		calc(var(--uaf-blob-t, 58) * 1%) calc((100 - var(--uaf-blob-t, 58)) * 1%)
		calc((100 - var(--uaf-blob-b, 62)) * 1%) calc(var(--uaf-blob-b, 62) * 1%) /
		calc(var(--uaf-blob-l, 42) * 1%) calc(var(--uaf-blob-r, 38) * 1%)
		calc((100 - var(--uaf-blob-r, 38)) * 1%) calc((100 - var(--uaf-blob-l, 42)) * 1%);
}

/* Morph: halfway through, each edge point moves to where the next edge's point was
   (top <- right <- bottom <- left <- top), so the shape stays related to the one the user
   designed instead of morphing into something random. */
.uaf-blob--morph-shape .uaf-blob-shape {
	animation: uaf-blob-morph calc(var(--uaf-blob-speed, 6) * 1s) ease-in-out infinite;
}

/* Image morph: same edge-point rotation using the image's own shape values, but no extra
   rotate - spinning the photo itself would tilt the person in it. */
.uaf-blob--morph-img .uaf-blob-img-wrap {
	animation: uaf-blob-morph-img calc(var(--uaf-blob-speed, 6) * 1s) ease-in-out infinite;
}

@keyframes uaf-blob-morph {
	50% {
		rotate: calc(var(--uaf-blob-rotate, 0) * 1deg + 8deg);
		border-radius:
			calc(var(--uaf-blob-r, 38) * 1%) calc((100 - var(--uaf-blob-r, 38)) * 1%)
			calc((100 - var(--uaf-blob-l, 42)) * 1%) calc(var(--uaf-blob-l, 42) * 1%) /
			calc(var(--uaf-blob-t, 58) * 1%) calc(var(--uaf-blob-b, 62) * 1%)
			calc((100 - var(--uaf-blob-b, 62)) * 1%) calc((100 - var(--uaf-blob-t, 58)) * 1%);
	}
}

@keyframes uaf-blob-morph-img {
	50% {
		border-radius:
			calc(var(--uaf-blob-img-r, 60) * 1%) calc((100 - var(--uaf-blob-img-r, 60)) * 1%)
			calc((100 - var(--uaf-blob-img-l, 55)) * 1%) calc(var(--uaf-blob-img-l, 55) * 1%) /
			calc(var(--uaf-blob-img-t, 35) * 1%) calc(var(--uaf-blob-img-b, 45) * 1%)
			calc((100 - var(--uaf-blob-img-b, 45)) * 1%) calc((100 - var(--uaf-blob-img-t, 35)) * 1%);
	}
}

@media (prefers-reduced-motion: reduce) {
	.uaf-blob--morph-shape .uaf-blob-shape,
	.uaf-blob--morph-img .uaf-blob-img-wrap {
		animation: none;
	}
}

/* Image */
.uaf-blob .uaf-blob-img-wrap {
	position: absolute;
	z-index: 1;
	display: block;
	left: calc(50% + var(--uaf-blob-img-x, 10) * 1%);
	top: calc(50% + var(--uaf-blob-img-y, 2) * 1%);
	width: calc(var(--uaf-blob-img-size, 62) * 1%);
	aspect-ratio: 1 / 1;
	translate: -50% -50%;
	overflow: hidden;
	border-radius: 50%;
}

.uaf-blob--img-blob .uaf-blob-img-wrap {
	border-radius:
		calc(var(--uaf-blob-img-t, 35) * 1%) calc((100 - var(--uaf-blob-img-t, 35)) * 1%)
		calc((100 - var(--uaf-blob-img-b, 45)) * 1%) calc(var(--uaf-blob-img-b, 45) * 1%) /
		calc(var(--uaf-blob-img-l, 55) * 1%) calc(var(--uaf-blob-img-r, 60) * 1%)
		calc((100 - var(--uaf-blob-img-r, 60)) * 1%) calc((100 - var(--uaf-blob-img-l, 55)) * 1%);
}

.uaf-blob .uaf-blob-img-wrap .uaf-blob-img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	transition: transform .6s ease;
}

.uaf-blob--zoom .uaf-blob-img-wrap:hover .uaf-blob-img {
	transform: scale(1.06);
}
