/**
 * Revita: mini-cart badge and drawer (woocommerce/mini-cart, owner D).
 *
 * Honey count badge; drawer with a purple title bar, cream image wells and a
 * footer with subtotal, "View cart" outline + honey "Checkout" and the free
 * delivery note. Placement of the header button belongs to the header part.
 * Uses variables from woocommerce.css.
 *
 * @package Revita
 */

/* Badge: WooCommerce sets inline colours, so these must win. */
.wc-block-mini-cart .wc-block-mini-cart__badge {
	min-width: 1.35em;
	height: 1.35em;
	padding: 0 0.3em;
	border: 2px solid var(--wp--preset--color--base);
	background-color: var(--wp--preset--color--accent) !important;
	color: var(--wp--preset--color--primary-deep) !important;
	font: 700 0.7rem / 1 var(--wp--preset--font-family--heading);
}

/* Drawer */
body .wc-block-components-drawer__screen-overlay:not(.wc-block-components-drawer__screen-overlay--is-hidden) { background-color: color-mix(in srgb, var(--wp--preset--color--primary-dark) 45%, transparent); }

/* The closed drawer is aria-hidden, so its links and buttons must not stay in the Tab order. */
body .wc-block-components-drawer__screen-overlay--is-hidden { visibility: hidden; }

/* Rounded corners, and vertical scrolling on short screens (phone landscape) so "Checkout" stays reachable. */
.wc-block-mini-cart__drawer.wc-block-components-drawer {
	overflow: hidden auto;
	overscroll-behavior: contain;
	border-start-start-radius: var(--wp--custom--radius--xl);
	border-end-start-radius: var(--wp--custom--radius--xl);
	background: var(--wp--preset--color--base);
	box-shadow: var(--wp--preset--shadow--lifted);
}

.wc-block-mini-cart__drawer h2.wc-block-mini-cart__title {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.4em;
	margin: 0;
	padding: 1.15rem 4rem 1.15rem var(--wp--preset--spacing--40);
	background: var(--wp--preset--gradient--royal);
	color: var(--wp--preset--color--base);
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--large);
	-webkit-mask-image: none;
	mask-image: none;
}

.wc-block-mini-cart__drawer .wc-block-mini-cart__title .wp-block-woocommerce-mini-cart-title-items-counter-block { color: var(--wp--preset--color--accent-soft); font: 500 var(--wp--preset--font-size--small) / 1.4 var(--wp--preset--font-family--body); }

/* The close button sits on the purple bar while the cart has items. */
.wc-block-mini-cart__drawer .wp-block-woocommerce-mini-cart-contents:has(.wp-block-woocommerce-filled-mini-cart-contents-block:not([hidden])) .wc-block-components-drawer__close { color: var(--wp--preset--color--base) !important; opacity: 1; }

/* The notices area above the purple bar keeps a 16px top margin while it is empty (it holds only
 * white space, so :empty does not match), which left a white strip above the bar: the close
 * button straddled it and the top of its white focus ring vanished there. */
.wc-block-mini-cart__drawer .wp-block-woocommerce-filled-mini-cart-contents-block > .wc-block-components-notices:not(:has(*)) { margin: 0; }

/* Items */
.wc-block-mini-cart__drawer .wc-block-mini-cart__items { padding: var(--wp--preset--spacing--30) var(--wp--preset--spacing--40) 0; }

/* Rows: image, a flexible name column and the line total, so long totals fit a 360px drawer. */
body .wc-block-mini-cart__drawer table.wc-block-cart-items .wc-block-cart-items__row { grid-template-columns: 4.5rem minmax(0, 1fr) auto; column-gap: 0.75rem; }
body .wc-block-mini-cart__drawer table.wc-block-cart-items .wc-block-cart-items__row .wc-block-cart-item__image { padding-inline-end: 0; }
body .wc-block-mini-cart__drawer table.wc-block-cart-items .wc-block-cart-items__row .wc-block-cart-item__product { grid-column: 2 / 3; min-inline-size: 0; }
body .wc-block-mini-cart__drawer table.wc-block-cart-items .wc-block-cart-items__row .wc-block-cart-item__total { grid-column: 3 / 4; grid-row: 1; }
body .wc-block-mini-cart__drawer table.wc-block-cart-items .wc-block-cart-items__row .wc-block-cart-item__quantity { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem; }
.wc-block-mini-cart__drawer .wc-block-cart-item__image a { display: block; overflow: hidden; border-radius: var(--wp--custom--radius--md); background: var(--wp--preset--color--cream); }
.wc-block-mini-cart__drawer .wc-block-cart-item__image img { max-inline-size: 100%; block-size: auto; mix-blend-mode: multiply; }
.wc-block-mini-cart__drawer .wc-block-components-product-name { color: var(--wp--preset--color--primary-deep); font-family: var(--wp--preset--font-family--heading); font-weight: 600; text-decoration: none; }
.wc-block-mini-cart__drawer a.wc-block-components-product-name:hover { color: var(--wp--preset--color--primary); }
.wc-block-mini-cart__drawer .wc-block-cart-item__total .wc-block-components-product-price { color: var(--wp--preset--color--primary); }
.wc-block-mini-cart__drawer .wc-block-cart-item__remove-link { color: var(--wp--preset--color--muted); font-size: var(--wp--preset--font-size--x-small); }
.wc-block-mini-cart__drawer .wc-block-cart-item__remove-link:hover { color: var(--wp--preset--color--rose); }

/* Phones and touch screens: the remove button (a 24px bin icon) is a 44px target, the icon centred
 * in it. The quantity row is already taller than 44px, and the start margin keeps the icon where it
 * was: in line with the stepper when it wraps under it (up to about 400px), 8px after it otherwise. */
@media (max-width: 781px), (pointer: coarse) {
	body .wc-block-mini-cart__drawer table.wc-block-cart-items .wc-block-cart-items__row .wc-block-cart-item__quantity .wc-block-cart-item__remove-link {
		display: inline-grid;
		place-items: center;
		min-inline-size: 2.75rem;
		min-block-size: 2.75rem;
		margin-inline-start: -0.625rem;
		border-radius: var(--wp--custom--radius--pill);
	}

	/* The ring goes just inside the 44px circle, clear of the stepper beside it. */
	body .wc-block-mini-cart__drawer table.wc-block-cart-items .wc-block-cart-items__row .wc-block-cart-item__quantity .wc-block-cart-item__remove-link:focus-visible { outline-offset: -3px; box-shadow: none; }
}

/* Footer */
.wc-block-mini-cart__drawer .wc-block-mini-cart__footer { padding: var(--wp--preset--spacing--40); border-block-start: 1px solid var(--wp--preset--color--border); background: var(--wp--preset--gradient--lavender-mist); }
.wc-block-mini-cart__drawer .wc-block-mini-cart__footer-subtotal .wc-block-components-totals-item__label { color: var(--wp--preset--color--primary-deep); font-family: var(--wp--preset--font-family--heading); }
.wc-block-mini-cart__drawer .wc-block-mini-cart__footer-subtotal .wc-block-components-totals-item__value { color: var(--wp--preset--color--primary); font-size: var(--wp--preset--font-size--large); font-weight: 700; }
.wc-block-mini-cart__drawer .wc-block-mini-cart__footer-actions { flex-wrap: wrap; gap: var(--wp--preset--spacing--20); }
.wc-block-mini-cart__drawer .wc-block-mini-cart__footer-actions > .wc-block-components-button { flex: 1 1 10rem; min-height: 3rem; }

/* WooCommerce stacks the two buttons under 480px; a 10rem basis would then become their height. */
@media (max-width: 480px) {
	.wc-block-mini-cart__drawer .wc-block-mini-cart__footer-actions > .wc-block-components-button { flex: 0 0 auto; }
}
.wc-block-mini-cart__drawer .wc-block-mini-cart__footer-checkout:hover { box-shadow: var(--wp--preset--shadow--glow); }

.wc-block-mini-cart__drawer .wc-block-mini-cart__footer-checkout::before {
	content: "";
	width: 1.05em;
	height: 1.05em;
	margin-inline-end: 0.5em;
	background: currentColor;
	-webkit-mask: url(../../images/icons/lock.svg) center / contain no-repeat;
	mask: url(../../images/icons/lock.svg) center / contain no-repeat;
}

.wc-block-mini-cart__drawer .revita-mini-cart-note {
	display: flex;
	flex: none;
	box-sizing: border-box;
	width: 100%;
	align-items: center;
	justify-content: center;
	gap: 0.5em;
	margin: 0;
	padding: 0.55em 1em;
	border-radius: var(--wp--custom--radius--pill);
	background: var(--wp--preset--color--accent-soft);
	color: var(--wp--preset--color--primary-deep);
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 600;
}

.wc-block-mini-cart__drawer .revita-mini-cart-note::before {
	content: "";
	width: 1.3em;
	height: 1.3em;
	background: var(--wp--preset--color--primary);
	-webkit-mask: url(../../images/icons/truck.svg) center / contain no-repeat;
	mask: url(../../images/icons/truck.svg) center / contain no-repeat;
}

/* Empty state */
.wc-block-mini-cart__drawer .wp-block-woocommerce-empty-mini-cart-contents-block { text-align: center; }

.wc-block-mini-cart__drawer .wc-block-mini-cart__empty-cart-wrapper::before {
	content: "";
	display: block;
	width: 4rem;
	margin: var(--wp--preset--spacing--40) auto var(--wp--preset--spacing--30);
	aspect-ratio: 100 / 86.6;
	background: var(--wp--preset--gradient--honey);
	-webkit-mask: url(../../images/hexagon.svg) center / contain no-repeat;
	mask: url(../../images/hexagon.svg) center / contain no-repeat;
}

.wc-block-mini-cart__drawer .wc-block-mini-cart__empty-cart-wrapper p { color: var(--wp--preset--color--primary-deep); font-family: var(--wp--preset--font-family--heading); }

/* Focus. The floating cart button sits on page content, so it keeps the theme's two-colour ring
 * (parts/footer.css, components/floating-cart.css): a white currentColor ring would vanish there.
 * <body> carries the option class "revita-floating-cart" too, so the exclusion names the group as
 * a descendant of body ("body .revita-floating-cart"), which keeps the header button's ring. It has
 * its own rule: a browser that cannot read the complex :not() then drops only this one. */
.wc-block-mini-cart .wc-block-mini-cart__button:not(body .revita-floating-cart .wc-block-mini-cart__button):focus-visible {
	outline: 2px solid currentColor !important;
	outline-offset: 2px;
}

/* Items sit on the drawer's white: the theme ring (woocommerce.css). */
.wc-block-mini-cart__drawer .wc-block-cart-item__remove-link:focus-visible,
.wc-block-mini-cart__drawer a.wc-block-components-product-name:focus-visible {
	outline: 2px solid var(--revita-focus, var(--wp--preset--color--primary-deep)) !important;
	outline-offset: 3px;
	box-shadow: 0 0 0 3px var(--revita-focus-ring, var(--wp--preset--color--base));
}

/* The close button sits in the drawer's top corner, which clips anything drawn outside it, and
 * WooCommerce's margin of -1em pushes its 54px box 3px past the drawer's edge: the ring goes
 * 6-8px inside the box instead, a 38px circle around the icon. currentColor follows the button
 * (ink on the white drawer, white on the purple header of a filled cart). The second selector
 * outranks the WooCommerce-wide button ring in woocommerce.css (body .wc-block-components-button). */
.wc-block-mini-cart__drawer .wc-block-components-drawer__close:focus-visible,
body .wc-block-mini-cart__drawer .wc-block-components-button.wc-block-components-drawer__close:focus-visible {
	outline: 2px solid currentColor !important;
	outline-offset: -8px;
}

/* Motion: keep the drawer visible while it slides out, then hide it. */
@media (prefers-reduced-motion: no-preference) {
	body:not(.revita-motion-off) .wc-block-components-drawer__screen-overlay--with-slide-out.wc-block-components-drawer__screen-overlay--is-hidden { transition: opacity 0.3s, visibility 0s linear 0.3s; }
}

/* Reduced motion: the global reset (global.css) gives every element a 0.01ms transition, so the
 * drawer's controls would turn visible a frame after the drawer, too late for WooCommerce to move
 * focus to "Close". Nothing inside the drawer transitions then. */
@media (prefers-reduced-motion: reduce) {
	body .wc-block-components-drawer__screen-overlay,
	body .wc-block-components-drawer__screen-overlay * { transition: none !important; }
}
