/**
 * ==========================================================
 * YTStealth
 * Controls
 * Version: 3.0 - Premium UX
 * ==========================================================
 *
 * This stylesheet powers all user-facing controls for the
 * YTStealth video player. It follows a premium streaming
 * application aesthetic inspired by Netflix, Disney+, and Vimeo.
 *
 * Architecture:
 *   - CSS Variables for theming
 *   - Floating control bar
 *   - Auto-hide on idle
 *   - Large hit areas (44px minimum)
 *   - Smooth fade animations
 *   - Minimal visual clutter
 *
 * ==========================================================
 */

/*==========================================================
=            CSS Variables
==========================================================*/

:root {
	/* ── Layout ── */
	--yts-control-bar-height: 64px;
	--yts-control-padding: 0 16px;
	--yts-control-gap: 8px;
	--yts-control-radius: 8px;

	/* ── Typography ── */
	--yts-font-size-sm: 12px;
	--yts-font-size-md: 14px;
	--yts-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;

	/* ── Sizing ── */
	--yts-control-button-size: 44px;
	--yts-control-icon-size: 20px;

	/* ── Colors ── */
	--yts-controls-bg: rgba(0, 0, 0, 0.75);
	--yts-controls-bg-hover: rgba(0, 0, 0, 0.85);
	--yts-controls-text: rgba(255, 255, 255, 0.9);
	--yts-controls-text-dim: rgba(255, 255, 255, 0.6);
	--yts-controls-text-hover: #ffffff;
	--yts-controls-accent: #ff0000;
	--yts-controls-accent-hover: #cc0000;
	--yts-controls-border: rgba(255, 255, 255, 0.1);

	/* ── Progress ── */
	--yts-progress-height: 4px;
	--yts-progress-bg: rgba(255, 255, 255, 0.2);
	--yts-progress-buffered: rgba(255, 255, 255, 0.3);
	--yts-progress-played: #ff0000;
	--yts-progress-thumb-size: 14px;
	--yts-progress-thumb-bg: #ff0000;
	--yts-progress-thumb-shadow: 0 0 10px rgba(255, 0, 0, 0.4);

	/* ── Motion ── */
	--yts-transition-fast: 150ms ease;
	--yts-transition-smooth: 300ms cubic-bezier(0.4, 0, 0.2, 1);
	--yts-transition-bounce: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
	--yts-transition-slow: 600ms ease;

	/* ── Layers ── */
	--yts-z-controls: 10;
	--yts-z-progress: 5;
	--yts-z-tooltip: 20;
	--yts-z-menu: 30;
	--yts-z-spinner: 40;
}

/*==========================================================
=            Control Bar - Premium Layout
==========================================================*/

/**
 * Floating control bar overlay
 * Sits at the bottom of the video container
 * Auto-hides on idle for a clean viewing experience
 */

.yts-player .yts-controls {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: var(--yts-z-controls);
	height: var(--yts-control-bar-height);
	padding: var(--yts-control-padding);
	background: linear-gradient(
		to top,
		var(--yts-controls-bg) 0%,
		transparent 100%
	);
	opacity: 1;
	transition: opacity var(--yts-transition-smooth), transform var(--yts-transition-smooth);
	display: flex;
	align-items: center;
	gap: var(--yts-control-gap);
	transform: translateY(0);
}

/* ── Idle State (hidden) ── */

.yts-player.idle .yts-controls {
	opacity: 0;
	pointer-events: none;
	transform: translateY(20px);
	transition: opacity var(--yts-transition-slow), transform var(--yts-transition-slow);
}

/* ── Hover / Active State (visible) ── */

.yts-player:not(.idle) .yts-controls,
.yts-player:hover .yts-controls,
.yts-player.idle .yts-controls:focus-within {
	opacity: 1;
	pointer-events: auto;
	transform: translateY(0);
}

/*==========================================================
=            Controls Layout - Minimal & Clean
==========================================================*/

/**
 * Three-section layout:
 * ┌──────────────┬────────────────────────────┬──────────────┐
 * │ Left         │ Center                     │ Right        │
 * │ (play/pause) │ (progress)                 │ (menu/fs)    │
 * └──────────────┴────────────────────────────┴──────────────┘
 *
 * The progress bar now occupies the majority of the space
 * for a premium streaming experience.
 */

.yts-player .yts-controls .yts-controls-left {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 0 0 auto;
}

.yts-player .yts-controls .yts-controls-center {
	display: flex;
	align-items: center;
	gap: 12px;
	flex: 1 1 auto;
	min-width: 0; /* Prevents flex overflow */
}

.yts-player .yts-controls .yts-controls-right {
	display: flex;
	align-items: center;
	gap: 4px;
	flex: 0 0 auto;
	margin-left: auto;
}

/*==========================================================
=            Buttons - Premium Minimal
==========================================================*/

/**
 * All control buttons inherit from .yts-button
 * This ensures consistent sizing, hover states,
 * and accessibility across the entire player.
 */

.yts-controls .yts-button {
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--yts-control-button-size);
	height: var(--yts-control-button-size);
	border: 0;
	background: transparent;
	color: var(--yts-controls-text);
	cursor: pointer;
	border-radius: 50%;
	transition: all var(--yts-transition-fast);
	padding: 0;
	flex-shrink: 0;
	position: relative;
}

.yts-controls .yts-button:hover {
	background: rgba(255, 255, 255, 0.1);
	transform: scale(1.05);
	color: var(--yts-controls-text-hover);
}

.yts-controls .yts-button:active {
	transform: scale(0.95);
}

.yts-controls .yts-button:focus-visible {
	outline: 2px solid var(--yts-controls-text);
	outline-offset: 2px;
}

.yts-controls .yts-button:disabled {
	opacity: 0.4;
	cursor: not-allowed;
	transform: none !important;
}

/* ── Primary Button (Play/Pause) ── */

.yts-controls .yts-button-primary {
	background: var(--yts-controls-accent);
	color: #ffffff;
}

.yts-controls .yts-button-primary:hover {
	background: var(--yts-controls-accent-hover);
	transform: scale(1.05);
}

.yts-controls .yts-button-primary:active {
	transform: scale(0.95);
}

.yts-controls .yts-button-primary:focus-visible {
	outline: 2px solid var(--yts-controls-accent);
	outline-offset: 2px;
}

/* ── Settings Button ── */

.yts-controls .yts-button-settings {
	position: relative;
}

.yts-controls .yts-button-settings.is-active {
	color: var(--yts-controls-accent);
}

/*==========================================================
=            Button Variants (Play/Pause)
==========================================================*/

/* ── Pause button hidden by default ── */

.yts-player .yts-button-pause {
	display: none;
}

/* ── Show pause when playing ── */

.yts-player.is-playing .yts-button-pause {
	display: flex;
}

.yts-player.is-playing .yts-button-play {
	display: none;
}

/*==========================================================
=            SVG Icons
==========================================================*/

.yts-controls .yts-icon {
	display: block;
	width: var(--yts-control-icon-size);
	height: var(--yts-control-icon-size);
	fill: currentColor;
	pointer-events: none;
	flex-shrink: 0;
}

/*==========================================================
=            Tooltips
==========================================================*/

.yts-controls .yts-tooltip {
	position: absolute;
	bottom: calc(100% + 8px);
	left: 50%;
	transform: translateX(-50%) scale(0.9);
	padding: 4px 10px;
	background: rgba(0, 0, 0, 0.85);
	color: #ffffff;
	font-size: 11px;
	font-weight: 500;
	font-family: var(--yts-font-family);
	border-radius: 4px;
	white-space: nowrap;
	opacity: 0;
	pointer-events: none;
	transition: all var(--yts-transition-fast);
	z-index: var(--yts-z-tooltip);
	letter-spacing: 0.3px;
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
}

.yts-controls .yts-tooltip::after {
	content: '';
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%);
	border: 4px solid transparent;
	border-top-color: rgba(0, 0, 0, 0.85);
}

.yts-controls .yts-button:hover .yts-tooltip,
.yts-controls .yts-button:focus-visible .yts-tooltip {
	opacity: 1;
	transform: translateX(-50%) scale(1);
}

.yts-controls .yts-tooltip .yts-shortcut {
	display: inline-block;
	margin-left: 4px;
	padding: 0 4px;
	background: rgba(255, 255, 255, 0.15);
	border-radius: 2px;
	font-size: 9px;
	font-weight: 600;
	color: var(--yts-controls-text-dim);
	letter-spacing: 0.5px;
}

/*==========================================================
=            Progress Container - Full Width
==========================================================*/

/**
 * The progress container now uses flex: 1 to fill all
 * available space between the left and right controls.
 */

.yts-controls .yts-progress-container {
	display: flex;
	align-items: center;
	gap: 12px;
	flex: 1 1 auto;
	min-width: 0;
}

/*==========================================================
=            Progress Bar - Full Width
==========================================================*/

.yts-controls .yts-progress {
	position: relative;
	flex: 1 1 auto;
	height: var(--yts-progress-height);
	min-height: 20px; /* Large hit area for interaction */
	cursor: pointer;
	background: transparent;
	touch-action: none;
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	user-select: none;
}

.yts-controls .yts-progress::before {
	content: '';
	position: absolute;
	top: 50%;
	left: 0;
	right: 0;
	height: var(--yts-progress-height);
	transform: translateY(-50%);
	background: var(--yts-progress-bg);
	border-radius: 2px;
	transition: transform var(--yts-transition-fast);
	pointer-events: none;
	will-change: transform;
}

.yts-controls .yts-progress:hover::before {
	transform: translateY(-50%) scaleY(1.8);
}

.yts-controls .yts-progress.is-disabled {
	pointer-events: none;
	opacity: 0.5;
	cursor: not-allowed;
}

/*==========================================================
=            Buffered Progress
==========================================================*/

.yts-controls .yts-progress-buffered {
	position: absolute;
	top: 50%;
	left: 0;
	height: var(--yts-progress-height);
	transform: translateY(-50%);
	background: var(--yts-progress-buffered);
	border-radius: 2px;
	pointer-events: none;
	transition: width var(--yts-transition-fast);
	width: 0%;
	will-change: width;
}

.yts-controls .yts-progress:hover .yts-progress-buffered {
	transform: translateY(-50%) scaleY(1.8);
}

/*==========================================================
=            Played Progress
==========================================================*/

.yts-controls .yts-progress-played {
	position: absolute;
	top: 50%;
	left: 0;
	height: var(--yts-progress-height);
	transform: translateY(-50%);
	background: var(--yts-progress-played);
	border-radius: 2px;
	pointer-events: none;
	transition: width var(--yts-transition-fast);
	width: 0%;
	will-change: width;
}

.yts-controls .yts-progress:hover .yts-progress-played {
	transform: translateY(-50%) scaleY(1.8);
}

/*==========================================================
=            Progress Thumb
==========================================================*/

.yts-controls .yts-progress-thumb {
	position: absolute;
	top: 50%;
	left: 0%;
	width: var(--yts-progress-thumb-size);
	height: var(--yts-progress-thumb-size);
	transform: translate(-50%, -50%) scale(0);
	background: var(--yts-progress-thumb-bg);
	border-radius: 50%;
	pointer-events: none;
	transition: transform var(--yts-transition-bounce);
	box-shadow: var(--yts-progress-thumb-shadow);
	z-index: var(--yts-z-progress);
	will-change: transform;
}

.yts-controls .yts-progress:hover .yts-progress-thumb,
.yts-controls .yts-progress.is-dragging .yts-progress-thumb {
	transform: translate(-50%, -50%) scale(1);
}

.yts-controls .yts-progress.is-dragging .yts-progress-thumb {
	transform: translate(-50%, -50%) scale(1.2);
	box-shadow: 0 0 20px rgba(255, 0, 0, 0.6);
}

/*==========================================================
=            Native Range Input (Hidden)
==========================================================*/

/**
 * The native range input is hidden but remains functional
 * for keyboard accessibility and mouse/touch interaction.
 * The custom progress bar provides the visual feedback.
 */

.yts-controls .yts-progress-slider {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	opacity: 0;
	cursor: pointer;
	z-index: calc(var(--yts-z-progress) + 1);
	-webkit-appearance: none;
	appearance: none;
	background: transparent;
	margin: 0;
	padding: 0;
}

/* Remove default styling for WebKit */
.yts-controls .yts-progress-slider::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 20px;
	height: 20px;
	background: transparent;
	cursor: pointer;
}

/* Remove default styling for Firefox */
.yts-controls .yts-progress-slider::-moz-range-thumb {
	width: 20px;
	height: 20px;
	background: transparent;
	cursor: pointer;
	border: 0;
}

/* Remove default track styling */
.yts-controls .yts-progress-slider::-webkit-slider-runnable-track {
	width: 100%;
	height: 100%;
	background: transparent;
	border: 0;
}

.yts-controls .yts-progress-slider::-moz-range-track {
	width: 100%;
	height: 100%;
	background: transparent;
	border: 0;
}

/*==========================================================
=            Time Display - Minimal
==========================================================*/

.yts-controls .yts-time {
	font-size: var(--yts-font-size-sm);
	font-weight: 500;
	font-family: var(--yts-font-family);
	color: var(--yts-controls-text);
	letter-spacing: 0.5px;
	font-variant-numeric: tabular-nums;
	font-feature-settings: "tnum";
	white-space: nowrap;
	flex-shrink: 0;
}

.yts-controls .yts-time-duration {
	color: var(--yts-controls-text-dim);
}

/*==========================================================
=            Keyboard Shortcuts - Visual Feedback
==========================================================*/

.yts-player .yts-keyboard-hint {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%) scale(0.8);
	padding: 12px 24px;
	background: rgba(0, 0, 0, 0.8);
	color: #ffffff;
	font-size: 24px;
	font-weight: 600;
	font-family: var(--yts-font-family);
	border-radius: 8px;
	opacity: 0;
	pointer-events: none;
	transition: all var(--yts-transition-smooth);
	z-index: var(--yts-z-tooltip);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
}

.yts-player .yts-keyboard-hint.is-visible {
	opacity: 1;
	transform: translate(-50%, -50%) scale(1);
}

/*==========================================================
=            Loading / Buffering Overlay
==========================================================*/

.yts-player .yts-buffering-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.18);
	opacity: 0;
	pointer-events: none;
	transition: opacity var(--yts-transition-smooth);
	z-index: var(--yts-z-spinner);
}

.yts-player.is-buffering .yts-buffering-overlay {
	opacity: 1;
}

.yts-player .yts-buffering-overlay .yts-icon-spinner {
	width: 48px;
	height: 48px;
	color: #ffffff;
}

/*==========================================================
=            Accessibility - Keyboard Focus
==========================================================*/

.yts-controls .yts-button:focus-visible {
	outline: 2px solid rgba(255, 255, 255, 0.8);
	outline-offset: 2px;
}

.yts-controls .yts-button-primary:focus-visible {
	outline: 2px solid var(--yts-controls-accent);
	outline-offset: 2px;
}

.yts-controls input[type="range"]:focus-visible {
	outline: 2px solid rgba(255, 255, 255, 0.8);
	outline-offset: 2px;
}

/*==========================================================
=            Accessibility - Reduced Motion
==========================================================*/

@media (prefers-reduced-motion: reduce) {
	.yts-controls .yts-button .yts-icon {
		transition: none;
	}

	.yts-controls .yts-icon-spinner {
		animation: none;
	}

	.yts-controls .yts-tooltip {
		transition: none;
	}

	.yts-controls .yts-button {
		transition: none;
	}

	.yts-player .yts-controls {
		transition: none;
	}

	.yts-controls .yts-progress-played {
		transition: none;
	}

	.yts-controls .yts-progress-buffered {
		transition: none;
	}

	.yts-controls .yts-progress-thumb {
		transition: none;
	}

	.yts-controls .yts-progress-preview {
		transition: none;
	}

	.yts-controls .yts-progress::before {
		transition: none;
	}

	.yts-player .yts-keyboard-hint {
		transition: none;
	}

	.yts-player .yts-buffering-overlay {
		transition: none;
	}
}

/*==========================================================
=            Responsive - Touch Devices
==========================================================*/

@media (hover: none) {
	.yts-controls .yts-progress-preview {
		display: none;
	}

	.yts-controls .yts-progress-thumb {
		transform: translate(-50%, -50%) scale(0.6);
	}

	.yts-controls .yts-progress.is-dragging .yts-progress-thumb {
		transform: translate(-50%, -50%) scale(1.2);
	}
}

/*==========================================================
=            Responsive - Screen Size
==========================================================*/

@media (max-width: 768px) {
	:root {
		--yts-control-bar-height: 56px;
		--yts-control-button-size: 40px;
		--yts-control-icon-size: 18px;
		--yts-control-padding: 0 12px;
	}

	.yts-player .yts-controls-center {
		gap: 8px;
	}

	.yts-controls .yts-tooltip {
		font-size: 10px;
		padding: 3px 8px;
	}

	.yts-controls .yts-tooltip .yts-shortcut {
		font-size: 8px;
	}

	.yts-controls .yts-time {
		font-size: 11px;
	}
}

@media (max-width: 480px) {
	:root {
		--yts-control-bar-height: 48px;
		--yts-control-button-size: 36px;
		--yts-control-icon-size: 16px;
		--yts-control-padding: 0 8px;
		--yts-control-gap: 4px;
	}

	.yts-controls .yts-tooltip {
		display: none;
	}

	.yts-controls .yts-time-duration {
		display: none;
	}
}