/*
 * Cart and checkout styles.
 *
 * Loaded only on WooCommerce cart, checkout and order-received pages.
 * Kept separate from main.css so the storefront restyle can proceed
 * without touching the commerce flow.
 */

/* -------------------------------------------------------------------------
 * Shared section shell
 * ---------------------------------------------------------------------- */

.ns-section {
	margin: 0 0 34px;
}

.ns-section__title {
	margin: 0 0 4px;
	font-size: 20px;
	letter-spacing: -.02em;
}

.ns-section__aside {
	margin: 0 0 18px;
	color: var(--muted);
	font-size: 14px;
}

.ns-section > .ns-fields,
.ns-section > .woocommerce-billing-fields__field-wrapper {
	margin-top: 18px;
}

/* -------------------------------------------------------------------------
 * Checkout layout
 * ---------------------------------------------------------------------- */

.ns-checkout__layout {
	display: grid;
	grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
	align-items: start;
	gap: 64px;
}

.ns-checkout__main {
	min-width: 0;
}

.ns-checkout__summary {
	position: sticky;
	top: 100px;
	min-width: 0;
}

.ns-summary {
	padding: 26px;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: var(--cream);
}

.ns-summary .ns-section__title {
	margin-bottom: 18px;
}

/* Summary table */
.woocommerce table.shop_table.ns-summary__table {
	width: 100%;
	margin: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
}

.ns-summary__table thead {
	display: none;
}

.ns-summary__table td,
.ns-summary__table th {
	padding: 12px 0;
	border: 0;
	vertical-align: top;
}

.ns-summary__table tbody tr + tr td {
	border-top: 1px solid var(--line);
}

.ns-summary__table .product-name {
	display: flex;
	gap: 14px;
	align-items: flex-start;
}

.ns-summary__thumb img {
	display: block;
	width: 58px;
	height: 58px;
	border-radius: var(--radius-sm);
	object-fit: cover;
}

.ns-summary__detail {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.ns-summary__title {
	font-weight: 650;
	line-height: 1.35;
}

.ns-summary__qty,
.ns-summary__detail .variation {
	color: var(--muted);
	font-size: 13px;
}

.ns-summary__table .product-total {
	text-align: right;
	font-weight: 650;
	white-space: nowrap;
}

.ns-summary__table tfoot th,
.ns-summary__table tfoot td {
	padding: 10px 0;
	font-size: 15px;
}

.ns-summary__table tfoot tr:first-child th,
.ns-summary__table tfoot tr:first-child td {
	padding-top: 18px;
	border-top: 1px solid var(--line);
}

.ns-summary__table tfoot th {
	font-weight: 500;
	text-align: left;
	color: var(--muted);
}

.ns-summary__table tfoot td {
	text-align: right;
	font-weight: 650;
}

.ns-summary__table tfoot tr.order-total th,
.ns-summary__table tfoot tr.order-total td {
	padding-top: 16px;
	border-top: 1px solid var(--line);
	color: var(--ink);
	font-size: 19px;
	font-weight: 800;
}

/* -------------------------------------------------------------------------
 * Form fields
 * ---------------------------------------------------------------------- */

.woocommerce form .ns-fields {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 16px;
}

.woocommerce form .ns-fields .form-row {
	margin: 0;
	padding: 0;
	float: none;
	width: auto;
}

/* Fields that should span the full row. */
.woocommerce form .ns-fields .form-row-wide,
.woocommerce form .ns-fields #billing_email_field,
.woocommerce form .ns-fields #billing_country_field,
.woocommerce form .ns-fields #billing_address_1_field,
.woocommerce form .ns-fields #billing_address_2_field,
.woocommerce form .ns-fields #shipping_country_field,
.woocommerce form .ns-fields #shipping_address_1_field,
.woocommerce form .ns-fields #shipping_address_2_field {
	grid-column: 1 / -1;
}

.woocommerce form .form-row label {
	display: block;
	margin-bottom: 6px;
	font-size: 14px;
	font-weight: 600;
}

.woocommerce form .form-row .optional {
	color: var(--muted);
	font-weight: 400;
}

.woocommerce form .form-row .required {
	color: #b3261e;
	text-decoration: none;
}

.woocommerce form .form-row input.input-text,
.woocommerce form .form-row textarea,
.woocommerce form .form-row select {
	width: 100%;
}

.woocommerce form .form-row textarea {
	min-height: 110px;
	resize: vertical;
}

.woocommerce form .form-row input.input-text:focus,
.woocommerce form .form-row textarea:focus,
.woocommerce form .form-row select:focus {
	border-color: var(--forest);
	outline: 2px solid var(--forest);
	outline-offset: 1px;
}

.woocommerce form .form-row.woocommerce-invalid input.input-text,
.woocommerce form .form-row.woocommerce-invalid select {
	border-color: #b3261e;
}

/* -------------------------------------------------------------------------
 * Delivery options
 * ---------------------------------------------------------------------- */

.ns-delivery__group {
	display: grid;
	gap: 10px;
	margin: 18px 0 0;
	padding: 0;
	border: 0;
}

.ns-delivery__option {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 18px;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: #fff;
	cursor: pointer;
	transition: border-color .15s ease, background-color .15s ease;
}

.ns-delivery__option:hover {
	border-color: var(--forest);
}

.ns-delivery__option:has(input:checked) {
	border-color: var(--forest);
	background: #f3f7f4;
	box-shadow: inset 0 0 0 1px var(--forest);
}

.ns-delivery__option:has(input:focus-visible) {
	outline: 2px solid var(--forest);
	outline-offset: 2px;
}

.ns-delivery__option input {
	width: 18px;
	height: 18px;
	margin: 0;
	accent-color: var(--forest);
	flex: none;
}

.ns-delivery__label {
	flex: 1 1 auto;
	font-weight: 600;
}

.ns-delivery__price {
	font-weight: 750;
	white-space: nowrap;
}

.ns-delivery__empty {
	margin: 18px 0 0;
	padding: 16px 18px;
	border: 1px dashed var(--line);
	border-radius: var(--radius);
	color: var(--muted);
}

.ns-delivery__package {
	margin: 8px 0 0;
	color: var(--muted);
	font-size: 13px;
}

/* -------------------------------------------------------------------------
 * Payment
 * ---------------------------------------------------------------------- */

.woocommerce-checkout #payment {
	padding: 0;
	border-radius: 0;
	background: transparent !important;
}

.woocommerce-checkout #payment ul.payment_methods {
	display: grid;
	gap: 10px;
	margin: 18px 0 0;
	padding: 0;
	border: 0;
}

.woocommerce-checkout #payment ul.payment_methods li {
	padding: 16px 18px;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: #fff;
	list-style: none;
}


.woocommerce-checkout #payment ul.payment_methods li:has(input:checked) {
	border-color: var(--forest);
	background: #f3f7f4;
	box-shadow: inset 0 0 0 1px var(--forest);
}

.woocommerce-checkout #payment ul.payment_methods li label {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	font-weight: 600;
}

.woocommerce-checkout #payment ul.payment_methods li input[type="radio"] {
	width: 18px;
	height: 18px;
	margin: 0;
	accent-color: var(--forest);
}

.woocommerce-checkout #payment div.payment_box {
	margin: 12px 0 0;
	padding: 14px 16px;
	border-radius: var(--radius-sm);
	background: var(--cream);
	color: var(--ink);
	font-size: 14px;
}

.woocommerce-checkout #payment div.payment_box::before {
	display: none;
}

.woocommerce-checkout #payment .form-row.place-order {
	margin: 22px 0 0;
	padding: 0;
}

.woocommerce-checkout #payment #place_order {
	width: 100%;
}

.woocommerce-checkout .woocommerce-terms-and-conditions-wrapper {
	margin-bottom: 16px;
	font-size: 14px;
}

/* -------------------------------------------------------------------------
 * Cart
 * ---------------------------------------------------------------------- */

.woocommerce table.cart.ns-cart-table {
	width: 100%;
	margin-bottom: 26px;
	border: 0;
	border-collapse: collapse;
}

.ns-cart-table thead th {
	padding: 0 0 14px;
	border-bottom: 1px solid var(--line);
	color: var(--muted);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
	text-align: left;
}

.ns-cart-table td {
	padding: 20px 12px 20px 0;
	border-bottom: 1px solid var(--line);
	vertical-align: middle;
}

.ns-cart-table td.product-thumbnail img {
	display: block;
	width: 84px;
	height: 84px;
	border-radius: var(--radius);
	object-fit: cover;
}

.ns-cart-table td.product-name a {
	font-weight: 650;
}

.ns-cart-table td.product-price,
.ns-cart-table td.product-subtotal {
	white-space: nowrap;
	font-weight: 650;
}

.ns-cart-table td.product-remove .remove {
	display: grid;
	place-items: center;
	width: 30px;
	height: 30px;
	border-radius: 999px;
	background: var(--cream);
	color: var(--muted) !important;
	font-size: 20px;
	line-height: 1;
	text-decoration: none;
}

.ns-cart-table td.product-remove .remove:hover {
	background: #f6dcd9;
	color: #b3261e !important;
}

.ns-cart-table td.actions {
	padding: 24px 0 0;
	border-bottom: 0;
}

.ns-cart-table td.actions .ns-coupon {
	display: inline-flex;
	gap: 8px;
	margin-right: 12px;
}

.ns-cart-table td.actions .ns-coupon input.input-text {
	min-width: 190px;
}

/* Quantity stepper */
.ns-qty {
	display: inline-flex;
	align-items: center;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: #fff;
	overflow: hidden;
}

.ns-qty__btn {
	width: 38px;
	height: 42px;
	border: 0;
	background: none;
	color: var(--ink);
	font-size: 17px;
	line-height: 1;
	cursor: pointer;
}

.ns-qty__btn:hover:not(:disabled) {
	background: var(--cream);
}

.ns-qty__btn:disabled {
	color: #b8c2bb;
	cursor: not-allowed;
}

.ns-qty__btn:focus-visible {
	outline: 2px solid var(--forest);
	outline-offset: -2px;
}

.woocommerce .ns-qty .quantity {
	margin: 0;
	float: none;
}

.woocommerce .ns-qty input.qty {
	width: 46px;
	height: 42px;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	text-align: center;
	font-weight: 650;
	-moz-appearance: textfield;
}

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

.ns-continue-shopping {
	display: inline-block;
	margin-bottom: 26px;
	font-weight: 650;
	color: var(--forest);
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* Cart totals */
.woocommerce-cart .cart-collaterals .cart_totals {
	float: none;
	width: min(100%, 460px);
	margin-left: auto;
	padding: 26px;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: var(--cream);
}

.woocommerce-cart .cart_totals h2 {
	margin: 0 0 16px;
	font-size: 20px;
}

.woocommerce-cart .cart_totals table {
	width: 100%;
	border: 0;
}

.woocommerce-cart .cart_totals table th,
.woocommerce-cart .cart_totals table td {
	padding: 10px 0;
	border: 0;
	border-bottom: 1px solid var(--line);
}

.woocommerce-cart .cart_totals table td {
	text-align: right;
	font-weight: 650;
}

.woocommerce-cart .cart_totals .order-total th,
.woocommerce-cart .cart_totals .order-total td {
	border-bottom: 0;
	font-size: 19px;
	font-weight: 800;
}

.woocommerce-cart .wc-proceed-to-checkout {
	padding: 18px 0 0;
}

.woocommerce-cart .wc-proceed-to-checkout .button,
.ns-button-disabled {
	display: flex;
	justify-content: center;
	width: 100%;
}

.ns-button-disabled {
	opacity: .5;
	cursor: not-allowed;
	pointer-events: none;
}

.ns-minimum-hint {
	margin: 10px 0 0;
	color: var(--muted);
	font-size: 13px;
	text-align: center;
}

/* Cross-sells */
.ns-cart-collaterals .cross-sells {
	margin-top: 56px;
}

/* Empty state */
.ns-cart-empty__title {
	margin: 6px 0 10px;
	font-size: calc(clamp(32px, 4vw, 46px) * var(--ns-heading-scale));
	letter-spacing: -.04em;
}

.ns-cart-empty__lead {
	max-width: 460px;
	margin: 0 auto 26px;
	color: var(--muted);
}

/* -------------------------------------------------------------------------
 * Order received
 * ---------------------------------------------------------------------- */

.ns-order-received {
	max-width: 720px;
	margin-inline: auto;
}

.ns-order-received__head {
	margin-bottom: 32px;
}

.ns-order-received__title {
	margin: 6px 0 10px;
	font-size: calc(clamp(32px, 4vw, 46px) * var(--ns-heading-scale));
	line-height: 1.1;
	letter-spacing: -.04em;
}

.ns-order-received__lead {
	margin: 0;
	color: var(--muted);
	font-size: 17px;
}

/*
 * Content-sized cells. Equal-width grid tracks (repeat(auto-fit, minmax(150px,
 * 1fr))) capped every cell at the same width regardless of what it held, so a
 * long email address overflowed its cell and was then clipped by the overflow
 * hidden that rounds the corners. A flex row with an auto basis lets each cell
 * take the width its content needs, share the slack, and wrap to a new row when
 * the content no longer fits.
 */
.woocommerce ul.order_details.ns-order-received__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 2px;
	margin: 0 0 32px;
	padding: 0;
	border-radius: var(--radius);
	overflow: hidden;
	background: var(--line);
}

.woocommerce ul.order_details.ns-order-received__meta li {
	flex: 1 1 auto;
	min-width: 150px;
	max-width: 100%;
	margin: 0;
	padding: 18px 20px;
	border: 0;
	background: var(--cream);
	list-style: none;
	float: none;
	font-size: 13px;
	text-transform: none;
}

.ns-order-received__meta li span {
	display: block;
	margin-bottom: 4px;
	color: var(--muted);
}

.ns-order-received__meta li strong {
	font-size: 16px;
	/* An email or a gateway title has no spaces to break on. */
	overflow-wrap: anywhere;
}

.ns-order-received__actions {
	margin-top: 32px;
}

.ns-order-received .woocommerce-order-details,
.ns-order-received .woocommerce-customer-details {
	margin-top: 40px;
}

/* -------------------------------------------------------------------------
 * Responsive
 * ---------------------------------------------------------------------- */

@media (max-width: 1024px) {
	.ns-checkout__layout {
		grid-template-columns: 1fr;
		gap: 40px;
	}

	/* Summary first on narrow screens so the order is visible up front. */
	.ns-checkout__summary {
		position: static;
		order: -1;
	}
}

@media (max-width: 768px) {
	.woocommerce form .ns-fields {
		grid-template-columns: 1fr;
	}

	.woocommerce table.cart.ns-cart-table thead {
		display: none;
	}

	.ns-cart-table tr.woocommerce-cart-form__cart-item {
		position: relative;
		display: grid;
		grid-template-columns: 84px minmax(0, 1fr);
		gap: 4px 16px;
		padding: 18px 0;
		border-bottom: 1px solid var(--line);
	}

	.ns-cart-table td {
		padding: 0;
		border: 0;
	}

	.ns-cart-table td.product-thumbnail {
		grid-row: 1 / span 3;
	}

	.ns-cart-table td.product-name,
	.ns-cart-table td.product-price,
	.ns-cart-table td.product-quantity {
		grid-column: 2;
	}

	.ns-cart-table td.product-remove {
		position: absolute;
		top: 18px;
		right: 0;
	}

	.ns-cart-table td.product-subtotal {
		grid-column: 2;
		padding-top: 6px;
	}

	.ns-cart-table td.product-subtotal::before {
		content: attr(data-title) ": ";
		color: var(--muted);
		font-weight: 400;
	}

	.ns-cart-table td.actions {
		display: grid;
		gap: 10px;
	}

	.ns-cart-table td.actions .ns-coupon {
		display: grid;
		grid-template-columns: minmax(0, 1fr) auto;
		margin-right: 0;
	}

	.ns-cart-table td.actions .ns-coupon input.input-text {
		min-width: 0;
	}

	.woocommerce-cart .cart-collaterals .cart_totals {
		width: 100%;
	}

	.ns-summary {
		padding: 20px;
	}
}
