/*
 * TikTok frame. 100% scale is 325×578, the native player/v1 size.
 * --wtt-video-scale and --wtt-thumb-scale are percents (40–200).
 * --wtt-thumb-x is the horizontal crop, 0% left through 100% right.
 * The iframe stays 325×578 and is scaled to the box so it can be smaller
 * than TikTok's minimum width. Keep these sizes in sync with helpers.php.
 */

.wtt {
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 100%;
	min-width: 0;
}

.wtt *,
.wtt *::before,
.wtt *::after {
	box-sizing: border-box;
}

.wtt.is-start {
	align-items: flex-start;
	text-align: start;
}

.wtt.is-center {
	align-items: center;
	text-align: center;
}

.wtt.is-end {
	align-items: flex-end;
	text-align: end;
}

.wtt-title {
	margin: 0 0 8px;
	max-width: 100%;
	font-size: 1.05rem;
	font-weight: 700;
	line-height: 1.4;
}

.wtt-stage {
	display: flex;
	width: 100%;
	max-width: 100%;
	min-width: 0;
}

.wtt.is-start .wtt-stage {
	justify-content: flex-start;
}

.wtt.is-center .wtt-stage {
	justify-content: center;
}

.wtt.is-end .wtt-stage {
	justify-content: flex-end;
}

.wtt-thumb,
.wtt-video {
	min-width: 0;
	max-width: 100%;
}

.wtt-thumb {
	position: relative;
	width: calc(325px * var(--wtt-scale, var(--wtt-video-scale)) / 100);
	aspect-ratio: 325 / 578;
	overflow: hidden;
	border-radius: 12px;
	background: #111;
}

.wtt-video {
	position: relative;
	width: calc(325px * var(--wtt-scale, var(--wtt-video-scale)) / 100);
	aspect-ratio: 325 / 578;
	overflow: hidden;
	border-radius: 12px;
	background: #111;
	container-type: inline-size;
}

.elementor .wtt-video iframe,
.wtt-video iframe {
	position: absolute;
	top: 0;
	left: 0;
	width: 325px;
	height: 578px;
	/* Theme iframe { max-width: 100% } and Elementor .elementor iframe
	   { width: 100%; max-width: 100% } would shrink this before the scale
	   transform and leave a black gap on the right. */
	max-width: none;
	max-height: none;
	border: 0;
	transform-origin: top left;
	transform: scale(calc(100cqw / 325px));
}

@supports not (width: 1cqw) {
	.wtt-video {
		height: calc(578px * var(--wtt-scale, var(--wtt-video-scale)) / 100);
		aspect-ratio: auto;
	}

	.elementor .wtt-video iframe,
	.wtt-video iframe {
		transform: scale(calc(var(--wtt-scale, var(--wtt-video-scale)) / 100));
	}

	.wtt-thumb {
		height: calc(578px * var(--wtt-scale, var(--wtt-video-scale)) / 100);
		aspect-ratio: auto;
	}
}

.wtt-play {
	position: relative;
	display: block;
	width: 100%;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border: 0;
	border-radius: 12px;
	background: radial-gradient(circle at 50% 42%, #3a3f4b 0%, #121418 70%);
	height: 100%;
	aspect-ratio: auto;
	color: #fff;
	line-height: 0;
	text-decoration: none;
	cursor: pointer;
}

a.wtt-play,
a.wtt-play:hover,
a.wtt-play:focus {
	color: #fff;
	text-decoration: none;
}

.elementor .wtt-play img,
.wtt-play img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	/* Elementor .elementor img { height: auto; max-width: 100% } would
	   show the whole poster as a strip and leave the frame empty, so
	   the horizontal crop has nothing to move. */
	max-width: none;
	max-height: none;
	object-fit: cover;
	object-position: var(--wtt-thumb-x, 50%) center;
}

.wtt-play-icon {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
}

.wtt-play-icon span {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 68px;
	height: 68px;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.55);
	box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
}

.wtt-play:hover .wtt-play-icon span,
.wtt-play:focus-visible .wtt-play-icon span {
	background: rgba(0, 0, 0, 0.72);
}

.wtt-play:focus-visible {
	outline: 3px solid #0a4f9a;
	outline-offset: 3px;
}

.wtt-note {
	margin: 0;
	padding: 12px 14px;
	border: 1px dashed #c3c4c7;
	border-radius: 8px;
	color: #50575e;
	font-size: 14px;
	line-height: 1.5;
}

.wow-tiktok-editor {
	width: 100%;
}

.wow-tiktok-editor .wtt {
	margin-top: 12px;
}

.wow-tiktok-editor .wtt-video iframe {
	pointer-events: none;
}

.wow-tiktok-editor.is-selected .wtt-video,
.wow-tiktok-editor.is-selected .wtt-thumb {
	outline: 1px dashed rgba(10, 79, 154, 0.9);
	outline-offset: 3px;
}

.wow-tiktok-editor .wtt-drag {
	position: absolute;
	z-index: 3;
	inset: 0;
	display: block;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: nwse-resize;
	opacity: 0;
	pointer-events: none;
	touch-action: none;
}

.wow-tiktok-editor.is-selected .wtt-drag {
	opacity: 1;
	pointer-events: auto;
}

.wow-tiktok-editor .wtt-pan {
	position: absolute;
	z-index: 2;
	inset: 0;
	display: block;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: ew-resize;
	pointer-events: none;
	touch-action: none;
}

.wow-tiktok-editor.is-selected .wtt-pan {
	pointer-events: auto;
}

.wow-tiktok-editor .wtt-pan:focus-visible {
	outline: 3px solid #0a4f9a;
	outline-offset: -3px;
}

.wow-tiktok-editor.is-selected .wtt-thumb.has-pan .wtt-drag {
	pointer-events: none;
}

.wow-tiktok-editor.is-selected .wtt-thumb.has-pan .wtt-drag-grip {
	pointer-events: auto;
	cursor: nwse-resize;
}

.wow-tiktok-editor.is-selected .wtt.is-end .wtt-thumb.has-pan .wtt-drag-grip {
	cursor: nesw-resize;
}

.wow-tiktok-editor .wtt-drag-grip::before {
	content: "";
	position: absolute;
	right: -14px;
	bottom: -14px;
	width: 48px;
	height: 48px;
}

.wow-tiktok-editor .wtt.is-end .wtt-drag-grip::before {
	right: auto;
	left: -14px;
}

.wow-tiktok-editor .wtt.is-end .wtt-drag {
	cursor: nesw-resize;
}

.wow-tiktok-editor .wtt-drag-grip {
	position: absolute;
	right: 8px;
	bottom: 8px;
	width: 22px;
	height: 22px;
	border-right: 3px solid #fff;
	border-bottom: 3px solid #fff;
	filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.8));
	pointer-events: none;
}

.wow-tiktok-editor .wtt.is-end .wtt-drag-grip {
	right: auto;
	left: 8px;
	border-right: 0;
	border-left: 3px solid #fff;
}

.wow-tiktok-editor .wtt-drag-label {
	position: absolute;
	top: 8px;
	left: 8px;
	padding: 2px 8px;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.72);
	color: #fff;
	font-size: 12px;
	line-height: 1.4;
	pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
	.wtt-play-icon span {
		transition: none;
	}
}
