/**
 * Pathway Marquee — frontend styles.
 *
 * @package Pathway_Marquee
 */

.pwmq {
	position: relative;
	width: 100%;
	--pwmq-size: 180px;
	--pwmq-path-color: currentColor;
	--pwmq-path-width: 1px;
}

.pwmq--clip {
	overflow: hidden;
}

.pwmq--draggable {
	cursor: grab;
	touch-action: none;
	-webkit-user-select: none;
	user-select: none;
}

.pwmq--dragging {
	cursor: grabbing;
}

.pwmq--draggable img {
	-webkit-user-drag: none;
	pointer-events: none;
}

.pwmq__canvas {
	position: absolute;
	inset: var( --pwmq-inset, 0 );
	width: 100%;
	height: 100%;
	overflow: visible;
	pointer-events: none;
}

.pwmq__path {
	fill: none;
	stroke: none;
}

.pwmq--show-path .pwmq__path {
	stroke: var(--pwmq-path-color);
	stroke-width: var(--pwmq-path-width);
	vector-effect: non-scaling-stroke;
}

/* Insetting the stage keeps the path away from the edges, so items centred on
   it stop hanging over the side and getting clipped. */
.pwmq__stage {
	position: absolute;
	inset: var( --pwmq-inset, 0 );
}

.pwmq__item {
	position: absolute;
	top: 0;
	left: 0;
	width: var(--pwmq-size);
	transform-origin: 50% 50%;
	will-change: transform;
	backface-visibility: hidden;
}

/* Until the engine paints the first frame, keep items out of the way. */
.pwmq:not(.pwmq--ready) .pwmq__item {
	opacity: 0;
}

/*
 * The engine rewrites the transform on .pwmq__item every frame, so a CSS
 * transition there would be overwritten. Anything that animates on hover
 * goes on this inner wrapper instead.
 */
.pwmq__inner {
	display: block;
	transform-origin: 50% 50%;
	will-change: transform;
}

.pwmq--hover-scale .pwmq__inner {
	transition: transform 0.45s cubic-bezier( 0.2, 0.8, 0.2, 1 );
}

.pwmq--hover-scale .pwmq__item:hover .pwmq__inner {
	transform: scale( var( --pwmq-hover-scale, 1 ) );
}

/* A growing item has to clear the ones around it, and the engine writes its
   z-index inline, so this needs the extra weight. */
.pwmq--hover-scale .pwmq__item:hover {
	z-index: 2147483000 !important;
}

.pwmq__item img {
	display: block;
	width: 100%;
	height: auto;
	max-width: none;
}

/* -----------------------------------------------------------------------
 * Taking images back from the theme
 *
 * Themes commonly wrap a product image in a placeholder with an inline
 * `padding-bottom` percentage and stretch the image over it with
 * `object-fit: cover`, which crops every picture to one shape. The inline
 * style and the theme's own specificity are why these need !important.
 * -------------------------------------------------------------------- */

.pwmq--media-fix .pwmq__inner .ph,
.pwmq--media-fix .pwmq__inner [style*="padding-bottom"],
.pwmq--media-fix .pwmq__inner [style*="padding-top"] {
	height: auto !important;
	padding-top: 0 !important;
	padding-bottom: 0 !important;
}

.pwmq--media-fix .pwmq__inner img {
	position: static !important;
	inset: auto !important;
	width: 100% !important;
	max-width: none !important;
}

.pwmq--media-original .pwmq__inner img {
	height: auto !important;
	aspect-ratio: auto !important;
	object-fit: contain !important;
}

.pwmq--media-ratio .pwmq__inner img {
	height: auto !important;
	aspect-ratio: var( --pwmq-media-ratio, 1 / 1 ) !important;
	object-fit: cover !important;
}

@media ( prefers-reduced-motion: reduce ) {
	.pwmq--hover-scale .pwmq__inner {
		transition: none;
	}
}

/* -----------------------------------------------------------------------
 * Product items
 * -------------------------------------------------------------------- */

.pwmq__link {
	display: block;
	text-decoration: none;
	color: inherit;
}

.pwmq__media {
	display: block;
	overflow: hidden;
	border-radius: var(--pwmq-radius, 0);
}

.pwmq__meta {
	display: block;
	margin-top: 0.5em;
	text-align: center;
	line-height: 1.3;
}

.pwmq__title {
	display: block;
	font-size: 0.8125rem;
}

.pwmq__price {
	display: block;
	margin-top: 0.15em;
	font-size: 0.8125rem;
	opacity: 0.7;
}

.pwmq__price del {
	opacity: 0.6;
}

.pwmq__price ins {
	text-decoration: none;
}

/* -----------------------------------------------------------------------
 * Pause control
 * -------------------------------------------------------------------- */

.pwmq__toggle {
	position: absolute;
	right: 8px;
	bottom: 8px;
	z-index: 2147483001;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	color: inherit;
	background: var( --pwmq-toggle-bg, rgba( 255, 255, 255, 0.8 ) );
	border: 1px solid var( --pwmq-toggle-border, rgba( 0, 0, 0, 0.12 ) );
	border-radius: 50%;
	opacity: 0.45;
	cursor: pointer;
	transition: opacity 0.2s ease;
}

.pwmq:hover .pwmq__toggle,
.pwmq__toggle:hover,
.pwmq__toggle:focus-visible {
	opacity: 1;
}

.pwmq__toggle:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* Two bars for pause, swapped for a triangle once stopped. */
.pwmq__toggle-icon {
	display: block;
	width: 10px;
	height: 11px;
	background: currentColor;
	-webkit-clip-path: polygon( 0 0, 35% 0, 35% 100%, 0 100%, 0 0, 65% 0, 100% 0, 100% 100%, 65% 100% );
	clip-path: polygon( 0 0, 35% 0, 35% 100%, 0 100%, 0 0, 65% 0, 100% 0, 100% 100%, 65% 100% );
}

.pwmq--paused .pwmq__toggle-icon {
	-webkit-clip-path: polygon( 0 0, 100% 50%, 0 100% );
	clip-path: polygon( 0 0, 100% 50%, 0 100% );
}

/* Matches core's helper, restated so the plugin does not rely on the theme. */
.pwmq .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect( 0, 0, 0, 0 );
	white-space: nowrap;
	border: 0;
}

/* -----------------------------------------------------------------------
 * Accessibility
 * -------------------------------------------------------------------- */

@media ( prefers-reduced-motion: reduce ) {
	.pwmq__item {
		will-change: auto;
	}
}
