/**
 * WooCommerce — shared surfaces.
 * ==========================================================================
 * Loaded on every WooCommerce page (shop, product, cart, checkout, account).
 * Its job is to map WooCommerce's own class names onto the theme's components
 * so that markup we do not own — notices, buttons injected by extensions,
 * price strings — looks like the rest of the site.
 *
 * WooCommerce's three stylesheets (~99 KB) are dequeued by `cropped-core`, so
 * nothing here is fighting a default; these rules are the only styling those
 * elements get.
 *
 * @package Cropped
 * @since   1.0.0
 * ========================================================================== */

/* --------------------------------------------------------------------------
 * Buttons
 *
 * `.button` is what WooCommerce and every extension emits. Mapping it onto the
 * button component here means an "Apply coupon" or a gateway's own button
 * arrives styled, without either being restyled separately.
 * -------------------------------------------------------------------------- */

.woocommerce .button,
.woocommerce a.button,
.woocommerce button.button,
.woocommerce input.button,
.woocommerce #respond input#submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var( --cr-space-xs );
	min-height: var( --cr-tap-target );
	padding: var( --cr-space-sm ) var( --cr-space-lg );
	border: 1px solid transparent;
	border-radius: var( --cr-radius-sm );
	background-color: var( --cr-action );
	color: var( --cr-action-text );
	font-family: var( --cr-font-body );
	font-size: var( --cr-text-sm );
	font-weight: var( --cr-weight-medium );
	letter-spacing: var( --cr-tracking-wide );
	line-height: 1.2;
	text-align: center;
	text-transform: uppercase;
	text-decoration: none;
	cursor: pointer;
	transition: background-color var( --cr-duration ) var( --cr-ease );
}

.woocommerce .button:hover,
.woocommerce a.button:hover,
.woocommerce button.button:hover,
.woocommerce input.button:hover {
	background-color: var( --cr-action-hover );
	color: var( --cr-action-text );
}

.woocommerce .button:disabled,
.woocommerce .button.disabled,
.woocommerce button.button:disabled {
	background-color: var( --cr-surface-sunken );
	border-color: var( --cr-border );
	color: var( --cr-text-disabled );
	cursor: not-allowed;
}

/* WooCommerce's own "secondary" is the outline treatment here. */
.woocommerce .button.alt {
	background-color: var( --cr-action );
}

/* --------------------------------------------------------------------------
 * Prices
 * -------------------------------------------------------------------------- */

.woocommerce .price,
.woocommerce-Price-amount {
	color: var( --cr-text );
	font-variant-numeric: tabular-nums;
}

/*
 * A struck-through original price. `<del>` is the semantic carrier — the strike
 * is not decoration here, it is the difference between "was" and "is" — and the
 * muted colour is a second, non-colour-dependent cue on top of it.
 */
.woocommerce .price del,
.woocommerce del .woocommerce-Price-amount {
	color: var( --cr-text-muted );
	text-decoration: line-through;
	margin-inline-end: var( --cr-space-xs );
	font-weight: var( --cr-weight-regular );
}

.woocommerce .price ins,
.woocommerce ins .woocommerce-Price-amount {
	color: var( --cr-text-sale );
	text-decoration: none;
	font-weight: var( --cr-weight-medium );
}

/*
 * The currency symbol is set slightly smaller and lighter than the figure.
 * "PKR 2,450" reads as a price; "PKR 2,450" with both at the same weight reads
 * as a code.
 */
.woocommerce-Price-currencySymbol {
	font-size: 0.82em;
	color: var( --cr-text-muted );
}

/* --------------------------------------------------------------------------
 * Notices
 *
 * WooCommerce prints three notice types. They are mapped onto `.cr-notice`
 * rather than restyled, so a cart error and a form error look identical.
 * -------------------------------------------------------------------------- */

.woocommerce-message,
.woocommerce-info,
.woocommerce-error,
.woocommerce-notice {
	display: flex;
	align-items: flex-start;
	flex-wrap: wrap;
	gap: var( --cr-space-sm );
	padding: var( --cr-space-md );
	margin-block-end: var( --cr-space-md );
	border: 1px solid var( --cr-border );
	border-inline-start-width: 3px;
	border-radius: var( --cr-radius-sm );
	background-color: var( --cr-surface );
	font-size: var( --cr-text-sm );
	list-style: none;
}

.woocommerce-message {
	border-inline-start-color: var( --cr-success );
}

.woocommerce-info {
	border-inline-start-color: var( --cr-info );
}

.woocommerce-error {
	border-inline-start-color: var( --cr-sale );
}

.woocommerce-error li + li {
	margin-block-start: var( --cr-space-xs );
	inline-size: 100%;
}

/* The action link a notice carries sits on the end of the row. */
.woocommerce-message .button,
.woocommerce-info .button {
	margin-inline-start: auto;
	min-height: 2.25rem;
	padding: var( --cr-space-xs ) var( --cr-space-md );
	font-size: var( --cr-text-xs );
}

.cr-wc-notices:empty {
	display: none;
}

/* --------------------------------------------------------------------------
 * Stock state
 * -------------------------------------------------------------------------- */

.cr-stock,
.woocommerce .stock {
	display: flex;
	align-items: center;
	gap: var( --cr-space-xs );
	margin: 0;
	font-size: var( --cr-text-sm );
	font-weight: var( --cr-weight-medium );
}

.woocommerce .stock.in-stock,
.cr-stock--in {
	color: var( --cr-success );
}

.woocommerce .stock.out-of-stock,
.cr-stock--out {
	color: var( --cr-sale );
}

/*
 * Low stock is a nudge, not an alarm. Warning rather than sale colour, and no
 * exclamation — a fashion brand that shouts at a shopper about scarcity reads
 * as a discount site.
 */
.cr-stock--low {
	color: var( --cr-warning );
}

/* --------------------------------------------------------------------------
 * Quantity input
 *
 * A pill-shaped stepper: minus, number, plus.
 *
 * This was a plain number input, on the grounds that two buttons per line item
 * adds four tab stops to a cart and the native control already has increment
 * arrows. That argument was a desktop argument. On a phone the native arrows
 * are not rendered at all, so the only way to change a quantity was to raise
 * the keyboard and retype the figure — and the shop is mostly read on phones.
 *
 * The tab-stop cost is paid off in the template instead: both buttons are
 * `tabindex="-1"`, so tab order runs through the inputs exactly as it did
 * before. They remain real buttons with real labels for anyone browsing by
 * control.
 *
 * It lives here, not in `checkout.css`, because the same control renders on
 * single product pages, and `checkout.css` is only enqueued on cart and
 * checkout — a shared component in a conditional stylesheet is a bug this
 * theme has already shipped three times.
 * -------------------------------------------------------------------------- */

.woocommerce .quantity {
	display: inline-flex;
}

.woocommerce .quantity.cr-qty {
	align-items: center;
	gap: var( --cr-space-3xs );
	padding: 3px;
	background-color: var( --cr-surface );
	border: 1px solid var( --cr-border-strong );
	border-radius: var( --cr-radius-full );
	transition: border-color var( --cr-duration ) var( --cr-ease );
}

.woocommerce .quantity.cr-qty:focus-within {
	border-color: var( --cr-text );
}

.woocommerce .quantity .qty {
	inline-size: 5rem;
	min-block-size: var( --cr-control-height );
	padding: var( --cr-space-xs ) var( --cr-space-sm );
	border: 1px solid var( --cr-border-strong );
	border-radius: var( --cr-radius-sm );
	background-color: var( --cr-surface );
	color: var( --cr-text );
	font-size: 1rem;
	font-variant-numeric: tabular-nums;
	text-align: center;
}

/* Inside the pill the field carries no chrome of its own — the pill is it. */
.woocommerce .quantity.cr-qty .qty {
	inline-size: 2.75rem;
	min-block-size: auto;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	font-size: var( --cr-text-sm );
	font-weight: var( --cr-weight-medium );
}

.woocommerce .quantity.cr-qty .qty:focus {
	outline: none;
}

/* The native spinners duplicate the two buttons either side of them. */
.woocommerce .quantity.cr-qty .qty::-webkit-outer-spin-button,
.woocommerce .quantity.cr-qty .qty::-webkit-inner-spin-button {
	margin: 0;
	appearance: none;
}

.woocommerce .quantity.cr-qty .qty {
	appearance: textfield;
}

.cr-qty__step {
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	inline-size: 2rem;
	block-size: 2rem;
	padding: 0;
	color: var( --cr-text-secondary );
	background: none;
	border: 0;
	border-radius: var( --cr-radius-full );
	cursor: pointer;
	transition:
		background-color var( --cr-duration ) var( --cr-ease ),
		color var( --cr-duration ) var( --cr-ease );
}

.cr-qty__step:hover {
	color: var( --cr-text-inverse );
	background-color: var( --cr-surface-inverse );
}

.cr-qty__step:disabled {
	color: var( --cr-text-disabled );
	background: none;
	cursor: default;
}

.cr-qty__step svg {
	inline-size: 0.8125rem;
	block-size: 0.8125rem;
}

/* --------------------------------------------------------------------------
 * WooCommerce tables — cart, order details, account orders.
 * -------------------------------------------------------------------------- */

.woocommerce table.shop_table {
	inline-size: 100%;
	border-collapse: collapse;
	font-size: var( --cr-text-sm );
}

.woocommerce table.shop_table th {
	padding: var( --cr-space-sm ) var( --cr-space-sm );
	border-block-end: 1px solid var( --cr-border-strong );
	font-size: var( --cr-text-xs );
	font-weight: var( --cr-weight-semibold );
	letter-spacing: var( --cr-tracking-wider );
	text-transform: uppercase;
	color: var( --cr-text-muted );
	text-align: start;
}

.woocommerce table.shop_table td {
	padding: var( --cr-space-md ) var( --cr-space-sm );
	border-block-end: 1px solid var( --cr-border );
	vertical-align: top;
}

.woocommerce table.shop_table .product-total,
.woocommerce table.shop_table .product-subtotal,
.woocommerce table.shop_table td[data-title="Total"] {
	text-align: end;
	white-space: nowrap;
}

/*
 * `.cr-table-scroll` used to be declared here. It is used by the size guide too,
 * which is a plain page and therefore never loads this file — so the size chart
 * (min-inline-size: 32rem) pushed the whole page to 512 px on a 360 px phone and
 * `body { overflow-x: clip }` then quietly cut the last two columns off with no
 * way to scroll to them. It now lives in `layout/container.css`, which is
 * always loaded. A shared utility must not sit in a conditional stylesheet.
 */

/* --------------------------------------------------------------------------
 * Form rows
 *
 * WooCommerce emits the same `.form-row` markup everywhere it asks for input —
 * checkout, login, registration, lost password, address editing, account
 * details — so these rules belong in the file every WooCommerce page loads,
 * not beside the checkout. `.form-row-first` / `-last` are the side-by-side
 * pair; `cropped-core` assigns those to City and Province.
 * -------------------------------------------------------------------------- */

.woocommerce form .form-row {
	display: flex;
	flex-direction: column;
	gap: var( --cr-space-2xs );
	margin-block-end: var( --cr-space-md );
}

.woocommerce form .form-row label {
	font-size: var( --cr-text-sm );
	font-weight: var( --cr-weight-medium );
	color: var( --cr-text-secondary );
}

.woocommerce form .form-row .required {
	color: var( --cr-text-sale );
	text-decoration: none;
}

/* WooCommerce appends its own "(optional)"; see REFERENCE-NOTES 3.4. */
.woocommerce form .form-row .optional {
	color: var( --cr-text-muted );
	font-weight: var( --cr-weight-regular );
}

.woocommerce form .form-row input.input-text,
.woocommerce form .form-row textarea,
.woocommerce form .form-row select {
	inline-size: 100%;
	min-block-size: var( --cr-control-height );
	padding: var( --cr-space-sm ) var( --cr-space-md );
	background-color: var( --cr-surface );
	border: 1px solid var( --cr-border-strong );
	border-radius: var( --cr-radius-sm );
	color: var( --cr-text );
	/* Never smaller than 16px: iOS zooms a focused input below it and does not
	   zoom back out, leaving the shopper scrolled sideways through checkout. */
	font-size: 1rem;
	line-height: 1.4;
}

.woocommerce form .form-row textarea {
	min-block-size: 5rem;
}

.woocommerce form .form-row input.input-text:focus,
.woocommerce form .form-row textarea:focus,
.woocommerce form .form-row select:focus {
	outline: none;
	border-color: var( --cr-text );
	box-shadow: 0 0 0 1px var( --cr-text );
}

.woocommerce form .form-row.woocommerce-invalid input.input-text,
.woocommerce form .form-row.woocommerce-invalid select {
	border-color: var( --cr-sale );
	box-shadow: 0 0 0 1px var( --cr-sale );
}

.woocommerce form .form-row.woocommerce-validated input.input-text {
	border-color: var( --cr-success );
}

@media ( min-width: 30rem ) {
	.woocommerce form .form-row-first,
	.woocommerce form .form-row-last {
		display: inline-flex;
		inline-size: calc( 50% - ( var( --cr-space-md ) / 2 ) );
		vertical-align: top;
	}

	.woocommerce form .form-row-first {
		margin-inline-end: var( --cr-space-md );
	}
}

.woocommerce form .form-row-wide {
	inline-size: 100%;
}

/*
 * A checkbox row — "Remember me", "Subscribe", "Ship to a different address" —
 * is laid out sideways, not stacked, and the `.form-row` rules above would
 * otherwise put the label on its own line under a lone 13 px box.
 *
 * The whole row is the target: the label is padded to 44 px and the checkbox
 * sits inside it, so the tappable area is the text as well as the box. Sizing
 * the checkbox itself to 44 px instead would give a comically large control.
 */
.woocommerce form .form-row.woocommerce-form__label-for-checkbox,
.woocommerce form label.woocommerce-form__label-for-checkbox {
	flex-direction: row;
	align-items: center;
	gap: var( --cr-space-sm );
	min-block-size: var( --cr-tap-target );
	cursor: pointer;
}

.woocommerce form input[type="checkbox"] {
	inline-size: 1.15rem;
	block-size: 1.15rem;
	flex: 0 0 auto;
	accent-color: var( --cr-stone-900 );
	cursor: pointer;
}

/* --------------------------------------------------------------------------
 * Pagination — WooCommerce emits its own wrapper class.
 * -------------------------------------------------------------------------- */

.woocommerce-pagination {
	margin-block-start: var( --cr-space-3xl );
	padding-block-start: var( --cr-space-xl );
	border-block-start: 1px solid var( --cr-border );
}

.woocommerce-pagination ul.page-numbers {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: var( --cr-space-3xs );
	margin: 0;
	padding: 0;
	list-style: none;
	border: 0;
}

.woocommerce-pagination a.page-numbers,
.woocommerce-pagination span.page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-inline-size: var( --cr-tap-target );
	min-block-size: var( --cr-tap-target );
	padding-inline: var( --cr-space-xs );
	border: 1px solid transparent;
	border-radius: var( --cr-radius-sm );
	color: var( --cr-text-muted );
	font-size: var( --cr-text-sm );
	font-variant-numeric: tabular-nums;
	text-decoration: none;
}

.woocommerce-pagination a.page-numbers:hover {
	color: var( --cr-text );
	border-color: var( --cr-border-strong );
}

.woocommerce-pagination .page-numbers.current {
	color: var( --cr-text );
	border-color: var( --cr-text );
	font-weight: var( --cr-weight-medium );
}

/* --------------------------------------------------------------------------
 * Loading state
 *
 * WooCommerce adds `.processing` during an AJAX update. Dimming the block tells
 * the shopper the figure they are looking at is stale — without it a cart total
 * silently changes under them.
 * -------------------------------------------------------------------------- */

.woocommerce .blockUI.blockOverlay {
	background: var( --cr-canvas ) !important;
	opacity: 0.6 !important;
}

.woocommerce .processing {
	opacity: 0.55;
	pointer-events: none;
	transition: opacity var( --cr-duration ) var( --cr-ease );
}
