/**
 * Background job progress overlay. See application/assets/js/background-jobs-overlay.js
 *
 * Bottom-right, above the page and above modals (a job queued from inside a dialog still
 * has to be watchable) but below toasts, which sit at z-index 1081 and carry the outcome.
 */

.bg-jobs-overlay {
	position: fixed;
	right: 1rem;
	bottom: 1rem;
	z-index: 1060;
	width: 44rem;
	max-width: calc(100vw - 2rem);

	/* Hidden state. visibility rather than display so the card can transition, and
	   pointer-events so an invisible card never eats a click on the page underneath. */
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: translateY(0.75rem);
	transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s linear 0.25s;
}

.bg-jobs-overlay.is-visible {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transform: translateY(0);
	transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s;
}

.bg-jobs-card {
	background: #fff;
	border: 1px solid rgba(0, 0, 0, 0.08);
	border-radius: 0.5rem;
	box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.15);
	padding: 0.75rem 0.875rem;
	font-size: 0.8125rem;
	color: #666;
}

.bg-jobs-head {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 0.5rem;
}

.bg-jobs-head-icon {
	color: var(--bs-primary, #0d6efd);
}

.bg-jobs-title {
	font-weight: 600;
	color: #333;
	flex: 1 1 auto;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.bg-jobs-close {
	flex: 0 0 auto;
	border: 0;
	background: none;
	color: #999;
	line-height: 1;
	padding: 0.125rem 0.25rem;
	border-radius: 0.25rem;
}

.bg-jobs-close:hover {
	color: #333;
	background: rgba(0, 0, 0, 0.05);
}

.bg-jobs-bar {
	height: 6px;
	border-radius: 3px;
	background: rgba(0, 0, 0, 0.08);
	overflow: hidden;
}

.bg-jobs-fill {
	height: 100%;
	width: 0;
	border-radius: 3px;
	background: var(--bs-primary, #0d6efd);
	transition: width 0.4s ease;
}

/* A handler that reports no percentage would otherwise sit at a stuck 0%, which reads as
   a hang. Sweeping stripes say "running, cannot tell you how far" instead. */
.bg-jobs-bar.is-indeterminate .bg-jobs-fill {
	background-image: linear-gradient(45deg,
		rgba(255, 255, 255, 0.35) 25%, transparent 25%,
		transparent 50%, rgba(255, 255, 255, 0.35) 50%,
		rgba(255, 255, 255, 0.35) 75%, transparent 75%, transparent);
	background-size: 1rem 1rem;
	animation: bg-jobs-stripes 1s linear infinite;
	transition: none;
}

@keyframes bg-jobs-stripes {
	from { background-position: 1rem 0; }
	to   { background-position: 0 0; }
}

.bg-jobs-status {
	display: flex;
	align-items: baseline;
	gap: 0.5rem;
	margin-top: 0.375rem;
	font-size: 0.75rem;
	color: #888;
}

.bg-jobs-remaining {
	margin-left: auto;
	flex: 0 0 auto;
	font-variant-numeric: tabular-nums;
	color: #aaa;
}

.bg-jobs-queue {
	margin: 0;
	padding: 0;
}

.bg-jobs-queue-item {
	display: flex;
	align-items: center;
	gap: 0.375rem;
	padding-top: 0.375rem;
	margin-top: 0.375rem;
	border-top: 1px solid rgba(0, 0, 0, 0.06);
	font-size: 0.75rem;
}

.bg-jobs-queue-icon {
	color: #bbb;
}

.bg-jobs-queue-name {
	color: #555;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.bg-jobs-queue-when {
	color: #aaa;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.bg-jobs-queue-pos {
	margin-left: auto;
	flex: 0 0 auto;
	color: #aaa;
}

.bg-jobs-more {
	margin-top: 0.375rem;
	font-size: 0.75rem;
	color: #aaa;
}

/* The mobile preview player is already parked in this corner (see global.css), so get out
   of its way rather than sitting on top of it. */
@media screen and (max-width: 768px) {
	.bg-jobs-overlay {
		right: 0.75rem;
		left: 0.75rem;
		bottom: 4.5rem;
		width: auto;
		max-width: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.bg-jobs-overlay,
	.bg-jobs-overlay.is-visible {
		transition: opacity 0.01s linear, visibility 0s;
		transform: none;
	}

	.bg-jobs-fill {
		transition: none;
	}

	.bg-jobs-bar.is-indeterminate .bg-jobs-fill {
		animation: none;
	}
}
