/**
 * Paripoorn Product Grid widget.
 * The card itself (.pp-product-card and children) is styled by the
 * theme's own components.css — this file only adds the grid/carousel
 * wrapper layer, badge modifiers, and the description/review-count
 * additions this widget introduces on top of the shared card markup.
 */

.pp-pg {
	position: relative;
}

.pp-pg__viewport {
	overflow: hidden;
	width: 100%;
	max-width: 100%;
}

.pp-pg--grid .pp-pg__grid {
	display: grid;
	grid-template-columns: repeat(var(--pp-pg-columns, 4), 1fr);
	gap: 24px;
}

/*
 * Carousel mode: a hand-built sliding track (see product-grid.js), not
 * Swiper. Card width and the transform distance are computed in JS
 * from the viewport's real measured clientWidth and written back as
 * exact pixel values — never a CSS percentage/calc() guess — so a
 * card can't end up sitting half on/half off the visible edge. Same
 * approach as the Testimonials widget, after the same bug there.
 */
.pp-pg--carousel .pp-pg__grid {
	display: flex;
	gap: 24px;
	will-change: transform;
	transition: transform 500ms cubic-bezier(.4, 0, .2, 1);
}

/*
 * Slide width is normally written as an exact px value by
 * product-grid.js (see above). This flex-basis is the fallback for
 * before/without that measurement — most importantly inside the
 * Elementor editor, where the widget is re-rendered into a canvas
 * iframe that can still report clientWidth: 0 at render time, so the
 * measured width comes out as 0 and every card collapses to nothing.
 *
 * --pp-pg-slides is printed by the widget from its own Slides Per View
 * setting, so this fallback shows the configured number of cards rather
 * than a hardcoded guess. The JS still overrides it with the precise
 * measured value as soon as a real width is available.
 */
.pp-pg--carousel .pp-pg__slide {
	flex-shrink: 0;
	flex-basis: calc(
		(100% - (24px * (var(--pp-pg-slides, 4) - 1))) / var(--pp-pg-slides, 4)
	);
}

@media (prefers-reduced-motion: reduce) {
	.pp-pg--carousel .pp-pg__grid {
		transition: none;
	}
}

.pp-pg__badge--sale {
	background: var(--pp-sale, #F20D16);
}

.pp-pg__badge--bestseller {
	background: #D89B32;
}

.pp-pg__badge--new {
	background: #F20D16;
}

.pp-pg__description {
	font-family: var(--pp-font-body, "Manrope", sans-serif);
	font-size: 13px;
	line-height: 1.5;
	color: var(--pp-muted, #8A8A8A);
	margin: 0;
}

.pp-pg__rating {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
}

.pp-pg__review-count {
	font-family: var(--pp-font-body, "Manrope", sans-serif);
	font-size: 0.8125rem;
	color: var(--pp-muted, #8A8A8A);
}

.pp-pg .pp-pg__arrow {
	position: absolute;
	top: 38%;
	transform: translateY(-50%);
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background-color: var(--pp-bg, #fff);
	padding: 0;
	box-shadow: var(--pp-shadow-md, 0 8px 24px rgba(34, 34, 34, 0.08));
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--pp-heading, #222);
	z-index: 3;
	transition: color 250ms ease, background-color 250ms ease;
}

.pp-pg__arrow--prev {
	left: -8px;
}

.pp-pg__arrow--next {
	right: -8px;
}

.pp-pg__arrow:hover {
	color: var(--pp-primary, #F20D16);
}

.pp-pg__dots {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin-top: 24px;
}

.pp-pg__dot {
	width: 8px;
	height: 8px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--pp-border, #E9E3D8);
	cursor: pointer;
}

.pp-pg__dot--active {
	background: var(--pp-primary, #F20D16);
}

@media (max-width: 1023px) {
	.pp-pg--grid .pp-pg__grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (max-width: 599px) {
	.pp-pg--grid .pp-pg__grid {
		grid-template-columns: 1fr;
	}

	.pp-pg__arrow {
		width: 34px;
		height: 34px;
	}
}

/*
 * Price in the serif display face, matching the product title.
 *
 * Scoped to .pp-pg so this is the Product Grid widget's default only —
 * the theme's own shop/archive cards keep whatever components.css sets.
 * The widget's Price typography control targets this same selector, so
 * anything set there still wins (Elementor prints it later, inline).
 */
.pp-pg .pp-product-card__price,
.pp-pg .pp-product-card__price .woocommerce-Price-amount,
.pp-pg .pp-product-card__price ins,
.pp-pg .pp-product-card__price del {
	font-family: var(--pp-font-heading, "Libre Caslon Text", Georgia, serif);
}
