/**
 * Summary box — mediaMEANS-V5 / Brauerei Wittmann
 *
 * The box on the right of the cart and of the checkout. Both render the same
 * markup (woocommerce/cart/cart-totals.php and btw_checkout_totals_html()), so
 * this file is the single place where it is styled. btw_cart.css and
 * btw_shop.css must not contain rules for it.
 *
 * Enqueue on both pages and after the other two, so it has the last word.
 *
 * Every rule is stated through WooCommerce's cart selector chain as well
 * (.woocommerce .cart-collaterals .cart_totals): three classes, which a single
 * class cannot outweigh.
 */

:root {
	--mM_co_bg: #faf7f1;
	--mM_co_surface: #ffffff;
	--mM_co_heading: #014f28;
	--mM_co_text: #5a615b;
	--mM_co_body: #012d15;
	--mM_co_accent: #ffef00;
	--mM_co_border: #e2ded4;
	--mM_co_line: #81ad97;
	--mM_co_grey: #b9bbb6;
	--mM_co_radius: 4px;
	--mM_co_aside_width: 380px;
}

/* ============================================================ container */

.woocommerce .shipping-calculator-form,
.cart-collaterals .shipping-calculator-form{
	text-align: left;
}

.woocommerce .cart-collaterals .cart_totals,
.cart-collaterals .cart_totals {
	width: 100%;
	float: none;
	margin: 0;
	padding: 0;
	background: none;
	border: none;
}

.woocommerce .cart-collaterals .cart_totals .mM_checkout_totals_container,
.mM_checkout_aside .mM_checkout_totals_container {
	width: 100%;
	margin: 0;
	padding: 0;
	background: var(--mM_co_surface);
	border: 1px solid var(--mM_co_border);
	border-radius: var(--mM_co_radius);
	color: var(--mM_co_body);
}

.woocommerce .cart-collaterals .cart_totals .mM_custom_checkout_container_inner,
.mM_checkout_aside .mM_custom_checkout_container_inner {
	padding: 24px;
}

/* ================================================================= rows */

/* Label left, value right, on one line. */
.woocommerce .cart-collaterals .cart_totals .mM_custom_checkout_info_content > div,
.mM_checkout_aside .mM_custom_checkout_info_content > div {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 16px;
	padding: 8px 0;
	font-size: 1rem;
	color: var(--mM_co_text);
}

.woocommerce .cart-collaterals .cart_totals .mM_order_label,
.woocommerce .cart-collaterals .cart_totals .mM_subtotal_label,
.mM_checkout_aside .mM_order_label,
.mM_checkout_aside .mM_subtotal_label {
	flex: 1 1 auto;
	min-width: 0;
	font-weight: 400;
	text-align: left;
	color: var(--mM_co_text);
}

.woocommerce .cart-collaterals .cart_totals .mM_order_value,
.woocommerce .cart-collaterals .cart_totals .mM_subtotal_amount,
.mM_checkout_aside .mM_order_value,
.mM_checkout_aside .mM_subtotal_amount {
	flex: 0 0 auto;
	text-align: right;
	white-space: nowrap;
	font-weight: 400;
	color: var(--mM_co_body);
}

/* ============================================================= shipping */

.woocommerce .cart-collaterals .cart_totals .woocommerce-shipping-methods,
.mM_checkout_aside .woocommerce-shipping-methods {
	list-style: none;
	margin: 0;
	padding: 0;
	text-align: right;
}

/* The shipping cost is the value of that row, so it carries the same weight. */
.woocommerce .cart-collaterals .cart_totals .woocommerce-shipping-methods label,
.mM_checkout_aside .woocommerce-shipping-methods label {
	color: var(--mM_co_body);
	font-weight: 400;
}

.woocommerce .cart-collaterals .cart_totals .woocommerce-shipping-destination,
.mM_checkout_aside .woocommerce-shipping-destination {
	display: none;
}

.woocommerce .cart-collaterals .cart_totals .shipping-calculator-button,
.mM_checkout_aside .shipping-calculator-button {
	display: inline-block;
	margin-top: 8px;
	font-size: 0.8125rem;
	color: var(--mM_co_heading);
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* =============================================================== coupon */

/*
 * Closed off above and below: the line below separates it from the applied
 * coupons, so the grand total adds none of its own.
 */
.woocommerce .cart-collaterals .cart_totals div.mM_coupon_container,
.mM_checkout_aside div.mM_coupon_container {
	display: block;
	margin: 16px 0;
	padding: 16px 0;
	border-top: 1px solid var(--mM_co_border);
	border-bottom: 1px solid var(--mM_co_border);
}

/*
 * The label floats over the field and moves up on focus or once the field
 * holds a value, so it costs no line of its own. .mM_coupon_field is the
 * positioning context; the input sits before the label in the markup, which is
 * what makes the sibling selector below possible.
 */
.woocommerce .cart-collaterals .cart_totals .mM_coupon_field,
.mM_checkout_aside .mM_coupon_field {
	position: relative;
	flex: 0 1 110px;
	min-width: 0;
	padding-top: 16px;
}

.woocommerce .cart-collaterals .cart_totals .mM_coupon_label,
.mM_checkout_aside .mM_coupon_label {
	position: absolute;
	top: 16px;
	left: 0;
	margin: 0;
	font-size: 0.8125rem;
	font-weight: 400;
	color: var(--mM_co_text);
	transform-origin: left;
	transition: transform 0.25s;
	white-space: nowrap;
	pointer-events: none;
}

/*
 * :placeholder-shown reports whether the field is empty. The placeholder is a
 * single space, so nothing is ever visible from it.
 */
.woocommerce .cart-collaterals .cart_totals .mM_coupon_input:focus + .mM_coupon_label,
.woocommerce .cart-collaterals .cart_totals .mM_coupon_input:not(:placeholder-shown) + .mM_coupon_label,
.mM_checkout_aside .mM_coupon_input:focus + .mM_coupon_label,
.mM_checkout_aside .mM_coupon_input:not(:placeholder-shown) + .mM_coupon_label {
	transform: translate(0, -16px) scale(0.85);
}

/* Field left, button right. */
.woocommerce .cart-collaterals .cart_totals .mM_coupon_row,
.mM_checkout_aside .mM_coupon_row {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: flex-end;
	gap: 12px;
}

.woocommerce .cart-collaterals .cart_totals .mM_coupon_input,
.mM_checkout_aside .mM_coupon_input {
	width: 100%;
	padding: 5px 0 2px;
	background: transparent;
	border: none;
	border-bottom: 1px solid var(--mM_co_line);
	border-radius: 0;
	color: var(--mM_co_body);
}

.woocommerce .cart-collaterals .cart_totals .mM_coupon_input:focus,
.mM_checkout_aside .mM_coupon_input:focus {
	outline: none;
	border-bottom-color: var(--mM_co_heading);
}

/* .wb_button.third from theme.css. */
.woocommerce .cart-collaterals .cart_totals button.button.mM_coupon_apply,
.mM_checkout_aside button.button.mM_coupon_apply,
.woocommerce .cart-collaterals .cart_totals button[name="calc_shipping"] {
	flex: 0 0 auto;
	margin: 0;
	padding: 10px 24px 8px;
	border: 2px solid var(--mM_co_grey);
	border-radius: 50px;
	background: transparent;
	color: #002b13;
	font-weight: 400;
	font-size: 1rem;
	line-height: 1.2;
	cursor: pointer;
	transition: color 0.4s, background 0.4s;
}

.woocommerce .cart-collaterals .cart_totals button.button.mM_coupon_apply:hover,
.mM_checkout_aside button.button.mM_coupon_apply:hover,
.woocommerce .cart-collaterals .cart_totals button[name="calc_shipping"]:hover {
	background: var(--mM_co_grey);
}

.woocommerce .cart-collaterals .cart_totals .mM_coupon_feedback,
.mM_checkout_aside .mM_coupon_feedback {
	margin: 10px 0 0;
	font-size: 0.8125rem;
	color: var(--mM_co_heading);
}

.woocommerce .cart-collaterals .cart_totals .mM_coupon_feedback:empty,
.mM_checkout_aside .mM_coupon_feedback:empty {
	display: none;
}

/* ================================================ discounts and total */

/* Holds the coupon lines and the amount, so it is a block, not a row. */
.woocommerce .cart-collaterals .cart_totals .mM_custom_checkout_info_content .order-total,
.mM_checkout_aside .mM_custom_checkout_info_content .order-total {
	display: block;
	margin: 0;
	padding: 0;
	border: none;
}

/*
 * Applied coupons: code on the first line, amount and the remove link below.
 * The code alone can be as long as the row, so putting the amount next to it
 * would break the line anyway.
 */
.woocommerce .cart-collaterals .cart_totals .order-total .cart-discount,
.mM_checkout_aside .order-total .cart-discount {
	display: block;
	padding: 8px 0;
}

.woocommerce .cart-collaterals .cart_totals .order-total .cart-discount .mM_order_label,
.mM_checkout_aside .order-total .cart-discount .mM_order_label {
	display: block;
	font-weight: 400;
	color: var(--mM_co_text);
}

.woocommerce .cart-collaterals .cart_totals .order-total .cart-discount .mM_order_value,
.mM_checkout_aside .order-total .cart-discount .mM_order_value {
	display: block;
	margin-top: 2px;
	text-align: left;
	font-weight: 700;
	color: var(--mM_co_heading);
}

.woocommerce .cart-collaterals .cart_totals .woocommerce-remove-coupon,
.mM_checkout_aside .woocommerce-remove-coupon {
	display: inline-block;
	margin-left: 8px;
	font-size: 0.75rem;
	font-weight: 400;
	white-space: nowrap;
	color: var(--wc-red, #e2401c) !important;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.woocommerce .cart-collaterals .cart_totals .woocommerce-remove-coupon:hover,
.mM_checkout_aside .woocommerce-remove-coupon:hover {
	color: #b3301f;
}

/* Grand total. No line above it: the coupon block already closed off. */
.woocommerce .cart-collaterals .cart_totals .order-total_inner,
.mM_checkout_aside .order-total_inner {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 16px;
	margin: 0;
	padding: 16px 0 0;
	border: none;
}

.woocommerce .cart-collaterals .cart_totals .order-total_inner .mM_order_label,
.woocommerce .cart-collaterals .cart_totals .order-total_inner .mM_order_value,
.mM_checkout_aside .order-total_inner .mM_order_label,
.mM_checkout_aside .order-total_inner .mM_order_value {
	font-weight: 700;
	font-size: 1.125rem;
	color: var(--mM_co_heading);
}

/* The amount is stated once, on the line below. */
.woocommerce .cart-collaterals .cart_totals .order-total .includes_tax,
.mM_checkout_aside .order-total .includes_tax {
	display: none;
}

/* Tax note: label and amount both to the right, underneath the total. */
.woocommerce .cart-collaterals .cart_totals .mM_custom_checkout_info_content .order-tax,
.mM_checkout_aside .mM_custom_checkout_info_content .order-tax {
	display: flex;
	justify-content: flex-end;
	gap: 16px;
	padding: 2px 0 0;
}

.woocommerce .cart-collaterals .cart_totals .order-tax .mM_order_label,
.woocommerce .cart-collaterals .cart_totals .order-tax .mM_order_value,
.mM_checkout_aside .order-tax .mM_order_label,
.mM_checkout_aside .order-tax .mM_order_value {
	flex: 0 0 auto;
	font-size: 0.8125rem;
	font-weight: 400;
	color: var(--mM_co_text);
}

/* =============================================================== button */

.woocommerce .cart-collaterals .cart_totals .mM_order_custom_submit_container,
.mM_checkout_aside .mM_order_custom_submit_container {
	margin-top: 24px;
	padding: 0;
}

.woocommerce .cart-collaterals .cart_totals .wc-proceed-to-checkout,
.mM_checkout_aside .wc-proceed-to-checkout {
	margin: 0;
	padding: 0;
}

.woocommerce .cart-collaterals .cart_totals a.checkout-button,
.woocommerce .cart-collaterals .cart_totals a.checkout-button.button,
.mM_checkout_aside button.mM_proxy_submit,
.mM_checkout_aside button.button.mM_proxy_submit {
	display: block;
	width: 100%;
	margin: 0;
	padding: 15px 30px 13px;
	border: 2px solid var(--mM_co_accent);
	border-radius: 50px;
	background: var(--mM_co_accent);
	color: #373737;
	font-weight: 400;
	font-size: 1rem;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
	transition: color 0.4s, background 0.4s, border-color .4s;
}

.woocommerce .cart-collaterals .cart_totals a.checkout-button:hover,
.mM_checkout_aside button.mM_proxy_submit:hover {
	background: var(--mM_co_accent);
	color: var(--mM_co_heading);
	border-color:var( --mM_co_heading);
}

.mM_checkout_aside button.mM_proxy_submit .verlinkung_beschriftung {
	display: flex;
	justify-content: center;
	gap: 12px;
}

/* ====================================================== sticky behaviour */

/*
 * The box sticks below the header and scrolls inside itself when it is taller
 * than the room that leaves. dvh instead of vh, because vh on mobile refers to
 * the viewport with the address bar hidden and the lower edge would end up
 * behind it.
 */
.woocommerce-cart .cart-collaterals,
.woocommerce-checkout .mM_checkout_aside {
	position: sticky;
	top: calc(var(--mM_co_header_height, 120px) + 24px);
	align-self: start;
	max-height: calc(100dvh - var(--mM_co_header_height, 120px) - 48px);
	overflow-y: auto;
	overscroll-behavior: contain;
}

.woocommerce-cart .cart-collaterals > *,
.woocommerce-checkout .mM_checkout_aside > * {
	max-height: none;
}

/*
 * Below this height sticky stops helping: a scrollbar inside the page's
 * scrollbar is hard to operate, and parts of the box stay out of reach. It
 * scrolls along with the page instead.
 */
@media (max-height: 700px) {
	.woocommerce-cart .cart-collaterals,
	.woocommerce-checkout .mM_checkout_aside {
		position: static;
		max-height: none;
		overflow: visible;
	}
}

@media (max-width: 991px) {
	.woocommerce-cart .cart-collaterals,
	.woocommerce-checkout .mM_checkout_aside {
		position: static;
		max-height: none;
		overflow: visible;
	}
}
