/* [uaf_expandable_image]
   Decorations stay inside the root's padding, never outside its box, so they can't cause
   horizontal page scroll on phones or collide with the next column. */

.uaf-exi {
	--uaf-exi-c: var(--uaf-exi-accent, var(--fs-color-secondary, #446084));
	--uaf-exi-o: var(--uaf-exi-offset, 24px);
	--uaf-exi-r: var(--uaf-exi-radius, 0px);
	--uaf-exi-l: var(--uaf-exi-line, 2px);
	box-sizing: border-box;
	display: block;
	margin-bottom: 1em;
	max-width: 100%;
	position: relative;
	width: 100%;
}

.uaf-exi--align-center { margin-left: auto; margin-right: auto; }
.uaf-exi--align-left   { margin-left: 0; margin-right: auto; }
.uaf-exi--align-right  { margin-left: auto; margin-right: 0; }

/* Smaller decorations on phones, so the image keeps most of the narrow column. */
@media (max-width: 549px) {
	.uaf-exi { --uaf-exi-o: calc(var(--uaf-exi-offset, 24px) * .6); }
}

/* ---------- Size ---------- */

.uaf-exi-stage {
	aspect-ratio: 1 / 1;
	position: relative;
	width: 100%;
	z-index: 1;
}

.uaf-exi--height .uaf-exi-stage {
	aspect-ratio: auto;
	height: 420px;
}

.uaf-exi--fill .uaf-exi-stage {
	aspect-ratio: var(--uaf-exi-fill-ratio, 1 / 1);
}

/* Fill Column Height: the image is taken out of the height calculation (.uaf-exi-media is
   absolute), so the text column alone sets the row's height and the image stretches to match.
   Only from 550px up: Flatsome stacks columns below that, so phones use Mobile Ratio. */
@media (min-width: 550px) {
	.col:has(> .col-inner > .uaf-exi--fill) {
		align-self: stretch;
		display: flex;
	}

	.col:has(> .col-inner > .uaf-exi--fill) > .col-inner {
		display: flex;
		flex-direction: column;
	}

	/* Without this, the last paragraph's bottom margin leaves the text ending above the image. */
	.row:has(> .col > .col-inner > .uaf-exi--fill) > .col > .col-inner > :last-child {
		margin-bottom: 0;
	}

	.uaf-exi--fill {
		display: flex;
		flex: 1 1 auto;
		flex-direction: column;
		margin-bottom: 0;
	}

	.uaf-exi--fill .uaf-exi-stage {
		aspect-ratio: auto;
		flex: 1 1 auto;
		min-height: 200px;
	}
}

/* ---------- Image ---------- */

.uaf-exi-media {
	border-radius: var(--uaf-exi-r);
	display: block;
	inset: 0;
	overflow: hidden;
	position: absolute;
	transition: box-shadow .35s ease;
}

.uaf-exi .uaf-exi-img {
	display: block;
	filter: brightness(var(--uaf-exi-brightness, 100%)) contrast(var(--uaf-exi-contrast, 100%)) saturate(var(--uaf-exi-saturation, 100%)) blur(var(--uaf-exi-blur, 0px)) grayscale(var(--uaf-exi-gray, 0));
	height: 100%;
	max-width: none;
	object-fit: cover;
	object-position: var(--uaf-exi-pos, 50% 50%);
	transform: scale(var(--uaf-exi-scale, 1));
	transition: transform .6s cubic-bezier(.2, .7, .2, 1), filter .35s ease;
	width: 100%;
}

/* Hides the see-through edge a blur would otherwise leave around the image. */
.uaf-exi--blur { --uaf-exi-scale: 1.08; }

.uaf-exi--gray { --uaf-exi-gray: 1; }
.uaf-exi--gray-hover:hover { --uaf-exi-gray: 0; }

.uaf-exi--hover-zoom:hover { --uaf-exi-scale: 1.06; }
.uaf-exi--hover-out { --uaf-exi-scale: 1.08; }
.uaf-exi--hover-out:hover { --uaf-exi-scale: 1; }
.uaf-exi--blur.uaf-exi--hover-zoom:hover { --uaf-exi-scale: 1.14; }
.uaf-exi--blur.uaf-exi--hover-out:hover { --uaf-exi-scale: 1.08; }

/* ---------- Overlay ---------- */

.uaf-exi-overlay {
	background: var(--uaf-exi-overlay);
	inset: 0;
	pointer-events: none;
	position: absolute;
	transition: opacity .35s ease;
}

.uaf-exi-overlay--fade {
	background: linear-gradient(to top, var(--uaf-exi-overlay) 0%, transparent 75%);
}

.uaf-exi-overlay--show,
.uaf-exi:hover .uaf-exi-overlay--hide { opacity: 0; }
.uaf-exi:hover .uaf-exi-overlay--show { opacity: 1; }

/* ---------- Decorative styles ---------- */

.uaf-exi-decor,
.uaf-exi-decor::before,
.uaf-exi-decor::after {
	pointer-events: none;
	position: absolute;
}

.uaf-exi-decor {
	inset: 0;
	transition: transform .45s cubic-bezier(.2, .7, .2, 1);
	z-index: 0;
}

.uaf-exi-decor::before,
.uaf-exi-decor::after {
	border-radius: var(--uaf-exi-r);
	box-sizing: border-box;
	content: "";
	transition: transform .45s cubic-bezier(.2, .7, .2, 1);
}

/* 1. Offset Frame: a hatched shadow, misaligned from the image, inside a thin frame. */
.uaf-exi--frame { padding: 0 var(--uaf-exi-o) var(--uaf-exi-o) 0; }
.uaf-exi--frame .uaf-exi-decor::before {
	background: repeating-linear-gradient(135deg, var(--uaf-exi-c) 0 2px, transparent 2px 8px);
	inset: calc(var(--uaf-exi-o) * .5) calc(var(--uaf-exi-o) * .5 - 1px) calc(var(--uaf-exi-o) * .5 - 1px) calc(var(--uaf-exi-o) * .5);
}
.uaf-exi--frame .uaf-exi-decor::after {
	border: var(--uaf-exi-l) solid var(--uaf-exi-c);
	inset: var(--uaf-exi-o) 0 0 var(--uaf-exi-o);
}
.uaf-exi--frame.uaf-exi--frame-hover:hover .uaf-exi-decor::after {
	transform: translate(calc(var(--uaf-exi-o) * -.3), calc(var(--uaf-exi-o) * -.3));
}

/* 2. Dot Grid: a dotted block under one corner, a solid block behind the opposite one. */
.uaf-exi--dots { padding: var(--uaf-exi-o) var(--uaf-exi-o) var(--uaf-exi-o) var(--uaf-exi-o); }
.uaf-exi--dots .uaf-exi-decor::before {
	background: radial-gradient(circle, var(--uaf-exi-c) 1.6px, transparent 2.1px) 0 0 / 14px 14px;
	bottom: 0;
	height: 55%;
	left: 0;
	width: 55%;
}
.uaf-exi--dots .uaf-exi-decor::after {
	background: var(--uaf-exi-c);
	height: 42%;
	right: 0;
	top: 0;
	width: 42%;
}
.uaf-exi--dots.uaf-exi--frame-hover:hover .uaf-exi-decor::before {
	transform: translate(calc(var(--uaf-exi-o) * .3), calc(var(--uaf-exi-o) * -.3));
}
.uaf-exi--dots.uaf-exi--frame-hover:hover .uaf-exi-decor::after {
	transform: translate(calc(var(--uaf-exi-o) * -.3), calc(var(--uaf-exi-o) * .3));
}

/* 3. Corner Brackets: an architect's crop marks floating clear of the image. */
.uaf-exi--brackets { padding: var(--uaf-exi-o); }
.uaf-exi--brackets .uaf-exi-decor::before,
.uaf-exi--brackets .uaf-exi-decor::after {
	border: 0 solid var(--uaf-exi-c);
	border-radius: 0;
	height: 34%;
	width: 34%;
}
.uaf-exi--brackets .uaf-exi-decor::before {
	border-left-width: calc(var(--uaf-exi-l) + 1px);
	border-top-width: calc(var(--uaf-exi-l) + 1px);
	left: 0;
	top: 0;
}
.uaf-exi--brackets .uaf-exi-decor::after {
	border-bottom-width: calc(var(--uaf-exi-l) + 1px);
	border-right-width: calc(var(--uaf-exi-l) + 1px);
	bottom: 0;
	right: 0;
}
.uaf-exi--brackets.uaf-exi--frame-hover:hover .uaf-exi-decor::before {
	transform: translate(calc(var(--uaf-exi-o) * .35), calc(var(--uaf-exi-o) * .35));
}
.uaf-exi--brackets.uaf-exi--frame-hover:hover .uaf-exi-decor::after {
	transform: translate(calc(var(--uaf-exi-o) * -.35), calc(var(--uaf-exi-o) * -.35));
}

/* 4. Layered Sheets: a tilted solid sheet and a tilted outline, like stacked prints. Both are
   inset before rotating so their corners stay inside the element's box. */
.uaf-exi--sheets { padding: var(--uaf-exi-o); }
.uaf-exi--sheets .uaf-exi-decor::before {
	background: var(--uaf-exi-c);
	inset: 3%;
	transform: rotate(-2.5deg);
}
.uaf-exi--sheets .uaf-exi-decor::after {
	border: var(--uaf-exi-l) solid var(--uaf-exi-c);
	inset: 3%;
	transform: rotate(2.5deg);
}
.uaf-exi--sheets.uaf-exi--frame-hover:hover .uaf-exi-decor::before { transform: rotate(-1deg); }
.uaf-exi--sheets.uaf-exi--frame-hover:hover .uaf-exi-decor::after { transform: rotate(1deg); }

/* 5. Angled Cut: a sliced corner reveals the solid color block behind the image. */
.uaf-exi--cut { padding: 0 var(--uaf-exi-o) var(--uaf-exi-o) 0; }
.uaf-exi--cut .uaf-exi-stage {
	clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--uaf-exi-o) * 3), calc(100% - var(--uaf-exi-o) * 3) 100%, 0 100%);
}
.uaf-exi--cut .uaf-exi-media { border-radius: 0; }
.uaf-exi--cut .uaf-exi-decor::before {
	background: var(--uaf-exi-c);
	border-radius: 0;
	inset: var(--uaf-exi-o) 0 0 var(--uaf-exi-o);
}
.uaf-exi--cut.uaf-exi--frame-hover:hover .uaf-exi-decor::before {
	transform: translate(calc(var(--uaf-exi-o) * -.3), calc(var(--uaf-exi-o) * -.3));
}

@media (prefers-reduced-motion: reduce) {
	.uaf-exi-media,
	.uaf-exi .uaf-exi-img,
	.uaf-exi-overlay,
	.uaf-exi-decor,
	.uaf-exi-decor::before,
	.uaf-exi-decor::after {
		transition: none;
	}
}
