/**
 * Layali archive cards — restyles the DEFAULT WC loop card to match the
 * brand on shop / category / tag / search pages only.
 *
 * Strictly scoped under `body.woocommerce` so:
 *   - single-product pages (related products, upsells)
 *   - cart cross-sells
 *   - any product-slider widget on regular pages
 * are NEVER touched. WC's default markup is what we style here — no template
 * override, no replacement loop item.
 *
 * Target structure (WC default):
 *   <li class="product">
 *     <a class="woocommerce-LoopProduct-link">
 *       <img class="attachment-woocommerce_thumbnail wp-post-image" />
 *       <h2 class="woocommerce-loop-product__title">Title</h2>
 *       <span class="price">...</span>
 *     </a>
 *     <a class="button add_to_cart_button">Read more</a>
 *   </li>
 */

body.woocommerce ul.products li.product {
	background: transparent;
	padding: 0;
	margin: 0 0 32px;
	text-align: left;
	border: none;
}

/* Wrapping anchor: stack image / title / excerpt / price vertically. Flex
   (not grid) so the optional short-description row flows without a fixed
   row template. */
body.woocommerce ul.products li.product > a.woocommerce-LoopProduct-link {
	display: flex;
	flex-direction: column;
	gap: 6px;
	color: inherit;
	text-decoration: none;
}

/* Image shows at its native proportions — no fixed box, so nothing is cropped
   and there are no letterbox bands. Card heights can vary slightly between
   products as a result. `background-color` is kept only as a fallback for a
   missing/transparent source. */
body.woocommerce ul.products li.product img.wp-post-image,
body.woocommerce ul.products li.product img.attachment-woocommerce_thumbnail {
	display: block;
	width: 100%;
	height: auto;
	background-color: var(--ly-color-surface-subtle, #f4f0eb);
	border-radius: 18px;
	padding: 0;
	/* Extra breathing room below the image before the text block (on top of
	   the link's 6px flex gap). */
	margin: 0 0 8px;
	transition: transform 250ms ease;
}

body.woocommerce ul.products li.product:hover img.wp-post-image,
body.woocommerce ul.products li.product:hover img.attachment-woocommerce_thumbnail {
	transform: scale( 1.02 );
}

/* Title — bold, primary-color. */
body.woocommerce ul.products li.product .woocommerce-loop-product__title {
	margin: 0;
	padding: 0;
	font-size: 1.05rem;
	font-weight: 700;
	line-height: 1.3;
	color: var(--ly-color-primary, #53225e);
}

/* Short-description excerpt (Wc_Filters::loop_short_description) — muted,
   clamped to two lines, sits between title and price. */
body.woocommerce ul.products li.product .ly-loop-excerpt {
	font-size: 0.85rem;
	line-height: 1.45;
	font-weight: 400;
	color: var(--ly-color-text-muted, #6b6b73);
	display: -webkit-box;
	-webkit-line-clamp: 1;
	line-clamp: 1;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* Price — primary-color, slightly lighter weight. */
body.woocommerce ul.products li.product .price {
	margin: 0;
	padding: 0;
	font-size: 1rem;
	font-weight: 500;
	color: var(--ly-color-primary, #53225e);
}

body.woocommerce ul.products li.product .price .woocommerce-Price-amount,
body.woocommerce ul.products li.product .price bdi {
	color: inherit;
	font: inherit;
}

/* Sale-price comparison: muted strikethrough + primary "new" price. */
body.woocommerce ul.products li.product .price del .woocommerce-Price-amount {
	color: var(--ly-color-text-muted, #4a4a52);
	font-weight: 400;
	font-size: 0.85em;
	text-decoration: line-through;
}

body.woocommerce ul.products li.product .price ins {
	text-decoration: none;
	color: var(--ly-color-primary, #53225e);
}

/* Hide elements not in the design: star rating, sale ribbon. */
body.woocommerce ul.products li.product .star-rating,
body.woocommerce ul.products li.product .onsale {
	display: none !important;
}

/* Add to cart — full-width plum pill at the bottom of the card. WC outputs
   the button as a sibling of the LoopProduct-link <a> for both simple
   (ajax_add_to_cart) and variable (Select options → linkback) cases. */
body.woocommerce ul.products li.product .button.add_to_cart_button,
body.woocommerce ul.products li.product a.button.product_type_simple,
body.woocommerce ul.products li.product a.button.product_type_variable,
body.woocommerce ul.products li.product a.button.product_type_grouped,
body.woocommerce ul.products li.product a.button.product_type_external {
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	width: 100% !important;
	box-sizing: border-box !important;
	margin: 16px 0 0 !important;
	padding: 16px 24px !important;
	border: none !important;
	border-radius: 999px !important;
	background: var(--ly-color-primary, #53225e) !important;
	background-color: var(--ly-color-primary, #53225e) !important;
	color: #ffffff !important;
	font-size: 1rem !important;
	font-weight: 600 !important;
	line-height: 1.2 !important;
	letter-spacing: 0.01em !important;
	text-decoration: none !important;
	text-transform: none !important;
	cursor: pointer !important;
	box-shadow: none !important;
	transition: background-color 150ms ease, transform 150ms ease !important;
}

body.woocommerce ul.products li.product .button.add_to_cart_button:hover,
body.woocommerce ul.products li.product a.button.product_type_simple:hover,
body.woocommerce ul.products li.product a.button.product_type_variable:hover,
body.woocommerce ul.products li.product a.button.product_type_grouped:hover,
body.woocommerce ul.products li.product a.button.product_type_external:hover {
	background: var(--ly-color-primary-dark, #3d1846) !important;
	background-color: var(--ly-color-primary-dark, #3d1846) !important;
	color: #ffffff !important;
	transform: translateY( -1px );
}

/* "Added to cart" confirmation link WC drops after AJAX add — small,
   left-aligned underneath the button. */
body.woocommerce ul.products li.product .added_to_cart {
	display: inline-block !important;
	margin: 8px 0 0 !important;
	padding: 0 !important;
	background: transparent !important;
	color: var(--ly-color-primary, #53225e) !important;
	font-size: 0.85rem !important;
	text-decoration: underline !important;
}

/* AJAX loading state — WC adds .loading on the button during the request. */
body.woocommerce ul.products li.product .button.add_to_cart_button.loading {
	opacity: 0.7 !important;
	pointer-events: none !important;
}

/* Tighter grid spacing between cards. */
body.woocommerce ul.products {
	gap: 32px 24px;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* =============================================================================
   Toolbar — Filter pill (left), Sort by pill (right), product count
   =============================================================================
   Filter pill ships via [layali_filter_button] shortcode. Sort pill is WC's
   default <select.orderby> restyled in place (Pro Elements' "WC Catalog
   Ordering" widget renders that markup). Product count via
   [layali_product_count].
   ============================================================================= */

.ly-filter-btn {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 14px 26px;
	border: 1.5px solid var(--ly-color-primary, #53225e);
	border-radius: 999px;
	background: var(--ly-color-primary, #53225e);
	color: #ffffff;
	font-family: inherit;
	font-size: 0.95rem;
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: 0.01em;
	cursor: pointer;
	text-decoration: none;
	box-shadow: none;
	transition: background-color 150ms ease, transform 150ms ease;
}

.ly-filter-btn:hover,
.ly-filter-btn:focus-visible {
	background: var(--ly-color-primary-dark, #3d1846);
	border-color: var(--ly-color-primary-dark, #3d1846);
	color: #ffffff;
	transform: translateY( -1px );
	outline: none;
}

.ly-product-count {
	margin-top: 10px;
	font-size: 0.9rem;
	color: var(--ly-color-text, #1f1f23);
}

/* Sort by — restyle WC's catalog-ordering <select> to match the outlined
   pill design. Native arrow is suppressed via `appearance: none`; an inline
   SVG (3 stacked lines, decreasing length) is rendered as the background. */
.woocommerce-ordering,
.woocommerce-ordering form {
	margin: 0;
	display: inline-block;
}

.woocommerce-ordering select,
.woocommerce-ordering select.orderby,
select.orderby {
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	display: inline-flex;
	align-items: center;
	height: auto;
	padding: 14px 50px 14px 26px;
	border: 1.5px solid var(--ly-color-primary, #53225e);
	border-radius: 999px;
	background-color: transparent;
	color: var(--ly-color-primary, #53225e);
	font-family: inherit;
	font-size: 0.95rem;
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: 0.01em;
	cursor: pointer;
	box-shadow: none;
	background-image: url( "data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2353225e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='3' y1='6' x2='21' y2='6'/%3E%3Cline x1='6' y1='12' x2='18' y2='12'/%3E%3Cline x1='10' y1='18' x2='14' y2='18'/%3E%3C/svg%3E" );
	background-repeat: no-repeat;
	background-position: right 22px center;
	background-size: 16px 16px;
	transition: border-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.woocommerce-ordering select:hover,
.woocommerce-ordering select:focus,
.woocommerce-ordering select.orderby:hover,
.woocommerce-ordering select.orderby:focus,
select.orderby:hover,
select.orderby:focus {
	border-color: var(--ly-color-primary-dark, #3d1846);
	color: var(--ly-color-primary-dark, #3d1846);
	transform: translateY( -1px );
	outline: none;
}

@media ( max-width: 600px ) {
	.ly-filter-btn,
	.woocommerce-ordering select,
	select.orderby {
		padding: 12px 22px;
	}
	select.orderby {
		padding-right: 44px;
	}
}

@media ( max-width: 600px ) {
	body.woocommerce ul.products li.product img.wp-post-image,
	body.woocommerce ul.products li.product img.attachment-woocommerce_thumbnail {
		border-radius: 14px;
	}
	body.woocommerce ul.products li.product .woocommerce-loop-product__title {
		font-size: 0.95rem;
	}
}

/* =============================================================================
   Pagination — branded circular buttons
   --------------------------------------------------------------------------
   Overrides Elementor's WC Archive Products default boxes. WooCommerce outputs
   <ul.page-numbers> with <a|span.page-numbers> children (.current = active,
   .dots = ellipsis, .prev/.next = arrows). !important is needed to beat
   Elementor's per-element `elementor-show-pagination-border-yes` styling.
   ============================================================================= */

.woocommerce-pagination ul,
.woocommerce-pagination ul.page-numbers {
	display: flex !important;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	gap: 14px;
	margin: 40px 0 8px;
	padding: 0;
	border: 0 !important;
	list-style: none;
}

.woocommerce-pagination ul li,
.woocommerce-pagination ul.page-numbers li {
	display: inline-flex;
	margin: 0;
	border: 0 !important;
	overflow: visible;
}

/* The circle (covers links and the current/dots spans). The flex-centering and
   box metrics carry !important: Elementor's pagination CSS sets the link to
   `display:block` (numbers then sit at the top, not centered) and can impose its
   own width/height — so all of these must win, like the border rules below. */
.woocommerce-pagination li .page-numbers {
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	box-sizing: border-box !important;
	min-width: 52px !important;
	width: 52px !important;
	height: 52px !important;
	padding: 0 !important;
	border-radius: 999px !important;
	border: 1.5px solid var( --ly-color-primary, #53225e ) !important;
	background: transparent;
	color: var( --ly-color-primary, #53225e );
	font-family: var( --ly-text-body, 'DM Sans', sans-serif );
	font-weight: 600;
	font-size: 17px;
	line-height: 1;
	text-decoration: none;
	transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.woocommerce-pagination li a.page-numbers:hover {
	background: var( --ly-color-primary, #53225e );
	color: #ffffff;
	transform: translateY( -1px );
}

.woocommerce-pagination li a.page-numbers:focus-visible {
	outline: 2px solid var( --ly-color-focus-ring, #ff7477 );
	outline-offset: 2px;
}

/* Active page — solid plum fill. */
.woocommerce-pagination li .page-numbers.current {
	background: var( --ly-color-primary, #53225e ) !important;
	color: #ffffff !important;
	border-color: var( --ly-color-primary, #53225e ) !important;
}

/* Ellipsis circle (not a link). */
.woocommerce-pagination li .page-numbers.dots {
	color: var( --ly-color-primary, #53225e );
	letter-spacing: 1px;
}

/* Prev / next as thin chevrons (hide the native arrow glyph / icon child). */
.woocommerce-pagination li .page-numbers.prev,
.woocommerce-pagination li .page-numbers.next {
	font-size: 0;
}
.woocommerce-pagination li .page-numbers.prev > *,
.woocommerce-pagination li .page-numbers.next > * {
	display: none;
}
.woocommerce-pagination li .page-numbers.prev::before {
	content: "\2039"; /* ‹ */
	font-size: 26px;
	line-height: 1;
}
.woocommerce-pagination li .page-numbers.next::before {
	content: "\203A"; /* › */
	font-size: 26px;
	line-height: 1;
}

/* Disabled end-arrow when rendered as a non-link span. */
.woocommerce-pagination li span.page-numbers.prev,
.woocommerce-pagination li span.page-numbers.next,
.woocommerce-pagination li .page-numbers.disabled {
	border-color: var( --ly-color-border, #e6e6e8 ) !important;
	color: var( --ly-color-text-muted, #b8b8bd );
	cursor: default;
}

@media ( max-width: 600px ) {
	.woocommerce-pagination ul,
	.woocommerce-pagination ul.page-numbers {
		gap: 10px;
	}
	.woocommerce-pagination li .page-numbers {
		min-width: 44px;
		width: 44px;
		height: 44px;
		font-size: 15px;
	}
}

/* =============================================================================
   Branded sort dropdown (archive-sort.js)
   --------------------------------------------------------------------------
   Replaces the native <select.orderby> UI (which opens the OS dropdown) with a
   styled button + menu. JS adds .ly-sort-on to the form and hides the select,
   keeping it in the DOM so the GET form still submits ?orderby=.
   ============================================================================= */

.woocommerce-ordering.ly-sort-on select.orderby {
	display: none !important;
}

.ly-sort {
	position: relative;
	display: inline-block;
	text-align: left;
}

.ly-sort__btn {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 14px 22px;
	border: 1.5px solid var( --ly-color-primary, #53225e );
	border-radius: 999px;
	background: transparent;
	color: var( --ly-color-primary, #53225e );
	font-family: inherit;
	font-size: 0.95rem;
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: 0.01em;
	cursor: pointer;
	transition: border-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.ly-sort__btn:hover {
	border-color: var( --ly-color-primary-dark, #3d1846 );
	color: var( --ly-color-primary-dark, #3d1846 );
	transform: translateY( -1px );
}

.ly-sort__icon {
	flex: 0 0 auto;
}

.ly-sort__menu {
	position: absolute;
	right: 0;
	top: calc( 100% + 10px );
	min-width: 248px;
	max-width: 80vw;
	background: #ffffff;
	border: 1px solid var( --ly-color-border, #ece6e0 );
	border-radius: 18px;
	box-shadow: var( --ly-shadow-md, 0 18px 40px rgba( 40, 20, 40, 0.14 ) );
	padding: 8px;
	z-index: 60;
	display: none;
}

.ly-sort.is-open .ly-sort__menu {
	display: block;
}

.ly-sort__option {
	display: block;
	width: 100%;
	box-sizing: border-box;
	padding: 13px 16px;
	border: none;
	background: transparent;
	border-radius: 12px;
	font-family: inherit;
	font-size: 0.95rem;
	font-weight: 500;
	line-height: 1.3;
	color: var( --ly-color-text, #3d1d46 );
	text-align: left;
	cursor: pointer;
	transition: background-color 120ms ease, color 120ms ease;
}

.ly-sort__option:hover {
	background: var( --ly-color-surface, #fbf5ef );
}

.ly-sort__option[aria-selected="true"] {
	background: var( --ly-color-surface, #fbf5ef );
	color: var( --ly-color-primary, #53225e );
	font-weight: 700;
}
