/* ---------------------------------------------------------------------------
 * Phase 3/4 — shop, category, search + single product.
 *
 * Intentionally small. `.sp-grid` and every `.sp-card*` rule already live in base.css, so the
 * archive inherits the catalogue look for free. What is left is the archive header, the PDP
 * layout, and neutralising WooCommerce's own stylesheets, which actively fight a modern theme.
 *
 * Every override below targets a REAL defect documented in STANDARDS.md, not a hypothetical:
 * each produces a visibly wrong page that passes structural checks.
 * ------------------------------------------------------------------------- */

/* --- 1. Woo's clearfix pseudo-element becomes a real grid item ------------
 * woocommerce-layout.css and woocommerce.css both ship
 *   .woocommerce ul.products::before{content:" ";display:table}
 * On a display:grid container that occupies CELL 1, shifting the whole catalogue one cell right
 * at every breakpoint — empty top-left slot, orphan card on the last row. Card COUNT stays
 * correct, so no count-based test catches it. We render our own <section>, but Woo's rules also
 * match .sp-grid on pages whose body carries `woocommerce`. */
.woocommerce .sp-grid::before,
.woocommerce .sp-grid::after,
.sp-grid::before,
.sp-grid::after {
	content: none !important;
	display: none !important;
}

/* --- 2. Woo's button skin outranks the card CTA --------------------------
 * `.woocommerce:where(body:not(...)) a.button` computes at (0,2,1) — :where() contributes
 * nothing — and beats a single-class selector. The card CTA override lives in base.css because
 * the card also renders on /cart/, which does not load this sheet. Here we only neutralise the
 * Woo chrome that is unique to listing/product pages. */
.woocommerce .sp-grid a.button,
.woocommerce .sp-detail a.button {
	background-image: none;
}

/* --- 3. Archive header --------------------------------------------------- */
.sp-storehead--archive {
	max-width: var(--sp-wrap, 1360px);
	margin: 0 auto;
	padding: 28px 20px 10px;
	text-align: center;
}

.sp-storehead-title {
	font-family: var(--sp-ff-display);
	font-size: clamp(1.6rem, 1.1rem + 1.6vw, 2.4rem);
	font-weight: 600;
	letter-spacing: 0.02em;
	margin: 0 0 18px;
	color: var(--sp-chrome-hi, #ecedf0);
}

.sp-shop-grid {
	padding-bottom: 56px;
}

.sp-empty {
	grid-column: 1 / -1;
	text-align: center;
	padding: 48px 16px;
	color: var(--sp-chrome-mid, #c2c8d0);
}

/* --- 4. PDP ---------------------------------------------------------------
 * RECON-DESIGN 5.4: two columns — media | panel. No tabs, no thumbnail strip, no lightbox,
 * no spec table, no reviews, no breadcrumbs. Do not add them; the source has none. */
.sp-detail {
	max-width: var(--sp-wrap, 1360px);
	margin: 0 auto;
	padding: 28px 20px 56px;
}

.sp-detail-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: clamp(20px, 3vw, 46px);
	align-items: start;
}

/* Woo ships `.woocommerce div.product div.summary{float:right;width:48%}`. A float is IGNORED
 * inside grid but the PERCENTAGE is not — it squeezes the info column to ~269px inside its own
 * 560px track. Same defect class as the account sidebar collapsing to 78px. */
.woocommerce div.product .sp-detail-panel,
.sp-detail-panel {
	float: none !important;
	width: auto !important;
	margin: 0 !important;
}

.woocommerce div.product .sp-detail-media,
.sp-detail-media {
	float: none !important;
	width: auto !important;
}

.sp-media-frame {
	position: relative;
	border: 1px solid var(--sp-border, rgba(255, 255, 255, 0.08));
	border-radius: var(--sp-r-card, 18px);
	overflow: hidden;
	background: var(--sp-b1, #101014);
}

.sp-media-frame img {
	display: block;
	width: 100%;
	height: auto;
}

.sp-detail-title {
	font-family: var(--sp-ff-display);
	font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2.15rem);
	font-weight: 600;
	line-height: 1.15;
	margin: 0 0 12px;
	color: var(--sp-chrome-hi, #ecedf0);
}

.sp-detail-price {
	font-size: clamp(1.35rem, 1.1rem + 0.9vw, 1.8rem);
	font-weight: 700;
	margin: 0 0 10px;
}

/* Match the card's gold treatment so price reads identically on both surfaces. */
.sp-detail-price .sp-price-now,
.sp-detail-price .amount {
	background: var(--sp-gold-pop);
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
	color: var(--sp-gold-mid, #e9ddc0);
}

@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
	.sp-detail-price .sp-price-now,
	.sp-detail-price .amount {
		-webkit-text-fill-color: currentColor;
		color: var(--sp-gold-mid, #e9ddc0);
	}
}

.sp-detail-price del {
	opacity: 0.55;
	font-weight: 500;
	font-size: 0.72em;
	margin-right: 8px;
	-webkit-text-fill-color: currentColor;
	background: none;
	color: var(--sp-chrome-mid, #c2c8d0);
}

/* HARD RULE 10 — always the in-stock variant. There is no --out state on this build. */
.sp-availability {
	display: inline-block;
	font-size: 0.86rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--sp-good, #7fd3a0);
	margin: 0 0 16px;
}

.sp-detail-desc {
	color: var(--sp-chrome-mid, #c2c8d0);
	line-height: 1.65;
	margin: 0 0 22px;
	max-width: 60ch;
}

/* --- 5. Quantity row + cap ------------------------------------------------
 * The stepper's `max` is the per-product PURCHASE CEILING (_sassypharma_qty_max), never stock. */
.sp-qty-row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px;
	margin: 0 0 14px;
}

.sp-qty-label {
	flex: 1 0 100%;
	font-size: 0.8rem;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--sp-chrome-lo, #8b929c);
}

.sp-qty-pill {
	display: inline-flex;
	align-items: center;
	border: 1px solid var(--sp-border, rgba(255, 255, 255, 0.12));
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.03);
	overflow: hidden;
}

.sp-qty-btn {
	appearance: none;
	border: 0;
	background: transparent;
	color: var(--sp-chrome-hi, #ecedf0);
	font-size: 1.1rem;
	line-height: 1;
	width: 42px;
	height: 46px;
	cursor: pointer;
}

.sp-qty-btn:disabled {
	opacity: 0.35;
	cursor: not-allowed;
}

.sp-qty-btn:focus-visible {
	outline: 2px solid var(--sp-gold-mid, #e9ddc0);
	outline-offset: -2px;
}

.sp-qty-input {
	width: 62px;
	height: 46px;
	border: 0;
	background: transparent;
	color: var(--sp-chrome-hi, #ecedf0);
	text-align: center;
	font-size: 1rem;
	font-variant-numeric: tabular-nums;
	-moz-appearance: textfield;
}

.sp-qty-input::-webkit-outer-spin-button,
.sp-qty-input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.sp-qty-grow {
	flex: 1 1 200px;
}

.sp-qty-note {
	flex: 1 0 100%;
	font-size: 0.8rem;
	color: var(--sp-chrome-lo, #8b929c);
	margin: 2px 0 0;
}

.sp-detail-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 18px;
}

/* --- 6. Related products -------------------------------------------------
 * RECON-DESIGN 5.4: one panel titled "Related products", same-category, 2-6 items. */
.sp-related {
	max-width: var(--sp-wrap, 1360px);
	margin: 0 auto;
	padding: 0 20px 64px;
}

.sp-related-title {
	font-family: var(--sp-ff-display);
	font-size: 1.25rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	margin: 0 0 18px;
	color: var(--sp-chrome-hi, #ecedf0);
}

.sp-rv-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
	gap: var(--sp-grid-gap, 20px);
}

.sp-rv-card {
	display: block;
	text-decoration: none;
	border: 1px solid var(--sp-border, rgba(255, 255, 255, 0.08));
	border-radius: var(--sp-r-card, 18px);
	overflow: hidden;
	background: var(--sp-b1, #101014);
	transition: border-color 0.25s var(--sp-ease, ease), transform 0.25s var(--sp-ease, ease);
}

.sp-rv-card:hover,
.sp-rv-card:focus-visible {
	border-color: rgba(var(--sp-gold-rgb, 200 165 80), 0.45);
	transform: translateY(-2px);
}

.sp-rv-media img {
	display: block;
	width: 100%;
	height: auto;
}

.sp-rv-body {
	padding: 12px 14px 16px;
	text-align: center;
}

.sp-rv-name {
	display: block;
	font-size: 0.92rem;
	line-height: 1.3;
	color: var(--sp-chrome-hi, #ecedf0);
	margin-bottom: 6px;
}

.sp-rv-price {
	display: block;
	font-size: 0.86rem;
	color: var(--sp-chrome-lo, #8b929c);
}

/* --- 7. Woo notices on product pages ------------------------------------- */
.woocommerce-notices-wrapper .woocommerce-message,
.woocommerce-notices-wrapper .woocommerce-info,
.woocommerce-notices-wrapper .woocommerce-error {
	background: rgba(255, 255, 255, 0.04);
	border-top: 2px solid rgba(var(--sp-gold-rgb, 200 165 80), 0.55);
	color: var(--sp-chrome-hi, #ecedf0);
	border-radius: var(--sp-r-card, 14px);
}

/* --- 8. Responsive ------------------------------------------------------- */
@media (max-width: 900px) {
	.sp-detail-grid {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 520px) {
	.sp-storehead--archive {
		padding-top: 18px;
	}

	.sp-rv-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}
