/**
 * Dimple Whisky — WooCommerce, the part every page needs.
 *
 * The header pattern carries the Mini Cart and Customer Account BLOCKS on
 * every page, so the two icons, the cart drawer, the block buttons inside it
 * and the block notice banners have to be styled site-wide. Everything that
 * only matches a shop, product, cart or checkout view lives in one of the
 * woocommerce-*.css files beside this one and is enqueued only on the
 * templates that render it (see dimple_whisky_enqueue_styles()).
 *
 * Enqueued at priority 20, after WooCommerce's own styles (priority 10), so
 * the overrides below win on source order rather than on !important.
 */

/*
 * A note on the doubled class names below (.x.x): the Cart, Checkout, Mini Cart
 * and Customer Account blocks register their stylesheet through block.json, so
 * on a block theme it is enqueued while the template renders — after this file
 * is printed in <head>. Source order therefore favours WooCommerce there, and
 * a single class would tie and lose. Repeating the class raises specificity by
 * one class without an !important, which stays reserved for beating an inline
 * style. The classic (legacy-template) rules above need none of this: those
 * stylesheets are enqueued on wp_enqueue_scripts at priority 10 and this file
 * at 20.
 */

/*
 * Cart / Checkout block buttons. The doubled class raises specificity over
 * wc-blocks-style.css, whose rule uses the same single class — the blocks
 * stylesheet can be printed after this file, so source order is not enough.
 * Deliberately a specificity bump, not an !important.
 */
.wc-block-components-button.wc-block-components-button:not(.is-link) {
	background-color: var(--wp--preset--color--brand);
	color: var(--wp--preset--color--brand-contrast);
	border-radius: 0;
	min-height: 48px;
	font-weight: 600;
}

.wc-block-components-button.wc-block-components-button:not(.is-link):hover,
.wc-block-components-button.wc-block-components-button:not(.is-link):focus {
	background-color: var(--wp--preset--color--brand-dark);
	color: var(--wp--preset--color--brand-contrast);
}

.wc-block-components-button.wc-block-components-button.is-link {
	color: var(--wp--preset--color--brand);
}

/*
 * The Mini Cart drawer renders cart markup — a .wc-block-cart-items table of
 * .wc-block-components-product-name rows — on EVERY page, so these two rules
 * cannot live in woocommerce-cart-checkout.css with the rest of the cart
 * styling. Verified by querying every template of the site with the drawer
 * both closed and open: .wc-block-cart-items matches on all twelve.
 */

.woocommerce table.shop_table,
.woocommerce table.cart,
.wc-block-cart-items {
	width: 100%;
	max-width: 100%;
}

.wc-block-components-product-name.wc-block-components-product-name,
.wc-block-components-product-metadata.wc-block-components-product-metadata,
.woocommerce td.product-name {
	overflow-wrap: anywhere;
}

/* The Cart, Checkout and Mini Cart blocks render notices (added-to-cart,
   coupon errors, checkout validation) as wc-block-components-notice-banner,
   not .woocommerce-message/-info/-error above. WooCommerce ships its own
   per-state colours (e.g. is-info defaults to #f4f8ff / #007cba, WordPress
   admin blue) with no theme token involved. Repeated class to out-specify
   WooCommerce's own block.json styles, enqueued after this stylesheet. */
.wc-block-components-notice-banner.wc-block-components-notice-banner.is-info,
.wc-block-components-notice-banner.wc-block-components-notice-banner.is-success,
.wc-block-components-notice-banner.wc-block-components-notice-banner.is-error {
	border-color: var(--wp--preset--color--brand);
	background-color: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--contrast);
}

.wc-block-components-notice-banner.wc-block-components-notice-banner.is-info > svg,
.wc-block-components-notice-banner.wc-block-components-notice-banner.is-success > svg,
.wc-block-components-notice-banner.wc-block-components-notice-banner.is-error > svg {
	background-color: var(--wp--preset--color--brand);
}

/* ----------------------------------------------- header cart / account -- */

.wc-block-mini-cart__button.wc-block-mini-cart__button {
	min-width: 44px;
	min-height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0 6px;
	color: var(--wp--preset--color--contrast);
}

.wc-block-mini-cart__badge.wc-block-mini-cart__badge {
	background-color: var(--wp--preset--color--brand);
	color: var(--wp--preset--color--brand-contrast);
}

.wc-block-customer-account.wc-block-customer-account {
	display: inline-flex;
}

.wc-block-customer-account__link.wc-block-customer-account__link,
.wc-block-customer-account.wc-block-customer-account > a,
.wc-block-customer-account.wc-block-customer-account > button {
	min-width: 44px;
	min-height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--wp--preset--color--contrast);
	text-decoration: none;
}

/*
 * The Mini Cart drawer sits in the page while closed, carrying aria-hidden
 * but still holding focusable links — axe flags it (aria-hidden-focus) and a
 * keyboard user can tab into a panel they cannot see. WooCommerce binds
 * aria-hidden to the open state, so keying visibility off the same attribute
 * takes the closed drawer out of the tab order and puts it back on open.
 */
.wc-block-mini-cart__drawer[aria-hidden="true"] {
	visibility: hidden;
}
