/*
 * Front-end styles for both showcase features, enqueued as one file:
 *   - 3D: the trigger button and its full-screen lightbox.
 *   - 2D: the inline player (poster, stage, play/pause toggle, progress line).
 * Zero-dependency.
 */

.pxks-3d {
	display: inline-block;
}

.pxks-3d__config {
	display: none;
}

[data-pxks-3d-trigger][aria-busy="true"] {
	opacity: 0.6;
	pointer-events: none;
}

html.pxks-showcase-3d-locked {
	overflow: hidden;
}

.pxks-showcase-3d-lightbox {
	position: fixed;
	inset: 0;
	/* Above page-builder overlays, sticky headers and admin bars. */
	z-index: 2147483647;
	background: #cbc3c3;
	display: flex;
	align-items: stretch;
	justify-content: stretch;
	opacity: 0;
	transition: opacity 300ms ease;
}

.pxks-showcase-3d-lightbox[hidden] {
	display: none;
}

.pxks-showcase-3d-lightbox--visible {
	opacity: 1;
}

.pxks-showcase-3d-lightbox__stage {
	flex: 1 1 auto;
	position: relative;
	overflow: hidden;
}

.pxks-showcase-3d-canvas {
	display: block;
	width: 100%;
	height: 100%;
	outline: none;
}

.pxks-showcase-3d-lightbox__close {
	position: absolute;
	top: 16px;
	right: 16px;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.5);
	color: #fff;
	line-height: 1;
	cursor: pointer;
}

.pxks-showcase-3d-lightbox__close:hover,
.pxks-showcase-3d-lightbox__close:focus-visible {
	background: rgba(0, 0, 0, 0.75);
	outline: 2px solid #fff;
}

/*
---------------------------------------------------------------------
 * 2D inline player
 * ------------------------------------------------------------------- */

.pxks-2d {
	display: block;
	width: 100%;
}

/* Default player size: full-width 8:6 (4:3). Themes size the player however
   they like by overriding this rule - a different aspect-ratio, a fixed
   height, a max-width, etc. The stage tracks it (inset: 0). */
.pxks-2d__frame {
	position: relative;
	width: 100%;
	aspect-ratio: 8 / 6;
	background: #000;
	overflow: hidden;
}

/* Poster button - covers the whole box; the visible circle is the centred
   glyph inside it. Removed from flow (hidden) once playback starts. */
.pxks-2d__poster {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: pointer;
}

.pxks-2d__poster img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	/* Matches the running showcase (product-reveal covers the frame), so first
	   paint doesn't jump when playback starts. */
	object-fit: cover;
}

.pxks-2d__poster[aria-busy="true"] {
	pointer-events: none;
}

.pxks-2d__play,
.pxks-2d__toggle-icon {
	position: relative;
	z-index: 1;
	width: 64px;
	height: 64px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	font-size: 20px;
	line-height: 1;
	transition: opacity 0.2s ease, background-color 0.15s ease, transform 0.15s ease;
}

.pxks-2d__poster:hover .pxks-2d__play {
	background: rgba(0, 0, 0, 0.7);
	transform: scale(1.05);
}

.pxks-2d__stage {
	position: absolute;
	inset: 0;
}

/* The class rules below set `display`, which beats the UA `[hidden]` rule at
   equal specificity - so `el.hidden = true` needs this higher-specificity
   guard to actually take the poster / loading overlay out of view. */
.pxks-2d__poster[hidden],
.pxks-2d__loading[hidden] {
	display: none;
}

.pxks-2d__loading {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	font-size: 14px;
	pointer-events: none;
}

/* Full-box toggle over the running showcase - the glyph fades out during
   playback like a video player's overlay and returns on hover. */
.pxks-2d__toggle {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: pointer;
}

.pxks-2d__toggle:disabled {
	cursor: default;
}

.pxks-2d__toggle:disabled .pxks-2d__toggle-icon {
	opacity: 0.4;
}

/* Paused mid-playback: the play glyph sits centred and visible (the base
   .pxks-2d__toggle-icon rule). During playback the whole frame stays the
   click target, but the pause glyph parks in the bottom-right corner and is
   invisible until the frame is hovered - only the progress line shows. */
.pxks-2d__toggle.is-playing {
	align-items: flex-end;
	justify-content: flex-end;
	padding: 12px;
}

.pxks-2d__toggle.is-playing .pxks-2d__toggle-icon {
	width: 44px;
	height: 44px;
	font-size: 16px;
	opacity: 0;
}

.pxks-2d__toggle.is-playing:hover .pxks-2d__toggle-icon {
	opacity: 1;
}

.pxks-2d__toggle:hover:not(:disabled) .pxks-2d__toggle-icon {
	background: rgba(0, 0, 0, 0.7);
}

/* Progress line - 2px along the bottom edge of the frame, brand yellow fill.
   Driven by a requestAnimationFrame loop in trigger.ts (width %). */
.pxks-2d__progress {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 2;
	height: 2px;
	background: rgba(255, 255, 255, 0.2);
	pointer-events: none;
}

.pxks-2d__progress-fill {
	width: 0;
	height: 100%;
	/* Khatra brand yellow (theme --px-color-yellow); hardcoded because this
	   stylesheet is zero-dependency and can't assume the theme is loaded. */
	background: #fbdf4b;
}
