/**
 * Bricksify widget: Hover Image. See hover-image.js for the contract.
 *
 * Timings are the reference's: card clip/scale/opacity 1s, image
 * blur/opacity (and zoom) 1.5s, all on cubic-bezier(.19,1,.22,1).
 */

/* The image printed inside the element: hidden by default... */
.bx-himg > .bx-himg__img {
	display: none;
}

/* ...shown inline under 992px / on touch when the panel asks for it. */
@media (max-width: 991px), (hover: none) {
	.bx-himg[data-bx-himg-inline="1"] > .bx-himg__img {
		display: block;
		width: min(60vw, 320px);
		max-width: 100%;
		height: auto;
		aspect-ratio: var(--bx-himg-ratio, 300 / 370);
		object-fit: cover;
		border-radius: var(--bx-himg-radius, 8px);
	}
}

/* Layer "behind": neighbours under the card, the hovered one over it. */
.bx-himg-on .bx-himg[data-bx-himg-layer="behind"] {
	position: relative;
	z-index: 10;
}

.bx-himg-on .bx-himg[data-bx-himg-layer="behind"].is-himg-active {
	z-index: 16;
}

/* ------------------------------------------------------------ card */

.bx-himg-card {
	position: fixed;
	top: 0;
	left: 0;
	z-index: 15;
	display: flex;
	width: var(--bx-himg-w, clamp(120px, 8.21vw, 320px));
	aspect-ratio: var(--bx-himg-ratio, 300 / 370);
	border-radius: var(--bx-himg-radius, 8px);
	overflow: hidden;
	pointer-events: none;
	will-change: transform;
}

.bx-himg-card__inner {
	position: relative;
	width: 100%;
	height: 100%;
	box-sizing: border-box;
	background-color: var(--bx-himg-bg, transparent);
	border: var(--bx-himg-border, 0 none);
	opacity: 0;
	transform: scale(0);
	clip-path: inset(20% 20% 20% 20% round var(--bx-himg-radius, 8px));
	transition: opacity 1s cubic-bezier(.19, 1, .22, 1), transform 1s cubic-bezier(.19, 1, .22, 1), clip-path 1s cubic-bezier(.19, 1, .22, 1);
	will-change: transform, opacity, clip-path;
}

.bx-himg-card.is-active .bx-himg-card__inner {
	opacity: 1;
	transform: scale(1);
	clip-path: inset(0 0 0 0 round var(--bx-himg-radius, 8px));
}

.bx-himg-card__img {
	position: absolute;
	top: 0;
	left: 0;
	z-index: 2;
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	object-fit: cover;
	opacity: 0;
	visibility: hidden;
	filter: blur(1vw);
	transition: opacity 1.5s cubic-bezier(.19, 1, .22, 1), filter 1.5s cubic-bezier(.19, 1, .22, 1), transform 1.5s cubic-bezier(.19, 1, .22, 1), visibility 1.5s;
	will-change: filter, opacity;
}

.bx-himg-card.is-zoom .bx-himg-card__img {
	transform: scale(1.2);
}

.bx-himg-card .bx-himg-card__img.is-active {
	z-index: 3;
	opacity: 1;
	visibility: visible;
	filter: blur(0);
	transform: scale(1);
}

/* Motion "pop": the script drives scale and opacity on a spring; images
   swap at once, no clip, no blur. */
.bx-himg-card.is-pop .bx-himg-card__inner {
	clip-path: none;
	transition: none;
}

.bx-himg-card.is-pop .bx-himg-card__img {
	filter: none;
	transform: none;
	transition: none;
}

@media (max-width: 991px), (hover: none), (prefers-reduced-motion: reduce) {
	.bx-himg-card {
		display: none;
	}
}

/* ------------------------------------------------------- inline: other widths */

@media (max-width: 767px) {
	.bx-himg[data-bx-himg-inline="767"] > .bx-himg__img {
		display: block;
		width: min(60vw, 320px);
		max-width: 100%;
		height: auto;
		aspect-ratio: var(--bx-himg-ratio, 300 / 370);
		object-fit: cover;
		border-radius: var(--bx-himg-radius, 8px);
	}
}

@media (max-width: 478px) {
	.bx-himg[data-bx-himg-inline="478"] > .bx-himg__img {
		display: block;
		width: min(60vw, 320px);
		max-width: 100%;
		height: auto;
		aspect-ratio: var(--bx-himg-ratio, 300 / 370);
		object-fit: cover;
		border-radius: var(--bx-himg-radius, 8px);
	}
}

/* ------------------------------------------------------------ stack */

/* The stage holds the frame behind its own content (zero specificity: any
   position or z-index set in Bricks wins). */
:where(.bx-himg-stage) {
	position: relative;
}

:where(.bx-himg-stage > :not(.bx-himg-frame)) {
	position: relative;
	z-index: 1;
}

.bx-himg-frame {
	position: absolute;
	top: 50%;
	left: 50%;
	z-index: 0;
	width: var(--bx-himg-w, 25vw);
	height: var(--bx-himg-h, 70%);
	overflow: hidden;
	border-radius: var(--bx-himg-radius, 0px);
	transform: translate(-50%, -50%);
	pointer-events: none;
	will-change: transform;
}

.bx-himg-frame__img {
	position: absolute;
	top: 0;
	left: 0;
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	object-fit: cover;
	opacity: 0;
	visibility: hidden;
	clip-path: inset(50%);
	transition: clip-path var(--bx-himg-reveal, .8s) var(--bx-himg-ease, cubic-bezier(.645, .045, .355, 1)), opacity var(--bx-himg-reveal, .8s) var(--bx-himg-ease, cubic-bezier(.645, .045, .355, 1)), visibility 0s linear var(--bx-himg-reveal, .8s);
	will-change: clip-path, opacity;
}

.bx-himg-frame__img.is-on {
	opacity: 1;
	visibility: visible;
	clip-path: inset(0%);
	transition: clip-path var(--bx-himg-reveal, .8s) var(--bx-himg-ease, cubic-bezier(.645, .045, .355, 1)), opacity .22s cubic-bezier(.215, .61, .355, 1), visibility 0s;
}

.bx-himg-frame__img.is-on.is-drop {
	opacity: 0;
	transition: opacity .25s linear;
}

@media (max-width: 991px), (hover: none), (prefers-reduced-motion: reduce) {
	.bx-himg-frame {
		display: none;
	}
}
