/**
 * DKM Mini Cart.
 *
 * The button is a header control, so it keeps to the same three heights as
 * everything else in the design system and takes its colours from the same
 * settings screen. The drawer is a panel over the page rather than a dropdown
 * under the button: a dropdown has to fit under wherever the button happens to
 * be, and a cart with six things in it never does.
 */

.wcg-mc {
	/* The interactive blue, not the brand lime: the badge is a count on an
	   icon, which is a piece of interface rather than a piece of branding. It
	   follows the shop's own Elementor global Secondary until told otherwise. */
	--wcg-mc-badge-bg: var(--action-primary);
	--wcg-mc-badge-text: var(--text-inverse);
	--wcg-mc-icon: var(--text-primary);
	--wcg-mc-text: var(--text-primary);
	--wcg-mc-border: var(--border-subtle);
	--wcg-mc-muted: var(--text-tertiary);
	--wcg-mc-height: var(--control-md);
	--wcg-mc-icon-size: 24px;
	--wcg-mc-font: 15px;

	display: inline-block;
	max-width: 100%;
	margin: 0;
	padding: 0;
}

.wcg-mc--size-sm {
	--wcg-mc-height: var(--control-sm);
	--wcg-mc-icon-size: 18px;
	--wcg-mc-font: 13px;
}

.wcg-mc--size-md {
	--wcg-mc-height: var(--control-md);
	--wcg-mc-icon-size: 24px;
	--wcg-mc-font: 15px;
}

.wcg-mc--size-lg {
	--wcg-mc-height: var(--control-lg);
	--wcg-mc-icon-size: 28px;
	--wcg-mc-font: 17px;
}

/* ---------------------------------------------------------------- button */

/* Doubled class, for the same reason as the add to cart button: a WooCommerce
   theme reaches its buttons as `.woocommerce button.button` and Elementor as
   `.elementor button`, both of which outrank a single class. A header control
   that turns the theme's pink on hover is not this module's idea. */
.wcg-mc .wcg-mc__button.wcg-mc__button {
	display: inline-flex;
	align-items: center;
	box-sizing: border-box;
	gap: 10px;
	min-height: var(--wcg-mc-height);
	margin: 0;
	padding: 0 10px;
	border: 0;
	/* DS v3.4.1: a pill, paired with the account trigger beside it - the two
	   are one group of header controls and read as one shape. */
	border-radius: var(--radius-full);
	background: transparent;
	color: var(--wcg-mc-text);
	font: inherit;
	font-size: var(--wcg-mc-font);
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	transition: var(--motion-control);
}

.wcg-mc .wcg-mc__button.wcg-mc__button:hover,
.wcg-mc .wcg-mc__button.wcg-mc__button:focus-visible {
	background: var(--button-tertiary-hover-bg, var(--bg-subtle));
	color: var(--wcg-mc-text);
}

.wcg-mc .wcg-mc__button.wcg-mc__button:focus {
	outline: none;
}

.wcg-mc .wcg-mc__button.wcg-mc__button:focus-visible {
	outline: 2px solid var(--border-focus);
	outline-offset: 2px;
}

.wcg-mc__icon-wrap {
	position: relative;
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
}

.wcg-mc__icon {
	width: var(--wcg-mc-icon-size);
	height: var(--wcg-mc-icon-size);
	color: var(--wcg-mc-icon);
}

/* DS v3.4.2: the account and the cart are one pair of header controls - a
   tertiary button each: no fill at rest, an Ink 100 pill on hover and focus
   (and, for the account, while its panel is open). One shape, one behaviour.
   Below 768px the mobile choice (tile, icon, ...) still decides. */
@media (min-width: 768px) {
	.wcg-mc .wcg-mc__button.wcg-mc__button:hover,
	.wcg-mc .wcg-mc__button.wcg-mc__button:focus-visible {
		background: var(--button-tertiary-hover-bg, var(--bg-subtle));
		color: var(--button-tertiary-hover-text, var(--wcg-mc-text));
	}

	.wcg-mc .wcg-mc__button.wcg-mc__button:active {
		background: var(--bg-press);
	}
}

/* The badge sits on the icon rather than beside it: it is a property of the
   cart, not another thing in the row. */
.wcg-mc__badge {
	position: absolute;
	top: -6px;
	right: -8px;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	border-radius: var(--radius-full);
	background: var(--wcg-mc-badge-bg);
	color: var(--wcg-mc-badge-text);
	font-size: 11px;
	font-weight: 700;
	line-height: 1;
}

.wcg-mc__badge[hidden],
.wcg-mc__live[hidden] {
	display: none;
}

.wcg-mc__total {
	white-space: nowrap;
}

/* WooCommerce wraps the amount in its own markup, which arrives with whatever
   the theme has done to prices. Inside this button it is one figure. */
.wcg-mc__total .woocommerce-Price-amount,
.wcg-mc__total bdi {
	color: inherit;
	font: inherit;
	text-decoration: none;
}

.wcg-mc__label {
	white-space: nowrap;
}

/* ------------------------------------------------------------- what shows

   The parts are hidden rather than left out. WooCommerce redraws this button
   from the server on every cart change, and the server has no element to ask
   what the page was showing - so the markup is always whole and the choice
   lives in CSS, where it survives being redrawn. */

.wcg-mc--show-compact .wcg-mc__label,
.wcg-mc--show-compact .wcg-mc__total,
.wcg-mc--show-icon .wcg-mc__label,
.wcg-mc--show-icon .wcg-mc__total,
.wcg-mc--show-icon .wcg-mc__badge {
	display: none;
}

/* Below the breakpoint the mobile choice takes over from the one above, in
   both directions - a button that is bare on desktop can still carry its total
   on a phone, and the rule that puts it back has to be here to win. */
@media (max-width: 767px) {
	.wcg-mc--m-compact .wcg-mc__label,
	.wcg-mc--m-compact .wcg-mc__total,
	.wcg-mc--m-icon .wcg-mc__label,
	.wcg-mc--m-icon .wcg-mc__total,
	.wcg-mc--m-icon .wcg-mc__badge {
		display: none;
	}

	.wcg-mc--m-full .wcg-mc__label,
	.wcg-mc--m-full .wcg-mc__total {
		display: revert;
	}

	/* The badge is a positioned flex box, not an inline span, so putting it
	   back is not the same rule as the two above. */
	.wcg-mc--m-full .wcg-mc__badge,
	.wcg-mc--m-compact .wcg-mc__badge {
		display: flex;
	}

	/* Icon on a grey tile: the icon alone in a square the control's height,
	   drawn as an 8px Ink 100 tile so it reads as a button rather than a
	   glyph. Hover and focus go one step darker, to Ink 200. */
	.wcg-mc--m-tile .wcg-mc__label,
	.wcg-mc--m-tile .wcg-mc__total {
		display: none;
	}

	.wcg-mc--m-tile .wcg-mc__badge {
		display: flex;
	}

	.wcg-mc--m-tile .wcg-mc__button.wcg-mc__button {
		gap: 0;
		width: var(--wcg-mc-height);
		padding: 0;
		justify-content: center;
		/* 8px, not the 4px button radius: kept by the shop's choice (1.48.0). */
		border-radius: var(--radius-md);
		background: var(--button-secondary-bg);
	}

	.wcg-mc--m-tile .wcg-mc__button.wcg-mc__button:hover,
	.wcg-mc--m-tile .wcg-mc__button.wcg-mc__button:focus-visible {
		background: var(--button-secondary-hover-bg);
	}

	/* Whatever the choice, a count the shop asked to hide when empty stays
	   hidden, and so does a whole button hidden with an empty cart. */
	.wcg-mc--m-full .wcg-mc__badge[hidden],
	.wcg-mc--m-compact .wcg-mc__badge[hidden],
	.wcg-mc--m-tile .wcg-mc__badge[hidden],
	.wcg-mc__live[hidden] {
		display: none;
	}
}
