/*
 * Card Hover (hash b81f3d).
 *
 * Layout: the card is a fixed-size box. Inside the padding, an inner box holds two absolutely
 * positioned layers: the image (media) and the text (content).
 *
 * Base rules below are the ACTIVE state (image small at the top, text visible). Devices that can
 * hover get the REST state inside the media query, and the active state returns on hover or
 * keyboard focus. Touch devices simply keep the active state.
 *
 * Width, height, padding, radius, background, alignment, gaps, typography and colours are written
 * by the Elementor controls. The custom properties here are only fallbacks.
 */

.chv-b81f3d {
	--chv-img-h: 140px;
	--chv-img-hover-h: 70px;
	--chv-img-gap: 24px;
	--chv-dur: 0.4s;
	--chv-ease: cubic-bezier(0.22, 1, 0.36, 1);
	--chv-shift: 0px;
	--chv-shift-ease: cubic-bezier(0.22, 1, 0.36, 1);
	--chv-scroll: rgba(255, 255, 255, 0.6);

	position: relative;
	display: block;
	box-sizing: border-box;
	max-width: 100%;
	color: inherit;
}

a.chv-b81f3d,
a.chv-b81f3d:hover,
a.chv-b81f3d:focus {
	text-decoration: none;
}

.chv-b81f3d:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 3px;
}

/*
 * The inner box clips the layers (not the card itself), so the card can use a pseudo element
 * outside its own box to keep the hover alive while it shifts up.
 */
.chv-b81f3d__inner {
	position: relative;
	width: 100%;
	height: 100%;
	overflow: hidden;
}

/* Image layer */
.chv-b81f3d .chv-b81f3d__media {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: var(--chv-img-hover-h);
	display: flex;
	justify-content: center;
	align-items: center;
	margin: 0;
	padding: 0;
}

.chv-b81f3d .chv-b81f3d__img {
	display: block;
	width: auto;
	height: 100%;
	max-width: 100%;
	object-fit: contain;
	margin: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
}

/* Text layer: scrolls when taller than the space below the image. The image stays put. */
.chv-b81f3d .chv-b81f3d__content {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	top: calc(var(--chv-img-hover-h) + var(--chv-img-gap));
	display: flex;
	flex-direction: column;
	justify-content: flex-start;
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
	scrollbar-color: var(--chv-scroll) transparent;
}

.chv-b81f3d .chv-b81f3d__content::-webkit-scrollbar {
	width: 6px;
}

.chv-b81f3d .chv-b81f3d__content::-webkit-scrollbar-track {
	background: transparent;
}

.chv-b81f3d .chv-b81f3d__content::-webkit-scrollbar-thumb {
	background: var(--chv-scroll);
	border-radius: 3px;
}

/* Without an image the text starts at the top. */
.chv-b81f3d.chv-b81f3d--no-image .chv-b81f3d__content {
	top: 0;
}

.chv-b81f3d__sub {
	display: flex;
	flex-direction: column;
	flex: 0 0 auto;
}

/* Reset theme margins so spacing comes from the gap controls only. Blocks never shrink, they scroll. */
.chv-b81f3d .chv-b81f3d__title,
.chv-b81f3d .chv-b81f3d__text,
.chv-b81f3d .chv-b81f3d__sub-title,
.chv-b81f3d .chv-b81f3d__sub-text {
	flex: 0 0 auto;
	margin: 0;
	padding: 0;
}

/* Hover capable devices: animate between REST and ACTIVE. */
@media (hover: hover) {
	/* The whole card shifts up on hover by --chv-shift. Own easing, shared duration. */
	.chv-b81f3d {
		transition: transform var(--chv-dur) var(--chv-shift-ease);
	}

	.chv-b81f3d:hover,
	.chv-b81f3d:focus-visible,
	.chv-b81f3d.chv-b81f3d--preview {
		transform: translateY(calc(var(--chv-shift) * -1));
		z-index: 1;
	}

	/*
	 * Bridge the strip the card leaves behind when it shifts up. Without it the pointer sits over
	 * empty space, hover drops, the card falls back and the cycle repeats (flicker). The pseudo
	 * element only exists while hovered, so it never widens the resting hit area.
	 */
	.chv-b81f3d:hover::after {
		content: "";
		position: absolute;
		left: 0;
		right: 0;
		top: 100%;
		height: var(--chv-shift);
	}

	.chv-b81f3d .chv-b81f3d__media {
		top: calc(50% - var(--chv-img-h) / 2);
		height: var(--chv-img-h);
		transition: top var(--chv-dur) var(--chv-ease), height var(--chv-dur) var(--chv-ease);
	}

	.chv-b81f3d .chv-b81f3d__content {
		opacity: 0;
		transform: translateY(100%);
		pointer-events: none;
		transition: opacity var(--chv-dur) var(--chv-ease), transform var(--chv-dur) var(--chv-ease);
	}

	/* Keyboard focus only (focus-visible), so a mouse click on a link card does not pin it open. */
	.chv-b81f3d:hover .chv-b81f3d__media,
	.chv-b81f3d:focus-visible .chv-b81f3d__media,
	.chv-b81f3d.chv-b81f3d--preview .chv-b81f3d__media {
		top: 0;
		height: var(--chv-img-hover-h);
	}

	.chv-b81f3d:hover .chv-b81f3d__content,
	.chv-b81f3d:focus-visible .chv-b81f3d__content,
	.chv-b81f3d.chv-b81f3d--preview .chv-b81f3d__content {
		opacity: 1;
		transform: translateY(0);
		pointer-events: auto;
	}

	/* No text (the content layer is absent): the image stays centred and does not move. */
	.chv-b81f3d .chv-b81f3d__media:only-child,
	.chv-b81f3d:hover .chv-b81f3d__media:only-child,
	.chv-b81f3d:focus-visible .chv-b81f3d__media:only-child,
	.chv-b81f3d.chv-b81f3d--preview .chv-b81f3d__media:only-child {
		top: calc(50% - var(--chv-img-h) / 2);
		height: var(--chv-img-h);
	}
}

/* No text on any device: keep the image at its rest height, centred. */
.chv-b81f3d .chv-b81f3d__media:only-child {
	top: calc(50% - var(--chv-img-h) / 2);
	height: var(--chv-img-h);
}

@media (prefers-reduced-motion: reduce) {
	.chv-b81f3d,
	.chv-b81f3d .chv-b81f3d__media,
	.chv-b81f3d .chv-b81f3d__content {
		transition: none;
	}
}
