/**
 * Cart page styles — WooCommerce block cart overrides
 *
 * Design: Match wireframe design-lab/wf-c-cart.html
 * Targets: WooCommerce block cart (wp:woocommerce/cart), React-rendered.
 * Selectors extracted from plugins/woocommerce/assets/client/blocks/cart.css
 *
 * @package Nouthemes
 * @since 2.1.0
 */

/* ================================================================== *
 * LAYOUT — override Woo's 65/35 flex with a fixed-sidebar grid
 *
 * Woo ships .wc-block-components-sidebar-layout as flex (main 65% +
 * sidebar 35%). We swap it to a grid with a 340px sidebar so the totals
 * column matches the product page buy box width.
 * ================================================================== */

.nou-page-cart .wc-block-cart.wc-block-components-sidebar-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 340px;
	gap: clamp(28px, 4vw, 56px);
	align-items: start;
	margin: 0;
}

.nou-page-cart .wc-block-components-main,
.nou-page-cart .wc-block-components-sidebar {
	width: auto;
	padding: 0;
	box-sizing: border-box;
}

@media (max-width: 900px) {
	.nou-page-cart .wc-block-cart.wc-block-components-sidebar-layout {
		grid-template-columns: minmax(0, 1fr);
	}

	/* Totals sidebar comes first on mobile — price + checkout button
	   are what the buyer needs to see when they open the cart. */
	.nou-page-cart .wc-block-components-sidebar {
		order: -1;
	}
}

/* ================================================================== *
 * CART ITEMS TABLE — block structure (3 cells: image | product | total)
 * ================================================================== */

.nou-page-cart .wc-block-cart-items {
	width: 100%;
	margin: 0;
	border-collapse: separate;
	border-spacing: 0;
	border-top: 1px solid var(--wp--custom--line--soft);
}

/* Hide the table header visually (keep for accessibility) */
.nou-page-cart .wc-block-cart-items__header {
	border: 0;
	clip: rect(0 0 0 0);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	width: 1px;
}

/* Each cart item row */
.nou-page-cart .wc-block-cart-items__row {
	display: grid;
	grid-template-columns: 96px minmax(0, 1fr) auto;
	grid-template-areas: "image product total";
	gap: clamp(14px, 2vw, 20px);
	align-items: start;
	padding: clamp(18px, 2.2vw, 24px) 0;
	border-bottom: 1px solid var(--wp--custom--line--soft);
}

.nou-page-cart .wc-block-cart-items__row > td {
	padding: 0;
	border: 0;
	vertical-align: top;
}

/* ================================================================== *
 * ITEM IMAGE
 * ================================================================== */

.nou-page-cart .wc-block-cart-item__image {
	grid-area: image;
}

.nou-page-cart .wc-block-cart-item__image > a,
.nou-page-cart .wc-block-cart-item__image > img {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 10;
	overflow: hidden;
	border: 1px solid var(--wp--custom--line--strong);
	border-radius: var(--wp--custom--radius--sm);
	background: var(--wp--custom--neutral--100);
}

.nou-page-cart .wc-block-cart-item__image img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: top;
}

/* ================================================================== *
 * ITEM PRODUCT CELL — name, unit price, plan meta, quantity, remove
 * ================================================================== */

.nou-page-cart .wc-block-cart-item__product {
	grid-area: product;
	min-width: 0;
}

.nou-page-cart .wc-block-cart-item__wrap {
	display: block;
}

/* Product name
 *
 * The selector mirrors Woo's own — table.wc-block-cart-items
 * .wc-block-cart-items__row .wc-block-components-product-name (0-3-1) — with a
 * leading .nou-page-cart so it outranks it (0-4-1). Without the extra weight
 * Woo's rule wins and forces font-size to --small (18px); the wireframe wants
 * --x-small (16px). The :hover rule carries the same base so it stays above.
 */
.nou-page-cart table.wc-block-cart-items .wc-block-cart-items__row .wc-block-components-product-name {
	display: block;
	margin-bottom: 6px;
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: var(--wp--custom--font-weight--medium);
	letter-spacing: var(--wp--custom--tracking--snug);
	line-height: 1.35;
	color: var(--wp--preset--color--contrast);
	text-decoration: none;
}

.nou-page-cart table.wc-block-cart-items .wc-block-cart-items__row .wc-block-components-product-name:hover {
	color: var(--wp--preset--color--primary);
}

/* Unit price (shown small under the name) */
.nou-page-cart .wc-block-cart-item__product .wc-block-components-product-price {
	display: block;
	margin-bottom: 6px;
	font-family: var(--wp--preset--font-family--mono);
	font-size: 12px;
	font-variant-numeric: tabular-nums;
	color: var(--wp--custom--neutral--600);
}

/* Plan / variation metadata */
.nou-page-cart .wc-block-components-product-metadata {
	margin: 0 0 8px;
	font-family: var(--wp--preset--font-family--mono);
	font-size: 11px;
	letter-spacing: var(--wp--custom--tracking--wide);
	text-transform: uppercase;
	color: var(--wp--custom--neutral--600);
}

.nou-page-cart .wc-block-components-product-details {
	margin: 0;
	padding: 0;
	list-style: none;
}

.nou-page-cart .wc-block-components-product-details__name {
	display: none; /* Hide "Plan:" label, keep only value */
}

.nou-page-cart .wc-block-components-product-details__value {
	margin: 0;
}

/* ================================================================== *
 * QUANTITY SELECTOR — [-] input [+] with "SITES" label
 * ================================================================== */

.nou-page-cart .wc-block-cart-item__quantity {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-top: 8px;
}

/* "SITES" label before the selector */
.nou-page-cart .wc-block-cart-item__quantity::before {
	content: "Sites";
	font-family: var(--wp--preset--font-family--mono);
	font-size: 10px;
	letter-spacing: var(--wp--custom--tracking--wide);
	text-transform: uppercase;
	color: var(--wp--custom--neutral--600);
}

.nou-page-cart .wc-block-components-quantity-selector {
	display: inline-flex;
	align-items: center;
	overflow: hidden;
	/* Woo hardcodes `width: 107px` here, sized for ITS 3-part box. Ours is
	   32 + 44 + 32 + 2px of border = 110px, so the last 3px — the right edge of
	   the `+` stepper — got clipped by `overflow: hidden`. `auto` lets the box
	   follow its own contents instead of Woo's assumption. */
	width: auto;
	border: 1px solid var(--wp--custom--line--strong);
	border-radius: var(--wp--custom--radius--xs);
}

.nou-page-cart .wc-block-components-quantity-selector__button {
	display: grid;
	place-items: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	background: none;
	font-family: var(--wp--preset--font-family--mono);
	font-size: 14px;
	line-height: 1;
	color: var(--wp--custom--neutral--700);
	cursor: pointer;
	transition: background-color 160ms var(--wp--custom--easing--base);
}

.nou-page-cart .wc-block-components-quantity-selector__button:hover {
	background: var(--wp--custom--neutral--100);
	color: var(--wp--preset--color--contrast);
}

/* Woo styles this element as `.wc-block-components-quantity-selector
   input.wc-block-components-quantity-selector__input` (0-2-1), which outranks a
   plain `.nou-page-cart .…__input` (0-2-0) and so wins on EVERY property it
   declares — not just one. That meant font-size fell through to Woo's
   `var(--wp--preset--font-size--small, 14px)`, and since this theme's `small`
   token is 18px (not the 14px fallback Woo assumes) the count rendered at 18px
   in a 0.4em box: a number visibly larger than the −/+ glyphs beside it, with
   the width and padding here silently discarded too. Matching Woo's
   `input.`-qualified chain and prefixing `.nou-page-cart` puts this one class
   ahead. `flex`/`order`/`box-shadow`/`appearance` are respecified because they
   were Woo's, not inherited defaults. */
.nou-page-cart .wc-block-components-quantity-selector input.wc-block-components-quantity-selector__input {
	order: 2;
	width: 44px;
	min-width: 44px;
	flex: 0 0 auto;
	padding: 7px 0;
	border: 0;
	border-inline: 1px solid var(--wp--custom--line--soft);
	border-radius: 0;
	background: none;
	box-shadow: none;
	font-family: var(--wp--preset--font-family--mono);
	font-size: 12px;
	line-height: 1;
	font-variant-numeric: tabular-nums;
	text-align: center;
	color: var(--wp--preset--color--contrast);
	appearance: textfield;
}

/* The native number spinners duplicate the −/+ buttons and break the 44px box. */
.nou-page-cart .wc-block-components-quantity-selector__input::-webkit-outer-spin-button,
.nou-page-cart .wc-block-components-quantity-selector__input::-webkit-inner-spin-button {
	margin: 0;
	appearance: none;
}

/* Woo lets the steppers shrink (`flex` defaults let them give up ~1px each),
   which knocks them under the 32px square the design sizes the row around. */
.nou-page-cart .wc-block-components-quantity-selector__button {
	flex: 0 0 auto;
}

/* ================================================================== *
 * REMOVE LINK
 * ================================================================== */

.nou-page-cart .wc-block-cart-item__remove-link {
	padding: 0;
	border: 0;
	background: none;
	font-family: var(--wp--preset--font-family--mono);
	font-size: 10px;
	letter-spacing: var(--wp--custom--tracking--wide);
	text-transform: uppercase;
	text-decoration: underline;
	text-underline-offset: 3px;
	color: var(--wp--custom--neutral--600);
	cursor: pointer;
	transition: color 160ms var(--wp--custom--easing--base);
}

.nou-page-cart .wc-block-cart-item__remove-link:hover {
	color: #b42318;
}

/* ================================================================== *
 * ITEM TOTAL (line price)
 * ================================================================== */

.nou-page-cart .wc-block-cart-item__total {
	grid-area: total;
	text-align: right;
}

.nou-page-cart .wc-block-cart-item__total-price-and-sale-badge-wrapper {
	align-items: flex-end;
}

.nou-page-cart .wc-block-cart-item__total .wc-block-components-product-price {
	font-family: var(--wp--preset--font-family--mono);
	font-size: 13px;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	color: var(--wp--preset--color--contrast);
}

/* ================================================================== *
 * ORDER SUMMARY / TOTALS SIDEBAR
 * ================================================================== */

@media (min-width: 901px) {
	.nou-page-cart .wc-block-components-sidebar {
		position: sticky;
		top: 88px;
	}
}

.nou-page-cart .wp-block-woocommerce-cart-order-summary-block {
	padding: clamp(20px, 2.6vw, 26px);
	margin-bottom: 0;
	border: 1px solid var(--wp--custom--line--strong);
	border-radius: var(--wp--custom--radius--md);
	background: var(--wp--preset--color--base);
}

/* "Cart totals" title */
.nou-page-cart .wc-block-cart__totals-title {
	display: block;
	margin: 0 0 16px;
	padding: 0;
	font-family: var(--wp--preset--font-family--mono);
	font-size: 11px;
	font-weight: normal;
	letter-spacing: var(--wp--custom--tracking--wide);
	text-transform: uppercase;
	text-align: left;
	color: var(--wp--custom--neutral--600);
}

/* Totals rows */
.nou-page-cart .wc-block-components-totals-wrapper {
	padding: 0;
	margin: 0;
	border: 0;
}

.nou-page-cart .wc-block-components-totals-item {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 14px;
	padding: 9px 0;
	margin: 0;
}

.nou-page-cart .wc-block-components-totals-item__label {
	font-size: 14px;
	color: var(--wp--custom--neutral--700);
}

.nou-page-cart .wc-block-components-totals-item__value {
	font-family: var(--wp--preset--font-family--mono);
	font-size: 14px;
	font-variant-numeric: tabular-nums;
	text-align: right;
	white-space: nowrap;
	color: var(--wp--preset--color--contrast);
}

/* Discount row — accent color for the negative amount */
.nou-page-cart .wc-block-components-totals-discount .wc-block-components-totals-item__value,
.nou-page-cart .wc-block-components-totals-discount__coupon-list-item {
	color: var(--wp--preset--color--primary);
}

/* ================================================================== *
 * COUPON FORM
 * ================================================================== */

.nou-page-cart .wc-block-components-totals-coupon {
	padding: 12px 0;
}

/*
 * "Add coupons" collapsed panel toggle.
 *
 * WooCommerce renders the coupon field as a collapsible panel whose toggle is
 * a .wc-block-components-panel__button carrying the label text and a chevron.
 * Left unstyled it inherits the body font, so it read out of place next to the
 * mono, uppercase totals labels around it. This matches it to the same system:
 * mono, uppercase, wide tracking, neutral label color, chevron pushed right.
 */
.nou-page-cart .wc-block-components-panel__button {
	display: flex;
	align-items: center;
	width: 100%;
	padding: 4px 0;
	margin: 0;
	background: none;
	border: 0;
	font-family: var(--wp--preset--font-family--mono);
	font-size: 11px;
	font-weight: normal;
	letter-spacing: var(--wp--custom--tracking--wide);
	text-transform: uppercase;
	text-align: left;
	color: var(--wp--custom--neutral--600);
	cursor: pointer;
	transition: color 180ms var(--wp--custom--easing--base);
}

.nou-page-cart .wc-block-components-panel__button:hover {
	color: var(--wp--preset--color--contrast);
}

.nou-page-cart .wc-block-components-panel__button-icon {
	order: 1;
	width: 18px;
	height: 18px;
	margin-left: auto;
	fill: currentColor;
}

.nou-page-cart .wc-block-components-totals-coupon__form {
	display: flex;
	gap: 8px;
}

.nou-page-cart .wc-block-components-totals-coupon__input {
	flex: 1;
	min-width: 0;
}

.nou-page-cart .wc-block-components-totals-coupon__input input {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid var(--wp--custom--line--strong);
	border-radius: var(--wp--custom--radius--xs);
	background: var(--wp--custom--surface--soft);
	font-family: var(--wp--preset--font-family--mono);
	font-size: 12px;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--wp--preset--color--contrast);
}

.nou-page-cart .wc-block-components-totals-coupon__button {
	padding: 10px 14px;
	border: 1px solid var(--wp--custom--line--strong);
	border-radius: var(--wp--custom--radius--xs);
	background: transparent;
	font-family: var(--wp--preset--font-family--mono);
	font-size: 10px;
	letter-spacing: var(--wp--custom--tracking--wide);
	text-transform: uppercase;
	color: var(--wp--preset--color--contrast);
	cursor: pointer;
	transition: border-color 180ms var(--wp--custom--easing--base);
}

.nou-page-cart .wc-block-components-totals-coupon__button:hover {
	border-color: var(--wp--preset--color--primary);
}

/* ================================================================== *
 * ORDER TOTAL (footer item) — larger, emphasized
 * ================================================================== */

.nou-page-cart .wc-block-components-totals-footer-item {
	margin-top: 12px;
	padding-top: 14px;
	border-top: 1px solid var(--wp--custom--line--strong);
}

.nou-page-cart .wc-block-components-totals-footer-item .wc-block-components-totals-item__label {
	font-family: var(--wp--preset--font-family--mono);
	font-size: 11px;
	letter-spacing: var(--wp--custom--tracking--wide);
	text-transform: uppercase;
	color: var(--wp--custom--neutral--600);
}

.nou-page-cart .wc-block-components-totals-footer-item .wc-block-components-totals-item__value {
	font-size: 22px;
	letter-spacing: var(--wp--custom--tracking--snug);
	color: var(--wp--preset--color--contrast);
}

/* Hide the "including x tax" sub-note under the total */
.nou-page-cart .wc-block-components-totals-item__description {
	font-size: 11px;
	color: var(--wp--custom--neutral--600);
}

/* ================================================================== *
 * PROCEED TO CHECKOUT BUTTON
 * ================================================================== */

.nou-page-cart .wc-block-cart__submit,
.nou-page-cart .wp-block-woocommerce-proceed-to-checkout-block {
	margin-top: 18px;
	padding: 0;
}

.nou-page-cart .wc-block-cart__submit-container {
	padding: 0;
}

.nou-page-cart .wc-block-cart__submit-button {
	display: block;
	width: 100%;
	padding: 14px 20px;
	border: 0;
	border-radius: var(--wp--custom--radius--xs);
	background: var(--wp--preset--color--contrast);
	font-family: var(--wp--preset--font-family--mono);
	font-size: 11px;
	font-weight: var(--wp--custom--font-weight--medium);
	letter-spacing: var(--wp--custom--tracking--wide);
	text-align: center;
	text-decoration: none;
	text-transform: uppercase;
	color: var(--wp--preset--color--base);
	cursor: pointer;
	transition: background-color 180ms var(--wp--custom--easing--base);
}

.nou-page-cart .wc-block-cart__submit-button:hover {
	background: var(--wp--preset--color--primary);
}

/* ================================================================== *
 * EMPTY CART STATE
 * ================================================================== */

.nou-page-cart .wp-block-woocommerce-empty-cart-block {
	padding: clamp(40px, 6vw, 72px) 0;
	text-align: center;
}

.nou-page-cart .wc-block-cart__empty-cart__title,
.nou-page-cart .wp-block-woocommerce-empty-cart-block > p:first-child {
	margin: 0;
	padding-bottom: 22px;
	font-family: var(--wp--preset--font-family--mono);
	font-size: clamp(18px, 2vw, 22px);
	font-weight: var(--wp--custom--font-weight--medium);
	letter-spacing: var(--wp--custom--tracking--snug);
	color: var(--wp--preset--color--contrast);
}

.nou-page-cart .return-to-shop {
	margin: 0;
	text-align: center;
}

.nou-page-cart .return-to-shop .button,
.nou-page-cart .wp-block-woocommerce-empty-cart-block .wc-block-cart__submit-button {
	display: inline-block;
	width: auto;
	padding: 14px 20px;
}

/* ================================================================== *
 * MOBILE RESPONSIVE
 * ================================================================== */

@media (max-width: 560px) {
	.nou-page-cart .wc-block-cart-items__row {
		grid-template-columns: 72px minmax(0, 1fr);
		grid-template-areas:
			"image product"
			"image total";
	}

	.nou-page-cart .wc-block-cart-item__total {
		text-align: left;
	}
}

/* ================================================================== *
 * REDUCED MOTION
 * ================================================================== */

@media (prefers-reduced-motion: reduce) {
	.nou-page-cart .wc-block-components-quantity-selector__button,
	.nou-page-cart .wc-block-cart-item__remove-link,
	.nou-page-cart .wc-block-components-totals-coupon__button,
	.nou-page-cart .wc-block-cart__submit-button {
		transition: none;
	}
}
