/**
 * Second-hand marketplace front end styles.
 *
 * Deliberately small and theme-agnostic: the badge positions itself against the
 * thumbnail wrapper XStore already uses, and everything else inherits the
 * theme's typography rather than setting its own.
 */

.wgsh-badge {
	display: inline-flex;
	align-items: baseline;
	gap: .4em;
	padding: .25em .6em;
	border-radius: 2em;
	background: #2f4858;
	color: #fff;
	font-size: .72rem;
	font-weight: 600;
	line-height: 1.4;
	letter-spacing: .02em;
	text-transform: uppercase;
}

.wgsh-badge__condition {
	font-weight: 400;
	text-transform: none;
	opacity: .85;
}

/* In listings the badge sits over the image, opposite the sale flash. */
.wgsh-badge--loop {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 3;
	pointer-events: none;
}

.products .product,
.product-image-wrapper {
	position: relative;
}

.wgsh-badge--single {
	margin: 0 0 .6em;
}

.wgsh-saving {
	display: inline-block;
	margin-left: .5em;
	font-size: .85em;
	font-weight: 600;
	color: #2f4858;
	white-space: nowrap;
}

.wgsh-final-sale {
	margin: 1em 0 0;
	padding: .7em .9em;
	border-left: 3px solid #2f4858;
	background: #f6f8f9;
	font-size: .9em;
	line-height: 1.5;
}

.wgsh-catalog {
	margin: 0 0 2em;
}

.wgsh-empty {
	margin: 1.5em 0;
	font-style: italic;
}

.wgsh-pagination {
	margin: 1.5em 0 0;
}

.wgsh-pagination .page-numbers {
	display: inline-block;
	margin: 0 .15em;
	padding: .35em .7em;
	border: 1px solid #dcdcdc;
	border-radius: 3px;
	text-decoration: none;
}

.wgsh-pagination .page-numbers.current {
	background: #2f4858;
	border-color: #2f4858;
	color: #fff;
}

@media (max-width: 767px) {
	.wgsh-badge {
		font-size: .65rem;
		padding: .2em .5em;
	}

	.wgsh-badge--loop {
		top: 6px;
		right: 6px;
	}
}

/*
 * Category sidebar for [products sidebar="categories"]. The sidebar stays to the
 * left of the products at every width; on phones it narrows and the products drop
 * to one column so the cards keep a usable size.
 */
.wgsh-filter-layout {
	display: grid;
	grid-template-columns: 230px minmax(0, 1fr);
	gap: 40px;
	align-items: start;
}

.wgsh-filter {
	position: sticky;
	top: 120px;
}

.wgsh-filter fieldset {
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.wgsh-filter .wgsh-filter__title {
	display: block;
	width: 100%;
	margin: 0 0 12px;
	padding: 0 0 10px;
	border-bottom: 2px solid #49976d;
	font-size: 1rem;
	font-weight: 600;
	letter-spacing: .04em;
	text-transform: uppercase;
}

.wgsh-filter .wgsh-filter__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.wgsh-filter .wgsh-filter__list li {
	margin: 0;
	padding: 0;
	list-style: none;
}

.wgsh-filter .wgsh-filter__option {
	position: relative;
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0;
	padding: 8px 6px;
	border-radius: 8px;
	font-weight: 400;
	cursor: pointer;
	transition: background-color .15s ease;
}

.wgsh-filter .wgsh-filter__option:hover {
	background: rgba(73, 151, 109, .07);
}

/* The real checkbox stays in place for keyboards and screen readers; the box below is drawn over it. */
.wgsh-filter .wgsh-filter__input {
	position: absolute;
	top: 50%;
	left: 6px;
	width: 18px;
	height: 18px;
	margin: -9px 0 0;
	opacity: 0;
	cursor: pointer;
}

.wgsh-filter .wgsh-filter__box {
	position: relative;
	flex: 0 0 18px;
	width: 18px;
	height: 18px;
	border: 1.5px solid #9aa5a0;
	border-radius: 4px;
	background: #fff;
	transition: background-color .15s ease, border-color .15s ease;
}

.wgsh-filter .wgsh-filter__input:checked + .wgsh-filter__box {
	border-color: #49976d;
	background: #49976d;
}

.wgsh-filter .wgsh-filter__input:checked + .wgsh-filter__box::after {
	content: "";
	position: absolute;
	top: 2px;
	left: 5px;
	width: 5px;
	height: 9px;
	border: solid #fff;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}

.wgsh-filter .wgsh-filter__input:focus-visible + .wgsh-filter__box {
	outline: 2px solid #49976d;
	outline-offset: 2px;
}

.wgsh-filter .wgsh-filter__name {
	flex: 1 1 auto;
	min-width: 0;
}

.wgsh-filter .wgsh-filter__input:checked ~ .wgsh-filter__name {
	color: #2f6b4b;
	font-weight: 600;
}

.wgsh-filter .wgsh-filter__count {
	flex: 0 0 auto;
	min-width: 26px;
	padding: 1px 8px;
	border-radius: 20px;
	background: rgba(128, 128, 128, .12);
	font-size: .8em;
	text-align: center;
}

.wgsh-filter .wgsh-filter__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
	margin-top: 14px;
}

.wgsh-filter .wgsh-filter__clear {
	color: #2f6b4b;
	font-size: .875em;
	text-decoration: underline;
}

.wgsh-filter .wgsh-filter__clear[hidden] {
	display: none;
}

/* With the script running, ticking a box applies at once. */
.wgsh-js .wgsh-filter__apply {
	display: none;
}

.wgsh-filter-products {
	position: relative;
	min-height: 200px;
	transition: opacity .2s ease;
}

.wgsh-filter-layout.is-loading .wgsh-filter-products {
	opacity: .4;
	pointer-events: none;
}

.wgsh-filter-layout.is-loading .wgsh-filter-products::after {
	content: "";
	position: absolute;
	top: 80px;
	left: 50%;
	width: 36px;
	height: 36px;
	margin-left: -18px;
	border: 3px solid rgba(73, 151, 109, .25);
	border-top-color: #49976d;
	border-radius: 50%;
	animation: wgsh-spin .7s linear infinite;
}

@keyframes wgsh-spin {
	to {
		transform: rotate(360deg);
	}
}

@media (prefers-reduced-motion: reduce) {
	.wgsh-filter-layout.is-loading .wgsh-filter-products::after {
		animation-duration: 2s;
	}
}

@media (max-width: 991px) {
	.wgsh-filter-layout {
		grid-template-columns: 190px minmax(0, 1fr);
		gap: 24px;
	}
}

/* Phones: a narrow sidebar on the left, one product per row beside it. */
@media (max-width: 767px) {
	.wgsh-filter-layout {
		grid-template-columns: 118px minmax(0, 1fr);
		gap: 14px;
	}

	.wgsh-filter {
		top: 80px;
	}

	.wgsh-filter .wgsh-filter__title {
		font-size: .75rem;
	}

	.wgsh-filter .wgsh-filter__option {
		gap: 7px;
		padding: 7px 2px;
		font-size: .875rem;
	}

	.wgsh-filter .wgsh-filter__input {
		left: 2px;
	}

	.wgsh-filter .wgsh-filter__box {
		flex-basis: 16px;
		width: 16px;
		height: 16px;
	}

	.wgsh-filter .wgsh-filter__input:checked + .wgsh-filter__box::after {
		top: 1px;
		left: 4px;
	}

	.wgsh-filter .wgsh-filter__count {
		min-width: 0;
		padding: 0 5px;
		font-size: .7rem;
	}

	.wgsh-filter-products .products {
		display: flex;
		flex-wrap: wrap;
		margin-right: 0;
		margin-left: 0;
	}

	.wgsh-filter-products .products > .product {
		flex: 0 0 100%;
		width: 100%;
		max-width: 100%;
		padding-right: 0;
		padding-left: 0;
	}
}
