/* Direction is set on every PWA element because the document is not dir="rtl". */

/* ---------- Install: header button (desktop) ---------- */
.pwa-install-nav:not([hidden]) {
	display: inline-flex;
}

.pwa-install-nav {
	position: relative;
	align-items: center;
	gap: 7px;
	height: 34px;
	margin: 0 4px;
	padding: 0 6px 0 13px;
	direction: rtl;
	border: 0;
	border-radius: 999px;
	background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #d946ef 100%);
	background-size: 160% 160%;
	color: #ffffff;
	font: inherit;
	font-size: 0.8rem;
	font-weight: 600;
	white-space: nowrap;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(99, 102, 241, 0.38);
	animation: pwa-gradient-shift 6s ease infinite;
	transition: transform .2s ease, box-shadow .2s ease;
}

	/* Soft halo that keeps drawing the eye without moving the layout. */
	.pwa-install-nav::before {
		content: "";
		position: absolute;
		inset: -3px;
		border-radius: inherit;
		border: 2px solid rgba(139, 92, 246, 0.55);
		animation: pwa-halo 2.4s ease-out infinite;
		pointer-events: none;
	}

	.pwa-install-nav:hover {
		transform: translateY(-1px);
		box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
	}

	.pwa-install-nav:focus-visible {
		outline: 2px solid #a5b4fc;
		outline-offset: 3px;
	}

.pwa-install-nav-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.22);
	font-size: 0.72rem;
}

	.pwa-install-nav-icon i {
		animation: pwa-nudge 2.4s ease-in-out infinite;
	}

@media (max-width: 767.98px) {
	.pwa-install-nav:not([hidden]) {
		display: none;
	}
}

/* ---------- Install: card on top of the side menu (mobile) ---------- */
.pwa-install-menu:not([hidden]) {
	display: flex;
}

.pwa-install-menu {
	position: relative;
	flex: 0 0 auto;
	align-items: center;
	gap: 10px;
	margin: 0 1rem 0.85rem;
	padding: 12px 12px 12px 30px;
	direction: rtl;
	text-align: right;
	border-radius: 14px;
	background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(217, 70, 239, 0.1));
	border: 1px solid rgba(99, 102, 241, 0.28);
	overflow: hidden;
}

	.pwa-install-menu::after {
		content: "";
		position: absolute;
		top: 0;
		bottom: 0;
		width: 40%;
		left: -40%;
		background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
		animation: pwa-sweep 3.8s ease-in-out infinite;
		pointer-events: none;
	}

.pwa-install-menu-icon {
	width: 40px;
	height: 40px;
	flex: 0 0 40px;
	border-radius: 11px;
	box-shadow: 0 3px 10px rgba(79, 70, 229, 0.3);
}

.pwa-install-menu-text {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	line-height: 1.6;
}

	.pwa-install-menu-text strong {
		font-size: 0.84rem;
		color: #3730a3;
	}

	.pwa-install-menu-text span {
		font-size: 0.7rem;
		color: var(--text-secondary, #6b7280);
	}

.pwa-install-menu-btn {
	flex: 0 0 auto;
	border: 0;
	border-radius: 999px;
	padding: 6px 16px;
	background: linear-gradient(135deg, #6366f1, #8b5cf6);
	color: #ffffff;
	font: inherit;
	font-size: 0.78rem;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 3px 10px rgba(99, 102, 241, 0.4);
}

.pwa-install-menu-close {
	position: absolute;
	top: 4px;
	left: 4px;
	width: 20px;
	height: 20px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--text-secondary, #6b7280);
	font-size: 0.65rem;
	line-height: 20px;
	cursor: pointer;
	opacity: 0.7;
	z-index: 1;
}

@media (min-width: 768px) {
	.pwa-install-menu:not([hidden]) {
		display: none;
	}
}

[data-dark-mode='true'] .pwa-install-menu {
	background: linear-gradient(135deg, rgba(129, 140, 248, 0.16), rgba(217, 70, 239, 0.12));
	border-color: rgba(165, 180, 252, 0.3);
}

	[data-dark-mode='true'] .pwa-install-menu::after {
		background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
	}

[data-dark-mode='true'] .pwa-install-menu-text strong {
	color: #c7d2fe;
}

/* ---------- Update card ---------- */
.pwa-update {
	position: fixed;
	left: 12px;
	right: 12px;
	bottom: calc(16px + env(safe-area-inset-bottom, 0px));
	z-index: 20000;
	direction: rtl;
	text-align: right;
	display: flex;
	justify-content: center;
	pointer-events: none;
}

.pwa-update-card {
	position: relative;
	display: flex;
	gap: 14px;
	width: 100%;
	max-width: 440px;
	padding: 18px 18px 14px;
	border-radius: 20px;
	background: radial-gradient(120% 140% at 100% 0%, #4338ca 0%, #312e81 45%, #1e1b4b 100%);
	color: #eef2ff;
	box-shadow: 0 18px 50px rgba(30, 27, 75, 0.45), 0 0 0 1px rgba(165, 180, 252, 0.25) inset;
	overflow: hidden;
	pointer-events: auto;
	opacity: 0;
	transform: translateY(30px) scale(.96);
	transition: opacity .35s ease, transform .45s cubic-bezier(.34, 1.56, .64, 1);
}

	/* Moving light along the top edge. */
	.pwa-update-card::before {
		content: "";
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		height: 3px;
		background: linear-gradient(90deg, #22d3ee, #a78bfa, #f472b6, #22d3ee);
		background-size: 200% 100%;
		animation: pwa-strip 3s linear infinite;
	}

.pwa-update.is-in .pwa-update-card {
	opacity: 1;
	transform: none;
}

.pwa-update-badge {
	position: relative;
	flex: 0 0 46px;
	width: 46px;
	height: 46px;
	border-radius: 14px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, #22d3ee, #8b5cf6);
	color: #ffffff;
	font-size: 1.1rem;
	box-shadow: 0 6px 18px rgba(34, 211, 238, 0.35);
}

	.pwa-update-badge::after {
		content: "";
		position: absolute;
		inset: -4px;
		border-radius: 17px;
		border: 2px solid rgba(34, 211, 238, 0.6);
		animation: pwa-halo 2s ease-out infinite;
	}

	.pwa-update-badge i {
		animation: pwa-spin 2.8s linear infinite;
	}

.pwa-update-body {
	flex: 1 1 auto;
	min-width: 0;
}

.pwa-update-title {
	font-size: 0.98rem;
	font-weight: 700;
	line-height: 1.6;
}

.pwa-update-sub {
	margin-top: 2px;
	font-size: 0.78rem;
	line-height: 1.8;
	color: #c7d2fe;
}

.pwa-update-ver {
	display: inline-block;
	margin-left: 6px;
	padding: 0 8px;
	border-radius: 999px;
	background: rgba(34, 211, 238, 0.18);
	color: #67e8f9;
	font-size: 0.7rem;
	font-weight: 600;
}

.pwa-update-actions {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 12px;
}

.pwa-update-go {
	position: relative;
	overflow: hidden;
	display: inline-flex;
	align-items: center;
	gap: 7px;
	border: 0;
	border-radius: 12px;
	padding: 9px 18px;
	background: linear-gradient(135deg, #22d3ee 0%, #6366f1 100%);
	color: #ffffff;
	font: inherit;
	font-size: 0.84rem;
	font-weight: 700;
	cursor: pointer;
	box-shadow: 0 6px 18px rgba(34, 211, 238, 0.3);
	transition: transform .2s ease;
}

	.pwa-update-go::after {
		content: "";
		position: absolute;
		top: 0;
		bottom: 0;
		width: 45%;
		left: -45%;
		background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
		animation: pwa-sweep 2.6s ease-in-out infinite;
	}

	.pwa-update-go:hover {
		transform: translateY(-1px);
	}

.pwa-update-later {
	border: 0;
	border-radius: 12px;
	padding: 9px 14px;
	background: rgba(255, 255, 255, 0.08);
	color: #c7d2fe;
	font: inherit;
	font-size: 0.8rem;
	cursor: pointer;
}

	.pwa-update-later:hover {
		background: rgba(255, 255, 255, 0.14);
	}

.pwa-update-hint {
	margin-top: 10px;
	font-size: 0.68rem;
	color: rgba(199, 210, 254, 0.7);
}

/* "Later" keeps a small reminder instead of the card. */
.pwa-update-pill {
	display: none;
	align-items: center;
	gap: 8px;
	padding: 9px 16px;
	border: 0;
	border-radius: 999px;
	background: linear-gradient(135deg, #312e81, #4338ca);
	color: #eef2ff;
	font: inherit;
	font-size: 0.8rem;
	font-weight: 600;
	cursor: pointer;
	pointer-events: auto;
	box-shadow: 0 10px 28px rgba(30, 27, 75, 0.4);
	animation: pwa-pop .4s cubic-bezier(.34, 1.56, .64, 1);
}

.pwa-update-pill-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #22d3ee;
	box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.7);
	animation: pwa-dot 1.8s ease-out infinite;
}

.pwa-update.is-minimized .pwa-update-card {
	display: none;
}

.pwa-update.is-minimized .pwa-update-pill {
	display: inline-flex;
}

/* ---------- iOS guide ---------- */
.pwa-sheet {
	position: fixed;
	inset: 0;
	z-index: 20001;
	display: flex;
	align-items: flex-end;
	justify-content: center;
	padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
	background: rgba(15, 23, 42, 0.45);
	direction: rtl;
	text-align: right;
}

.pwa-sheet-card {
	width: 100%;
	max-width: 420px;
	padding: 18px;
	border-radius: 20px;
	background: #ffffff;
	color: #1f2937;
	font-size: 0.84rem;
	line-height: 1.9;
	box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
	animation: pwa-pop .4s cubic-bezier(.34, 1.56, .64, 1);
}

	.pwa-sheet-card ol {
		margin: 8px 0 14px;
		padding-right: 20px;
		padding-left: 0;
	}

.pwa-sheet-icon {
	display: block;
	width: 48px;
	height: 48px;
	margin-bottom: 8px;
	border-radius: 12px;
}

.pwa-ios-share {
	display: inline-block;
	direction: ltr;
	font-weight: bold;
	color: #4f46e5;
}

[data-dark-mode='true'] .pwa-sheet-card {
	background: #1f2937;
	color: #f3f4f6;
}

[data-dark-mode='true'] .pwa-ios-share {
	color: #a5b4fc;
}

/* ---------- Motion ---------- */
@keyframes pwa-gradient-shift {
	0%, 100% { background-position: 0% 50%; }
	50% { background-position: 100% 50%; }
}

@keyframes pwa-halo {
	0% { opacity: .9; transform: scale(1); }
	100% { opacity: 0; transform: scale(1.18); }
}

@keyframes pwa-nudge {
	0%, 60%, 100% { transform: translateY(0); }
	75% { transform: translateY(2px); }
	90% { transform: translateY(-1px); }
}

@keyframes pwa-sweep {
	0% { left: -45%; }
	60%, 100% { left: 110%; }
}

@keyframes pwa-strip {
	to { background-position: -200% 0; }
}

@keyframes pwa-spin {
	to { transform: rotate(360deg); }
}

@keyframes pwa-pop {
	from { opacity: 0; transform: translateY(16px) scale(.94); }
	to { opacity: 1; transform: none; }
}

@keyframes pwa-dot {
	0% { box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.7); }
	100% { box-shadow: 0 0 0 9px rgba(34, 211, 238, 0); }
}

@media (prefers-reduced-motion: reduce) {
	.pwa-install-nav,
	.pwa-install-nav::before,
	.pwa-install-nav-icon i,
	.pwa-install-menu::after,
	.pwa-update-card::before,
	.pwa-update-badge::after,
	.pwa-update-badge i,
	.pwa-update-go::after,
	.pwa-update-pill-dot {
		animation: none;
	}
}
