/**
 * GaryModule – Audio Player Front CSS
 * Premium dark player, responsive, animated
 */

/* ── Variables & Root ── */
#gary-player {
	--gary-height: 80px;
	--gary-primary: #e74c3c;
	--gary-bg: #111827;
	--gary-text: #f9fafb;
	--gary-progress: #e74c3c;
	--gary-radius: 8px;
	--gary-shadow: 0 -4px 30px rgba(0, 0, 0, 0.4);
	--gary-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Main Player Bar ── */
#gary-player {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 9999;
	font-family:
		-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
		sans-serif;
	color: var(--gary-text);
	user-select: none;
	-webkit-user-select: none;
}

.gary-bar {
	height: var(--gary-height);
	background: var(--gary-bg);
	display: flex;
	align-items: center;
	padding: 0 16px;
	gap: 12px;
	box-shadow: var(--gary-shadow);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	position: relative;
	border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* ── Cover Art ── */
.gary-cover-wrap {
	width: 52px;
	height: 52px;
	flex-shrink: 0;
	position: relative;
}

.gary-cover {
	width: 52px;
	height: 52px;
	border-radius: 50%;
	object-fit: cover;
	border: 2px solid rgba(255, 255, 255, 0.12);
	transition: transform var(--gary-transition);
	position: relative;
	z-index: 2;
}

#gary-player.playing .gary-cover {
	animation: gary-spin 4s linear infinite;
}

@keyframes gary-spin {
	from {
		transform: rotate(0deg);
	}
	to {
		transform: rotate(360deg);
	}
}

.gary-cover-vinyl {
	position: absolute;
	top: 0;
	left: 0;
	width: 52px;
	height: 52px;
	border-radius: 50%;
	background: radial-gradient(
		circle at 50% 50%,
		#222 20%,
		#333 21%,
		#222 22%,
		#333 40%,
		#222 41%,
		#111 60%,
		#222 100%
	);
	z-index: 1;
	opacity: 0;
	transition: opacity var(--gary-transition);
}

#gary-player.playing .gary-cover-vinyl {
	opacity: 1;
	transform: translateX(8px);
}

/* ── Track Info ── */
.gary-info {
	flex-shrink: 1;
	min-width: 0;
	max-width: 180px;
	overflow: hidden;
}

.gary-title {
	font-size: 13px;
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	color: var(--gary-text);
}

.gary-artist {
	font-size: 11px;
	color: rgba(255, 255, 255, 0.5);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ── Control Buttons ── */
.gary-controls {
	display: flex;
	align-items: center;
	gap: 4px;
	flex-shrink: 0;
}

.gary-btn {
	background: none;
	border: none;
	cursor: pointer;
	padding: 6px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all var(--gary-transition);
	color: var(--gary-text);
	outline: none;
}

.gary-btn:hover {
	background: rgba(255, 255, 255, 0.1);
	transform: scale(1.1);
}

.gary-btn:active {
	transform: scale(0.95);
}

.gary-btn svg {
	width: 22px;
	height: 22px;
	fill: currentColor;
}

.gary-btn-play {
	width: 40px;
	height: 40px;
	background: var(--gary-primary);
	border-radius: 50%;
	color: #fff;
	margin: 0 4px;
}

.gary-btn-play:hover {
	background: var(--gary-primary);
	filter: brightness(1.15);
}

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

/* Show/hide play/pause icons */
.gary-icon-pause {
	display: none;
}
#gary-player.playing .gary-icon-play {
	display: none;
}
#gary-player.playing .gary-icon-pause {
	display: block;
}

/* ── Progress Bar ── */
.gary-progress-wrap {
	flex: 1;
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
}

.gary-time {
	font-size: 11px;
	color: rgba(255, 255, 255, 0.5);
	font-variant-numeric: tabular-nums;
	flex-shrink: 0;
	min-width: 36px;
	text-align: center;
}

.gary-progress-bar {
	flex: 1;
	height: 5px;
	background: rgba(255, 255, 255, 0.12);
	border-radius: 3px;
	cursor: pointer;
	position: relative;
	transition: height var(--gary-transition);
}

.gary-progress-bar:hover {
	height: 8px;
}

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

.gary-progress-filled {
	position: absolute;
	top: 0;
	left: 0;
	height: 100%;
	background: var(--gary-progress);
	border-radius: 3px;
	width: 0%;
	transition: width 0.05s linear;
}

.gary-progress-handle {
	position: absolute;
	top: 50%;
	left: 0%;
	width: 14px;
	height: 14px;
	background: var(--gary-primary);
	border: 2px solid #fff;
	border-radius: 50%;
	transform: translate(-50%, -50%) scale(0);
	transition: transform var(--gary-transition);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
	z-index: 3;
}

.gary-progress-bar:hover .gary-progress-handle,
.gary-progress-bar.dragging .gary-progress-handle {
	transform: translate(-50%, -50%) scale(1);
}

/* ── Volume ── */
.gary-volume-wrap {
	display: flex;
	align-items: center;
	gap: 4px;
	flex-shrink: 0;
}

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

.gary-icon-muted {
	display: none;
}
#gary-player.muted .gary-icon-vol {
	display: none;
}
#gary-player.muted .gary-icon-muted {
	display: block;
}

.gary-volume-slider {
	width: 80px;
	height: 4px;
	background: rgba(255, 255, 255, 0.15);
	border-radius: 2px;
	cursor: pointer;
	position: relative;
}

.gary-volume-filled {
	position: absolute;
	top: 0;
	left: 0;
	height: 100%;
	background: var(--gary-primary);
	border-radius: 2px;
	width: 70%;
}

.gary-volume-handle {
	position: absolute;
	top: 50%;
	left: 70%;
	width: 12px;
	height: 12px;
	background: #fff;
	border-radius: 50%;
	transform: translate(-50%, -50%) scale(0);
	transition: transform var(--gary-transition);
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.gary-volume-slider:hover .gary-volume-handle,
.gary-volume-slider.dragging .gary-volume-handle {
	transform: translate(-50%, -50%) scale(1);
}

/* ── Playlist Toggle ── */
.gary-playlist-toggle {
	margin-left: 4px;
}

.gary-playlist-toggle.active {
	color: var(--gary-primary);
}

/* ── Playlist Panel ── */
.gary-playlist {
	position: absolute;
	bottom: var(--gary-height);
	right: 16px;
	width: 340px;
	max-height: 380px;
	background: var(--gary-bg);
	border-radius: var(--gary-radius) var(--gary-radius) 0 0;
	box-shadow: var(--gary-shadow);
	overflow: hidden;
	transform: translateY(100%);
	opacity: 0;
	transition:
		transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
		opacity 0.25s;
	pointer-events: none;
	border: 1px solid rgba(255, 255, 255, 0.06);
	border-bottom: none;
}

.gary-playlist.open {
	transform: translateY(0);
	opacity: 1;
	pointer-events: auto;
}

.gary-playlist-header {
	padding: 12px 16px;
	font-weight: 600;
	font-size: 14px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.06);
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.gary-playlist-close {
	color: rgba(255, 255, 255, 0.5);
	padding: 4px;
}

.gary-playlist-close svg {
	width: 18px;
	height: 18px;
	fill: currentColor;
}

.gary-playlist-tracks {
	overflow-y: auto;
	max-height: 330px;
	padding: 4px 0;
}

.gary-playlist-tracks::-webkit-scrollbar {
	width: 5px;
}
.gary-playlist-tracks::-webkit-scrollbar-track {
	background: transparent;
}
.gary-playlist-tracks::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, 0.15);
	border-radius: 3px;
}

/* ── Playlist Track Item ── */
.gary-pl-track {
	display: flex;
	align-items: center;
	padding: 8px 16px;
	gap: 12px;
	cursor: pointer;
	transition: background var(--gary-transition);
	position: relative;
}

.gary-pl-track:hover {
	background: rgba(255, 255, 255, 0.06);
}

.gary-pl-track.active {
	background: rgba(255, 255, 255, 0.08);
}

.gary-pl-track.active::before {
	content: "";
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: 3px;
	background: var(--gary-primary);
	border-radius: 0 2px 2px 0;
}

.gary-pl-cover {
	width: 40px;
	height: 40px;
	border-radius: 4px;
	object-fit: cover;
	flex-shrink: 0;
}

.gary-pl-info {
	flex: 1;
	min-width: 0;
}

.gary-pl-title {
	font-size: 13px;
	font-weight: 500;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.gary-pl-artist {
	font-size: 11px;
	color: rgba(255, 255, 255, 0.4);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.gary-pl-type {
	flex-shrink: 0;
	font-size: 9px;
	padding: 2px 6px;
	border-radius: 3px;
	background: rgba(255, 255, 255, 0.08);
	color: rgba(255, 255, 255, 0.4);
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.gary-pl-type.youtube {
	background: rgba(255, 0, 0, 0.15);
	color: #ff4444;
}

/* ── Equalizer animation (active track) ── */
.gary-eq {
	display: flex;
	align-items: flex-end;
	gap: 2px;
	height: 14px;
	flex-shrink: 0;
}

.gary-eq span {
	width: 3px;
	background: var(--gary-primary);
	border-radius: 1px;
	animation: gary-eq-bar 0.8s ease-in-out infinite;
}

.gary-eq span:nth-child(1) {
	height: 6px;
	animation-delay: 0s;
}
.gary-eq span:nth-child(2) {
	height: 10px;
	animation-delay: 0.2s;
}
.gary-eq span:nth-child(3) {
	height: 4px;
	animation-delay: 0.4s;
}
.gary-eq span:nth-child(4) {
	height: 8px;
	animation-delay: 0.1s;
}

@keyframes gary-eq-bar {
	0%,
	100% {
		height: 4px;
	}
	50% {
		height: 14px;
	}
}

/* ── Body margin for footer ── */
body.gary-active {
	padding-bottom: var(--gary-height) !important;
}

/* ── Responsive ── */
@media (max-width: 768px) {
	.gary-bar {
		padding: 0 10px;
		gap: 8px;
	}

	.gary-info {
		max-width: 100px;
	}

	.gary-volume-wrap {
		display: none;
	}

	.gary-playlist {
		right: 0;
		left: 0;
		width: 100%;
		border-radius: var(--gary-radius) var(--gary-radius) 0 0;
	}

	.gary-title {
		font-size: 12px;
	}
	.gary-artist {
		font-size: 10px;
	}
}

@media (max-width: 480px) {
	.gary-info {
		display: none;
	}

	.gary-cover-wrap {
		width: 40px;
		height: 40px;
	}

	.gary-cover {
		width: 40px;
		height: 40px;
	}

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

	.gary-btn-play {
		width: 34px;
		height: 34px;
	}
}
