/* ============================================
   CART BLOCK — Krem.no
   Styles for the WooCommerce Cart Block (React-based).
   Uses body.woocommerce-cart prefix to beat WC block defaults.
   All values use CSS variables from theme.json.
   ============================================ */

/* --- Outer wrapper --- */
body.woocommerce-cart .wp-block-woocommerce-cart {
	margin-bottom: var(--wp--custom--spacing--2-xl);
}

/* Space between the page-hero and the cart content */
body.woocommerce-cart .wc-block-components-sidebar-layout.wc-block-cart {
	margin-top: var(--wp--custom--spacing--lg);
}

/* --- Two-column layout: items left, totals right --- */
body.woocommerce-cart .wc-block-components-sidebar-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 360px;
	gap: var(--wp--custom--spacing--xl);
	align-items: start;
	flex-wrap: initial;
}

body.woocommerce-cart .wc-block-components-main,
body.woocommerce-cart .wc-block-components-sidebar {
	width: 100%;
	max-width: 100%;
	padding: 0;
	min-width: 0;
	margin: 0;
	float: none;
}

/* ============================================
   CART ITEMS TABLE (left column)
   ============================================ */

body.woocommerce-cart .wc-block-cart-items {
	background: var(--wp--preset--color--white);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--border-radius--lg);
	overflow: hidden;
}

/* Items table header */
body.woocommerce-cart .wc-block-cart-items__header {
	background: var(--wp--preset--color--background-alt);
	padding: var(--wp--custom--spacing--md) var(--wp--custom--spacing--lg);
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 700;
	color: var(--wp--preset--color--text);
}

body.woocommerce-cart .wc-block-cart-items__header th,
body.woocommerce-cart .wc-block-cart-items__row td {
	padding: var(--wp--custom--spacing--md) var(--wp--custom--spacing--lg);
}

/* Each cart item row */
body.woocommerce-cart .wc-block-cart-items__row {
	padding: var(--wp--custom--spacing--md) var(--wp--custom--spacing--lg);
	border-top: 1px solid var(--wp--preset--color--border);
	align-items: center;
}

body.woocommerce-cart .wc-block-cart-items__row:first-of-type {
	border-top: none;
}

/* Item thumbnail */
body.woocommerce-cart .wc-block-cart-item__image img {
	border-radius: var(--wp--custom--border-radius--default);
	object-fit: cover;
}

/* Item product name */
body.woocommerce-cart .wc-block-cart-item__product .wc-block-components-product-name {
	font-family: var(--wp--preset--font-family--heading);
	font-size: 1rem;
	font-weight: 700;
	color: var(--wp--preset--color--text);
	text-decoration: none;
	transition: color var(--wp--custom--transition);
}

body.woocommerce-cart .wc-block-cart-item__product .wc-block-components-product-name:hover {
	color: var(--wp--preset--color--primary);
}

/* Item metadata (description, variations) — show full text, no truncation */
body.woocommerce-cart .wc-block-cart-item__product .wc-block-components-product-metadata {
	font-size: var(--wp--preset--font-size--x-small);
	color: var(--wp--preset--color--text-muted);
	line-height: 1.5;
	margin-top: var(--wp--custom--spacing--xs);
	display: block;
	-webkit-line-clamp: unset;
	-webkit-box-orient: unset;
	overflow: visible;
	max-height: none;
}

body.woocommerce-cart .wc-block-cart-item__product .wc-block-components-product-metadata__description {
	display: block;
	-webkit-line-clamp: unset;
	-webkit-box-orient: unset;
	overflow: visible;
	max-height: none;
}

body.woocommerce-cart .wc-block-cart-item__product .wc-block-components-product-metadata p {
	margin: 0;
	display: block;
	-webkit-line-clamp: unset;
	-webkit-box-orient: unset;
	overflow: visible;
}

/* Item prices */
body.woocommerce-cart .wc-block-cart-item__prices .wc-block-components-product-price__value {
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	color: var(--wp--preset--color--text);
}

body.woocommerce-cart .wc-block-cart-item__prices .wc-block-components-sale-badge {
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--white);
	border-radius: var(--wp--custom--border-radius--pill);
	font-size: 0.7rem;
	font-weight: 700;
	text-transform: uppercase;
}

/* Item total (right side) */
body.woocommerce-cart .wc-block-cart-item__total .wc-block-components-product-price__value {
	font-family: var(--wp--preset--font-family--heading);
	font-size: 1.05rem;
	font-weight: 700;
	color: var(--wp--preset--color--primary);
}

/* ============================================
   QUANTITY SELECTOR (+/− built into the block)
   ============================================ */

body.woocommerce-cart .wc-block-components-quantity-selector {
	display: flex;
	align-items: center;
	border: 2px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--border-radius--pill);
	overflow: hidden;
	width: fit-content;
}

body.woocommerce-cart .wc-block-cart-items .wc-block-components-quantity-selector__button,
body.woocommerce-cart .wc-block-components-quantity-selector .wc-block-components-quantity-selector__button {
	width: 44px;
	height: 44px;
	border: none;
	background: var(--wp--preset--color--background-alt);
	font-size: 1.1rem;
	font-weight: 700;
	color: var(--wp--preset--color--text);
	cursor: pointer;
	line-height: 1;
	transition: background var(--wp--custom--transition);
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: none;
	opacity: 1;
}

body.woocommerce-cart .wc-block-cart-items .wc-block-components-quantity-selector__button:hover,
body.woocommerce-cart .wc-block-components-quantity-selector .wc-block-components-quantity-selector__button:hover {
	background: var(--wp--preset--color--cream);
	color: var(--wp--preset--color--text);
}

body.woocommerce-cart .wc-block-cart-items .wc-block-components-quantity-selector__button svg,
body.woocommerce-cart .wc-block-components-quantity-selector .wc-block-components-quantity-selector__button svg {
	fill: var(--wp--preset--color--text);
}

body.woocommerce-cart .wc-block-components-quantity-selector__input {
	width: 50px;
	height: 44px;
	border: none;
	text-align: center;
	font-family: var(--wp--preset--font-family--body);
	font-size: 1rem;
	font-weight: 600;
	color: var(--wp--preset--color--text);
	background: transparent;
	padding: 0;
	-moz-appearance: textfield;
}

body.woocommerce-cart .wc-block-components-quantity-selector__input::-webkit-inner-spin-button,
body.woocommerce-cart .wc-block-components-quantity-selector__input::-webkit-outer-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

/*
 * Remove button — red circle with white trash icon.
 * WC's selector is very specific (0,4,1):
 *   table.wc-block-cart-items .wc-block-cart-items__row .wc-block-cart-item__quantity .wc-block-cart-item__remove-link
 * We match it with body prefix to win.
 */
body.woocommerce-cart table.wc-block-cart-items .wc-block-cart-items__row .wc-block-cart-item__quantity .wc-block-cart-item__remove-link {
	visibility: visible;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	min-width: 32px;
	min-height: 32px;
	border-radius: 50%;
	background-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--white);
	font-size: 0;
	text-decoration: none;
	transition: background-color var(--wp--custom--transition);
	overflow: hidden;
	border: none;
	padding: 0;
	cursor: pointer;
}

body.woocommerce-cart table.wc-block-cart-items .wc-block-cart-items__row .wc-block-cart-item__quantity .wc-block-cart-item__remove-link:hover {
	background-color: var(--wp--preset--color--primary-dark);
	color: var(--wp--preset--color--white);
	text-decoration: none;
}

body.woocommerce-cart table.wc-block-cart-items .wc-block-cart-items__row .wc-block-cart-item__quantity .wc-block-cart-item__remove-link svg {
	fill: var(--wp--preset--color--white);
	width: 16px;
	height: 16px;
}

/* ============================================
   SIDEBAR (order summary + totals, right column)
   ============================================ */

body.woocommerce-cart .wc-block-components-sidebar.wc-block-cart__sidebar {
	background: var(--wp--preset--color--white);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--border-radius--lg);
	padding: var(--wp--custom--spacing--lg);
}

/* Cart totals title */
body.woocommerce-cart .wc-block-cart__totals-title {
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--large);
	font-weight: 700;
	color: var(--wp--preset--color--text);
	margin: 0 0 var(--wp--custom--spacing--md);
	padding-bottom: var(--wp--custom--spacing--md);
	border-bottom: 1px solid var(--wp--preset--color--border);
}

/* Totals rows — reuse checkout patterns */
body.woocommerce-cart .wc-block-components-totals-wrapper {
	padding: var(--wp--custom--spacing--sm) 0;
}

body.woocommerce-cart .wc-block-components-totals-item {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: var(--wp--custom--spacing--sm);
	padding: var(--wp--custom--spacing--sm) 0;
	flex-wrap: wrap;
}

body.woocommerce-cart .wc-block-components-totals-item__label {
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--text);
	font-weight: 600;
}

body.woocommerce-cart .wc-block-components-totals-item__value {
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--text);
	font-weight: 700;
	white-space: nowrap;
}

/*
 * Shipping hint — when a shipping rate is showing, add a note that
 * more options are available at checkout. Norwegian-only site so
 * CSS content is acceptable for this informational text.
 */
body.woocommerce-cart .wp-block-woocommerce-cart-order-summary-shipping-block .wc-block-components-totals-shipping .wc-block-components-totals-item__description::after {
	content: 'Flere fraktalternativer tilgjengelig i kassen';
	display: block;
	margin-top: var(--wp--custom--spacing--sm);
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 400;
	color: var(--wp--preset--color--white);
	background-color: var(--wp--preset--color--primary);
	padding: 0.3rem 0.75rem;
	border-radius: var(--wp--custom--border-radius--pill);
	letter-spacing: 0.02em;
	text-align: center;
}

/* Also style the "will be calculated at checkout" text for guests */
body.woocommerce-cart .wc-block-components-totals-footer-item-shipping {
	font-size: var(--wp--preset--font-size--x-small);
	color: var(--wp--preset--color--text-muted);
	font-style: italic;
}

/* Final total row */
body.woocommerce-cart .wc-block-components-totals-footer-item {
	padding-top: var(--wp--custom--spacing--md);
	border-top: 2px solid var(--wp--preset--color--border);
	margin-top: var(--wp--custom--spacing--sm);
}

body.woocommerce-cart .wc-block-components-totals-footer-item .wc-block-components-totals-item__label {
	font-family: var(--wp--preset--font-family--heading);
	font-size: 1.1rem;
	font-weight: 700;
}

body.woocommerce-cart .wc-block-components-totals-footer-item-tax-value {
	font-family: var(--wp--preset--font-family--heading);
	font-size: 1.25rem;
	font-weight: 700;
	color: var(--wp--preset--color--primary);
}

body.woocommerce-cart .wc-block-components-totals-footer-item-tax {
	font-size: 0.75rem;
	color: var(--wp--preset--color--text-muted);
	font-weight: 400;
	margin: var(--wp--custom--spacing--xs) 0 0;
	text-align: right;
	width: 100%;
}

/* ============================================
   COUPON ACCORDION
   ============================================ */

body.woocommerce-cart .wc-block-components-totals-coupon .wc-block-components-panel__button {
	display: flex;
	align-items: center;
	gap: var(--wp--custom--spacing--xs);
	color: var(--wp--preset--color--primary);
	font-weight: 600;
	font-size: var(--wp--preset--font-size--small);
	background: transparent;
	border: none;
	padding: var(--wp--custom--spacing--xs) 0;
	cursor: pointer;
}

body.woocommerce-cart .wc-block-components-totals-coupon .wc-block-components-panel__button-icon {
	fill: currentColor;
	transition: transform var(--wp--custom--transition);
}

body.woocommerce-cart .wc-block-components-totals-coupon .wc-block-components-panel__button[aria-expanded="true"] .wc-block-components-panel__button-icon {
	transform: rotate(180deg);
}

/* Coupon form inside accordion */
body.woocommerce-cart .wc-block-components-totals-coupon__content {
	margin-top: var(--wp--custom--spacing--sm);
}

body.woocommerce-cart .wc-block-components-totals-coupon__content .wc-block-components-text-input input {
	height: 44px;
	border: 2px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--border-radius--default);
	padding: 0 var(--wp--custom--spacing--md);
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--small);
}

body.woocommerce-cart .wc-block-components-totals-coupon__content .wc-block-components-text-input input:focus {
	border-color: var(--wp--preset--color--primary);
	outline: none;
	box-shadow: 0 0 0 3px rgba(204, 46, 46, 0.15);
}

body.woocommerce-cart .wc-block-components-totals-coupon__content .wc-block-components-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 44px;
	padding: 0 var(--wp--custom--spacing--lg);
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 700;
	background: transparent;
	color: var(--wp--preset--color--primary);
	border: 2px solid var(--wp--preset--color--primary);
	border-radius: var(--wp--custom--border-radius--pill);
	cursor: pointer;
	transition: all var(--wp--custom--transition);
}

body.woocommerce-cart .wc-block-components-totals-coupon__content .wc-block-components-button:hover {
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--white);
}

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

body.woocommerce-cart .wc-block-cart__submit-button {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	padding: 0.875rem 2rem;
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 700;
	letter-spacing: 0.03em;
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--white);
	border: 2px solid var(--wp--preset--color--primary);
	border-radius: var(--wp--custom--border-radius--pill);
	text-decoration: none;
	cursor: pointer;
	transition: all var(--wp--custom--transition);
	line-height: 1;
	box-shadow: none;
}

body.woocommerce-cart .wc-block-cart__submit-button:hover {
	background: var(--wp--preset--color--primary-dark);
	border-color: var(--wp--preset--color--primary-dark);
	color: var(--wp--preset--color--white);
	transform: translateY(-2px);
	box-shadow: var(--wp--custom--shadow--md);
}

/* Payment options (express checkout) */
body.woocommerce-cart .wc-block-cart__payment-options {
	margin-top: var(--wp--custom--spacing--md);
}

body.woocommerce-cart .wc-block-components-express-payment__event-buttons {
	display: block;
}

body.woocommerce-cart #express-payment-method-vippsexpress,
body.woocommerce-cart .vipps-express-container {
	display: block;
	width: 100%;
}

body.woocommerce-cart a.vipps-express-checkout,
body.woocommerce-cart a.button.vipps-express-checkout {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 3rem;
	margin: 0;
	padding: 0;
	background-color: #ff5b24;
	border-radius: var(--wp--custom--border-radius--pill);
	overflow: hidden;
}

body.woocommerce-cart a.vipps-express-checkout img,
body.woocommerce-cart a.button.vipps-express-checkout img {
	display: block;
	width: auto;
	max-width: 100%;
	height: 100%;
	max-height: 100%;
	object-fit: contain;
	filter: none;
}

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

body.woocommerce-cart .wp-block-woocommerce-empty-cart-block {
	text-align: center;
	padding: var(--wp--custom--spacing--2-xl);
	background: var(--wp--preset--color--cream);
	border-radius: var(--wp--custom--border-radius--lg);
}

body.woocommerce-cart .wp-block-woocommerce-empty-cart-block p {
	font-family: var(--wp--preset--font-family--heading);
	font-size: 1.5rem;
	color: var(--wp--preset--color--text);
	margin: 0 0 var(--wp--custom--spacing--lg);
}

body.woocommerce-cart .wp-block-woocommerce-empty-cart-block .wp-block-button__link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.875rem 2rem;
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 700;
	letter-spacing: 0.03em;
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--white);
	border: 2px solid var(--wp--preset--color--primary);
	border-radius: var(--wp--custom--border-radius--pill);
	text-decoration: none;
	transition: all var(--wp--custom--transition);
}

body.woocommerce-cart .wp-block-woocommerce-empty-cart-block .wp-block-button__link:hover {
	background: var(--wp--preset--color--primary-dark);
	border-color: var(--wp--preset--color--primary-dark);
	color: var(--wp--preset--color--white);
}

/* ============================================
   NOTICES
   ============================================ */

body.woocommerce-cart .wc-block-components-notice-banner {
	border-radius: var(--wp--custom--border-radius--default);
	padding: var(--wp--custom--spacing--md);
	border-left: 4px solid var(--wp--preset--color--primary);
	background: var(--wp--preset--color--cream);
	color: var(--wp--preset--color--text);
	font-size: var(--wp--preset--font-size--small);
	margin-bottom: var(--wp--custom--spacing--md);
}

body.woocommerce-cart .wc-block-components-notice-banner.is-success {
	border-left-color: var(--wp--preset--color--success);
}


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

@media (prefers-reduced-motion: reduce) {
	body.woocommerce-cart .wc-block-components-quantity-selector__button,
	body.woocommerce-cart .wc-block-cart__submit-button,
	body.woocommerce-cart .wc-block-cart-item__remove-link,
	body.woocommerce-cart .wc-block-components-totals-coupon__content .wc-block-components-button {
		transition-duration: 0s;
	}

	body.woocommerce-cart .wc-block-cart__submit-button:hover {
		transform: none;
	}

}

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

@media (max-width: 1024px) {
	body.woocommerce-cart .wc-block-components-sidebar-layout {
		grid-template-columns: 1fr;
	}

	body.woocommerce-cart .wc-block-components-sidebar.wc-block-cart__sidebar {
		max-width: 520px;
		margin: 0 auto;
		width: 100%;
	}
}

/*
 * Mobile cart table.
 * WC Blocks uses a container query at 699px to reformat the <table> as a
 * CSS grid (80px image | 132px+ product | auto total). Our desktop td
 * padding (--spacing--lg = 2rem per side) overrides WC's padding:0 reset
 * because the selectors are equal specificity and our sheet loads later.
 * Fix: zero out cell padding and let the grid handle spacing.
 */
@media (max-width: 768px) {
	body.woocommerce-cart .wc-block-cart-items__header th,
	body.woocommerce-cart .wc-block-cart-items__row td {
		padding: 0;
	}

	/* Allow grid reflow; inner padding on the card instead of per-cell */
	body.woocommerce-cart .wc-block-cart-items {
		overflow: visible;
		border-radius: var(--wp--custom--border-radius--default);
		padding: var(--wp--custom--spacing--sm) var(--wp--custom--spacing--md);
	}

	/* WC hides the remove button on mobile (set qty to 0 instead).
	   Our desktop selector has very high specificity, so we must match it. */
	body.woocommerce-cart table.wc-block-cart-items .wc-block-cart-items__row .wc-block-cart-item__quantity .wc-block-cart-item__remove-link {
		display: none;
	}

	/* Smaller quantity selector to fit the narrow grid column */
	body.woocommerce-cart .wc-block-cart-items .wc-block-components-quantity-selector__button,
	body.woocommerce-cart .wc-block-components-quantity-selector .wc-block-components-quantity-selector__button {
		width: 36px;
		height: 36px;
	}

	body.woocommerce-cart .wc-block-components-quantity-selector__input {
		width: 36px;
		height: 36px;
		font-size: 0.875rem;
	}

	/* Truncate long product metadata on mobile */
	body.woocommerce-cart .wc-block-cart-item__product .wc-block-components-product-metadata {
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		display: -webkit-box;
		overflow: hidden;
	}
}

@media (max-width: 600px) {
	body.woocommerce-cart .wc-block-components-sidebar.wc-block-cart__sidebar {
		padding: var(--wp--custom--spacing--md);
	}
}
