/* ==========================================================================
   WOOCOMMERCE — shop archive, single product, cart, checkout

   Storefront lays these pages out with floats and hardcoded percentage
   widths. Everything here replaces that with grid/flex, then restyles the
   pieces to match the rest of the site.

   Note on specificity: Storefront's rules are mostly element+class at (0,2,0)
   or higher, and its customizer CSS is INLINE in <head>, so it lands after
   this file. Selectors here are deliberately scoped through `.nx-woo` (and
   occasionally doubled) to win without a wall of !important.
   ========================================================================== */

/* ---- Shared page shell --------------------------------------------------- */

.nx-woo {
	--nx-woo-gap: clamp(2rem, 1.2rem + 3vw, 4.5rem);
}

/* Storefront floats the two single-product columns and the tab rail. Kill all
   of it in one place so the grids below actually apply. The gallery itself
   (.nx-product-gallery) is the theme's own static markup — no FlexSlider,
   nothing sets an inline width on it — so it only needs the same float reset
   as everything else here. */
.single-product .nx-woo div.product .nx-product-gallery,
.single-product .nx-woo div.product .images,
.single-product .nx-woo div.product .summary,
.nx-woo .woocommerce-tabs,
.nx-woo .woocommerce-tabs ul.tabs,
.nx-woo .woocommerce-tabs .panel,
.nx-woo ul.products li.product {
	float: none;
	width: 100%;
	margin-right: 0;
	clear: none;
}

/* Slider internals must not inherit that 100% — FlexSlider owns their widths. */
/* ---- Page header --------------------------------------------------------- */

.nx-woo .woocommerce-products-header {
	margin-bottom: var(--nx-space-7);
	padding-bottom: var(--nx-space-6);
	border-bottom: 1px solid var(--nx-border);
}

.nx-woo .woocommerce-products-header__title,
.nx-woo .product_title {
	margin: 0;
	font-size: clamp(1.625rem, 1.25rem + 1.5vw, 2.375rem);
	line-height: 1.14;
	letter-spacing: -0.022em;
	color: var(--nx-primary);
}

/* Breadcrumb reads as a utility trail, not body copy. */
.nx-woo .woocommerce-breadcrumb {
	margin: 0 0 var(--nx-space-6);
	color: var(--nx-text-subtle);
	font-size: var(--nx-text-xs);
	letter-spacing: var(--nx-tracking-wide);
	text-transform: uppercase;
}

.nx-woo .woocommerce-breadcrumb a { color: var(--nx-text-muted); text-decoration: none; }
.nx-woo .woocommerce-breadcrumb a:hover { color: var(--nx-action); }

/* ---- Result count + sorting --------------------------------------------- */

.nx-woo .woocommerce-result-count,
.nx-woo .woocommerce-ordering {
	margin-bottom: var(--nx-space-6);
	font-size: var(--nx-text-sm);
	color: var(--nx-text-muted);
}

.nx-woo .woocommerce-ordering select,
.nx-woo select.orderby {
	min-height: 44px;
	padding: 0.5rem 2rem 0.5rem 0.875rem;
	border: 1px solid var(--nx-border-strong);
	border-radius: var(--nx-radius);
	background-color: var(--nx-surface);
	color: var(--nx-text);
	font-family: inherit;
	font-size: var(--nx-text-sm);
}

/* Storefront wraps the count + sort control in .storefront-sorting and prints
   it twice, once above the loop and again below. Keep the top one. */
.nx-woo ul.products ~ .storefront-sorting { display: none; }

.nx-woo .storefront-sorting {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--nx-space-4);
	margin-bottom: var(--nx-space-6);
}

.nx-woo .storefront-sorting .woocommerce-result-count,
.nx-woo .storefront-sorting .woocommerce-ordering { margin: 0; float: none; }

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

.nx-woo ul.products {
	display: grid;
	gap: var(--nx-space-6);
	/* auto-fill would leave a lone product hugging the left edge of an
	   otherwise empty three-column row. auto-fit collapses the empty tracks,
	   and the max-width caps how wide a single card can then stretch. */
	grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
	margin: 0;
	padding: 0;
	list-style: none;
}

/* One or two products: keep the cards a sane size rather than full-bleed. */
.nx-woo ul.products:has(> li.product:only-child) { max-width: 420px; }

.nx-woo ul.products:has(> li.product:nth-child(2):last-child) { max-width: 860px; }

.nx-woo ul.products::before,
.nx-woo ul.products::after { content: none; display: none; }

.nx-woo ul.products li.product {
	position: relative;
	display: flex;
	flex-direction: column;
	margin: 0;
	padding: 0;
	background: var(--nx-surface);
	border: 1px solid var(--nx-border);
	border-radius: var(--nx-radius-lg);
	overflow: hidden;
	text-align: left;
	transition:
		transform var(--nx-dur) var(--nx-ease),
		box-shadow var(--nx-dur) var(--nx-ease),
		border-color var(--nx-dur) var(--nx-ease);
}

.nx-woo ul.products li.product:hover {
	transform: translateY(-4px);
	border-color: var(--nx-border-strong);
	box-shadow: var(--nx-shadow);
}

/* Image sits on a tinted panel so a transparent product PNG has a surface. */
.nx-woo ul.products li.product > a img,
.nx-woo ul.products li.product img {
	width: 100%;
	aspect-ratio: 4 / 3;
	object-fit: contain;
	margin: 0;
	padding: var(--nx-space-6);
	background:
		radial-gradient(70% 70% at 50% 40%, rgba(46, 109, 196, 0.07) 0%, transparent 70%),
		var(--nx-grey-50);
	border-bottom: 1px solid var(--nx-border);
}

.nx-woo ul.products li.product .woocommerce-loop-product__title {
	margin: 0;
	padding: var(--nx-space-5) var(--nx-space-5) var(--nx-space-2);
	font-size: var(--nx-text-lg);
	font-weight: var(--nx-weight-semibold);
	line-height: 1.3;
	color: var(--nx-primary);
}

.nx-woo ul.products li.product .price {
	display: block;
	padding: 0 var(--nx-space-5);
	margin: 0 0 var(--nx-space-4);
	color: var(--nx-text);
	font-size: var(--nx-text-base);
	font-weight: var(--nx-weight-semibold);
}

/* Push the button to the card floor so uneven titles still line up. */
.nx-woo ul.products li.product .button,
.nx-woo ul.products li.product .added_to_cart {
	margin: auto var(--nx-space-5) var(--nx-space-5);
	align-self: flex-start;
}

.nx-woo ul.products li.product .star-rating { margin: 0 var(--nx-space-5) var(--nx-space-3); }

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

/* Flex, not grid: the product wrapper holds two different kinds of
   children — the gallery/summary pair that sits side by side, and the tabs +
   related-products blocks that each need to span the full width below them.
   Grid handled that by leaving them to fall into new implicit rows; flex-wrap
   does the same thing explicitly, with one line per child instead of an
   inferred row/column placement to reason about. */
.nx-woo div.product {
	display: flex;
	flex-wrap: wrap;
	gap: var(--nx-space-7) var(--nx-woo-gap);
	align-items: flex-start;
}

/* Storefront clears its floats with ::before/::after on the product wrapper —
   under flex those become empty flex items with their own implicit size, so
   kill them outright rather than let them eat layout space. */
.nx-woo div.product::before,
.nx-woo div.product::after { content: none; display: none; }

.nx-woo div.product .nx-product-gallery,
.nx-woo div.product .summary {
	flex: 1 1 100%;
}

@media (min-width: 900px) {
	.nx-woo div.product .nx-product-gallery,
	.nx-woo div.product .summary {
		/* min(...) instead of a bare 0 basis: a flex basis of 0 ignores content
		   width entirely and can let a long SKU/price line overflow before the
		   gap kicks in. */
		flex: 1 1 min(340px, 100%);
	}
}

/* Tabs and related products always take the full row on their own, at any
   width — no min-width query needed since they were never meant to sit next
   to the gallery or summary. */
.nx-woo div.product .woocommerce-tabs,
.nx-woo div.product .related.products {
	flex: 1 1 100%;
}

/* Custom gallery (woocommerce/single-product/product-image.php).
   Fully static markup, no FlexSlider/PhotoSwipe, no inline styles from
   WooCommerce's JS to fight — this is the entire gallery, top to bottom:

   .nx-product-gallery
     > .nx-product-gallery__main             (framed panel, sticky on desktop)
         > .nx-product-gallery__slide.is-active   (only the active one is display:block)
             > img.nx-product-gallery__image
     > ul.nx-product-gallery__thumbs         (row below the panel, not inside it)
         > li > button.nx-product-gallery__thumb.is-active */

.nx-woo div.product .nx-product-gallery {
	position: sticky;
	top: 1rem;
}

@media (max-width: 899px) {
	.nx-woo div.product .nx-product-gallery { position: static; }
}

.nx-woo div.product .nx-product-gallery__main {
	position: relative;
	padding: var(--nx-space-6);
	background:
		radial-gradient(70% 70% at 50% 35%, rgba(46, 109, 196, 0.08) 0%, transparent 70%),
		var(--nx-grey-50);
	border: 1px solid var(--nx-border);
	border-radius: var(--nx-radius-lg);
}

.nx-woo div.product .nx-product-gallery__slide {
	display: none;
}

.nx-woo div.product .nx-product-gallery__slide.is-active {
	display: block;
}

.nx-woo div.product .nx-product-gallery__image {
	display: block;
	width: 100%;
	height: auto;
	border-radius: var(--nx-radius);
	object-fit: contain;
	object-position: top;
}

.nx-woo div.product .nx-product-gallery__thumbs {
	display: flex;
	flex-wrap: wrap;
	gap: var(--nx-space-3);
	margin: var(--nx-space-5) 0 0;
	padding: 0;
	list-style: none;
}

.nx-woo div.product .nx-product-gallery__thumbs li {
	margin: 0;
	width: 76px;
}

.nx-woo div.product .nx-product-gallery__thumb {
	display: block;
	width: 100%;
	aspect-ratio: 1 / 1;
	padding: var(--nx-space-2);
	background: var(--nx-white);
	border: 1px solid var(--nx-border);
	border-radius: var(--nx-radius);
	cursor: pointer;
	transition: border-color var(--nx-dur-fast) var(--nx-ease);
}

.nx-woo div.product .nx-product-gallery__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.nx-woo div.product .nx-product-gallery__thumb:hover,
.nx-woo div.product .nx-product-gallery__thumb.is-active {
	border-color: var(--nx-action);
}

.nx-woo div.product .summary {
	margin: 0;
	padding: 0;
}

/* The short description carries the RUO notice — give it real presence. */
.nx-woo div.product .woocommerce-product-details__short-description {
	margin-bottom: var(--nx-space-6);
	color: var(--nx-text-muted);
	font-size: var(--nx-text-base);
	line-height: var(--nx-leading-normal);
}

.nx-woo div.product .woocommerce-product-details__short-description p:first-child {
	margin-bottom: var(--nx-space-4);
	padding: var(--nx-space-4) var(--nx-space-5);
	background: rgba(0, 163, 224, 0.07);
	border-left: 3px solid var(--nx-action);
	border-radius: 0 var(--nx-radius) var(--nx-radius) 0;
	color: var(--nx-navy-800);
	font-size: var(--nx-text-sm);
	font-weight: var(--nx-weight-semibold);
	letter-spacing: 0.01em;
}

.nx-woo div.product p.price,
.nx-woo div.product span.price {
	margin: 0 0 var(--nx-space-5);
	color: var(--nx-primary);
	font-size: var(--nx-text-2xl);
	font-weight: var(--nx-weight-bold);
}

.nx-woo div.product .product_meta {
	margin-top: var(--nx-space-6);
	padding-top: var(--nx-space-5);
	border-top: 1px solid var(--nx-border);
	font-size: var(--nx-text-sm);
	color: var(--nx-text-muted);
}

.nx-woo div.product .product_meta > span {
	display: block;
	margin-bottom: var(--nx-space-2);
}

.nx-woo div.product .product_meta .sku,
.nx-woo div.product .product_meta a { color: var(--nx-text); font-weight: var(--nx-weight-medium); }

.nx-woo div.product form.cart {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--nx-space-3);
	margin: 0 0 var(--nx-space-5);
}

/* Storefront floats the quantity box next to the button; the flex row above
   already handles that, and the float breaks its alignment. */
.single-product .nx-woo div.product form.cart .quantity {
	float: none;
	margin-right: 0;
}

/* ---- Tabs ---------------------------------------------------------------- */

.nx-woo .woocommerce-tabs {
	grid-column: 1 / -1;
	margin-top: var(--nx-space-8);
	padding-top: var(--nx-space-8);
	border-top: 1px solid var(--nx-border);
}

.nx-woo .woocommerce-tabs ul.tabs {
	display: flex;
	flex-wrap: wrap;
	gap: var(--nx-space-6);
	margin: 0 0 var(--nx-space-7);
	padding: 0;
	list-style: none;
	border-bottom: 1px solid var(--nx-border);
}

.nx-woo .woocommerce-tabs ul.tabs::before,
.nx-woo .woocommerce-tabs ul.tabs::after { content: none; display: none; border: 0; }

.nx-woo .woocommerce-tabs ul.tabs li {
	margin: 0;
	padding: 0;
	background: none;
	border: 0;
	border-radius: 0;
}

.nx-woo .woocommerce-tabs ul.tabs li::before,
.nx-woo .woocommerce-tabs ul.tabs li::after { content: none; display: none; border: 0; box-shadow: none; }

.nx-woo .woocommerce-tabs ul.tabs li a {
	display: block;
	padding: 0 0 var(--nx-space-4);
	margin-bottom: -1px;
	border-bottom: 2px solid transparent;
	color: var(--nx-text-muted);
	font-size: var(--nx-text-sm);
	font-weight: var(--nx-weight-semibold);
	letter-spacing: var(--nx-tracking-wide);
	text-transform: uppercase;
	text-decoration: none;
}

.nx-woo .woocommerce-tabs ul.tabs li a:hover { color: var(--nx-primary); }

.nx-woo .woocommerce-tabs ul.tabs li.active a {
	border-bottom-color: var(--nx-action);
	color: var(--nx-primary);
}

.nx-woo .woocommerce-tabs .panel {
	margin: 0;
	max-width: 72ch;
}

/* Woo prints an "Description" h2 above content that already has its own
   heading. Redundant — hide it and let the content lead. */
.nx-woo .woocommerce-Tabs-panel--description > h2:first-child { display: none; }

.nx-woo .woocommerce-tabs .panel h2 {
	margin: 0 0 var(--nx-space-4);
	font-size: var(--nx-text-2xl);
}

.nx-woo .woocommerce-tabs .panel h3 {
	margin: var(--nx-space-7) 0 var(--nx-space-4);
	font-size: var(--nx-text-xl);
}

.nx-woo .woocommerce-tabs .panel p,
.nx-woo .woocommerce-tabs .panel li {
	color: var(--nx-text-muted);
	line-height: var(--nx-leading-normal);
}

.nx-woo .woocommerce-tabs .panel ul { padding-left: 1.1rem; }

/* Spec table in the description reads as a datasheet. */
.nx-woo .woocommerce-tabs .panel table {
	width: 100%;
	margin: var(--nx-space-5) 0 var(--nx-space-6);
	border: 1px solid var(--nx-border);
	border-radius: var(--nx-radius-md);
	border-collapse: separate;
	border-spacing: 0;
	overflow: hidden;
	font-size: var(--nx-text-sm);
}

.nx-woo .woocommerce-tabs .panel table th,
.nx-woo .woocommerce-tabs .panel table td {
	padding: var(--nx-space-4) var(--nx-space-5);
	border-bottom: 1px solid var(--nx-border);
	text-align: left;
	vertical-align: top;
}

.nx-woo .woocommerce-tabs .panel table tr:last-child th,
.nx-woo .woocommerce-tabs .panel table tr:last-child td { border-bottom: 0; }

.nx-woo .woocommerce-tabs .panel table th {
	width: 34%;
	background: var(--nx-grey-50);
	color: var(--nx-primary);
	font-weight: var(--nx-weight-semibold);
}

.nx-woo .woocommerce-tabs .panel table td { color: var(--nx-text); }

/* ---- Related / upsells --------------------------------------------------- */

.nx-woo .related,
.nx-woo .upsells {
	grid-column: 1 / -1;
	margin-top: var(--nx-space-9);
	padding-top: var(--nx-space-8);
	border-top: 1px solid var(--nx-border);
}

.nx-woo .related > h2,
.nx-woo .upsells > h2 {
	margin-bottom: var(--nx-space-6);
	font-size: var(--nx-text-2xl);
}

/* ---- Buttons ------------------------------------------------------------- */

.nx-woo .button,
.nx-woo a.button,
.nx-woo button.button,
.nx-woo input.button,
.nx-woo .button.alt,
.nx-woo button.button.alt {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--nx-space-2);
	min-height: 48px;
	padding: 0.875rem 1.75rem;
	background: var(--nx-primary);
	border: 2px solid transparent;
	border-radius: var(--nx-radius);
	color: var(--nx-white);
	font-family: inherit;
	font-size: var(--nx-text-sm);
	font-weight: var(--nx-weight-semibold);
	letter-spacing: var(--nx-tracking-wide);
	line-height: 1;
	text-align: center;
	text-decoration: none;
	text-transform: none;
	cursor: pointer;
	transition:
		background-color var(--nx-dur-fast) var(--nx-ease),
		transform var(--nx-dur-fast) var(--nx-ease),
		box-shadow var(--nx-dur-fast) var(--nx-ease);
}

.nx-woo .button:hover,
.nx-woo a.button:hover,
.nx-woo button.button:hover,
.nx-woo input.button:hover,
.nx-woo .button.alt:hover,
.nx-woo button.button.alt:hover {
	background: var(--nx-primary-hover);
	color: var(--nx-white);
	transform: translateY(-2px);
	box-shadow: var(--nx-shadow);
}

.nx-woo .single_add_to_cart_button,
.nx-woo .single_add_to_cart_button.alt { background: var(--nx-action); }
.nx-woo .single_add_to_cart_button:hover,
.nx-woo .single_add_to_cart_button.alt:hover { background: var(--nx-action-hover); }

/* "Read more" on an unpurchasable product is secondary, not a primary action. */
.nx-woo ul.products li.product a.button.product_type_simple:not(.add_to_cart_button) {
	background: transparent;
	border-color: var(--nx-border-strong);
	color: var(--nx-primary);
}

.nx-woo ul.products li.product a.button.product_type_simple:not(.add_to_cart_button):hover {
	background: transparent;
	border-color: var(--nx-primary);
	color: var(--nx-primary);
	box-shadow: none;
}

.nx-woo .quantity .qty {
	width: 5rem;
	min-height: 48px;
	padding: 0.5rem;
	border: 1px solid var(--nx-border-strong);
	border-radius: var(--nx-radius);
	font-family: inherit;
	font-size: var(--nx-text-base);
	text-align: center;
}

/* ---- Narrow screens ------------------------------------------------------ */

@media (max-width: 600px) {
	/* enhance.css gives .nx-btn `width: 100%` below 600px. Combined with the
	   side margins that position the button inside the card, that resolves to
	   card width + 2 × margin and spills past the card edge. Let the flex
	   stretch do the sizing instead of a percentage width. */
	.nx-woo ul.products li.product .button,
	.nx-woo ul.products li.product .added_to_cart {
		width: auto;
		align-self: stretch;
		padding-inline: var(--nx-space-4);
	}

	.nx-woo div.product form.cart { gap: var(--nx-space-3); }
	.nx-woo div.product form.cart .button { flex: 1 1 auto; }

	/* A fixed first column squeezes the value cell on a phone. */
	.nx-woo .woocommerce-tabs .panel table th { width: 42%; }

	.nx-woo .woocommerce-tabs .panel table th,
	.nx-woo .woocommerce-tabs .panel table td {
		padding: var(--nx-space-3) var(--nx-space-4);
	}

	.nx-woo div.product .nx-product-gallery__main { padding: var(--nx-space-4); }
}

/* ---- Badges -------------------------------------------------------------- */

.nx-woo .nx-woo__flash,
.nx-woo span.onsale {
	position: absolute;
	top: var(--nx-space-4);
	left: var(--nx-space-4);
	z-index: 2;
	min-height: 0;
	min-width: 0;
	padding: 0.35rem 0.7rem;
	background: var(--nx-action);
	border-radius: var(--nx-radius-full);
	color: var(--nx-white);
	font-size: var(--nx-text-xs);
	font-weight: var(--nx-weight-semibold);
	letter-spacing: var(--nx-tracking-wide);
	line-height: 1.4;
	text-transform: uppercase;
}

.nx-woo .stock.in-stock { color: #1B7F4B; font-size: var(--nx-text-sm); font-weight: var(--nx-weight-medium); }
.nx-woo .stock.out-of-stock { color: #B3261E; font-size: var(--nx-text-sm); font-weight: var(--nx-weight-medium); }

/* ---- Tables, notices, forms (cart / checkout) ---------------------------- */

.nx-woo table.shop_table {
	border: 1px solid var(--nx-border);
	border-radius: var(--nx-radius-md);
	border-collapse: separate;
	border-spacing: 0;
	overflow: hidden;
}

.nx-woo table.shop_table th {
	background: var(--nx-grey-50);
	color: var(--nx-primary);
	font-weight: var(--nx-weight-semibold);
}

.nx-woo table.shop_table td,
.nx-woo table.shop_table th { padding: var(--nx-space-4) var(--nx-space-5); }

.nx-woo .woocommerce-message,
.nx-woo .woocommerce-info,
.nx-woo .woocommerce-error,
.nx-woo .woocommerce-noreviews,
.nx-woo p.no-comments {
	padding: var(--nx-space-5) var(--nx-space-6);
	background: var(--nx-grey-50);
	border: 1px solid var(--nx-border);
	border-top: 3px solid var(--nx-action);
	border-radius: var(--nx-radius);
	color: var(--nx-text);
	font-size: var(--nx-text-sm);
	list-style: none;
}

.nx-woo .woocommerce-error { border-top-color: #B3261E; }

.nx-woo .woocommerce-message::before,
.nx-woo .woocommerce-info::before,
.nx-woo .woocommerce-error::before { display: none; }

.nx-woo .woocommerce-form input.input-text,
.nx-woo form .form-row input.input-text,
.nx-woo form .form-row textarea,
.nx-woo form .form-row select,
.nx-woo .select2-container .select2-selection--single {
	width: 100%;
	min-height: 48px;
	padding: 0.8125rem 1rem;
	background: var(--nx-surface);
	border: 1px solid var(--nx-border-strong);
	border-radius: var(--nx-radius);
	color: var(--nx-text);
	font-family: inherit;
	font-size: var(--nx-text-base);
}

.nx-woo form .form-row textarea { min-height: 8rem; }

.nx-woo .woocommerce-form input.input-text:focus,
.nx-woo form .form-row input.input-text:focus,
.nx-woo form .form-row textarea:focus {
	outline: 2px solid var(--nx-focus);
	outline-offset: 1px;
	border-color: transparent;
}

/* ---- Reviews ------------------------------------------------------------- */

.nx-woo #reviews .commentlist { padding: 0; list-style: none; }

.nx-woo #reviews .comment_container {
	padding: var(--nx-space-5);
	background: var(--nx-grey-50);
	border: 1px solid var(--nx-border);
	border-radius: var(--nx-radius-md);
}
