/*
 * Feed cards: a square photo frame (card 67) and text clamped to three lines
 * with an in-card more/less toggle (card 70).
 *
 * Scoped to [data-ys-listing], the attribute only the plugin-indexed card
 * (template-parts/listing-card.php) carries, so the legacy product-card.php
 * is untouched. Each rule carries one more class-weight than the theme rule
 * it replaces in css/listing.css, so it wins whatever order the two sheets
 * load in, without !important. The shorter selectors are the same rules for
 * a card placed outside .cat-list-outer.
 */

/* ------------------------------------------------------------ square photo */

/* The theme gave the frame a fixed height per breakpoint (224px down to
   136px), which cut every photo to a different landscape strip. Square
   instead, as wide as the card. */
.cat-listings[data-ys-listing] .img-wrp,
.cat-list-outer .cat-list-wrp .cat-listings[data-ys-listing] .img-wrp {
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	border-radius: 5px;
}

/* Cover, not a crop: the file is whole. What shows is the centre, or the
   seller's own framing, which the card prints as an inline object-position
   (ListingPhoto::objectPosition()). */
.cat-listings[data-ys-listing] .img-wrp img,
.cat-list-outer .cat-list-wrp .cat-listings[data-ys-listing] .img-wrp img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* ------------------------------------------------------ three-line clamp */

.cat-listings[data-ys-listing] .cat-cont-wrp .desc,
.cat-list-outer .cat-list-wrp .cat-listings[data-ys-listing] .cat-cont-wrp .desc {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	overflow: hidden;
}

.cat-listings[data-ys-listing] .cat-cont-wrp .desc.is-expanded,
.cat-list-outer .cat-list-wrp .cat-listings[data-ys-listing] .cat-cont-wrp .desc.is-expanded {
	display: block;
	-webkit-line-clamp: none;
	line-clamp: none;
	overflow: visible;
}

/*
 * The toggle has to be clickable, and the whole card is covered by
 * .full-box-click (z-index 20), the "open this listing" link. The text block
 * is position:relative; z-index:2 in listing.css, which traps anything inside
 * it below that link. On a card that has a toggle the block drops its
 * z-index (no stacking context of its own), so the toggle alone can sit above
 * the link; the rest of the text stays under it and opens the listing as
 * before.
 */
.cat-listings[data-ys-listing] > .cat-cont-wrp.ys-has-more {
	z-index: auto;
}

.cat-listings[data-ys-listing] .ys-card-more {
	position: relative;
	z-index: 21;
	display: inline-block;
	margin: -4px 0 8px;
	padding: 4px 0;
	min-height: 24px;
	border: 0;
	background: none;
	color: #08BF06;
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
}

.cat-listings[data-ys-listing] .ys-card-more:hover {
	text-decoration: underline;
}

.cat-listings[data-ys-listing] .ys-card-more:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
	border-radius: 2px;
}

.cat-listings[data-ys-listing] .ys-card-more[hidden] {
	display: none;
}

@media (max-width: 767px) {
	.cat-listings[data-ys-listing] .ys-card-more {
		margin-top: 0;
		font-size: 12px;
	}
}

/* ---------------------------------------------------------- auction badge */

/*
 * Card 174: a purple AUCTION badge on the feed card and on the listing view.
 * White on #6b2fbf is about 7.5:1, past WCAG AA for small bold text. The
 * base rule is placement-free so the popup (listing-popup.js puts one beside
 * #modal-price) and the single listing page can reuse it; on a card it sits
 * top-right, opposite the orange FEATURED badge (top-left in the theme's
 * common.css), so a featured auction shows both without overlap.
 */
.ys-auction-badge {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 999px;
	background: #6b2fbf;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 1.5;
	letter-spacing: .04em;
	text-transform: uppercase;
	white-space: nowrap;
	vertical-align: middle;
}

.cat-listings[data-ys-listing] .img-wrp .ys-auction-badge,
.cat-list-outer .cat-list-wrp .cat-listings[data-ys-listing] .img-wrp .ys-auction-badge {
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 2;
}

/* On a dark page the purple keeps its white text; a thin light ring keeps
   the pill's edge visible against a dark photo or background. */
@media (prefers-color-scheme: dark) {
	.ys-auction-badge {
		background: #7c3fd4;
		box-shadow: 0 0 0 1px rgba(255, 255, 255, .35);
	}
}

@media (forced-colors: active) {
	.ys-auction-badge {
		border: 1px solid CanvasText;
	}
}

/* ------------------------------------------------------------- reduced */

/*
 * Round 2 item 4: for 7 days after a seller lowers the price, a small
 * REDUCED tag at the top left of the photo and the old price crossed out in
 * grey beside the new one. Orange, as the owner's spec asks: #E07B00, a deeper
 * shade of the logo's orange so the white text stays readable. Under the
 * FEATURED badge when a card has both.
 */
.cat-listings[data-ys-listing] .img-wrp {
	position: relative;
}

.cat-listings[data-ys-listing] .img-wrp .ys-reduced-badge {
	position: absolute;
	top: 8px;
	left: 8px;
	z-index: 2;
	padding: 2px 7px;
	border-radius: 4px;
	background: #E07B00;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 1.4;
	letter-spacing: 0.06em;
}

.cat-listings[data-ys-listing] .img-wrp .ys-featured-badge ~ .ys-reduced-badge {
	top: 34px;
}

.cat-listings[data-ys-listing] .cat-cont-wrp .price .ys-price-was,
.cat-list-outer .cat-list-wrp .cat-listings[data-ys-listing] .cat-cont-wrp .price .ys-price-was {
	margin-left: 6px;
	color: #6B6B70;
	font-size: 0.85em;
	font-weight: 400;
	text-decoration: line-through;
}
