/*
 * Kensington cart -- mobile first.
 *
 * Same design language as checkout.css: identical tokens, card sections, 54px
 * controls, 16px inputs, gold primary CTA. Base styles target ~390px with no
 * media query; wider viewports are enhancements at the bottom.
 *
 * Scoped to body.ken-cart-page so nothing leaks into shop, account or checkout.
 */

body.ken-cart-page {
	--ken-co-gap: 0.75rem;
	--ken-co-radius: 12px;
	--ken-co-border: #e6e3dc;
	--ken-co-ink: #1c1b19;
	--ken-co-muted: #6c6862;
	--ken-co-gold: #b6893e;
	--ken-co-bg: #faf9f7;
	--ken-co-card: #ffffff;
	--ken-co-ok: #1f7a4d;

	background: var(--ken-co-bg);
}

/* The desktop-era hero and step rail are noise on a phone. */
body.ken-cart-page .cart-hero-banner,
body.ken-cart-page .commerce-steps,
body.ken-cart-page .commerce-trust-row,
body.ken-cart-page .commerce-section-heading {
	display: none;
}

/* ---------------------------------------------------------------------------
 * Upsell offer bar
 * The upsell plugin prints its cart offer on woocommerce_before_cart, which is
 * outside .ken-cart, so it ran edge to edge above a cart that sits in a centred
 * column. Give it the cart's own measure and gutters at every breakpoint so the
 * two line up.
 * ------------------------------------------------------------------------- */

body.ken-cart-page .cuw-offer,
body.ken-cart-page .cuw-offers {
	max-width: 100%;
	margin-left: auto;
	margin-right: auto;
	padding-left: 1rem;
	padding-right: 1rem;
}

/* Nested wrappers must not add the gutter a second time. */
body.ken-cart-page .cuw-offers .cuw-offer {
	max-width: none;
	padding-left: 0;
	padding-right: 0;
}

/* ---------------------------------------------------------------------------
 * Shell
 * ------------------------------------------------------------------------- */

.ken-cart {
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--ken-co-gap);
	max-width: 100%;
	padding: 1rem 1rem 0;
	margin: 0 auto;
	color: var(--ken-co-ink);
}

.ken-cart > * {
	min-width: 0;
}

.ken-cart__header {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.75rem;
}

.ken-cart__title {
	margin: 0;
	font-size: 1.25rem;
	font-weight: 700;
	letter-spacing: -0.01em;
}

.ken-cart__count {
	font-size: 0.8125rem;
	color: var(--ken-co-muted);
}

.ken-cart__section {
	background: var(--ken-co-card);
	border: 1px solid var(--ken-co-border);
	border-radius: var(--ken-co-radius);
	padding: 0.25rem 1rem;
	min-width: 0;
}

.ken-cart__panel-title {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0 0 0.75rem;
	font-size: 0.8125rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--ken-co-muted);
}

/* ---------------------------------------------------------------------------
 * Line items
 *
 * A two-column grid: thumbnail, then everything else. At 390px a table would
 * either scroll sideways or crush the product name to two characters wide.
 * ------------------------------------------------------------------------- */

.ken-cart-item {
	display: grid;
	grid-template-columns: 72px minmax(0, 1fr);
	gap: 0.875rem;
	padding: 1rem 0;
	border-bottom: 1px solid var(--ken-co-border);
}

.ken-cart-item:last-of-type {
	border-bottom: 0;
}

.ken-cart-item__thumb {
	width: 72px;
	height: 72px;
	border-radius: 10px;
	overflow: hidden;
	background: var(--ken-co-bg);
	border: 1px solid var(--ken-co-border);
}

.ken-cart-item__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.ken-cart-item__body {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	min-width: 0;
}

.ken-cart-item__head {
	display: flex;
	align-items: flex-start;
	gap: 0.5rem;
}

.ken-cart-item__name {
	flex: 1 1 auto;
	min-width: 0;
	font-size: 0.9375rem;
	font-weight: 600;
	line-height: 1.35;
}

.ken-cart-item__name a {
	color: inherit;
	text-decoration: none;
}

.ken-cart-item__meta,
.ken-cart-item__meta p {
	margin: 0.125rem 0 0;
	font-size: 0.8125rem;
	color: var(--ken-co-muted);
}

.ken-cart-item__unit {
	font-size: 0.8125rem;
	color: var(--ken-co-muted);
}

/* Remove: a quiet icon, but a full 44px target. */
.ken-cart-item__remove {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 44px;
	height: 44px;
	margin: -0.5rem -0.5rem 0 0;
	border-radius: 8px;
	color: var(--ken-co-muted);
	text-decoration: none;
	font-size: 1rem;
}

.ken-cart-item__remove:hover,
.ken-cart-item__remove:focus-visible {
	color: #c0392b;
	background: #fdf3f2;
}

.ken-cart-item__foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
}

.ken-cart-item__subtotal {
	font-size: 1rem;
	font-weight: 700;
	white-space: nowrap;
}

/* Quantity stepper: 44px targets either side of a 16px field. */
body.ken-cart-page .quantity {
	display: inline-flex;
	align-items: center;
	border: 1px solid var(--ken-co-border);
	border-radius: 10px;
	overflow: hidden;
	background: var(--ken-co-card);
}

body.ken-cart-page .quantity .qty {
	width: 48px;
	min-height: 44px;
	padding: 0.5rem 0.25rem;
	border: 0;
	border-left: 1px solid var(--ken-co-border);
	border-right: 1px solid var(--ken-co-border);
	text-align: center;
	font-size: 16px; /* do not lower: prevents iOS focus zoom */
	background: transparent;
	color: var(--ken-co-ink);
	appearance: textfield;
	-moz-appearance: textfield;
}

body.ken-cart-page .quantity .qty::-webkit-outer-spin-button,
body.ken-cart-page .quantity .qty::-webkit-inner-spin-button {
	appearance: none;
	margin: 0;
}

body.ken-cart-page .quantity .qty:focus {
	outline: none;
	box-shadow: inset 0 0 0 2px rgba(182, 137, 62, 0.35);
}

body.ken-cart-page .ken-qty-step {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	min-height: 44px;
	border: 0;
	background: transparent;
	color: var(--ken-co-ink);
	font-size: 1.125rem;
	line-height: 1;
	cursor: pointer;
}

body.ken-cart-page .ken-qty-step:hover {
	background: var(--ken-co-bg);
}

body.ken-cart-page .ken-qty-step[disabled] {
	opacity: 0.35;
	cursor: not-allowed;
}

/* ---------------------------------------------------------------------------
 * Coupon disclosure + cart actions
 * ------------------------------------------------------------------------- */

.ken-disclosure {
	margin: 0;
	padding: 0.25rem 0 0.75rem;
}

.ken-disclosure__toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.375rem;
	min-height: 44px;
	padding: 0.5rem 0;
	border: 0;
	background: none;
	font: inherit;
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--ken-co-gold);
	cursor: pointer;
}

.ken-disclosure__toggle::before {
	content: "+";
	font-weight: 700;
	line-height: 1;
}

.ken-disclosure__toggle[aria-expanded="true"]::before {
	content: "−";
}

.ken-disclosure__panel[hidden] {
	display: none;
}

.ken-cart-coupon {
	display: flex;
	gap: 0.5rem;
	padding-bottom: 0.5rem;
}

body.ken-cart-page .ken-cart-coupon .input-text {
	flex: 1 1 auto;
	min-width: 0;
	min-height: 52px;
	padding: 0.75rem 0.875rem;
	font-size: 16px; /* no iOS zoom */
	border: 1px solid var(--ken-co-border);
	border-radius: 10px;
	background: var(--ken-co-card);
	color: var(--ken-co-ink);
}

body.ken-cart-page .ken-cart-coupon .input-text:focus {
	outline: none;
	border-color: var(--ken-co-gold);
	box-shadow: 0 0 0 3px rgba(182, 137, 62, 0.18);
}

body.ken-cart-page .ken-cart-coupon button {
	flex: 0 0 auto;
	min-height: 52px;
	padding: 0.75rem 1.125rem;
	border: 1.5px solid var(--ken-co-ink);
	border-radius: 10px;
	background: var(--ken-co-card);
	color: var(--ken-co-ink);
	font-size: 0.875rem;
	font-weight: 700;
	cursor: pointer;
}

body.ken-cart-page .ken-cart-coupon button:hover {
	background: var(--ken-co-ink);
	color: #fff;
}

/*
 * "Update cart" stays in the DOM as the no-JS fallback -- cart.js submits it
 * automatically after a quantity change -- so it is de-emphasised rather than
 * removed. It re-emphasises itself when there is an unsaved change.
 */
.ken-cart-update {
	display: flex;
	justify-content: flex-end;
	padding-bottom: 0.75rem;
}

body.ken-cart-page .ken-cart-update button {
	min-height: 44px;
	padding: 0.5rem 0.875rem;
	border: 1px solid var(--ken-co-border);
	border-radius: 10px;
	background: var(--ken-co-card);
	color: var(--ken-co-muted);
	font-size: 0.8125rem;
	font-weight: 600;
	cursor: pointer;
}

body.ken-cart-page .ken-cart-update.is-dirty button {
	border-color: var(--ken-co-gold);
	color: var(--ken-co-ink);
}

/* ---------------------------------------------------------------------------
 * Totals
 * ------------------------------------------------------------------------- */

body.ken-cart-page .cart_totals {
	background: var(--ken-co-card);
	border: 1px solid var(--ken-co-border);
	border-radius: var(--ken-co-radius);
	padding: 1rem;
}

.ken-total-row {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.75rem;
	padding: 0.5rem 0;
	font-size: 0.875rem;
}

.ken-total-row__label {
	color: var(--ken-co-muted);
}

.ken-total-row__value {
	font-weight: 600;
	text-align: right;
}

/* The one number that matters, sized like the checkout's pay total. */
.ken-total-row--grand {
	align-items: center;
	margin-top: 0.25rem;
	padding-top: 0.875rem;
	border-top: 1px solid var(--ken-co-border);
}

.ken-total-row--grand .ken-total-row__label {
	font-size: 0.8125rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--ken-co-muted);
}

.ken-total-row--grand .ken-total-row__value {
	font-size: 1.75rem;
	font-weight: 700;
	line-height: 1.1;
	letter-spacing: -0.02em;
	color: var(--ken-co-ink);
}

/*
 * Shipping row.
 *
 * WooCommerce prints this one as raw table markup (tr > th + td). Dropped into
 * the flex .ken-total-row it blockified into an anonymous table and laid the
 * package name, the method, the destination and the "Change address" toggle out
 * as one long line. Take the table display types off and rebuild the row the
 * way every other total row reads: label left, value right, with the
 * destination and the calculator toggle each on their own line beneath.
 */
body.ken-cart-page .kensington-shipping-rows {
	display: block;
}

body.ken-cart-page .woocommerce-shipping-totals {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.75rem;
	width: 100%;
}

body.ken-cart-page .woocommerce-shipping-totals > th {
	display: block;
	flex: 0 0 auto;
	font-size: 0.875rem;
	font-weight: 400;
	text-align: left;
	color: var(--ken-co-muted);
}

body.ken-cart-page .woocommerce-shipping-totals > td {
	display: block;
	flex: 1 1 auto;
	min-width: 0;
	font-size: 0.875rem;
	text-align: right;
}

body.ken-cart-page .kensington-shipping-rows ul,
body.ken-cart-page .woocommerce-shipping-methods {
	margin: 0;
	padding: 0;
	list-style: none;
}

body.ken-cart-page .woocommerce-shipping-methods li {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 0.5rem;
	padding: 0;
	font-size: 0.875rem;
	font-weight: 600;
}

body.ken-cart-page .woocommerce-shipping-methods input[type="radio"] {
	width: 20px;
	height: 20px;
	accent-color: var(--ken-co-gold);
}

body.ken-cart-page .woocommerce-shipping-destination {
	margin: 0.25rem 0 0;
	font-weight: 400;
	line-height: 1.4;
	color: var(--ken-co-muted);
}

/* Its own line, under the address it changes. */
body.ken-cart-page .woocommerce-shipping-calculator {
	display: block;
	margin: 0.35rem 0 0;
}

body.ken-cart-page .shipping-calculator-button {
	display: inline-block;
	font-size: 0.8125rem;
	color: var(--ken-co-gold);
}

/* Primary CTA -- identical treatment to the checkout's pay button. */
body.ken-cart-page .wc-proceed-to-checkout {
	margin-top: 0.875rem;
}

body.ken-cart-page .wc-proceed-to-checkout .checkout-button {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	width: 100%;
	min-height: 58px;
	padding: 0.875rem 1.25rem;
	border: 0;
	border-radius: 12px;
	background: var(--ken-co-gold);
	color: #1c1b19;
	font-size: 1.0625rem;
	font-weight: 800;
	letter-spacing: 0.02em;
	text-decoration: none;
	transition: background-color 0.15s ease;
}

body.ken-cart-page .wc-proceed-to-checkout .checkout-button:hover {
	background: #c99a4e;
	color: #1c1b19;
}

body.ken-cart-page .wc-proceed-to-checkout .checkout-button:focus-visible {
	outline: 3px solid #1c1b19;
	outline-offset: 2px;
}

/*
 * style.css sets `background/color/border ... !important` on
 * `body.woocommerce-cart a.checkout-button`, which would repaint this CTA with
 * white text. !important is matched here only for the three properties that
 * rule actually forces -- the legacy sheet is left untouched, exactly as on the
 * checkout, so nothing else on the site changes.
 */
body.ken-cart-page a.checkout-button,
body.ken-cart-page a.checkout-button.button,
body.ken-cart-page a.checkout-button.button.alt {
	border-color: transparent !important;
	background: var(--ken-co-gold) !important;
	color: #1c1b19 !important;
	box-shadow: none;
}

body.ken-cart-page a.checkout-button:hover,
body.ken-cart-page a.checkout-button:focus-visible {
	border-color: transparent !important;
	background: #c99a4e !important;
	color: #1c1b19 !important;
}

.ken-cart-reassurance {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.25rem 1rem;
	margin: 0.75rem 0 0;
	font-size: 0.75rem;
	color: var(--ken-co-muted);
	text-align: center;
}

.ken-cart-reassurance i {
	color: var(--ken-co-ok);
}

.ken-cart__continue {
	display: inline-flex;
	align-items: center;
	gap: 0.375rem;
	min-height: 44px;
	font-size: 0.875rem;
	color: var(--ken-co-muted);
	text-decoration: none;
}

.ken-cart__continue:hover {
	color: var(--ken-co-ink);
	text-decoration: underline;
}

/* ---------------------------------------------------------------------------
 * Empty state
 * ------------------------------------------------------------------------- */

.ken-cart-empty {
	max-width: 32rem;
	margin: 0 auto;
	padding: 2.5rem 1.25rem;
	text-align: center;
}

.ken-cart-empty__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 64px;
	height: 64px;
	margin-bottom: 1rem;
	border-radius: 50%;
	background: #f5f2ec;
	color: var(--ken-co-gold);
	font-size: 1.5rem;
}

.ken-cart-empty__title {
	margin: 0 0 0.5rem;
	font-size: 1.25rem;
	font-weight: 700;
}

.ken-cart-empty__text {
	margin: 0 0 1.25rem;
	font-size: 0.9375rem;
	color: var(--ken-co-muted);
}

body.ken-cart-page .ken-cart-empty .button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	min-height: 54px;
	padding: 0.875rem 1.75rem;
	border: 0;
	border-radius: 12px;
	background: var(--ken-co-gold);
	color: #1c1b19;
	font-size: 1rem;
	font-weight: 700;
	text-decoration: none;
}

/* ---------------------------------------------------------------------------
 * Sticky checkout bar (mobile only)
 * ------------------------------------------------------------------------- */

.ken-sticky-bar {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 40;
	background: var(--ken-co-card);
	border-top: 1px solid var(--ken-co-border);
	box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
	padding-bottom: env(safe-area-inset-bottom, 0px);
}

.ken-sticky-bar[hidden] {
	display: none;
}

.ken-sticky-bar__inner {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.625rem 1rem;
}

.ken-sticky-bar__total {
	display: flex;
	flex-direction: column;
	line-height: 1.15;
	min-width: 0;
}

.ken-sticky-bar__label {
	font-size: 0.6875rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--ken-co-muted);
}

.ken-sticky-bar__amount {
	font-size: 1.125rem;
	font-weight: 700;
	white-space: nowrap;
}

.ken-sticky-bar__button {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	flex: 1 1 auto;
	min-height: 52px;
	padding: 0.75rem 1rem;
	border-radius: 12px;
	background: var(--ken-co-gold);
	color: #1c1b19;
	font-size: 1rem;
	font-weight: 800;
	text-decoration: none;
}

body.ken-cart-page.has-sticky-bar {
	padding-bottom: 84px;
}

/* ---------------------------------------------------------------------------
 * Tablet and desktop
 * ------------------------------------------------------------------------- */

@media (min-width: 768px) {
	.ken-cart {
		max-width: 720px;
		padding: 1.5rem 1.5rem 0;
		--ken-co-gap: 1rem;
	}

	body.ken-cart-page .cuw-offer,
	body.ken-cart-page .cuw-offers {
		max-width: 720px;
		padding-left: 1.5rem;
		padding-right: 1.5rem;
	}

	.ken-cart-item {
		grid-template-columns: 88px minmax(0, 1fr);
	}

	.ken-cart-item__thumb {
		width: 88px;
		height: 88px;
	}
}

@media (min-width: 992px) {
	body.ken-cart-page .cuw-offer,
	body.ken-cart-page .cuw-offers {
		max-width: 1140px;
	}

	.ken-cart {
		max-width: 1140px;
		grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr);
		align-items: start;
		column-gap: 2rem;

		/*
		 * The summary spans a fixed number of rows (see below) so it can sit
		 * beside however many rows the left column happens to render. The rows
		 * it does not need are empty and zero-height -- but a row-gap is still
		 * drawn between every one of them, stacking into a band of dead space
		 * between the last card and the footer. Drop the row gap here and
		 * re-create it as margin on the left column's children, which only
		 * exist where there is real content.
		 */
		row-gap: 0;
	}

	.ken-cart > * {
		grid-column: 1;
	}

	.ken-cart > *:not(.ken-cart__summary) {
		margin-bottom: var(--ken-co-gap);
	}

	.ken-cart > *:not(.ken-cart__summary):last-child {
		margin-bottom: 0;
	}

	.ken-cart__header {
		grid-column: 1 / -1;
	}

	/* Totals become a sticky sidebar; it is short enough to stay pinned. */
	.ken-cart__summary {
		grid-column: 2;
		grid-row: 2 / span 99;
		position: sticky;
		top: 100px;
	}

	.ken-sticky-bar {
		display: none !important;
	}

	body.ken-cart-page.has-sticky-bar {
		padding-bottom: 0;
	}
}
