/* ──────────────────────────────────────────────────
 * HLS Video Player — Custom Styles
 * Cookieless · Glass Blur · Gradient Branded Controls
 * Zero external dependencies.
 * ────────────────────────────────────────────────── */

/* ── CSS Custom Properties (defaults — overridden by Elementor selectors) ── */
.hls-player-wrap {
	--gradient-start: #6366f1;
	--gradient-end: #ec4899;
	--icon-color: #ffffff;
	--glass-opacity: 0.25;
	--ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
	--ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
	--ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Wrapper & Aspect Ratios ── */

.hls-player-wrap {
	position: relative;
	width: 100%;
	overflow: hidden;
	border-radius: 12px;
	background: #000;
	cursor: pointer;
	user-select: none;
	-webkit-user-select: none;
	line-height: 0;
	contain: layout style;
	will-change: transform;
}

/* Hide cursor when controls are hidden during playback */
.hls-player-wrap.is-playing:not(.show-controls) {
	cursor: none;
}

.hls-ratio-16-9  { aspect-ratio: 16 / 9; }
.hls-ratio-4-3   { aspect-ratio: 4 / 3; }
.hls-ratio-1-1   { aspect-ratio: 1 / 1; }
.hls-ratio-9-16  { aspect-ratio: 9 / 16; }
.hls-ratio-21-9  { aspect-ratio: 21 / 9; }

@supports not (aspect-ratio: 1) {
	.hls-ratio-16-9::before  { content: ''; display: block; padding-top: 56.25%; }
	.hls-ratio-4-3::before   { content: ''; display: block; padding-top: 75%; }
	.hls-ratio-1-1::before   { content: ''; display: block; padding-top: 100%; }
	.hls-ratio-9-16::before  { content: ''; display: block; padding-top: 177.78%; }
	.hls-ratio-21-9::before  { content: ''; display: block; padding-top: 42.86%; }

	.hls-player-wrap .hls-video {
		position: absolute;
		top: 0;
		left: 0;
	}
}

/* ── Video Element ── */

.hls-video {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* ── Big Center Play Button ── */

.hls-big-play {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%) scale(1);
	width: 68px;
	height: 68px;
	border: 1px solid rgba(255, 255, 255, 0.15);
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.1);
	backdrop-filter: blur(24px) saturate(1.4);
	-webkit-backdrop-filter: blur(24px) saturate(1.4);
	color: #fff;
	cursor: pointer;
	z-index: 10;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow:
		0 8px 32px rgba(0, 0, 0, 0.12),
		0 2px 8px rgba(0, 0, 0, 0.08);
	transition: all 0.5s var(--ease-out-expo);
}

.hls-big-play:hover {
	background: rgba(255, 255, 255, 0.16);
	border-color: rgba(255, 255, 255, 0.25);
	transform: translate(-50%, -50%) scale(1.06);
	box-shadow:
		0 12px 40px rgba(0, 0, 0, 0.15),
		0 4px 12px rgba(0, 0, 0, 0.1);
}

.hls-big-play:active {
	transform: translate(-50%, -50%) scale(0.96);
	transition-duration: 0.1s;
}

.hls-big-play svg {
	width: 32px;
	height: 32px;
	margin-left: 2px;
}

.hls-player-wrap.is-playing .hls-big-play,
.hls-player-wrap.has-played .hls-big-play {
	opacity: 0;
	pointer-events: none;
	transform: translate(-50%, -50%) scale(1.15);
}

/* ── Loading Spinner ── */

.hls-loader {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	z-index: 9;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease;
}

.hls-player-wrap.is-loading .hls-loader {
	opacity: 1;
}

.hls-player-wrap.is-loading .hls-big-play {
	opacity: 0;
	pointer-events: none;
}

.hls-spinner {
	width: 36px;
	height: 36px;
	border: 2px solid rgba(255, 255, 255, 0.1);
	border-top-color: rgba(255, 255, 255, 0.8);
	border-radius: 50%;
	animation: none;
}

.hls-player-wrap.is-loading .hls-spinner {
	animation: hls-spin 0.7s linear infinite;
}

@keyframes hls-spin {
	to { transform: rotate(360deg); }
}

/* ── Controls Overlay ── */

.hls-controls {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	padding: 0 16px 14px;
	z-index: 20;
	background: linear-gradient(
		to top,
		rgba(0, 0, 0, calc(var(--glass-opacity) + 0.2)) 0%,
		rgba(0, 0, 0, calc(var(--glass-opacity) * 0.5)) 40%,
		rgba(0, 0, 0, calc(var(--glass-opacity) * 0.1)) 70%,
		transparent 100%
	);
	backdrop-filter: blur(16px) saturate(1.2);
	-webkit-backdrop-filter: blur(16px) saturate(1.2);
	opacity: 0;
	transform: translateY(2px);
	transition: opacity 0.18s ease-out, transform 0.18s ease-out;
	pointer-events: none;
}

.hls-player-wrap.show-controls .hls-controls,
.hls-player-wrap:not(.is-playing).has-played .hls-controls {
	opacity: 1;
	transform: translateY(0);
	pointer-events: auto;
	transition: opacity 0.22s var(--ease-out-quart), transform 0.22s var(--ease-out-expo);
}

/* ── Progress Bar ── */

.hls-progress-wrap {
	position: relative;
	width: 100%;
	padding: 8px 0;
	cursor: pointer;
}

.hls-progress-bar {
	position: relative;
	width: 100%;
	height: 3px;
	background: rgba(255, 255, 255, 0.12);
	border-radius: 99px;
	overflow: visible;
	transition: height 0.2s var(--ease-out-expo), background 0.2s ease;
}

.hls-progress-wrap:hover .hls-progress-bar {
	height: 5px;
}

.hls-progress-buffered {
	position: absolute;
	top: 0;
	left: 0;
	height: 100%;
	background: rgba(255, 255, 255, 0.12);
	border-radius: 99px;
	width: 0%;
	transition: width 0.3s ease;
}

.hls-progress-played {
	position: absolute;
	top: 0;
	left: 0;
	height: 100%;
	background: linear-gradient(90deg, #9142FF, #45C2FA 45%, #7CC800);
	background-size: var(--progress-total-width, 100vw) 100%;
	background-position: left;
	border-radius: 99px;
	width: 0%;
}

.hls-progress-handle {
	position: absolute;
	top: 50%;
	left: 0%;
	width: 12px;
	height: 12px;
	background: #fff;
	border-radius: 50%;
	transform: translate(-50%, -50%) scale(0);
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.1);
	transition: transform 0.25s var(--ease-spring), box-shadow 0.2s ease;
}

.hls-progress-wrap:hover .hls-progress-handle {
	transform: translate(-50%, -50%) scale(1);
}

.hls-progress-wrap:active .hls-progress-handle {
	transform: translate(-50%, -50%) scale(1.2);
	box-shadow: 0 1px 6px rgba(0, 0, 0, 0.3), 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.hls-progress-tooltip {
	position: absolute;
	bottom: calc(100% + 8px);
	left: 0;
	transform: translateX(-50%) translateY(4px);
	background: rgba(0, 0, 0, 0.75);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	color: rgba(255, 255, 255, 0.95);
	font-size: 12px;
	font-weight: 500;
	line-height: 1;
	padding: 5px 10px;
	border-radius: 6px;
	white-space: nowrap;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease, transform 0.2s var(--ease-out-expo);
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.01em;
}

.hls-progress-wrap:hover .hls-progress-tooltip {
	opacity: 1;
	transform: translateX(-50%) translateY(0);
}

/* ── Bottom Controls Row ── */

.hls-controls-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}

.hls-controls-left,
.hls-controls-right {
	display: flex;
	align-items: center;
	gap: 6px;
}

/* ── Buttons ── */

.hls-btn {
	background: transparent;
	border: none;
	padding: 7px;
	cursor: pointer;
	color: var(--icon-color);
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0.85;
	transition: opacity 0.2s ease, background 0.2s ease, transform 0.15s var(--ease-out-expo);
	line-height: 0;
}

.hls-btn:hover {
	opacity: 1;
	background: rgba(255, 255, 255, 0.08);
}

.hls-btn:active {
	transform: scale(0.9);
	transition-duration: 0.08s;
}

.hls-btn svg {
	width: 20px;
	height: 20px;
}

/* Play/Pause icon crossfade */
.hls-btn-play,
.hls-btn-fullscreen {
	position: relative;
}

.hls-btn-play .hls-icon-play,
.hls-btn-play .hls-icon-pause,
.hls-btn-fullscreen .hls-icon-fs-enter,
.hls-btn-fullscreen .hls-icon-fs-exit {
	transition: opacity 0.2s ease;
}

.hls-btn-play .hls-icon-pause,
.hls-btn-fullscreen .hls-icon-fs-exit {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	opacity: 0;
	pointer-events: none;
}

.hls-player-wrap.is-playing .hls-btn-play .hls-icon-play {
	opacity: 0;
	pointer-events: none;
}
.hls-player-wrap.is-playing .hls-btn-play .hls-icon-pause {
	opacity: 1;
	pointer-events: auto;
}

.hls-player-wrap.is-fullscreen .hls-btn-fullscreen .hls-icon-fs-enter {
	opacity: 0;
	pointer-events: none;
}
.hls-player-wrap.is-fullscreen .hls-btn-fullscreen .hls-icon-fs-exit {
	opacity: 1;
	pointer-events: auto;
}

/* Volume icon toggle */
.hls-player-wrap .hls-icon-vol-off         { display: none; }
.hls-player-wrap.is-muted .hls-icon-vol-on { display: none; }
.hls-player-wrap.is-muted .hls-icon-vol-off { display: block; }

/* ── Volume Slider ── */

.hls-volume-group {
	display: flex;
	align-items: center;
	gap: 4px;
}

.hls-volume-slider {
	--vol: 1;
	width: 0;
	opacity: 0;
	overflow: hidden;
	transition: width 0.3s var(--ease-out-expo), opacity 0.25s ease;
	-webkit-appearance: none;
	appearance: none;
	height: 4px;
	background: linear-gradient(
		to right,
		rgba(255, 255, 255, 0.9) 0%,
		rgba(255, 255, 255, 0.9) calc(var(--vol) * 100%),
		rgba(255, 255, 255, 0.2) calc(var(--vol) * 100%),
		rgba(255, 255, 255, 0.2) 100%
	);
	border-radius: 99px;
	outline: none;
	cursor: pointer;
}

.hls-volume-group:hover .hls-volume-slider,
.hls-volume-slider:focus {
	width: 64px;
	opacity: 1;
}

.hls-volume-slider::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 10px;
	height: 10px;
	background: #fff;
	border-radius: 50%;
	cursor: pointer;
	box-shadow: 0 0 2px rgba(0, 0, 0, 0.3);
}

.hls-volume-slider::-moz-range-thumb {
	width: 10px;
	height: 10px;
	background: #fff;
	border-radius: 50%;
	cursor: pointer;
	border: none;
	box-shadow: 0 0 2px rgba(0, 0, 0, 0.3);
}

.hls-volume-slider::-moz-range-track {
	height: 4px;
	background: transparent;
	border: none;
}

.hls-volume-slider::-moz-range-progress {
	height: 4px;
	background: #fff;
	border-radius: 99px;
}

/* ── Time Display ── */

.hls-time {
	font-size: 13px;
	font-weight: 500;
	color: var(--icon-color);
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	line-height: 1;
	opacity: 0.7;
	letter-spacing: 0.01em;
}

.hls-time-sep {
	margin: 0 4px;
	opacity: 0.35;
	font-weight: 400;
}

/* ── Fullscreen tweaks ── */

.hls-player-wrap:-webkit-full-screen { border-radius: 0; }
.hls-player-wrap:fullscreen          { border-radius: 0; }

/* ── Mobile adjustments ── */

@media (max-width: 600px) {
	.hls-big-play {
		width: 56px;
		height: 56px;
	}

	.hls-big-play svg {
		width: 24px;
		height: 24px;
	}

	.hls-controls {
		padding: 0 12px 10px;
		transition: opacity 0.15s ease-out, transform 0.15s ease-out;
		transform: translateY(0);
	}

	.hls-btn svg {
		width: 18px;
		height: 18px;
	}

	.hls-btn {
		padding: 6px;
	}

	.hls-time {
		font-size: 11px;
	}

	.hls-volume-group:hover .hls-volume-slider {
		width: 40px;
	}
}

/* ── Hide volume on touch-only devices (iOS ignores programmatic volume) ── */

@media (hover: none) and (pointer: coarse) {
	.hls-volume-slider {
		display: none;
	}
}

/* ── Unmute Prompt (autoplay-muted indicator) ── */

.hls-unmute-prompt {
	position: absolute;
	bottom: 16px;
	left: 16px;
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	background: rgba(0, 0, 0, 0.6);
	backdrop-filter: blur(12px) saturate(1.2);
	-webkit-backdrop-filter: blur(12px) saturate(1.2);
	border: 1px solid rgba(255, 255, 255, 0.12);
	border-radius: 8px;
	color: #fff;
	font-size: 13px;
	font-weight: 500;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	cursor: pointer;
	z-index: 15;
	opacity: 0;
	pointer-events: none;
	transform: translateY(4px);
	transition: opacity 0.3s ease, transform 0.3s var(--ease-out-expo);
}

.hls-unmute-prompt svg {
	width: 18px;
	height: 18px;
	flex-shrink: 0;
}

.hls-player-wrap.is-muted.is-playing .hls-unmute-prompt {
	opacity: 1;
	pointer-events: auto;
	transform: translateY(0);
}

.hls-unmute-prompt:hover {
	background: rgba(0, 0, 0, 0.75);
}

/* ── Poster gradient overlay for initial state ── */

.hls-player-wrap:not(.has-played)::after {
	content: '';
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	height: 50%;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.25) 0%, rgba(0, 0, 0, 0.08) 40%, transparent 100%);
	z-index: 5;
	pointer-events: none;
	transition: opacity 0.5s var(--ease-out-quart);
}

.hls-player-wrap.has-played::after {
	opacity: 0;
}

/* ── Play/Pause Center Indicator (YouTube-style) ── */

.hls-action-indicator {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%) scale(0.5);
	width: 52px;
	height: 52px;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.35);
	backdrop-filter: blur(12px) saturate(1.2);
	-webkit-backdrop-filter: blur(12px) saturate(1.2);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	pointer-events: none;
	z-index: 11;
}

.hls-action-indicator svg {
	width: 24px;
	height: 24px;
}

.hls-action-indicator .hls-action-pause {
	display: none;
}

.hls-action-indicator.show-play .hls-action-play  { display: block; }
.hls-action-indicator.show-play .hls-action-pause { display: none; }
.hls-action-indicator.show-pause .hls-action-play { display: none; }
.hls-action-indicator.show-pause .hls-action-pause { display: block; }

@keyframes hls-action-pop {
	0%   { opacity: 0.7; transform: translate(-50%, -50%) scale(0.8); }
	50%  { opacity: 0.5; }
	100% { opacity: 0;   transform: translate(-50%, -50%) scale(1.15); }
}

.hls-action-indicator.is-animating {
	animation: hls-action-pop 0.45s var(--ease-out-expo) forwards;
}

/* ── Focus-visible for keyboard accessibility ── */

.hls-player-wrap:focus-visible {
	outline: 2px solid var(--gradient-start);
	outline-offset: 2px;
}

.hls-btn:focus-visible {
	outline: 2px solid var(--gradient-start);
	outline-offset: 2px;
	opacity: 1;
}

.hls-big-play:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 4px;
	box-shadow: 0 6px 32px rgba(0, 0, 0, 0.5);
}

.hls-volume-slider:focus-visible {
	outline: 2px solid var(--gradient-start);
	outline-offset: 2px;
	width: 60px;
	opacity: 1;
}

/* ── Placeholder (no URL set in editor) ── */

.hls-player-placeholder {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
