/*
 * Seedlings first-visit loader (markup + decide script: inc/features/loader.php).
 * Phases 1-5 run here from first paint; sdl-loader.js adds .is-out at 1.42 s to lift the veil.
 *
 *   0.04-0.50  seed drops in and settles (squash)
 *   0.30-0.70  stem draws up out of the seed (mask stroke, dash = getTotalLength() = 84.94)
 *   0.58/0.68/0.78 (+0.44)  leaves 1 (left), 2 (right), 3 (top) unfold from their base, then fill
 *   0.74-1.40  wordmark letters rise left to right
 *   1.00-1.40  EARLY LEARNING fades in
 *   1.42-2.00  veil lifts off with a curved bottom edge (JS); sdl:loaded at 1.52
 *   3.50       safety: the loader hides itself even if no JS ran
 */

.sdl-load { display: none; }
.sdl-load.is-on {
	display: block;
	position: fixed;
	inset: 0;
	z-index: 100000;
	pointer-events: auto;
	animation: sdl-load-safety .3s 3.5s forwards;
}
html.sdl-loading body { overflow: hidden; }

.sdl-load-veil {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	background: #f6f1e8;
	will-change: transform;
}
/* the soft curved bottom edge, out of sight below the screen until the veil lifts */
.sdl-load-veil::after {
	content: "";
	position: absolute;
	left: -15%;
	right: -15%;
	top: calc(100% - 1px);
	height: 13vh;
	background: inherit;
	border-radius: 0 0 50% 50% / 0 0 100% 100%;
}
.sdl-load-mid { position: relative; }
.sdl-load-logo {
	display: block;
	width: min(340px, 72vw);
	height: auto;
	overflow: visible;
}

/* 1. seed: falls a little, lands with a squash, settles */
.sdl-load-logo #sdl-seed {
	transform-box: fill-box;
	transform-origin: 50% 100%;
	animation: sdl-load-seed .46s .04s linear both;
}
@keyframes sdl-load-seed {
	0% { opacity: 0; transform: translateY(-16px) scale(.95, 1.05); animation-timing-function: cubic-bezier(.5, 0, .9, .45); }
	22% { opacity: 1; }
	45% { opacity: 1; transform: translateY(0) scale(1.07, .9); animation-timing-function: cubic-bezier(.25, .7, .35, 1); }
	72% { transform: translateY(0) scale(.985, 1.025); animation-timing-function: ease-in-out; }
	100% { opacity: 1; transform: none; }
}

/* 2. stem: the mask's centreline draws bottom to top (real units: Safari ignores pathLength in CSS dashes) */
.sdl-load-stem-line {
	stroke-dasharray: 84.94;
	stroke-dashoffset: 84.94;
	animation: sdl-load-draw .4s .3s cubic-bezier(.45, 0, .25, 1) both;
}
@keyframes sdl-load-draw {
	from { stroke-dashoffset: 84.94; }
	to { stroke-dashoffset: 0; }
}

/* 3. leaves: unfold from the base with a slight turn, outline first, then fill */
.sdl-load-logo #sdl-leaf-1,
.sdl-load-logo #sdl-leaf-2,
.sdl-load-logo #sdl-leaf-3 {
	transform-box: view-box;
	animation: sdl-load-leaf .44s cubic-bezier(.3, .7, .3, 1) both;
}
.sdl-load-logo #sdl-leaf-1 { transform-origin: 184.9px 78.4px; --sdl-load-rot: 28deg; animation-delay: .58s; }
.sdl-load-logo #sdl-leaf-2 { transform-origin: 188.5px 78.1px; --sdl-load-rot: -28deg; animation-delay: .68s; }
.sdl-load-logo #sdl-leaf-3 { transform-origin: 188.5px 71.4px; --sdl-load-rot: -14deg; animation-delay: .78s; }
@keyframes sdl-load-leaf {
	0% { opacity: 0; transform: rotate(var(--sdl-load-rot)) scale(.12); }
	30% { opacity: 1; }
	72% { transform: rotate(calc(var(--sdl-load-rot) * -.1)) scale(1.025); }
	100% { opacity: 1; transform: none; }
}
.sdl-load-logo .sdl-leaf-blade {
	stroke: #0E8943;
	stroke-linejoin: round;
	animation: sdl-load-fill .26s ease-out both;
}
.sdl-load-logo .sdl-vein { animation: sdl-load-in .26s ease-out both; }
.sdl-load-logo #sdl-leaf-1 > path { animation-delay: .78s; }
.sdl-load-logo #sdl-leaf-2 > path { animation-delay: .88s; }
.sdl-load-logo #sdl-leaf-3 > path { animation-delay: .98s; }
@keyframes sdl-load-fill {
	from { fill-opacity: 0; stroke-width: 1.1; }
	to { fill-opacity: 1; stroke-width: 0; }
}
@keyframes sdl-load-in {
	from { opacity: 0; }
	to { opacity: 1; }
}

/* 4. wordmark: letters fade and rise left to right */
.sdl-load-logo #sdl-word > path {
	animation: sdl-load-rise .42s cubic-bezier(.22, 1, .36, 1) both;
}
.sdl-load-logo #sdl-word > path:nth-child(1) { animation-delay: .74s; }
.sdl-load-logo #sdl-word > path:nth-child(2) { animation-delay: .775s; }
.sdl-load-logo #sdl-word > path:nth-child(3) { animation-delay: .81s; }
.sdl-load-logo #sdl-word > path:nth-child(4) { animation-delay: .845s; }
.sdl-load-logo #sdl-word > path:nth-child(5) { animation-delay: .88s; }
.sdl-load-logo #sdl-word > path:nth-child(6) { animation-delay: .915s; }
.sdl-load-logo #sdl-word > path:nth-child(7) { animation-delay: .95s; }
.sdl-load-logo #sdl-word > path:nth-child(8) { animation-delay: .985s; }
@keyframes sdl-load-rise {
	from { opacity: 0; transform: translateY(14px); }
	to { opacity: 1; transform: none; }
}

/* 5. tagline */
.sdl-load-logo #sdl-tag { animation: sdl-load-tag .4s 1s ease-out both; }
@keyframes sdl-load-tag {
	from { opacity: 0; transform: translateY(5px); }
	to { opacity: 1; transform: none; }
}

/* 6. the veil lifts off the page (class from sdl-loader.js) */
.sdl-load.is-out { pointer-events: none; }
.sdl-load.is-out .sdl-load-veil { animation: sdl-load-lift .58s cubic-bezier(.76, 0, .24, 1) forwards; }
.sdl-load.is-out .sdl-load-mid { animation: sdl-load-mid .5s cubic-bezier(.55, 0, .75, .3) forwards; }
@keyframes sdl-load-lift {
	to { transform: translateY(calc(-100% - 13vh)); }
}
@keyframes sdl-load-mid {
	to { opacity: 0; transform: translateY(-5vh); }
}

/* safety: never trap the page */
@keyframes sdl-load-safety {
	to { opacity: 0; visibility: hidden; pointer-events: none; }
}

@media (prefers-reduced-motion: reduce) {
	.sdl-load.is-on { display: none; }
}
