/*
 * Animated product demos on the front page (assets/js/demos.js).
 *
 * The markup in front-page.php is the resting state, shown without JavaScript and with reduced motion. These rules
 * only add the states the script switches between. Everything is scoped to [data-pe-demo] (one attribute + one
 * class) so it wins over the Tailwind utilities on the same elements, which the CDN build injects after this file.
 */

[data-pe-demo] [data-pe-stage] {
	position: relative;
}

/* --- pointer ---------------------------------------------------------------------------------------------- */

[data-pe-demo] .pe-cursor {
	position: absolute;
	left: 0;
	top: 0;
	z-index: 40;
	pointer-events: none;
	opacity: 0;
	transition: opacity .3s;
	will-change: transform;
}

[data-pe-demo] .pe-cursor svg {
	position: relative;
	display: block;
	width: 20px;
	height: 20px;
	filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .3));
}

[data-pe-demo] .pe-ripple {
	position: absolute;
	left: -12px;
	top: -12px;
	width: 24px;
	height: 24px;
	border-radius: 9999px;
	background: rgba(5, 150, 105, .3);
	transform: scale(0);
	transition: transform .25s ease-out;
}

[data-pe-demo] .pe-ripple.is-on {
	transform: scale(1.6);
}

/* --- show / hide without moving the page ------------------------------------------------------------------- */

[data-pe-demo] .pe-fade {
	transition: opacity .3s ease, translate .3s ease, visibility .3s;
}

[data-pe-demo] .pe-off {
	opacity: 0;
	visibility: hidden;
}

/* "translate", not "transform": it adds to Tailwind's own transform (e.g. the dialog's -translate-x-1/2) */
[data-pe-demo] .pe-off.pe-slide {
	translate: 0 8px;
}

[data-pe-demo] .pe-dim {
	opacity: .45;
}

[data-pe-demo] .pe-gone {
	display: none !important;
}

/* a current price before the preview has a new one for it: not struck through yet */
[data-pe-demo] .pe-plain {
	text-decoration: none;
	color: #111111;
}

/* --- controls in their "on" state -------------------------------------------------------------------------- */

[data-pe-demo] .pe-tab {
	transition: background-color .2s, color .2s;
}

/* no bolder weight: a wider label could wrap the tab row in a longer language */
[data-pe-demo] .pe-tab.is-on {
	background-color: #111111;
	color: #ffffff;
}

/* segmented control (Tiered Pricing modification mode) */
[data-pe-demo] .pe-seg {
	transition: background-color .2s, color .2s, box-shadow .2s;
}

[data-pe-demo] .pe-seg.is-on {
	background-color: #ffffff;
	color: #111111;
	font-weight: 700;
	box-shadow: 0 1px 2px rgba(17, 17, 17, .1);
}

/* capability cards next to a mockup: the one for the step being shown lights up */
[data-pe-demo] .pe-card {
	transition: border-color .35s, box-shadow .35s, transform .35s;
}

[data-pe-demo][data-pe-step="set"] [data-pe-card="set"],
[data-pe-demo][data-pe-step="update"] [data-pe-card="update"],
[data-pe-demo][data-pe-step="preview"] [data-pe-card="preview"] {
	border-color: #059669;
	box-shadow: 0 0 0 3px rgba(5, 150, 105, .12), 0 14px 28px -12px rgba(5, 150, 105, .35);
	transform: translateX(4px);
}

[data-pe-demo] .pe-radio {
	transition: border-width .15s, border-color .15s;
}

[data-pe-demo] .pe-radio.is-on {
	border-width: 5px;
	border-color: #059669;
}

[data-pe-demo] .pe-radio-label.is-on {
	color: #111111;
	font-weight: 700;
}

[data-pe-demo] .pe-field {
	transition: border-color .2s, box-shadow .2s;
}

[data-pe-demo] .pe-field.is-focus {
	border-color: #059669;
	box-shadow: 0 0 0 3px rgba(5, 150, 105, .15);
}

[data-pe-demo] .pe-option.is-hover {
	background-color: #ecfdf5;
	color: #065f46;
}

[data-pe-demo] .pe-press {
	transition: transform .12s;
}

[data-pe-demo] .pe-press.is-down {
	transform: scale(.94);
}

/* typing caret */
[data-pe-demo] .pe-caret::after {
	content: "";
	display: inline-block;
	width: 1px;
	height: 1.05em;
	margin-left: 1px;
	vertical-align: -2px;
	background: #111111;
	animation: pe-blink 1s steps(1) infinite;
}

/* new-price badges are inline blocks from the start, so popping one in never changes the row height */
[data-pe-demo] .bg-preview-yellow {
	display: inline-block;
}

/* a value that just appeared or changed */
[data-pe-demo] .pe-pop {
	display: inline-block;
	animation: pe-pop .38s cubic-bezier(.2, .8, .3, 1.2);
}

[data-pe-demo] .pe-flash {
	animation: pe-flash 1.1s ease-out;
}

/* progress bars: the script sets the width */
[data-pe-demo] .pe-bar {
	width: 0;
	transition: width .2s linear;
}

@keyframes pe-blink {
	50% {
		opacity: 0;
	}
}

@keyframes pe-pop {
	0% {
		opacity: 0;
		transform: scale(.6);
	}
	70% {
		opacity: 1;
		transform: scale(1.08);
	}
	100% {
		transform: scale(1);
	}
}

@keyframes pe-flash {
	0% {
		background-color: #fef08a;
	}
	100% {
		background-color: transparent;
	}
}

@media (prefers-reduced-motion: reduce) {
	[data-pe-demo] *,
	[data-pe-demo] *::after {
		animation: none !important;
		transition: none !important;
	}
}
