/**
 * Canvas: hover parallax.
 *
 * Two pointer-driven depth effects that belong together:
 *
 *  1. `.move-bg`: a cover image that drifts a few pixels against the pointer,
 *     giving an otherwise static hero a sense of depth. Scaled slightly so the
 *     drift never exposes an edge.
 *  2. `.img-hover-wrap` / `.img-hover-card`: an image card that tilts in 3D
 *     under the pointer while its caption lifts toward the viewer on a separate
 *     Z plane. `.show-title` keeps the caption permanently visible for grids
 *     where the label is content rather than a reveal.
 *
 * Loaded only on pages whose content contains `img-hover-wrap` or `move-bg`
 * (see the `canvas_pattern_features` map in inc/block-theme.php).
 */

/* --------------------------------------------------------------------------
   1. Pointer-following background
   -------------------------------------------------------------------------- */

.move-bg {
	width: 100%;
	height: 100%;
	background-size: cover;
	transform: scale(1.1);
	-webkit-backface-visibility: hidden;
	backface-visibility: hidden;
}

/* --------------------------------------------------------------------------
   2. Tilting image cards
   -------------------------------------------------------------------------- */

.img-hover-wrap {
	-webkit-transition: transform .3s ease;
	-o-transition: transform .3s ease;
	transition: transform .3s ease;
	-moz-transform-style: flat !important;
	transform-style: flat !important;
	-webkit-backface-visibility: hidden;
	backface-visibility: hidden;
}

.img-hover-wrap:hover {
	-webkit-transform: scale(1.1);
	-ms-transform: scale(1.1);
	-o-transform: scale(1.1);
	transform: scale(1.1);
	z-index: 99;
}

.img-hover-card {
	position: relative;
	display: block;
	will-change: transform;
	transition: all 0.3s ease;
	box-shadow: 0 10px 40px transparent;
}

.img-hover-card::after {
	content: " ";
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	background: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.5));
	transition: all 0.3s ease;
	opacity: 0;
}

.img-hover-wrap.show-title .img-hover-card::after { opacity: 0.5; }

.img-hover-wrap:hover .img-hover-card::after { opacity: 1; }

.img-hover-card img {
	width: 100%;
	max-width: 100%;
	display: block;
}

/* The tilt runtime swaps these two classes so the ease differs on the way in
   and on the way out. */
.img-hover-card.hover-in {
	transition: -webkit-transform .2s ease-out;
	transition: transform .2s ease-out;
	transition: transform .2s ease-out, -webkit-transform .2s ease-out;
}

.img-hover-card.hover-out {
	transition: -webkit-transform .2s ease-in;
	transition: transform .2s ease-in;
	transition: transform .2s ease-in, -webkit-transform .2s ease-in;
}

.img-hover-card.hover-3d { z-index: 99; }

.img-hover-wrap:hover .img-hover-card { box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4); }

.img-hover-detail {
	position: absolute;
	inset: 40px;
	display: -webkit-flex;
	display: -ms-flexbox;
	display: flex;
	-webkit-flex-direction: column;
	-ms-flex-direction: column;
	flex-direction: column;
	-webkit-justify-content: center;
	-ms-flex-pack: center;
	justify-content: center;
	text-align: center;
	pointer-events: none;
	-webkit-transform: translateZ(40px);
	transform: translateZ(40px);
	-webkit-backface-visibility: hidden;
	backface-visibility: hidden;
}

.img-hover-detail a { color: #fff; }

.img-hover-title {
	margin: 0 0 10px;
	font-size: 24px;
	font-weight: 700;
	text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
	transition: 0.4s ease;
	opacity: 0;
	-webkit-transform: translateY(40px) scale(0);
	-ms-transform: translateY(40px) scale(0);
	transform: translateY(40px) scale(0);
	will-change: transform;
}

.img-hover-category {
	margin: 0 0 18px;
	opacity: 0;
	font-family: 'Lato';
	transition: 0.4s ease;
	transition-delay: 0.1s;
	-webkit-transform: translateY(40px) scale(0);
	-ms-transform: translateY(40px) scale(0);
	transform: translateY(40px) scale(0);
	will-change: transform;
}

.img-hover-wrap:hover .img-hover-title,
.img-hover-wrap:hover .img-hover-category,
.img-hover-wrap.show-title .img-hover-title,
.img-hover-wrap.show-title .img-hover-category {
	-webkit-transform: translateY(0) scale(1);
	-ms-transform: translateY(0) scale(1);
	transform: translateY(0) scale(1);
	opacity: 1;
}

.img-hover-wrap.show-title:hover .img-hover-title,
.img-hover-wrap.show-title:hover .img-hover-category {
	-webkit-transform: scale(1.106);
	-ms-transform: scale(1.106);
	transform: scale(1.106);
}

/* Motion here is decorative depth, not information. */
@media ( prefers-reduced-motion: reduce ) {

	.move-bg,
	.img-hover-wrap,
	.img-hover-card,
	.img-hover-title,
	.img-hover-category {
		transition: none;
		transform: none;
	}

	.img-hover-title,
	.img-hover-category {
		opacity: 1;
	}
}
