/*
 * Codewinglet loaders for the Frappe Desk and website (hooks.app_include_css and
 * web_include_css), for every app:
 *
 *   .splash   the screen while /desk starts, and right after signing in while
 *             Frappe redirects (it shows the site's app logo there)
 *   #freeze   the "please wait" cover during saves, imports and reports
 *
 * Only these two elements are styled; Frappe still shows and hides them.
 * Loaded in <head>, so the splash is restyled before it first appears.
 */

/* ------------------------------------------------------------- splash */

.splash,
.splash.centered {
	position: fixed;
	inset: 0;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	/* Frappe's .centered moves it by half its size; not needed full-screen. */
	transform: none;
	z-index: 1050;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 26px;
	background:
		radial-gradient(700px 380px at 50% 40%, rgb(37 99 235 / 0.07), transparent 70%),
		var(--bg-color, #fff);
}

/* Frappe's logo makes way for the Codewinglet mark. */
.splash img {
	display: none !important;
}

.splash::before {
	content: "";
	width: 76px;
	height: 76px;
	border-radius: 22px;
	background: #141414 url("/assets/codewinglet_cafe/images/cw-mark-white.svg") center / 44px no-repeat;
	box-shadow:
		0 0 0 8px rgb(37 99 235 / 0.06),
		0 22px 44px -18px rgb(16 24 40 / 0.55);
	animation: cwl-breathe 1.8s ease-in-out infinite;
}

/* A thin bar that keeps moving until the Desk is ready. */
.splash::after {
	content: "";
	width: 160px;
	height: 4px;
	border-radius: 999px;
	background:
		linear-gradient(90deg, transparent, #2563eb, #a855f7, #ff7f52, transparent) 0 0 / 50% 100% no-repeat,
		rgb(16 24 40 / 0.08);
	animation: cwl-slide 1.15s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

/* ------------------------------------------------------------- freeze */

#freeze {
	background-color: rgb(245 246 250 / 0.55);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
}

#freeze.in {
	opacity: 1;
}

/* The Desk centres this itself; website pages (login, sign-up) don't, so do it here. */
#freeze .freeze-message-container {
	position: absolute;
	inset: 0;
	display: grid;
	place-content: center;
	background: transparent;
	padding: 24px;
}

#freeze .freeze-message {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 18px;
	min-width: 240px;
	max-width: 360px;
	padding: 32px 30px 26px;
	border: 1px solid rgb(16 24 40 / 0.08);
	border-radius: 22px;
	background: #fff;
	box-shadow: 0 30px 70px -30px rgb(16 24 40 / 0.45);
	text-align: center;
	animation: cwl-pop 0.25s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* A gradient ring spins round the mark; the mark itself stays still. */
#freeze .freeze-message::before {
	content: "";
	width: 64px;
	height: 64px;
	border-radius: 50%;
	background: conic-gradient(from 0deg, rgb(37 99 235 / 0), #2563eb 35%, #a855f7 65%, #ff7f52);
	-webkit-mask: radial-gradient(circle, transparent 0 27px, #000 28px);
	mask: radial-gradient(circle, transparent 0 27px, #000 28px);
	animation: cwl-spin 0.9s linear infinite;
}

#freeze .freeze-message::after {
	content: "";
	position: absolute;
	top: 42px;
	left: 50%;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: #141414 url("/assets/codewinglet_cafe/images/cw-mark-white.svg") center / 24px no-repeat;
	transform: translateX(-50%);
}

#freeze .freeze-message .lead {
	margin: 0;
	font-size: 0.98rem;
	font-weight: 500;
	line-height: 1.5;
	color: #1f2329;
}

/* No message: just the spinner. */
#freeze .freeze-message .lead:empty {
	display: none;
}

/* ------------------------------------------------------------- motion */

@keyframes cwl-breathe {
	50% {
		transform: scale(1.06);
		box-shadow:
			0 0 0 14px rgb(37 99 235 / 0.04),
			0 26px 50px -18px rgb(16 24 40 / 0.6);
	}
}

@keyframes cwl-slide {
	from {
		background-position: -100% 0, 0 0;
	}
	to {
		background-position: 200% 0, 0 0;
	}
}

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

@keyframes cwl-pop {
	from {
		opacity: 0;
		transform: translateY(8px) scale(0.98);
	}
}

@media (prefers-reduced-motion: reduce) {
	.splash::before,
	.splash::after,
	#freeze .freeze-message,
	#freeze .freeze-message::before {
		animation: none !important;
	}
}
