/**
 * PWD Animations - Image Wipe widget stylesheet.
 * Loaded together with pwd-animations-core.css.
 *
 * HTML and CSS only. The second image sits on top of the first and is cut by a
 * mask whose size follows one registered custom property, --pwd-iw-p, from 0
 * (nothing shown) to 1 (all shown). Hover, a checkbox or a keyframe loop moves
 * it. A browser without @property cannot animate it and simply swaps the
 * images.
 *
 * Elementor and themes style bare img elements (".elementor img { height: auto;
 * max-width: 100% }"), so the image rules go three classes deep to win.
 */

@property --pwd-iw-p {
	syntax: "<number>";
	inherits: false;
	initial-value: 0;
}

.pwd-iw {
	--pwd-iw-dur: 1.6s;
	--pwd-iw-ease: ease-in-out;
	--pwd-iw-soft: 6;
	--pwd-iw-origin: 50% 50%;
	--pwd-iw-dir: to right;
	--pwd-iw-slat: 12%;
	--pwd-iw-cycle: 8s;
	position: relative;
	display: block;
	box-sizing: border-box;
	max-width: 100%;
}

.pwd-iw .pwd-iw__stage {
	position: relative;
	display: block;
	box-sizing: border-box;
	width: 100%;
	overflow: hidden;
}

/* The frame height comes from this spacer, so it works in every browser */
.pwd-iw .pwd-iw__stage::before {
	content: "";
	display: block;
	padding-top: 56.25%;
}

.pwd-iw .pwd-iw__a,
.pwd-iw .pwd-iw__b {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}

.pwd-iw .pwd-iw__stage .pwd-iw__img {
	display: block;
	width: 100%;
	max-width: none;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	object-fit: cover;
}

/* Captions */
.pwd-iw .pwd-iw__cap {
	position: absolute;
	z-index: 2;
	box-sizing: border-box;
	max-width: calc(100% - 40px);
	margin: 20px;
	font-size: 1.25em;
	line-height: 1.2;
}

.pwd-iw-cap-tl .pwd-iw__cap {
	top: 0;
	left: 0;
}

.pwd-iw-cap-tr .pwd-iw__cap {
	top: 0;
	right: 0;
	text-align: right;
}

.pwd-iw-cap-bl .pwd-iw__cap {
	bottom: 0;
	left: 0;
}

.pwd-iw-cap-br .pwd-iw__cap {
	right: 0;
	bottom: 0;
	text-align: right;
}

.pwd-iw-cap-c .pwd-iw__cap {
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	text-align: center;
}

/* ======================= The mask on the second image ================== */
.pwd-iw .pwd-iw__b {
	--pwd-iw-p: 0;
	--iw-ftd: calc(var(--pwd-iw-soft) * 3.6deg);
	--iw-ftp: calc(var(--pwd-iw-soft) * 1%);
	transition: --pwd-iw-p var(--pwd-iw-dur) var(--pwd-iw-ease);
	-webkit-mask-repeat: no-repeat;
	mask-repeat: no-repeat;
}

/* Clock, clockwise */
.pwd-iw--clock .pwd-iw__b {
	--iw-a: calc(var(--pwd-iw-p) * (360deg + 2 * var(--iw-ftd)) - var(--iw-ftd));
	-webkit-mask-image: conic-gradient(from 0deg at var(--pwd-iw-origin), #000 0deg, #000 calc(var(--iw-a) - var(--iw-ftd)), transparent calc(var(--iw-a) + var(--iw-ftd)), transparent 360deg);
	mask-image: conic-gradient(from 0deg at var(--pwd-iw-origin), #000 0deg, #000 calc(var(--iw-a) - var(--iw-ftd)), transparent calc(var(--iw-a) + var(--iw-ftd)), transparent 360deg);
}

/* Clock, counter-clockwise */
.pwd-iw--ccw .pwd-iw__b {
	--iw-b: calc(360deg + var(--iw-ftd) - var(--pwd-iw-p) * (360deg + 2 * var(--iw-ftd)));
	-webkit-mask-image: conic-gradient(from 0deg at var(--pwd-iw-origin), transparent 0deg, transparent calc(var(--iw-b) - var(--iw-ftd)), #000 calc(var(--iw-b) + var(--iw-ftd)), #000 360deg);
	mask-image: conic-gradient(from 0deg at var(--pwd-iw-origin), transparent 0deg, transparent calc(var(--iw-b) - var(--iw-ftd)), #000 calc(var(--iw-b) + var(--iw-ftd)), #000 360deg);
}

/* Fan: a half circle opening from the bottom centre, left to right */
.pwd-iw--fan .pwd-iw__b {
	--iw-a: calc(var(--pwd-iw-p) * (180deg + 2 * var(--iw-ftd)) - var(--iw-ftd));
	-webkit-mask-image: conic-gradient(from 270deg at 50% 100%, #000 0deg, #000 calc(var(--iw-a) - var(--iw-ftd)), transparent calc(var(--iw-a) + var(--iw-ftd)), transparent 360deg);
	mask-image: conic-gradient(from 270deg at 50% 100%, #000 0deg, #000 calc(var(--iw-a) - var(--iw-ftd)), transparent calc(var(--iw-a) + var(--iw-ftd)), transparent 360deg);
}

/* Iris: a circle growing out of a point */
.pwd-iw--iris .pwd-iw__b {
	--iw-r: calc(var(--pwd-iw-p) * (100% + 2 * var(--iw-ftp)) - var(--iw-ftp));
	-webkit-mask-image: radial-gradient(circle farthest-corner at var(--pwd-iw-origin), #000 0%, #000 calc(var(--iw-r) - var(--iw-ftp)), transparent calc(var(--iw-r) + var(--iw-ftp)));
	mask-image: radial-gradient(circle farthest-corner at var(--pwd-iw-origin), #000 0%, #000 calc(var(--iw-r) - var(--iw-ftp)), transparent calc(var(--iw-r) + var(--iw-ftp)));
}

/* Linear: a straight edge in any of eight directions */
.pwd-iw--linear .pwd-iw__b {
	--iw-r: calc(var(--pwd-iw-p) * (100% + 2 * var(--iw-ftp)) - var(--iw-ftp));
	-webkit-mask-image: linear-gradient(var(--pwd-iw-dir), #000 0%, #000 calc(var(--iw-r) - var(--iw-ftp)), transparent calc(var(--iw-r) + var(--iw-ftp)), transparent 100%);
	mask-image: linear-gradient(var(--pwd-iw-dir), #000 0%, #000 calc(var(--iw-r) - var(--iw-ftp)), transparent calc(var(--iw-r) + var(--iw-ftp)), transparent 100%);
}

/* Blinds: stripes that widen until they meet */
.pwd-iw--blinds .pwd-iw__b {
	-webkit-mask-image: repeating-linear-gradient(var(--pwd-iw-dir), #000 0, #000 calc(var(--pwd-iw-p) * var(--pwd-iw-slat)), transparent calc(var(--pwd-iw-p) * var(--pwd-iw-slat)), transparent var(--pwd-iw-slat));
	mask-image: repeating-linear-gradient(var(--pwd-iw-dir), #000 0, #000 calc(var(--pwd-iw-p) * var(--pwd-iw-slat)), transparent calc(var(--pwd-iw-p) * var(--pwd-iw-slat)), transparent var(--pwd-iw-slat));
}

/* ============================== Triggers =============================== */
.pwd-iw.pwd-iw--hover:hover .pwd-iw__b,
.pwd-iw.pwd-iw--hover:focus .pwd-iw__b,
.pwd-iw.pwd-iw--hover:focus-within .pwd-iw__b {
	--pwd-iw-p: 1;
}

/* Click: a transparent checkbox covers the frame, so a click, a tap and the
   Space key all toggle it without any script. */
.pwd-iw .pwd-iw__chk {
	position: absolute;
	z-index: 3;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	opacity: 0;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.pwd-iw .pwd-iw__chk:checked + .pwd-iw__stage .pwd-iw__b {
	--pwd-iw-p: 1;
}

.pwd-iw .pwd-iw__chk:focus-visible + .pwd-iw__stage {
	outline: 2px solid #fff;
	outline-offset: -4px;
}

.pwd-iw.pwd-iw--hover:focus-visible .pwd-iw__stage,
.pwd-iw.pwd-iw--loop:focus-visible .pwd-iw__stage {
	outline: 2px solid #fff;
	outline-offset: -4px;
}

/* Loop: wipe in, rest, wipe out, rest. Pauses while hovered or focused. */
@keyframes pwd-iw-loop {
	0%,
	10% {
		--pwd-iw-p: 0;
	}
	45%,
	55% {
		--pwd-iw-p: 1;
	}
	90%,
	100% {
		--pwd-iw-p: 0;
	}
}

.pwd-iw.pwd-iw--loop .pwd-iw__b {
	transition: none;
	animation: pwd-iw-loop var(--pwd-iw-cycle) var(--pwd-iw-ease) infinite;
}

.pwd-iw.pwd-iw--loop:hover .pwd-iw__b,
.pwd-iw.pwd-iw--loop:focus-within .pwd-iw__b {
	animation-play-state: paused;
}

/* Reduced motion: no sweep, no loop; the other image still appears on demand */
@media (prefers-reduced-motion: reduce) {
	.pwd-iw .pwd-iw__b {
		transition: none;
	}

	.pwd-iw.pwd-iw--loop .pwd-iw__b {
		animation: none;
	}
}
