/**
 * Image Compare (TwentyTwenty) Styles
 *
 * Before/after image comparison slider styles.
 *
 * @package Canvas_Core
 * @since 1.0.0
 */

/* ── Base Container ──────────────────────────────────────────────────────────── */

.twentytwenty-container {
	-webkit-box-sizing: content-box;
	-moz-box-sizing: content-box;
	box-sizing: content-box;
	z-index: 0;
	overflow: hidden;
	position: relative;
	-webkit-user-select: none;
	-moz-user-select: none;
	user-select: none;
}

.twentytwenty-container img {
	width: 100%;
	position: absolute;
	top: 0;
	display: block;
}

.twentytwenty-container * {
	-webkit-box-sizing: content-box;
	-moz-box-sizing: content-box;
	box-sizing: content-box;
}

/* ── Before / After Layers ───────────────────────────────────────────────────── */

.twentytwenty-before {
	z-index: 20;
}

.twentytwenty-after {
	z-index: 10;
}

/* ── Handle ──────────────────────────────────────────────────────────────────── */

.twentytwenty-handle {
	height: 38px;
	width: 38px;
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	border: 3px solid white;
	-webkit-border-radius: 1000px;
	-moz-border-radius: 1000px;
	border-radius: 1000px;
	background-color: #FFF;
	-webkit-box-shadow: 0px 0px 12px rgba(51, 51, 51, 0.5);
	-moz-box-shadow: 0px 0px 12px rgba(51, 51, 51, 0.5);
	box-shadow: 0px 0px 12px rgba(51, 51, 51, 0.5);
	z-index: 40;
	cursor: pointer;
}

/* ── Horizontal Handle Lines ─────────────────────────────────────────────────── */

.twentytwenty-horizontal .twentytwenty-handle:before,
.twentytwenty-horizontal .twentytwenty-handle:after {
	content: " ";
	display: block;
	background: white;
	position: absolute;
	z-index: 30;
	-webkit-box-shadow: 0px 0px 12px rgba(51, 51, 51, 0.5);
	-moz-box-shadow: 0px 0px 12px rgba(51, 51, 51, 0.5);
	box-shadow: 0px 0px 12px rgba(51, 51, 51, 0.5);
	width: 4px;
	height: 9999px;
	left: 50%;
	margin-left: -2px;
}

.twentytwenty-horizontal .twentytwenty-handle:before {
	bottom: 50%;
	margin-bottom: 22px;
	-webkit-box-shadow: 0 3px 0 white, 0px 0px 12px rgba(51, 51, 51, 0.5);
	-moz-box-shadow: 0 3px 0 white, 0px 0px 12px rgba(51, 51, 51, 0.5);
	box-shadow: 0 3px 0 white, 0px 0px 12px rgba(51, 51, 51, 0.5);
}

.twentytwenty-horizontal .twentytwenty-handle:after {
	top: 50%;
	margin-top: 22px;
	-webkit-box-shadow: 0 -3px 0 white, 0px 0px 12px rgba(51, 51, 51, 0.5);
	-moz-box-shadow: 0 -3px 0 white, 0px 0px 12px rgba(51, 51, 51, 0.5);
	box-shadow: 0 -3px 0 white, 0px 0px 12px rgba(51, 51, 51, 0.5);
}

/* ── Arrows ──────────────────────────────────────────────────────────────────── */

.twentytwenty-left-arrow,
.twentytwenty-right-arrow {
	width: 0;
	height: 0;
	border: 6px inset transparent;
	position: absolute;
	top: 50%;
	margin-top: -6px;
}

.twentytwenty-left-arrow {
	border-right: 6px solid #999;
	left: 50%;
	margin-left: -17px;
}

.twentytwenty-right-arrow {
	border-left: 6px solid #999;
	right: 50%;
	margin-right: -17px;
}

/* ── Overlay & Labels ────────────────────────────────────────────────────────── */

.twentytwenty-before-label,
.twentytwenty-after-label,
.twentytwenty-overlay {
	position: absolute;
	top: 0;
	width: 100%;
	height: 100%;
}

.twentytwenty-before-label,
.twentytwenty-after-label,
.twentytwenty-overlay {
	-webkit-transition-duration: 0.5s;
	-moz-transition-duration: 0.5s;
	transition-duration: 0.5s;
}

.twentytwenty-before-label,
.twentytwenty-after-label {
	-webkit-transition-property: opacity;
	-moz-transition-property: opacity;
	transition-property: opacity;
}

.twentytwenty-before-label {
	opacity: 0;
}

.twentytwenty-before-label:before {
	content: "Before";
}

.twentytwenty-after-label {
	opacity: 0;
}

.twentytwenty-after-label:before {
	content: "After";
}

.twentytwenty-before-label:before,
.twentytwenty-after-label:before {
	color: white;
	font-size: 13px;
	letter-spacing: 0.1em;
	position: absolute;
	background: rgba(255, 255, 255, 0.2);
	line-height: 38px;
	padding: 0 20px;
	-webkit-border-radius: 2px;
	-moz-border-radius: 2px;
	border-radius: 2px;
}

.twentytwenty-horizontal .twentytwenty-before-label:before,
.twentytwenty-horizontal .twentytwenty-after-label:before {
	top: 50%;
	margin-top: -19px;
}

.twentytwenty-horizontal .twentytwenty-before-label:before {
	left: 10px;
}

.twentytwenty-horizontal .twentytwenty-after-label:before {
	right: 10px;
}

.twentytwenty-overlay {
	-webkit-transition-property: background;
	-moz-transition-property: background;
	transition-property: background;
	background: rgba(0, 0, 0, 0);
	z-index: 25;
}

.twentytwenty-overlay:hover {
	background: rgba(0, 0, 0, 0.5);
}

.twentytwenty-overlay:hover .twentytwenty-after-label {
	opacity: 1;
}

.twentytwenty-overlay:hover .twentytwenty-before-label {
	opacity: 1;
}

/* ── Active State (dragging) ─────────────────────────────────────────────────── */

/* The upstream stylesheet writes the hovered form as one compound
   (`.active:hover.twentytwenty-overlay`), which asks a single element to be
   both the container and the overlay; the descendant form is the one that
   reaches the overlay. Both spellings are kept so the plugin's own rules are
   present verbatim alongside the form that applies. */
.twentytwenty-container.active .twentytwenty-overlay,
.twentytwenty-container.active:hover .twentytwenty-overlay,
.twentytwenty-container.active:hover.twentytwenty-overlay {
	background: rgba(0, 0, 0, 0);
}

.twentytwenty-container.active .twentytwenty-overlay .twentytwenty-before-label,
.twentytwenty-container.active .twentytwenty-overlay .twentytwenty-after-label,
.twentytwenty-container.active:hover .twentytwenty-overlay .twentytwenty-before-label,
.twentytwenty-container.active:hover .twentytwenty-overlay .twentytwenty-after-label,
.twentytwenty-container.active:hover.twentytwenty-overlay .twentytwenty-before-label,
.twentytwenty-container.active:hover.twentytwenty-overlay .twentytwenty-after-label {
	opacity: 0;
}

/* ── Handle Style: Transparent ───────────────────────────────────────────────── */

.arrow-transparent .twentytwenty-handle {
	background-color: transparent;
}

.arrow-transparent .twentytwenty-left-arrow,
.twentytwenty-container[class*="bg-"] .twentytwenty-left-arrow {
	border-right-color: #FFF;
}

.arrow-transparent .twentytwenty-right-arrow,
.twentytwenty-container[class*="bg-"] .twentytwenty-right-arrow {
	border-left-color: #FFF;
}

/* ── Handle Style: Rounded ───────────────────────────────────────────────────── */

.arrow-rounded .twentytwenty-handle {
	border-radius: 4px;
}

/* ── Handle Style: Square ────────────────────────────────────────────────────── */

.arrow-square .twentytwenty-handle {
	border-radius: 0;
}

/* ── Handle Style: Diamond ───────────────────────────────────────────────────── */

.arrow-diamond .twentytwenty-handle {
	border: 0;
	box-shadow: none;
	background-color: transparent;
}

.arrow-diamond .twentytwenty-handle span.twentytwenty-left-arrow:after {
	content: "";
	position: absolute;
	width: 38px;
	height: 38px;
	left: 50%;
	top: 50%;
	border: 3px solid #FFF;
	z-index: -1;
	border-radius: 2px;
	box-shadow: 0px 0px 12px rgba(51, 51, 51, 0.5);
	transform: translate(-22%, -50%) rotate(45deg);
}

.arrow-diamond:not(.arrow-transparent) .twentytwenty-handle span.twentytwenty-left-arrow:after {
	background-color: #FFF;
}

.arrow-diamond .twentytwenty-handle:before {
	bottom: calc(50% + 3px);
}

.arrow-diamond .twentytwenty-handle:after {
	top: calc(50% + 3px);
}

/* ── Handle Color: Bootstrap Presets ─────────────────────────────────────────── */

.twentytwenty-container:not(.arrow-transparent):not(.arrow-diamond).bg-primary .twentytwenty-handle,
.arrow-diamond.bg-primary .twentytwenty-handle span.twentytwenty-left-arrow:after {
	background-color: var(--primary, #007bff);
}

.twentytwenty-container:not(.arrow-transparent):not(.arrow-diamond).bg-secondary .twentytwenty-handle,
.arrow-diamond.bg-secondary .twentytwenty-handle span.twentytwenty-left-arrow:after {
	background-color: var(--secondary, #6c757d);
}

.twentytwenty-container:not(.arrow-transparent):not(.arrow-diamond).bg-warning .twentytwenty-handle,
.arrow-diamond.bg-warning .twentytwenty-handle span.twentytwenty-left-arrow:after {
	background-color: var(--warning, #ffc107);
}

.twentytwenty-container:not(.arrow-transparent):not(.arrow-diamond).bg-info .twentytwenty-handle,
.arrow-diamond.bg-info .twentytwenty-handle span.twentytwenty-left-arrow:after {
	background-color: var(--info, #17a2b8);
}

.twentytwenty-container:not(.arrow-transparent):not(.arrow-diamond).bg-danger .twentytwenty-handle,
.arrow-diamond.bg-danger .twentytwenty-handle span.twentytwenty-left-arrow:after {
	background-color: var(--danger, #dc3545);
}

.twentytwenty-container:not(.arrow-transparent):not(.arrow-diamond).bg-success .twentytwenty-handle,
.arrow-diamond.bg-success .twentytwenty-handle span.twentytwenty-left-arrow:after {
	background-color: var(--success, #28a745);
}

.twentytwenty-container:not(.arrow-transparent):not(.arrow-diamond).bg-dark .twentytwenty-handle,
.arrow-diamond.bg-dark .twentytwenty-handle span.twentytwenty-left-arrow:after {
	background-color: var(--dark, #343a40);
}
