/**
 * Category / Shop page product cards – rb-product-card design
 * Same look as home page cards, isolated to archive product grids.
 * Loaded only on is_shop() and is_product_taxonomy().
 */

/*
 * Product grid (mobile-first): 2-up should hit BOTH gutters.
 * We avoid "98% rows" (48% + 2% + 48%) by using 50% widths and creating the inner gap via per-column padding:
 * - left column: padding-right
 * - right column: padding-left
 * Outer edges: 0 padding so cards align to rb-gutter.
 */
@media (max-width: 649px) {
	.woocommerce ul.products li.product,
	.woocommerce-page ul.products li.product {
		box-sizing: border-box !important;
		width: 50% !important;
		margin-right: 0 !important;
		margin-bottom: 14px !important;
	}

	/* Reset any theme padding, then add "inner gap" only */
	.woocommerce ul.products[class*=columns-] li.product,
	.woocommerce-page ul.products[class*=columns-] li.product,
	.woocommerce ul.products li.product,
	.woocommerce-page ul.products li.product {
		padding-left: 0 !important;
		padding-right: 0 !important;
	}

	/* Left column items: add right padding for inner gap */
	.woocommerce ul.products[class*=columns-] li.product:nth-child(2n+1),
	.woocommerce-page ul.products[class*=columns-] li.product:nth-child(2n+1),
	.woocommerce ul.products li.product:nth-child(2n+1),
	.woocommerce-page ul.products li.product:nth-child(2n+1) {
		padding-right: 5px !important;
	}

	/* Right column items: add left padding for inner gap */
	.woocommerce ul.products[class*=columns-] li.product:nth-child(2n),
	.woocommerce-page ul.products[class*=columns-] li.product:nth-child(2n),
	.woocommerce ul.products li.product:nth-child(2n),
	.woocommerce-page ul.products li.product:nth-child(2n) {
		padding-left: 5px !important;
	}
}



@media (min-width: 650px) and (max-width: 769px) {
	.woocommerce ul.products li.product,
	.woocommerce-page ul.products li.product {
		width: 32% !important;
		margin-right: 2% !important;
		margin-bottom: 14px !important;
	}
	.woocommerce ul.products li.product:nth-child(2n),
	.woocommerce-page ul.products li.product:nth-child(2n) {
		margin-right: 2% !important;
	}
	.woocommerce ul.products li.product:nth-child(3n),
	.woocommerce-page ul.products li.product:nth-child(3n) {
		margin-right: 0 !important;
	}
}

@media (min-width: 770px) and (max-width: 1800px) {
	.woocommerce ul.products li.product,
	.woocommerce-page ul.products li.product {
		width: 23.5% !important;
		margin-right: 2% !important;
		margin-bottom: 14px !important;
	}
	.woocommerce ul.products li.product:nth-child(3n),
	.woocommerce-page ul.products li.product:nth-child(3n) {
		margin-right: 2% !important;
	}
	.woocommerce ul.products li.product:nth-child(5n),
	.woocommerce-page ul.products li.product:nth-child(5n) {
		margin-right: 2% !important;
	}
	.woocommerce ul.products li.product:nth-child(4n),
	.woocommerce-page ul.products li.product:nth-child(4n) {
		margin-right: 0 !important;
	}
}

@media (min-width: 1801px) {
	.woocommerce ul.products li.product,
	.woocommerce-page ul.products li.product {
		width: 18.6% !important;
		margin-right: 1.75% !important;
		margin-bottom: 14px !important;
	}
	.woocommerce ul.products li.product:nth-child(3n),
	.woocommerce-page ul.products li.product:nth-child(3n) {
		margin-right: 1.75% !important;
	}
	.woocommerce ul.products li.product:nth-child(4n),
	.woocommerce-page ul.products li.product:nth-child(4n) {
		margin-right: 1.75% !important;
	}
	.woocommerce ul.products li.product:nth-child(5n),
	.woocommerce-page ul.products li.product:nth-child(5n) {
		margin-right: 0 !important;
	}
}

@media (min-width: 770px) {
	/* One step lighter than base (600/500); header h3 bold needs !important */
	.woocommerce ul.products .rb-product-card__title,
	.woocommerce ul.products .rb-product-card__title a,
	.woocommerce-page ul.products .rb-product-card__title,
	.woocommerce-page ul.products .rb-product-card__title a {
		font-weight: 500 !important;
	}
	.woocommerce ul.products li.product .rb-product-card__btn,
	.woocommerce ul.products li.product .rb-product-card__btn-text,
	.woocommerce-page ul.products li.product .rb-product-card__btn,
	.woocommerce-page ul.products li.product .rb-product-card__btn-text {
		font-weight: 400 !important;
	}
}

/* Scope: product grid on shop and category pages only */
.rb-promo-page .rb-promo-title {
	font-family: "Clickuper", Oswald, "Fira Sans Condensed", system-ui, sans-serif;
}

.woocommerce ul.products .rb-product-card {
	--rb-card-radius: 20px;
	--rb-card-max-w: none;

	position: relative;
	background: #fff;
	border-radius: var(--rb-card-radius);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.24);
	border: 1px solid #b9b9b9;
	/* visible so box-shadow is not clipped (corners: image-wrap + content radii below) */
	overflow: visible;
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100%;
}

.woocommerce ul.products .rb-product-card__sale-label {
	position: absolute;
	top: 5px;
	left: 5px;
	z-index: 2;
	width: 50%;
	height: auto;
	display: block;
	pointer-events: none;
}

.woocommerce ul.products .rb-product-card__image-wrap {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	flex-shrink: 0;
	overflow: hidden;
	background: #f5f5f5;
	border-top-left-radius: var(--rb-card-radius);
	border-top-right-radius: var(--rb-card-radius);
}

.woocommerce ul.products .rb-product-card__image-wrap .woocommerce-image-swap-wrapper {
	position: relative;
	display: block;
	width: 100%;
	height: 100%;
	overflow: hidden;
}

.woocommerce ul.products .rb-product-card__image-wrap .woocommerce-image-swap-wrapper img {
	position: absolute;
	top: 0;
	left: 0;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	max-height: none !important;
	object-fit: cover !important;
	object-position: center !important;
	display: block;
}

.woocommerce ul.products .rb-product-card__image-wrap > img {
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	max-height: none !important;
	object-fit: cover !important;
	object-position: center !important;
	display: block;
}

.woocommerce ul.products .rb-product-card:hover .woocommerce-image-swap-wrapper img.wp-post-image {
	opacity: 0;
}

.woocommerce ul.products .rb-product-card:hover .woocommerce-image-swap-wrapper img.woocommerce-hover-image {
	opacity: 1;
	z-index: 2;
}

.woocommerce ul.products .rb-product-card__content {
	padding: 8px 10px;
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	min-width: 0;
	min-height: 0;
	border-bottom-left-radius: var(--rb-card-radius);
	border-bottom-right-radius: var(--rb-card-radius);
}

.woocommerce ul.products .rb-product-card__title {
	font-weight: 600;
	margin: 0 0 0.25rem;
	font-size: 0.9375rem;
	line-height: 1.3;
	min-height: unset;
}

.woocommerce ul.products .rb-product-card__title a {
	color: inherit;
	text-decoration: none;
}

.woocommerce ul.products .rb-product-card__title a:hover {
	text-decoration: underline;
}

.woocommerce ul.products .rb-product-card__price {
	margin: 0 0 0.5rem;
	font-size: 0.9375rem;
}

.woocommerce ul.products .rb-product-card__price del {
	display: block;
	opacity: 1;
	color: #666;
}

.woocommerce ul.products .rb-product-card__price del * {
	color: #666;
}

.woocommerce ul.products .rb-product-card__price del .amount {
	text-decoration: line-through;
	font-size: 0.875rem;
}

.woocommerce ul.products .rb-product-card__price ins {
	display: block;
	text-decoration: none;
	font-size: 1rem !important;
	font-weight: 700 !important;
	color: #E30000 !important;
}

.woocommerce ul.products .rb-product-card__price ins .amount,
.woocommerce ul.products .rb-product-card__price ins bdi,
.woocommerce ul.products .rb-product-card__price ins span,
.woocommerce ul.products .rb-product-card__price ins * {
	color: #E30000 !important;
	font-size: 1rem !important;
	font-weight: 700 !important;
}

.woocommerce ul.products li.product .rb-product-card__btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	width: 100%;
	padding: 0.5rem 1rem;
	border-radius: 15px;
	background: #2F6630 !important;
	color: #fff !important;
	text-decoration: none;
	font-size: 0.875rem;
	font-weight: 500;
	/* Pin to bottom of card; header.php .button { margin-top: 0 } loads later — must win */
	margin-top: auto !important;
	border: none !important;
	cursor: pointer;
}

.woocommerce ul.products li.product .rb-product-card__btn:hover {
	background: #275a28 !important;
	color: #fff !important;
}

/* Mobile (<1024px): full-width add-to-cart; label slightly smaller than button base */
@media (max-width: 1023px) {
	.woocommerce ul.products .rb-product-card__content {
		padding-top: 0;
	}

	/* Title: one step smaller + normal weight (overrides header h3 { font-weight: bold }) */
	.woocommerce ul.products .rb-product-card__title,
	.woocommerce ul.products .rb-product-card__title a {
		font-size: 0.875rem !important;
		font-weight: 400 !important;
	}

	.woocommerce ul.products li.product .rb-product-card__btn-text {
		font-size: 0.8125rem !important;
		font-weight: 400 !important;
		display: inline !important;
	}
	.woocommerce ul.products li.product .rb-product-card__btn {
		width: 100% !important;
		gap: 0.5rem !important;
		justify-content: center;
		border-radius: 15px !important;
		font-weight: 400 !important;
	}
	.woocommerce ul.products li.product .rb-product-card__btn i {
		font-size: 0.75rem !important;
	}
}

/* Grid: li wraps the card; stretch row height so card + flex column can pin CTA to bottom */
.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product {
	display: flex;
	align-items: stretch;
	text-align: center;
	/* header.php sets overflow:hidden on li — clips card box-shadow; space below for shadow blur */
	overflow: visible !important;
	padding-bottom: 12px;
	box-sizing: border-box;
}

.woocommerce ul.products li.product .rb-product-card {
	flex: 1 1 auto;
	align-self: stretch;
	min-height: 100%;
}

/* Shop toolbar: flex row aligns result count + sort (float layout misaligns) */
.woocommerce .rb-shop-toolbar .woocommerce-notices-wrapper {
	width: 100%;
	flex-basis: 100%;
}

.woocommerce .rb-shop-toolbar .woocommerce-result-count,
.woocommerce .rb-shop-toolbar .woocommerce-ordering {
	float: none;
	margin: 0;
}

.woocommerce .rb-shop-toolbar .woocommerce-result-count {
	line-height: 1.35;
}

/* Category extra description typography: keep h2 one step above paragraph size */
.term-description-extra h2,
.term-description h2 {
	font-family: Oswald, "Fira Sans Condensed", sans-serif;
	font-size: 1.25rem;
	font-weight: 600;
}

@media (min-width: 1024px) {
	.term-description-extra h2,
	.term-description h2 {
		font-size: 1.375rem;
		line-height: 1.2;
	}
}

/* Sorting dropdown – rounded, modern */
.woocommerce .woocommerce-ordering select.orderby {
	padding: 0.45rem 0.65rem;
	border-radius: 9999px;
	border: 1px solid #d4d4d4;
	background-color: #fff;
	font-size: 0.875rem;
	font-weight: 400;
	line-height: 1.35;
	color: #6b7280;
	cursor: pointer;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	min-height: 2.25rem;
}

.woocommerce .woocommerce-ordering select.orderby:hover {
	border-color: #a3a3a3;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.woocommerce .woocommerce-ordering select.orderby:focus {
	outline: none;
	border-color: #282828;
	box-shadow: 0 0 0 2px rgba(40, 40, 40, 0.12);
}
