/*
 * Loaded only on WooCommerce views (see Sorvex\Core\Assets::woocommerce_context_active()) —
 * never enqueued on a page that doesn't need it, per docs/ARCHITECTURE.md §16.
 */

/* Product grid / cards ------------------------------------------------------ */

.woocommerce ul.products {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 1.75rem;
	list-style: none;
	padding: 0;
	margin: 0 0 2rem;
}

.sorvex-product-grid__heading {
	margin-bottom: 1.5rem;
}

/*
 * Homepage product-grid sections (New Arrivals, Hot Deals) set an explicit `columns` prop meant to
 * form one clean row, e.g. 6 across — but the generic `.woocommerce ul.products` rule above is
 * auto-fill, which only coincidentally lines up with that count at any given viewport width.
 * Scoped to `.sorvex-product-grid` (this component's own wrapper) so the shop archive, related
 * products, and cross-sells keep their own organic auto-fill layout untouched.
 */
.sorvex-product-grid ul.products.columns-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sorvex-product-grid ul.products.columns-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sorvex-product-grid ul.products.columns-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.sorvex-product-grid ul.products.columns-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.sorvex-product-grid ul.products.columns-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

@media (max-width: 1024px) {
	.sorvex-product-grid ul.products.columns-5,
	.sorvex-product-grid ul.products.columns-6 {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (max-width: 600px) {
	.sorvex-product-grid ul.products[class*="columns-"] {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

.woocommerce ul.products li.product {
	position: relative;
	display: flex;
	flex-direction: column;
	background: var(--sorvex-color-background, #fff);
	border: 1px solid var(--sorvex-color-border, #e2e4e9);
	border-radius: 12px;
	padding: 0;
	overflow: hidden;
	transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.woocommerce ul.products li.product:hover {
	box-shadow: 0 10px 28px rgba(20, 33, 61, 0.1);
	transform: translateY(-3px);
	border-color: var(--sorvex-color-border, #e2e4e9);
}

.woocommerce ul.products li.product a.woocommerce-LoopProduct-link {
	display: flex;
	flex-direction: column;
	flex: 1;
	padding: 0 0 1.25rem;
	color: inherit;
	text-decoration: none;
}

.woocommerce ul.products li.product img {
	aspect-ratio: 1 / 1;
	object-fit: contain;
	background: var(--sorvex-color-surface, #f6f7fa);
	padding: 1.25rem;
	width: 100%;
}

.woocommerce ul.products li.product .woocommerce-loop-product__title {
	font-family: var(--sorvex-font-body-family);
	font-size: 0.95rem;
	font-weight: 600;
	color: var(--sorvex-color-heading, #14213d);
	margin: 0.9rem 1.1rem 0.4rem;
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.woocommerce ul.products li.product .price {
	margin: 0 1.1rem;
	font-size: 1.05rem;
}

.woocommerce ul.products li.product a.button,
.woocommerce ul.products li.product a.add_to_cart_button {
	margin: 0.9rem 1.1rem 0;
	align-self: flex-start;
}

.woocommerce span.onsale {
	position: absolute;
	top: 0.75rem;
	left: 0.75rem;
	z-index: 1;
	background: var(--sorvex-color-accent, #f15a24);
	color: #fff;
	border-radius: 999px;
	min-width: 0;
	padding: 0.25em 0.75em;
	font-size: 0.75em;
	font-weight: 700;
	line-height: 1.6;
}

.woocommerce ul.products li.product.outofstock {
	opacity: 0.7;
}

/*
 * The explicit "Out of stock" badge (below) is what actually communicates unavailability — this
 * opacity is a secondary visual cue, not the only one, so it can afford to be a bit lighter.
 * Raised from 0.6: combined with .price del's own 0.55 opacity (a separate, independent
 * de-emphasis for "was" prices), an out-of-stock item that's *also* on sale compounded to ~0.33
 * effective opacity — a real Lighthouse contrast failure (1.93:1), not just a visual nicety.
 */

.woocommerce ul.products li.product.outofstock::after {
	content: "Out of stock";
	position: absolute;
	top: 0.75rem;
	right: 0.75rem;
	background: var(--sorvex-color-text, #2b2f38);
	color: #fff;
	font-size: 0.7em;
	font-weight: 700;
	padding: 0.25em 0.65em;
	border-radius: 999px;
}

/* Price ---------------------------------------------------------------------- */

.woocommerce div.product p.price,
.woocommerce ul.products li.product .price {
	color: var(--sorvex-color-accent, #f15a24);
	font-weight: 700;
}

.woocommerce .price del {
	color: var(--sorvex-color-text, #2b2f38);
	opacity: 0.7;
	font-weight: 400;
	margin-right: 0.5em;
}

/*
 * Inside an out-of-stock card the whole li is already dimmed to 0.7 opacity (above) — without
 * this, the del's own 0.7 would multiply on top of that (0.7*0.7 = 0.49 effective), bringing back
 * the same compounding-opacity contrast failure this was meant to fix.
 */
.woocommerce ul.products li.product.outofstock .price del {
	opacity: 1;
}

.woocommerce .price ins {
	text-decoration: none;
}

.woocommerce .star-rating { color: var(--sorvex-color-accent, #f15a24); }

/* Buttons / add-to-cart -------------------------------------------------------- */

.woocommerce a.button,
.woocommerce button.button,
.woocommerce .added_to_cart,
.woocommerce #respond input#submit,
.woocommerce input.button,
.woocommerce #place_order {
	display: inline-block;
	background: var(--sorvex-color-accent, #f15a24);
	color: #fff;
	border: 0;
	border-radius: 8px;
	padding: 0.7em 1.4em;
	font-weight: 600;
	font-size: 0.92rem;
	cursor: pointer;
	text-decoration: none;
	transition: background-color 0.15s ease, transform 0.1s ease;
}

.woocommerce a.button:hover,
.woocommerce button.button:hover,
.woocommerce input.button:hover,
.woocommerce #place_order:hover {
	background: #d64a16;
	color: #fff;
}

.woocommerce a.button.loading,
.woocommerce button.button.loading {
	opacity: 0.6;
}

/* Notices ---------------------------------------------------------------------- */

.woocommerce-message,
.woocommerce-info,
.woocommerce-error {
	border-left: 4px solid var(--sorvex-color-secondary, #1c75e5);
	background: var(--sorvex-color-surface, #f6f7fa);
	padding: 1em 1.5em;
	border-radius: 4px;
	list-style: none;
}

.woocommerce-error { border-left-color: var(--sorvex-color-accent, #f15a24); }

/* Header cart -------------------------------------------------------------------- */

.sorvex-header__cart { display: inline-flex; align-items: center; gap: 0.35rem; }
.sorvex-cart-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.4em;
	height: 1.4em;
	border-radius: 50%;
	background: var(--sorvex-color-accent, #f15a24);
	color: #fff;
	font-size: 0.75em;
	font-weight: 700;
}

/* Breadcrumbs on shop/product pages ---------------------------------------------- */

.woocommerce-breadcrumb {
	font-size: 0.9em;
	opacity: 0.75;
	margin-bottom: 1.5rem;
}
.woocommerce-breadcrumb a { color: inherit; }

/* Single product ------------------------------------------------------------------ */

.woocommerce div.product {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	gap: 3rem;
	align-items: start;
}

@media (max-width: 880px) {
	.woocommerce div.product {
		grid-template-columns: minmax(0, 1fr);
		gap: 1.5rem;
	}
}

.woocommerce div.product div.images {
	position: sticky;
	top: calc(var(--sorvex-header-height, 80px) + 1rem);
}

/*
 * WooCommerce's flexslider gallery positions every slide side by side on a wrapper it sets to
 * N*100% wide, then slides between them with a translate3d() transform — it has never shipped
 * the overflow:hidden needed to clip that wide strip down to one visible slide; themes are
 * expected to supply it (a well-known WC theme-integration requirement). We disable WooCommerce's
 * own stylesheet entirely (woocommerce_enqueue_styles => __return_empty_array, see
 * inc/WooCommerce.php) to avoid the unrelated bloat it ships with, which means this rule has to
 * live here instead of coming along for free.
 */
.woocommerce-product-gallery {
	position: relative;
	overflow: hidden;
}
.woocommerce-product-gallery .flex-viewport {
	overflow: hidden;
}
/*
 * The wrapper's slides are floated (inline style from flexslider JS: float:left), and a container
 * with only floated children collapses to zero height unless it establishes its own block
 * formatting context — without this, .flex-viewport (and everything above it) collapses to 0px
 * tall even though each slide image inside is a real, visible 327px-ish square.
 */
.woocommerce-product-gallery__wrapper {
	overflow: hidden;
}

.woocommerce div.product div.images img {
	border-radius: 12px;
	background: var(--sorvex-color-surface, #f6f7fa);
	aspect-ratio: 1 / 1;
	object-fit: contain;
}

.woocommerce div.product .flex-control-thumbs {
	display: flex;
	gap: 0.75rem;
	list-style: none;
	padding: 0;
	margin-top: 0.75rem;
}
.woocommerce div.product .flex-control-thumbs li { width: 64px; }
.woocommerce div.product .flex-control-thumbs img {
	border-radius: 8px;
	border: 2px solid transparent;
	cursor: pointer;
	aspect-ratio: 1 / 1;
	object-fit: contain;
	background: var(--sorvex-color-surface, #f6f7fa);
}
.woocommerce div.product .flex-control-thumbs img.flex-active { border-color: var(--sorvex-color-accent, #f15a24); }

.woocommerce div.product .summary {
	padding-block: 0.25rem;
}

.woocommerce div.product .summary h1.product_title {
	margin-top: 0;
}

.woocommerce div.product .summary p.price {
	font-size: 1.6rem;
	margin: 0.75rem 0 1.25rem;
}

.woocommerce div.product .woocommerce-product-rating {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin-bottom: 1rem;
}

.woocommerce div.product form.cart {
	display: flex;
	align-items: center;
	gap: 1rem;
	margin: 1.5rem 0;
	flex-wrap: wrap;
}

.woocommerce div.product .quantity input.qty {
	width: 4.5rem;
	text-align: center;
}

.woocommerce div.product .woocommerce-variation-add-to-cart,
.woocommerce div.product form.cart .button {
	font-size: 1rem;
	padding: 0.85em 2em;
}

.woocommerce div.product .product_meta {
	margin-top: 1.5rem;
	padding-top: 1.25rem;
	border-top: 1px solid var(--sorvex-color-border, #e2e4e9);
	font-size: 0.9em;
	opacity: 0.85;
}

.woocommerce div.product .woocommerce-tabs {
	margin-top: 3rem;
	grid-column: 1 / -1;
}

.woocommerce div.product .woocommerce-tabs ul.tabs {
	display: flex;
	gap: 0.5rem;
	list-style: none;
	padding: 0;
	border-bottom: 1px solid var(--sorvex-color-border, #e2e4e9);
	margin-bottom: 1.5rem;
}
.woocommerce div.product .woocommerce-tabs ul.tabs li { margin: 0; }
.woocommerce div.product .woocommerce-tabs ul.tabs li a {
	display: inline-block;
	padding: 0.75em 1.25em;
	font-weight: 600;
	color: var(--sorvex-color-text, #2b2f38);
	text-decoration: none;
}
.woocommerce div.product .woocommerce-tabs ul.tabs li.active a {
	color: var(--sorvex-color-accent, #f15a24);
	border-bottom: 2px solid var(--sorvex-color-accent, #f15a24);
}

.woocommerce div.product .woocommerce-tabs table.shop_attributes {
	width: 100%;
	border-collapse: collapse;
}
.woocommerce div.product .woocommerce-tabs table.shop_attributes th,
.woocommerce div.product .woocommerce-tabs table.shop_attributes td {
	padding: 0.65em 1em;
	border: 1px solid var(--sorvex-color-border, #e2e4e9);
	text-align: left;
}
.woocommerce div.product .woocommerce-tabs table.shop_attributes tr:nth-child(odd) {
	background: var(--sorvex-color-surface, #f6f7fa);
}

/*
 * Product descriptions sometimes paste in their own spec table (e.g. "table table-striped",
 * imported along with the product copy) with more columns than a phone screen can fit. We can't
 * control that markup's width, so instead of letting a wide table blow out the whole page
 * horizontally, contain the overflow to the tab panel itself with its own scrollbar.
 */
.woocommerce div.product .woocommerce-Tabs-panel {
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

/* Related products --------------------------------------------------------------- */

.woocommerce div.product .related.products {
	grid-column: 1 / -1;
	margin-top: 3rem;
}

/* Cart ----------------------------------------------------------------------------- */

.woocommerce table.shop_table {
	width: 100%;
	border-collapse: collapse;
	margin-bottom: 2rem;
}
.woocommerce table.shop_table th,
.woocommerce table.shop_table td {
	padding: 1em;
	border-bottom: 1px solid var(--sorvex-color-border, #e2e4e9);
	text-align: left;
	vertical-align: middle;
}
.woocommerce table.shop_table thead th {
	font-family: var(--sorvex-font-heading-family);
	font-weight: 700;
	color: var(--sorvex-color-heading, #14213d);
}
.woocommerce table.shop_table img {
	width: 64px;
	border-radius: 8px;
	background: var(--sorvex-color-surface, #f6f7fa);
}

.woocommerce .cart-collaterals .cart_totals {
	background: var(--sorvex-color-surface, #f6f7fa);
	border-radius: 12px;
	padding: 1.5rem;
}
.woocommerce .cart-collaterals .cart_totals table { width: 100%; }
.woocommerce .cart-collaterals .cart_totals tr td,
.woocommerce .cart-collaterals .cart_totals tr th {
	border-bottom: 1px solid var(--sorvex-color-border, #e2e4e9);
	padding: 0.75em 0;
}
.woocommerce .cart-collaterals .cart_totals .order-total .woocommerce-Price-amount {
	font-size: 1.2rem;
	font-weight: 700;
	color: var(--sorvex-color-accent, #f15a24);
}

.woocommerce-cart-form .quantity input.qty { width: 4rem; }

/*
 * table.shop_table carries WooCommerce's own "shop_table_responsive" class, which implies a
 * mobile stacked layout — but that behavior lives in WooCommerce's own disabled stylesheet
 * (woocommerce_enqueue_styles => __return_empty_array), so without this the cart table just
 * renders at full width (6 columns: remove/thumbnail/name/price/quantity/subtotal) and overflows
 * a phone screen. Below 782px each row becomes its own block and each cell becomes a labeled
 * line instead of a table column.
 */
@media (max-width: 782px) {
	.woocommerce table.shop_table.shop_table_responsive thead { display: none; }
	.woocommerce table.shop_table.shop_table_responsive,
	.woocommerce table.shop_table.shop_table_responsive tbody,
	.woocommerce table.shop_table.shop_table_responsive tr,
	.woocommerce table.shop_table.shop_table_responsive td {
		display: block;
		width: 100%;
	}
	.woocommerce table.shop_table.shop_table_responsive tr {
		border: 1px solid var(--sorvex-color-border, #e2e4e9);
		border-radius: 12px;
		padding: 1rem;
		margin-bottom: 1rem;
	}
	.woocommerce table.shop_table.shop_table_responsive td {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 1rem;
		padding: 0.5em 0;
		border-bottom: 0;
		text-align: right;
	}
	.woocommerce table.shop_table.shop_table_responsive td.product-thumbnail {
		justify-content: center;
	}
	.woocommerce table.shop_table.shop_table_responsive td.product-name,
	.woocommerce table.shop_table.shop_table_responsive td.product-price,
	.woocommerce table.shop_table.shop_table_responsive td.product-quantity,
	.woocommerce table.shop_table.shop_table_responsive td.product-subtotal {
		border-top: 1px solid var(--sorvex-color-border, #e2e4e9);
	}
	.woocommerce table.shop_table.shop_table_responsive td.product-name::before,
	.woocommerce table.shop_table.shop_table_responsive td.product-price::before,
	.woocommerce table.shop_table.shop_table_responsive td.product-quantity::before,
	.woocommerce table.shop_table.shop_table_responsive td.product-subtotal::before {
		font-weight: 600;
		color: var(--sorvex-color-heading, #14213d);
		text-align: left;
	}
	.woocommerce table.shop_table.shop_table_responsive td.product-name::before { content: "Product"; }
	.woocommerce table.shop_table.shop_table_responsive td.product-price::before { content: "Price"; }
	.woocommerce table.shop_table.shop_table_responsive td.product-quantity::before { content: "Quantity"; }
	.woocommerce table.shop_table.shop_table_responsive td.product-subtotal::before { content: "Subtotal"; }
	.woocommerce table.shop_table.shop_table_responsive td.product-name {
		justify-content: flex-start;
		text-align: left;
	}
}

/* Checkout --------------------------------------------------------------------------- */

.woocommerce-checkout .col2-set,
.woocommerce-checkout form.checkout {
	display: grid;
	grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
	gap: 3rem;
	align-items: start;
}

@media (max-width: 880px) {
	.woocommerce-checkout .col2-set,
	.woocommerce-checkout form.checkout {
		grid-template-columns: minmax(0, 1fr);
	}
}

#order_review,
.woocommerce-checkout-review-order {
	background: var(--sorvex-color-surface, #f6f7fa);
	border-radius: 12px;
	padding: 1.5rem;
}

.woocommerce-checkout .form-row label {
	display: block;
	margin-bottom: 0.3rem;
	font-weight: 500;
	font-size: 0.9em;
}

.woocommerce-checkout .form-row {
	margin-bottom: 1rem;
}

.woocommerce-checkout #payment {
	background: var(--sorvex-color-surface, #f6f7fa);
	border-radius: 12px;
	padding: 1.25rem;
	margin-top: 1.5rem;
}

.woocommerce-checkout #payment ul.payment_methods {
	list-style: none;
	padding: 0;
}

/* My account ------------------------------------------------------------------------- */

.woocommerce-account .woocommerce-MyAccount-navigation ul {
	list-style: none;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}
.woocommerce-account .woocommerce-MyAccount-navigation a {
	display: block;
	padding: 0.6em 1em;
	border-radius: 8px;
	color: var(--sorvex-color-text, #2b2f38);
	text-decoration: none;
}
.woocommerce-account .woocommerce-MyAccount-navigation li.is-active a {
	background: var(--sorvex-color-surface, #f6f7fa);
	color: var(--sorvex-color-accent, #f15a24);
	font-weight: 600;
}

/*
 * WooCommerce's own (disabled) stylesheet puts the account nav and content side by side on wider
 * screens (nav 30%, content 68%, floated) — without it both just stack full-width on every screen
 * size, which is fine on a phone but wastes the whole page on desktop. Using floats for this
 * (like WC's original) risks the same float-collapse footgun hit elsewhere in this file (a
 * container with only floated children collapses to 0 height without a clearfix) — grid on the
 * shared parent sidesteps that entirely. 782px matches the breakpoint the rest of this file
 * already treats as "mobile".
 */
@media (min-width: 783px) {
	.woocommerce-account .woocommerce {
		display: grid;
		grid-template-columns: 220px minmax(0, 1fr);
		gap: 2.5rem;
		align-items: start;
	}
}

/* Category FAQ (AEO) ----------------------------------------------------------------------------- */

.sorvex-category-faq {
	margin-top: 3rem;
	max-width: 48rem;
}

.sorvex-category-faq__item {
	border-bottom: 1px solid var(--sorvex-color-border, #e2e4e9);
	padding-block: 1rem;
}

.sorvex-category-faq__item summary {
	cursor: pointer;
	font-weight: 600;
	color: var(--sorvex-color-heading, #14213d);
	list-style: none;
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 1rem;
}

.sorvex-category-faq__item summary::-webkit-details-marker {
	display: none;
}

/*
 * The "+"/"−" marker used to be `float: right`, which only reliably sits at the end of the text
 * when the question happens to wrap onto a second line — for a short, single-line question the
 * float has nowhere to tuck in next to and drops to a line of its own instead. `summary` is now a
 * flex row (text + this pseudo-element as its second item), so the marker pins to the right edge
 * regardless of how many lines the question takes.
 */
.sorvex-category-faq__item summary::after {
	content: '+';
	flex-shrink: 0;
	color: var(--sorvex-color-accent, #f15a24);
	font-weight: 700;
}

.sorvex-category-faq__item[open] summary::after {
	content: '\2212';
}

.sorvex-category-faq__item p {
	margin: 0.75rem 0 0;
	opacity: 0.85;
}
