/* PWM card shuffle: auto-cycling card stack (Home › Who We Serve). Pairs with pwm-card-shuffle.js.
   Geometry and timing are Mercurie's Claude board "Card shuffle — auto-cycling questions": a 501×484 stage,
   a 336×400 deck at (83, 40), 200×210 tiles at (-10, 0) and (293, 273), dots 40px under the stage. Percentages
   below are those numbers over the stage, so the composition scales with the column.
   Nothing applies until the script adds .is-pwm-ready, so without JS the cards render as ordinary blocks. */

.pwm-shuffle.is-pwm-ready {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--wp--preset--spacing--60);
}
.pwm-shuffle.is-pwm-ready > * {
	margin: 0;
	max-width: none;
}

/* min-height: 0 keeps the aspect ratio even if something lands in flow inside the stage
   (an aspect-ratio box otherwise grows to fit its content). */
.pwm-shuffle__stage {
	position: relative;
	width: 100%;
	min-height: 0;
	aspect-ratio: 501 / 484;
}

/* display: block because a site stylesheet may restyle image figures (a stray
   `.oi-section figure.wp-block-image { display: contents }` once left the tiles with no box). Specificity 0,3,0
   so it outranks that 0,2,1 selector whatever the load order. */
.pwm-shuffle .pwm-shuffle__stage > .pwm-shuffle__tile {
	display: block;
	position: absolute;
	z-index: 0;
	width: 39.92%;
	height: 43.39%;
	margin: 0;
	overflow: hidden;
}
.pwm-shuffle__stage > .pwm-shuffle__tile--a { left: -2%; top: 0; }
.pwm-shuffle__stage > .pwm-shuffle__tile--b { left: 58.48%; top: 56.4%; }
.pwm-shuffle__stage > .pwm-shuffle__tile img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.pwm-shuffle__deck {
	position: absolute;
	z-index: 1;
	left: 16.57%;
	top: 8.26%;
	width: 67.07%;
	height: 82.64%;
}

/* Cards keep their own block styling (radius, padding, overlay); only the box and motion change.
   min-height is inline on a cover block, hence !important. */
.pwm-shuffle__deck > .pwm-shuffle__card {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	min-height: 0 !important;
	margin: 0;
	overflow: hidden;
	transform-origin: 50% 60%;
	transition: transform 760ms cubic-bezier(0.32, 0.72, 0, 1), opacity 420ms ease-out;
}

/* .pwm-shuffle--bottom sets each card's text at the bottom, as on the Claude board (one question per card). */
.pwm-shuffle--bottom .pwm-shuffle__deck > .pwm-shuffle__card {
	align-items: flex-end;
}

/* Only the front card shows its text; the image and overlay stay visible on the cards behind it. */
.pwm-shuffle__deck > .pwm-shuffle__card > :not(.wp-block-cover__image-background, .wp-block-cover__video-background, .wp-block-cover__background) {
	transition: opacity 420ms ease-out;
}
.pwm-shuffle__deck > .pwm-shuffle__card:not(.is-front) > :not(.wp-block-cover__image-background, .wp-block-cover__video-background, .wp-block-cover__background) {
	opacity: 0;
}

.pwm-shuffle__dots {
	display: flex;
	justify-content: center;
}
.pwm-shuffle__dots > .pwm-shuffle__dot {
	display: grid;
	place-items: center;
	width: 24px;
	height: 24px;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 9999px;
	background: none;
	box-shadow: none;
	cursor: pointer;
	appearance: none;
}
.pwm-shuffle__dots > .pwm-shuffle__dot::before {
	content: "";
	width: 8px;
	height: 8px;
	border-radius: 9999px;
	background: var(--wp--preset--color--custom-slate-100, var(--wp--preset--color--palette-10));
	transition: background 420ms ease-out;
}
.pwm-shuffle__dots > .pwm-shuffle__dot[aria-current="true"]::before {
	background: var(--wp--preset--color--palette-1);
}
.pwm-shuffle__dots > .pwm-shuffle__dot:focus-visible {
	outline: 2px solid var(--wp--preset--color--palette-1);
	outline-offset: 0;
}

/* Labelled stacks (Home; the script adds .has-pwm-shuffle-labels and drops the dots). Review round 1:
   - the label of the front card takes the link button's hover pill (Figma "Home Questions": Slate 50 = palette-8,
     dark copper text), so the labels show the cycle;
   - a label links to its page: on hover or focus an arrow slides in after it, as on the site's linked cards;
   - question padding is 15% of the card, so it scales with the card (was spacing|70 at every size). */
.wp-block-button.is-pwm-shuffle-current > .wp-block-button__link {
	background-color: var(--wp--preset--color--palette-8);
	color: var(--wp--preset--color--palette-2);
	border-color: var(--wp--preset--color--palette-8);
}
.wp-block-button[class*="pwm-shuffle-to-"] > .wp-block-button__link {
	transition: background-color 420ms ease-out, color 420ms ease-out, border-color 420ms ease-out;
}
.wp-block-button[class*="pwm-shuffle-to-"] > .wp-block-button__link::after {
	content: "\2192";
	display: inline-block;
	margin-left: 0.3em;
	opacity: 0;
	transform: translateX(-0.4em);
	transition: opacity 200ms ease, transform 200ms ease;
}
.wp-block-button[class*="pwm-shuffle-to-"] > .wp-block-button__link:is(:hover, :focus-visible)::after {
	opacity: 1;
	transform: none;
}
.pwm-shuffle.has-pwm-shuffle-labels .pwm-shuffle__deck > .pwm-shuffle__card {
	padding: 15% !important;
}

@media (prefers-reduced-motion: reduce) {
	.wp-block-button[class*="pwm-shuffle-to-"] > .wp-block-button__link,
	.wp-block-button[class*="pwm-shuffle-to-"] > .wp-block-button__link::after,
	.pwm-shuffle__deck > .pwm-shuffle__card,
	.pwm-shuffle__deck > .pwm-shuffle__card > *,
	.pwm-shuffle__dots > .pwm-shuffle__dot::before {
		transition: none !important;
	}
}
