/**
 * Store — Cart
 *
 * Source: cart.dc.html
 *
 *   desktop  breadcrumb · 56px serif heading beside 26px kufi · a 1fr/400px
 *            grid: a four-column line-item table beside a beige summary panel
 *   mobile   40px heading · free-shipping bar · line items as cards · discount
 *            field · subtotal and shipping · a sticky Total + checkout bar
 *
 * The markup underneath is WooCommerce's cart form; see
 * woocommerce/cart/cart.php for what is deliberately left untouched.
 */

/* ==========================================================================
 * PAGE FRAME
 * ========================================================================== */

.scstore-cart {
	/* Room for the sticky bar so it never covers the last row. */
	padding-block-end: 150px;
}

.scstore-cart__head {
	max-inline-size: var(--scstore-container);
	margin-inline: auto;
	padding-block-start: 28px;
	padding-inline: 20px;
}

/*
 * At mobile the heading and its Arabic stack; at desktop they sit on one
 * baseline. Two compositions, as drawn.
 */
.scstore-cart__title {
	display: block;
}

.scstore-cart__heading {
	font-size: var(--scstore-text-40);
	font-weight: var(--scstore-weight-semibold);
	line-height: 0.9;
}

.scstore-cart__heading-ar {
	display: block;
	font-size: var(--scstore-text-20);
	color: var(--scstore-color-burgundy);
}

.scstore-cart__notices {
	max-inline-size: var(--scstore-container);
	margin-inline: auto;
	padding-inline: 20px;
}

.scstore-cart__notices:empty {
	display: none;
}

.scstore-cart__layout {
	max-inline-size: var(--scstore-container);
	margin-inline: auto;
	padding-inline: 20px;
}

/* ==========================================================================
 * LINE ITEMS
 *
 * The element is a real <table>. At mobile it is laid out as cards, which
 * changes its `display` — so woocommerce/cart/cart.php restates role="table",
 * role="row" and role="cell" to keep the semantics that change would strip.
 * ========================================================================== */

.scstore-cart-table {
	inline-size: 100%;
	border-collapse: collapse;
}

/* Mobile: the header row is not drawn at all — each row is a self-describing
 * card, and the columns it labels no longer exist. */
.scstore-cart-table thead {
	position: absolute;
	inline-size: 1px;
	block-size: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

.scstore-cart-table,
.scstore-cart-table tbody,
.scstore-cart-table tr,
.scstore-cart-table td {
	display: block;
}

.scstore-cart-table tbody {
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding-block-start: 20px;
}

.woocommerce-cart-form__cart-item {
	display: grid;
	grid-template-columns: 84px 1fr;
	gap: 14px;
	padding: var(--scstore-space-12);
	background-color: var(--scstore-color-surface-warm);
	border: 1px solid var(--scstore-color-surface-warm-2);
	border-radius: 4px;
}

.woocommerce-cart-form__cart-item .product-name {
	grid-column: 1 / -1;
	display: grid;
	grid-template-columns: 84px 1fr;
	gap: 14px;
}

.scstore-cart-item {
	display: contents;
}

.scstore-cart-item__frame {
	display: block;
	inline-size: 84px;
	block-size: 108px;
	overflow: hidden;
	background-color: var(--scstore-color-surface-alt);
	border-radius: 2px;
}

.scstore-cart-item__frame a,
.scstore-cart-item__frame img {
	display: block;
	inline-size: 100%;
	block-size: 100%;
	object-fit: cover;
	object-position: var(--scstore-focal, 50% 50%);
}

.scstore-cart-item__text {
	display: flex;
	flex-direction: column;
	min-inline-size: 0;
}

.scstore-cart-item__name-ar {
	font-size: var(--scstore-text-19);
	font-weight: var(--scstore-weight-semibold);
	line-height: var(--scstore-lh-100);
}

.scstore-cart-item__name {
	margin-block-start: 3px;
	font-size: var(--scstore-text-12-5);
	color: var(--scstore-color-text-copy);
}

.scstore-cart-item__name a {
	color: inherit;
}

.scstore-cart-item__name a:hover {
	color: var(--scstore-color-burgundy);
}

.scstore-cart-item__meta {
	margin-block-start: 5px;
	font-size: var(--scstore-text-11-5);
	color: var(--scstore-color-text-muted);
}

/*
 * Mobile places quantity and line total on one row at the foot of the card, and
 * the remove control in the card's top-right corner. Both are table cells, so
 * they are positioned rather than reordered.
 */
.woocommerce-cart-form__cart-item .product-quantity,
.woocommerce-cart-form__cart-item .product-subtotal {
	grid-row: 2;
	align-self: end;
	padding-block-start: 10px;
}

.woocommerce-cart-form__cart-item .product-quantity {
	grid-column: 1;
}

.woocommerce-cart-form__cart-item .product-subtotal {
	grid-column: 2;
	text-align: end;
	font-size: var(--scstore-text-15);
	font-weight: var(--scstore-weight-semibold);
}

.woocommerce-cart-form__cart-item .product-remove {
	position: absolute;
	inset-inline-end: var(--scstore-space-12);
	margin-block-start: 2px;
}

.woocommerce-cart-form__cart-item {
	position: relative;
}

.scstore-cart-item__remove {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	/* 44px target without a 44px box: the padding is transparent. */
	padding: 14px;
	margin: -14px;
	color: var(--scstore-color-beige-mid);
	transition: color var(--scstore-duration-fast) ease;
}

.scstore-cart-item__remove:hover,
.scstore-cart-item__remove:focus-visible {
	color: var(--scstore-color-burgundy);
}

/* The quantity stepper is the Phase 3 component; only its frame differs here. */
.woocommerce-cart-form__cart-item .quantity {
	display: flex;
	align-items: center;
	block-size: 38px;
	inline-size: max-content;
	border: var(--scstore-border-width-input) solid var(--scstore-color-border-strong);
	border-radius: var(--scstore-radius-sm);
	background-color: var(--scstore-color-bg);
}

.woocommerce-cart-form__cart-item .quantity .scstore-qty__btn {
	inline-size: 32px;
	font-size: var(--scstore-text-16);
}

.woocommerce-cart-form__cart-item .quantity .qty {
	inline-size: 22px;
	font-size: var(--scstore-text-13);
}

/*
 * Woo's own "Update cart" submit. With JavaScript it is redundant — a quantity
 * change submits the form — but it is the only way to apply one without, so it
 * is hidden by script rather than by CSS. See assets/js/cart.js.
 */
.scstore-cart-table .actions {
	padding-block-start: var(--scstore-space-16);
}

.scstore-cart__update {
	font-size: var(--scstore-text-12-5);
	font-weight: var(--scstore-weight-semibold);
	letter-spacing: var(--scstore-ls-10);
	text-transform: uppercase;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.scstore-cart__continue {
	display: inline-flex;
	align-items: center;
	gap: var(--scstore-space-8);
	margin-block-start: 28px;
	font-size: var(--scstore-text-12-5);
	font-weight: var(--scstore-weight-semibold);
	letter-spacing: var(--scstore-ls-10);
	text-transform: uppercase;
	color: var(--scstore-color-ink);
}

.scstore-cart__continue:hover {
	color: var(--scstore-color-burgundy);
}

/* ==========================================================================
 * FREE-SHIPPING NOTE
 * ========================================================================== */

.scstore-ship-progress {
	background-color: var(--scstore-color-surface-warm-2);
	padding: var(--scstore-space-12) 14px;
	border-radius: var(--scstore-radius-sm);
}

.scstore-ship-progress--mobile {
	max-inline-size: var(--scstore-container);
	margin: 20px auto 0;
	/* The note sits inside the page gutter, not against the viewport edge. */
	margin-inline: 20px;
}

.scstore-ship-progress__message {
	margin: 0;
	font-size: var(--scstore-text-12);
	line-height: var(--scstore-lh-140);
	color: var(--scstore-color-status-neutral-fg);
}

.scstore-ship-progress__track {
	block-size: 5px;
	margin-block-start: 9px;
	background-color: var(--scstore-color-track);
	border-radius: var(--scstore-radius-sm);
	overflow: hidden;
}

.scstore-ship-progress__bar {
	display: block;
	block-size: 100%;
	background-color: var(--scstore-color-burgundy);
	border-radius: var(--scstore-radius-sm);
}

/* Inside the summary the note is a plain message with the panel's own rhythm. */
.scstore-ship-progress--summary {
	margin-block: 6px 20px;
	font-size: var(--scstore-text-12-5);
	line-height: var(--scstore-lh-150);
}

.scstore-ship-progress--summary .scstore-ship-progress__message {
	font-size: var(--scstore-text-12-5);
	line-height: var(--scstore-lh-150);
}

/* ==========================================================================
 * SUMMARY PANEL
 * ========================================================================== */

.scstore-cart__aside {
	margin-block-start: 24px;
}

.scstore-cart-summary__title {
	margin: 0 0 24px;
	font-size: var(--scstore-text-12);
	font-weight: var(--scstore-weight-semibold);
	letter-spacing: var(--scstore-ls-14);
	text-transform: uppercase;
	color: var(--scstore-color-ink);
}

.scstore-cart-summary__lines {
	margin: 0;
}

.scstore-cart-summary__line {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: var(--scstore-space-16);
	margin-block-end: var(--scstore-space-12);
	font-size: var(--scstore-text-14);
	color: var(--scstore-color-text-copy);
}

.scstore-cart-summary__line dt,
.scstore-cart-summary__line dd {
	margin: 0;
}

.scstore-cart-summary__line dd {
	font-weight: var(--scstore-weight-semibold);
	color: var(--scstore-color-ink);
}

/*
 * WooCommerce's shipping block. It prints the available methods as radios when
 * there is a choice, and as plain text when there is only one — both are Woo's
 * own markup, restyled.
 */
.scstore-cart-summary__shipping {
	font-size: var(--scstore-text-14);
	color: var(--scstore-color-text-copy);
}

.scstore-cart-summary__shipping ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

.scstore-cart-summary__shipping li {
	display: flex;
	align-items: baseline;
	gap: var(--scstore-space-8);
	margin-block-end: var(--scstore-space-8);
}

.scstore-cart-summary__shipping label {
	display: flex;
	inline-size: 100%;
	align-items: baseline;
	justify-content: space-between;
	gap: var(--scstore-space-8);
}

.scstore-cart-summary__shipping .amount {
	font-weight: var(--scstore-weight-semibold);
	color: var(--scstore-color-ink);
}

.scstore-cart-summary__shipping p {
	margin: 0;
	font-size: var(--scstore-text-12);
	color: var(--scstore-color-text-muted);
}

.scstore-cart-summary__total {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	padding-block-start: 20px;
	border-block-start: 1px solid var(--scstore-color-border-strong);
}

.scstore-cart-summary__total-label {
	font-size: var(--scstore-text-16);
	font-weight: var(--scstore-weight-semibold);
}

.scstore-cart-summary__total-value {
	font-size: var(--scstore-text-22);
	font-weight: var(--scstore-weight-semibold);
}

/* Woo prints its checkout button through `woocommerce_proceed_to_checkout`. */
.scstore-cart-summary .checkout-button,
.scstore-cart-summary .wc-proceed-to-checkout a.button {
	display: flex;
	align-items: center;
	justify-content: center;
	margin-block-start: 24px;
	block-size: 56px;
	border-radius: var(--scstore-radius-sm);
	background-color: var(--scstore-color-burgundy);
	color: var(--scstore-color-text-on-dark);
	font-size: var(--scstore-text-13);
	font-weight: var(--scstore-weight-semibold);
	letter-spacing: var(--scstore-ls-10);
	text-transform: uppercase;
	transition: background-color var(--scstore-duration-fast) ease;
}

.scstore-cart-summary .checkout-button:hover {
	background-color: var(--scstore-color-burgundy-hover);
}

/* ==========================================================================
 * DISCOUNT FIELD
 * ========================================================================== */

.scstore-coupon {
	margin-block-end: 22px;
}

.scstore-coupon__row {
	display: flex;
	gap: 10px;
}

.scstore-coupon__input {
	flex: 1;
	min-inline-size: 0;
	block-size: 46px;
	padding-inline: 14px;
	border: var(--scstore-border-width-input) solid var(--scstore-color-border-strong);
	border-radius: var(--scstore-radius-sm);
	background-color: transparent;
	font-family: var(--scstore-font-body);
	font-size: var(--scstore-text-13-5);
	color: var(--scstore-color-ink);
}

.scstore-coupon__input:focus-visible {
	outline: 2px solid var(--scstore-color-burgundy);
	outline-offset: 2px;
}

.scstore-coupon__submit {
	flex: 0 0 auto;
	block-size: 46px;
	padding-inline: 20px;
	border: var(--scstore-border-width-input) solid var(--scstore-color-ink);
	border-radius: var(--scstore-radius-sm);
	background-color: transparent;
	color: var(--scstore-color-ink);
	font-size: var(--scstore-text-12);
	font-weight: var(--scstore-weight-semibold);
	letter-spacing: var(--scstore-ls-08);
	text-transform: uppercase;
}

.scstore-coupon__submit:hover {
	background-color: var(--scstore-color-ink);
	color: var(--scstore-color-text-on-dark);
}

/* ==========================================================================
 * MOBILE SUMMARY AND STICKY BAR
 * ========================================================================== */

.scstore-cart-summary {
	padding-block-start: 24px;
}

/*
 * At mobile the summary shows subtotal and shipping only; the total moves to
 * the sticky bar, and the panel has no background of its own.
 */
.scstore-cart-summary__total,
.scstore-cart-summary .wc-proceed-to-checkout {
	display: none;
}

.scstore-cart-sticky {
	position: fixed;
	inset-inline: 0;
	inset-block-end: 0;
	z-index: var(--scstore-z-sticky);
	background-color: rgba(250, 247, 242, 0.97);
	backdrop-filter: blur(8px);
	border-block-start: var(--scstore-border-hairline);
	padding: 16px 18px calc(16px + env(safe-area-inset-bottom));
}

.scstore-cart-sticky__total {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	margin-block-end: var(--scstore-space-12);
}

.scstore-cart-sticky__label {
	font-size: var(--scstore-text-14);
	font-weight: var(--scstore-weight-semibold);
}

.scstore-cart-sticky__value {
	font-size: var(--scstore-text-20);
	font-weight: var(--scstore-weight-semibold);
}

.scstore-cart-sticky__cta {
	display: flex;
	align-items: center;
	justify-content: center;
	block-size: 54px;
	border-radius: var(--scstore-radius-sm);
	background-color: var(--scstore-color-burgundy);
	color: var(--scstore-color-text-on-dark);
	font-size: var(--scstore-text-12-5);
	font-weight: var(--scstore-weight-semibold);
	letter-spacing: var(--scstore-ls-10);
	text-transform: uppercase;
}

/* ==========================================================================
 * DESKTOP
 * ========================================================================== */

@media (min-width: 1024px) {
	.scstore-cart {
		padding-block-end: 100px;
	}

	.scstore-cart__head {
		padding-block-start: 48px;
		padding-inline: var(--scstore-gutter);
	}

	.scstore-cart .scstore-breadcrumb {
		margin-block-end: 26px;
	}

	.scstore-cart__title {
		display: flex;
		align-items: flex-end;
		gap: var(--scstore-space-16);
		margin-block-end: 40px;
		flex-wrap: wrap;
	}

	.scstore-cart__heading {
		font-size: var(--scstore-text-56);
		line-height: 0.92;
	}

	.scstore-cart__heading-ar {
		font-size: var(--scstore-text-26);
		padding-block-end: var(--scstore-space-8);
	}

	.scstore-cart__notices,
	.scstore-cart__layout {
		padding-inline: var(--scstore-gutter);
	}

	.scstore-cart__layout {
		display: grid;
		grid-template-columns: 1fr 400px;
		gap: 56px;
		align-items: start;
	}

	/* The mobile-only note; desktop shows it inside the summary instead. */
	.scstore-ship-progress--mobile {
		display: none;
	}

	/* --- the line-item table becomes a real table again --- */

	.scstore-cart-table {
		display: table;
		table-layout: fixed;
	}

	.scstore-cart-table thead {
		position: static;
		inline-size: auto;
		block-size: auto;
		overflow: visible;
		clip-path: none;
		white-space: normal;
		display: table-header-group;
	}

	.scstore-cart-table tbody {
		display: table-row-group;
		padding-block-start: 0;
	}

	/*
	 * Every row and cell has to be restored, not just the item rows: a `<tr>`
	 * left as `display: block` drops out of the table's column model, and the
	 * header row then sizes its cells independently of the body's — which is
	 * exactly what happened, leaving the quantity and price columns bunched
	 * against the product name instead of aligned under their headings.
	 */
	.scstore-cart-table tr {
		display: table-row;
	}

	.scstore-cart-table td {
		display: table-cell;
	}

	.scstore-cart-table thead th {
		padding-block-end: var(--scstore-space-16);
		border-block-end: 1px solid var(--scstore-color-ink);
		font-size: var(--scstore-text-11);
		font-weight: var(--scstore-weight-regular);
		letter-spacing: var(--scstore-ls-14);
		text-transform: uppercase;
		color: var(--scstore-color-text-muted);
		text-align: start;
	}

	.scstore-cart-table thead .product-quantity {
		inline-size: 120px;
		text-align: center;
	}

	.scstore-cart-table thead .product-subtotal {
		inline-size: 90px;
		text-align: end;
	}

	.scstore-cart-table thead .product-remove {
		inline-size: 24px;
	}

	.woocommerce-cart-form__cart-item {
		display: table-row;
		position: static;
		background: none;
		border: 0;
		border-radius: 0;
		padding: 0;
	}

	.woocommerce-cart-form__cart-item td {
		display: table-cell;
		vertical-align: middle;
		padding-block: 26px;
		border-block-end: var(--scstore-border-hairline);
	}

	.woocommerce-cart-form__cart-item .product-name {
		display: table-cell;
	}

	.scstore-cart-item {
		display: flex;
		align-items: center;
		gap: 20px;
	}

	.scstore-cart-item__frame {
		inline-size: 96px;
		block-size: 124px;
		border-radius: 0;
	}

	.scstore-cart-item__name-ar {
		font-size: var(--scstore-text-22);
	}

	.scstore-cart-item__name {
		margin-block-start: 5px;
		font-size: var(--scstore-text-14);
	}

	.scstore-cart-item__meta {
		margin-block-start: var(--scstore-space-8);
		font-size: var(--scstore-text-12-5);
	}

	.woocommerce-cart-form__cart-item .product-quantity,
	.woocommerce-cart-form__cart-item .product-subtotal {
		padding-block-start: 26px;
	}

	.woocommerce-cart-form__cart-item .quantity {
		block-size: 44px;
		inline-size: 120px;
		justify-content: space-between;
		background: none;
	}

	.woocommerce-cart-form__cart-item .quantity .scstore-qty__btn {
		inline-size: 38px;
		font-size: var(--scstore-text-17);
	}

	.woocommerce-cart-form__cart-item .quantity .qty {
		inline-size: 34px;
		font-size: var(--scstore-text-14);
	}

	.woocommerce-cart-form__cart-item .product-remove {
		position: static;
		inline-size: 24px;
		text-align: center;
		margin-block-start: 0;
	}

	/* --- summary --- */

	.scstore-cart__aside {
		margin-block-start: 0;
	}

	.scstore-cart-summary {
		padding: 36px 32px;
		background-color: var(--scstore-color-surface-warm);
		border: 1px solid var(--scstore-color-surface-warm-2);
	}

	.scstore-cart-summary__line {
		margin-block-end: 14px;
		font-size: var(--scstore-text-14-5);
	}

	.scstore-cart-summary__total,
	.scstore-cart-summary .wc-proceed-to-checkout {
		display: block;
	}

	.scstore-cart-summary__total {
		display: flex;
	}

	.scstore-cart-sticky {
		display: none;
	}
}
