/*
 * PureCSS.com
 * https://purecss.com/3d-card-flip/
 * A card that flips on hover using CSS 3D transforms and perspective.
 */

.demo-3d-card-flip .flip-card {
		width: 200px;
		height: 130px;
		perspective: 800px;
	}

:is(.demo-3d-card-flip .flip-card):hover .flip-inner {
			transform: rotateY(180deg);
		}

.demo-3d-card-flip .flip-inner {
		width: 100%;
		height: 100%;
		position: relative;
		transform-style: preserve-3d;
		transition: transform .55s ease;
	}

.demo-3d-card-flip .flip-front,.demo-3d-card-flip .flip-back {
		position: absolute;
		inset: 0;
		border-radius: 12px;
		backface-visibility: hidden;
		display: flex;
		/* the faces are flex containers, so a <br> between the title and the
		   sub label does nothing; stacking them is what separates the lines */
		flex-direction: column;
		align-items: center;
		justify-content: center;
		font-size: .95rem;
		font-weight: 600;
		padding: 1rem;
		text-align: center;
	}

.demo-3d-card-flip .flip-front {
		background: var(--accent-in-palette);
		color: var(--bg);
	}

.demo-3d-card-flip .flip-back {
		background: var(--violet);
		color: var(--bg);
		transform: rotateY(180deg);
	}

/* ── Variant: flip on the X axis instead of the Y ── */

.demo-3d-card-flip .flip-vertical .flip-inner {
		transform-origin: center;
	}

:is(.demo-3d-card-flip .flip-vertical):hover .flip-inner {
			transform: rotateX(180deg);
		}

.demo-3d-card-flip .flip-vertical .flip-back {
		transform: rotateX(180deg);
	}

/* ── Variant: flip on click, for touch and keyboard ── */

.demo-3d-card-flip .flip-toggle {
		position: absolute;
		opacity: 0;
		width: 1px;
		height: 1px;
	}

.demo-3d-card-flip .flip-click {
		display: block;
		/* the label sits between the sized card and .flip-inner, so it has to
		   carry the box or the inner element's height: 100% resolves to zero */
		width: 100%;
		height: 100%;
		cursor: pointer;
	}

:is(.demo-3d-card-flip .flip-toggle):checked + .flip-click .flip-inner {
			transform: rotateY(180deg);
		}

/* the focus ring has to sit on the label, because the input driving it is
   visually hidden and would otherwise show no keyboard focus at all */
:is(.demo-3d-card-flip .flip-toggle):focus-visible + .flip-click .flip-inner {
			outline: 2px solid var(--accent);
			outline-offset: 3px;
		}

/* a click card must not also flip on hover, or the two fight each other */
:is(.demo-3d-card-flip .flip-click):hover .flip-inner {
			transform: none;
		}

:is(.demo-3d-card-flip .flip-toggle):checked + .flip-click:hover .flip-inner {
			transform: rotateY(180deg);
		}

/* Anyone who asks the system to reduce motion gets the same state change
   without the spin. The card still flips, it does not animate. */
@media (prefers-reduced-motion: reduce) {
	.demo-3d-card-flip .flip-inner {
		transition: none;
	}
}

/* The card preview demonstrates a hover flip, so it keeps its pointer events
   instead of letting clicks fall through to the card link. */
.card-preview .demo-3d-card-flip {
	pointer-events: auto;
}
