/**
 * Vendor icons (round 20 October, E3): popcorn filling and popping, a pizza
 * turning with a slice sliding out, soft-serve swirling up and chopsticks
 * lifting noodles. Cream lines with red accents, drawn to sit on a vendor's
 * photo under its navy shade.
 *
 * The resting state is the last frame, so without JavaScript, or with
 * reduced motion, each icon shows complete and still. vendor-icons.js adds
 * .is-armed (start frame) and .is-played (play) as the icon comes into view,
 * and takes .is-played off when it leaves below the window, so the icon
 * winds back on the way up and plays again on the way down. Transform and
 * opacity only; each pass finishes within 0.7s; nothing loops.
 *
 * Forward delays sit on .is-played and reverse delays on the armed state,
 * because a transition takes its delay from the state it is going to: the
 * last part in is the first part out.
 */

.pg-vendor-icon {
	display: inline-block;
	flex: none;
	width: 5rem;
	height: 5rem;
	color: var(--wp--preset--color--cream);
	line-height: 0;
	vertical-align: middle;
}

.pg-vendor-icon svg,
.pg-vendor-icon img {
	display: block;
	width: 100%;
	height: 100%;
}

.pg-vendor-icon svg {
	overflow: visible;
}

.pg-vendor-icon img {
	object-fit: contain;
}

.pg-vendor-icon .vi-red {
	stroke: var(--wp--preset--color--red);
}

.pg-vendor-icon .vi-red-fill {
	fill: var(--wp--preset--color--red);
	stroke: none;
}

/* ---------- Last frames (the resting state) ---------- */

.pg-vendor-icon .vi-fill,
.pg-vendor-icon .vi-pop,
.pg-vendor-icon .vi-swirl,
.pg-vendor-icon .vi-strands {
	transform-box: fill-box;
}

.pg-vendor-icon .vi-fill,
.pg-vendor-icon .vi-swirl {
	transform-origin: 50% 100%;
}

.pg-vendor-icon .vi-pop {
	transform-origin: 50% 50%;
}

.pg-vendor-icon .vi-strands {
	transform-origin: 50% 0;
}

.pg-vendor-icon .vi-pie {
	transform-box: view-box;
	transform-origin: 32px 32px;
}

.pg-vendor-icon .vi-slice {
	transform: translate(4.5px, 4.5px);
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: no-preference) {

	.pg-vendor-icon.is-armed {
		--tdic-vi-ease: var(--wp--custom--ease, cubic-bezier(0.23, 1, 0.32, 1));
		--tdic-vi-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
	}

	.pg-vendor-icon.is-armed .vi-fill,
	.pg-vendor-icon.is-armed .vi-pop,
	.pg-vendor-icon.is-armed .vi-pie,
	.pg-vendor-icon.is-armed .vi-slice,
	.pg-vendor-icon.is-armed .vi-swirl,
	.pg-vendor-icon.is-armed .vi-sprinkle,
	.pg-vendor-icon.is-armed .vi-lift,
	.pg-vendor-icon.is-armed .vi-strands {
		transition-property: transform, opacity;
		transition-duration: 300ms;
		transition-timing-function: var(--tdic-vi-ease);
	}

	/* Popcorn: the bucket fills, then three kernels pop out of it. */
	.pg-vendor-icon.is-armed:not(.is-played) .vi-fill {
		opacity: 0;
		transform: translateY(3px) scaleY(0.15);
		transition-delay: 280ms;
	}

	.pg-vendor-icon.is-armed:not(.is-played) .vi-pop {
		opacity: 0;
		transform: translateY(14px) scale(0.3);
	}

	.pg-vendor-icon.is-armed:not(.is-played) .vi-pop--1 { transition-delay: 160ms; }
	.pg-vendor-icon.is-armed:not(.is-played) .vi-pop--2 { transition-delay: 80ms; }
	.pg-vendor-icon.is-armed:not(.is-played) .vi-pop--3 { transition-delay: 0ms; }

	.pg-vendor-icon.is-played .vi-fill {
		transition-duration: 400ms;
		transition-delay: 0ms;
	}

	.pg-vendor-icon.is-played .vi-pop {
		transition-timing-function: var(--tdic-vi-pop);
	}

	.pg-vendor-icon.is-played .vi-pop--1 { transition-delay: 220ms; }
	.pg-vendor-icon.is-played .vi-pop--2 { transition-delay: 300ms; }
	.pg-vendor-icon.is-played .vi-pop--3 { transition-delay: 380ms; }

	/* Pizza: the pie turns, then a slice slides out. */
	.pg-vendor-icon.is-armed:not(.is-played) .vi-pie {
		transform: rotate(-150deg);
		transition-delay: 220ms;
	}

	.pg-vendor-icon.is-armed:not(.is-played) .vi-slice {
		transform: translate(0, 0);
		transition-delay: 0ms;
	}

	.pg-vendor-icon.is-played .vi-pie {
		transition-duration: 450ms;
		transition-delay: 0ms;
	}

	.pg-vendor-icon.is-played .vi-slice {
		transition-delay: 380ms;
	}

	/* Soft-serve: three swirls and the tip rise one after another, then the sprinkles. */
	.pg-vendor-icon.is-armed:not(.is-played) .vi-swirl {
		opacity: 0;
		transform: translateY(4px) rotate(-20deg) scale(0.2);
	}

	.pg-vendor-icon.is-armed:not(.is-played) .vi-sprinkle {
		opacity: 0;
		transition-delay: 0ms;
	}

	.pg-vendor-icon.is-armed:not(.is-played) .vi-swirl--1 { transition-delay: 450ms; }
	.pg-vendor-icon.is-armed:not(.is-played) .vi-swirl--2 { transition-delay: 340ms; }
	.pg-vendor-icon.is-armed:not(.is-played) .vi-swirl--3 { transition-delay: 230ms; }
	.pg-vendor-icon.is-armed:not(.is-played) .vi-swirl--4 { transition-delay: 120ms; }

	.pg-vendor-icon.is-played .vi-swirl--1 { transition-delay: 0ms; }
	.pg-vendor-icon.is-played .vi-swirl--2 { transition-delay: 110ms; }
	.pg-vendor-icon.is-played .vi-swirl--3 { transition-delay: 220ms; }
	.pg-vendor-icon.is-played .vi-swirl--4 { transition-delay: 330ms; }

	.pg-vendor-icon.is-played .vi-sprinkle {
		transition-duration: 200ms;
		transition-delay: 480ms;
	}

	/* Noodles: the chopsticks lift and the noodles stretch up out of the bowl. */
	.pg-vendor-icon.is-armed .vi-lift,
	.pg-vendor-icon.is-armed .vi-strands {
		transition-duration: 550ms;
	}

	.pg-vendor-icon.is-armed:not(.is-played) .vi-lift {
		transform: translateY(12px);
	}

	.pg-vendor-icon.is-armed:not(.is-played) .vi-strands {
		transform: scaleY(0.25);
	}

	.pg-vendor-icon.is-played .vi-lift,
	.pg-vendor-icon.is-played .vi-strands {
		transition-delay: 120ms;
	}
}
