/*
 * WooPOS store credit and points notices, and WooCommerce's notices on the
 * My Account pages. Added in 3.21.0.
 *
 * WooPOS prints its two lines ("You have $0.00 store credit on your account.",
 * "You have 465 points…") as
 *     <div class="woocommerce-info woopos-credit-points-balance-notice">
 * at the top of every My Account tab. Out of the box they take WooCommerce's
 * generic look: a blue rule along the top, grey box, and an icon drawn with
 * WooCommerce's icon font. The theme does not load that font, so the icon
 * shows as an empty square. The two notices also touch, because the theme
 * zeroes their margin.
 *
 * Specificity: the theme's rule is
 *   .woocommerce-account .entry-content .woocommerce .woocommerce-MyAccount-content .woocommerce-info
 * (five classes). `:is(#pm, …)` borrows an ID's weight, the same trick the
 * checkout stylesheet uses, so these win without !important. #pm does not
 * exist; the second argument is the one that matches.
 *
 * The icon is a CSS mask over a flat colour, so it takes the colour of the
 * notice and needs no font or image request.
 */

/* ------------------------------------------------------------------ */
/* WooPOS balance notices: anywhere they appear                        */
/* ------------------------------------------------------------------ */

:is(#pm, body) .woopos-credit-points-balance-notice {
	--pm-n-accent: var(--wp--preset--color--primary, #004b2a);

	position: relative;
	box-sizing: border-box;
	margin: 0 0 10px;
	padding: 14px 18px 14px 54px;
	border: 1px solid #d5e2d8;
	border-left: 4px solid var(--pm-n-accent);
	border-radius: var(--wp--custom--border-radius--md, 10px);
	background: #f3f8f4;
	color: #1f2a22;
	font-size: 16px;
	line-height: 1.5;
	overflow-wrap: break-word;
}

/* The last notice in a run leaves room before the "Hello …" paragraph. */
:is(#pm, body) .woopos-credit-points-balance-notice:not(:has(+ .woopos-credit-points-balance-notice)) {
	margin-bottom: 24px;
}

/* A star badge in place of the missing font icon. */
:is(#pm, body) .woopos-credit-points-balance-notice::before {
	content: "";
	display: block;
	position: absolute;
	top: 50%;
	left: 16px;
	width: 24px;
	height: 24px;
	margin: 0;
	transform: translateY(-50%);
	background-color: var(--pm-n-accent);
	font-family: inherit;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1a11 11 0 1 0 0 22 11 11 0 0 0 0-22zm0 4.2 1.98 4.02 4.44.64-3.21 3.13.76 4.42L12 15.32l-3.97 2.09.76-4.42-3.21-3.13 4.44-.64z'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1a11 11 0 1 0 0 22 11 11 0 0 0 0-22zm0 4.2 1.98 4.02 4.44.64-3.21 3.13.76 4.42L12 15.32l-3.97 2.09.76-4.42-3.21-3.13 4.44-.64z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* WooCommerce's clearfix ::after is not needed in a block box. */
:is(#pm, body) .woopos-credit-points-balance-notice::after {
	content: none;
}

/* The dollar amount is the point of the line. */
:is(#pm, body) .woopos-credit-points-balance-notice .woocommerce-Price-amount {
	color: var(--pm-n-accent);
	font-weight: 700;
}

:is(#pm, body) .woopos-credit-points-balance-notice a {
	color: var(--pm-n-accent);
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 2px;
}

/* ------------------------------------------------------------------ */
/* WooCommerce's own notices on My Account and the sign-in page        */
/* ("Address changed successfully.", "Account details changed", …)     */
/* Same broken font icon, same card treatment.                         */
/* ------------------------------------------------------------------ */

:is(#pm, .woocommerce-account) .woocommerce :is(.woocommerce-info, .woocommerce-message, .woocommerce-error):not(.woopos-credit-points-balance-notice) {
	--pm-n-accent: var(--wp--preset--color--primary, #004b2a);

	position: relative;
	box-sizing: border-box;
	margin: 0 0 16px;
	padding: 14px 18px 14px 54px;
	border: 1px solid #d5e2d8;
	border-left: 4px solid var(--pm-n-accent);
	border-radius: var(--wp--custom--border-radius--md, 10px);
	background: #f3f8f4;
	color: #1f2a22;
	font-size: 16px;
	line-height: 1.5;
	list-style: none;
}

/*
 * PetGrub narrows the notices box on every account page to 500px, centred,
 * with !important — right for the sign-in form, wrong beside the account
 * menu, where messages then float in the middle of the column above the
 * full-width WooPOS lines. Inside the signed-in area it fills the column.
 * !important is the only way past the theme's !important.
 */
.woocommerce-account .woocommerce-MyAccount-content .woocommerce-notices-wrapper {
	max-width: none !important;
	margin: 0;
}

:is(#pm, .woocommerce-account) .woocommerce .woocommerce-error:not(.woopos-credit-points-balance-notice) {
	--pm-n-accent: #b3261e;

	border-color: #efcfcc;
	border-left-color: var(--pm-n-accent);
	background: #fdf4f3;
}

:is(#pm, .woocommerce-account) .woocommerce :is(.woocommerce-info, .woocommerce-message, .woocommerce-error):not(.woopos-credit-points-balance-notice)::before {
	content: "";
	display: block;
	position: absolute;
	top: 15px;
	left: 16px;
	width: 22px;
	height: 22px;
	margin: 0;
	background-color: var(--pm-n-accent);
	font-family: inherit;
	/* Info: a circled "i". */
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1a11 11 0 1 0 0 22 11 11 0 0 0 0-22zm1.25 17h-2.5v-7.5h2.5zM12 8.75a1.6 1.6 0 1 1 0-3.2 1.6 1.6 0 0 1 0 3.2z'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1a11 11 0 1 0 0 22 11 11 0 0 0 0-22zm1.25 17h-2.5v-7.5h2.5zM12 8.75a1.6 1.6 0 1 1 0-3.2 1.6 1.6 0 0 1 0 3.2z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Success: a circled tick. */
:is(#pm, .woocommerce-account) .woocommerce .woocommerce-message:not(.woopos-credit-points-balance-notice)::before {
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1a11 11 0 1 0 0 22 11 11 0 0 0 0-22zm-1.4 15.6-4.3-4.3 1.77-1.77 2.53 2.53 5.63-5.63 1.77 1.77z'/%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1a11 11 0 1 0 0 22 11 11 0 0 0 0-22zm-1.4 15.6-4.3-4.3 1.77-1.77 2.53 2.53 5.63-5.63 1.77 1.77z'/%3E%3C/svg%3E");
}

/* Error: a circled "!". */
:is(#pm, .woocommerce-account) .woocommerce .woocommerce-error:not(.woopos-credit-points-balance-notice)::before {
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1a11 11 0 1 0 0 22 11 11 0 0 0 0-22zm1.25 17h-2.5v-2.5h2.5zm0-4.5h-2.5V6h2.5z'/%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1a11 11 0 1 0 0 22 11 11 0 0 0 0-22zm1.25 17h-2.5v-2.5h2.5zm0-4.5h-2.5V6h2.5z'/%3E%3C/svg%3E");
}

:is(#pm, .woocommerce-account) .woocommerce :is(.woocommerce-info, .woocommerce-message, .woocommerce-error):not(.woopos-credit-points-balance-notice)::after {
	content: none;
}

:is(#pm, .woocommerce-account) .woocommerce .woocommerce-error li {
	margin: 0;
	padding: 0;
}

:is(#pm, .woocommerce-account) .woocommerce :is(.woocommerce-info, .woocommerce-message, .woocommerce-error):not(.woopos-credit-points-balance-notice) a:not(.button) {
	color: var(--pm-n-accent);
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 2px;
}

/* "View cart" / "Browse products" buttons inside a notice. */
:is(#pm, .woocommerce-account) .woocommerce :is(.woocommerce-info, .woocommerce-message):not(.woopos-credit-points-balance-notice) .button {
	float: right;
	margin: -4px 0 0 12px;
}

@media (max-width: 600px) {
	:is(#pm, body) .woopos-credit-points-balance-notice,
	:is(#pm, .woocommerce-account) .woocommerce :is(.woocommerce-info, .woocommerce-message, .woocommerce-error):not(.woopos-credit-points-balance-notice) {
		padding: 12px 14px 12px 48px;
		font-size: 15px;
	}

	:is(#pm, body) .woopos-credit-points-balance-notice::before,
	:is(#pm, .woocommerce-account) .woocommerce :is(.woocommerce-info, .woocommerce-message, .woocommerce-error):not(.woopos-credit-points-balance-notice)::before {
		left: 13px;
	}

	:is(#pm, .woocommerce-account) .woocommerce :is(.woocommerce-info, .woocommerce-message):not(.woopos-credit-points-balance-notice) .button {
		float: none;
		display: inline-block;
		margin: 8px 0 0;
	}
}
