/**
 * Product options block.
 *
 * Uses the Marina's Art theme's presets (colours, fonts, radii) with
 * fallbacks, so it also looks right in other themes. The look follows the
 * theme's third design: white pills with a sea-glass ring, the chosen one
 * filled in teal with white text, and a hand-written preview line.
 */

/*
 * The variables are declared on the add-to-cart form too: the total next to
 * the button is drawn inside it, and the form is a sibling of .ma-po.
 */
.ma-po,
.ma-po-form {
	--ma-po-text: var(--wp--preset--color--contrast, #16211f);
	--ma-po-muted: var(--wp--preset--color--muted, #4f5855);
	--ma-po-divider: var(--wp--preset--color--sea-glass, #a9d6ce);
	--ma-po-accent: var(--wp--preset--color--accent, #046b5e);
	--ma-po-on-accent: var(--wp--preset--color--base, #fff);
	--ma-po-ring: var(--wp--preset--color--sea-glass, #a9d6ce);
	--ma-po-hover: var(--wp--preset--color--accent-tint, #eef7f5);
	--ma-po-focus: var(--wp--preset--color--accent-light, #028577);
	--ma-po-error: var(--wp--preset--color--berry-deep, #56366a);
	--ma-po-field-bg: var(--wp--preset--color--white, #fff);
	--ma-po-tint: var(--wp--preset--color--pink-tint, #f7f0fa);
	--ma-po-hand: var(--wp--preset--color--accent, #046b5e);
	--ma-po-hand-font: var(--wp--preset--font-family--playpen-sans, var(--wp--preset--font-family--mynerve, inherit));
	--ma-po-pill: var(--wp--preset--border-radius--pill, 999px);
}

.ma-po {
	display: flex;
	flex-direction: column;
	gap: 22px;
	margin-block: var(--wp--preset--spacing--20, 12px) 0;
	min-width: 0;
	position: relative;
}

.ma-po [hidden] {
	display: none !important;
}

.ma-po-sr {
	border: 0;
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	white-space: nowrap;
	width: 1px;
}

/* Fields */

.ma-po-field {
	border: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin: 0;
	min-width: 0;
	padding: 0;
}

.ma-po-field__legend {
	color: var(--ma-po-muted);
	font-size: 14px;
	line-height: 1.4;
	margin: 0 0 2px;
	padding: 0;
}

fieldset.ma-po-field > .ma-po-field__legend {
	margin-bottom: 10px;
}

.ma-po-field__current {
	color: var(--ma-po-text);
	font-weight: 600;
	margin-inline-start: 0.25em;
}

.ma-po-field__required {
	color: var(--wp--preset--color--berry, #734a8a);
	margin-inline-start: 0.2em;
}

/* "Flower colour *" until something is chosen, then "Flower colour: Purple". */
.ma-po-field__legend:has(.ma-po-field__current:empty) .ma-po-field__colon,
.ma-po-field__legend:has(.ma-po-field__current:not(:empty)) .ma-po-field__required {
	display: none;
}

.ma-po-field__head {
	align-items: baseline;
	display: flex;
	gap: 12px;
	justify-content: space-between;
}

.ma-po-field__count {
	color: var(--ma-po-muted);
	flex: none;
	font-size: 13px;
	font-variant-numeric: tabular-nums;
}

.ma-po-field__help {
	color: var(--ma-po-muted);
	font-size: 12.5px;
	line-height: 1.45;
	margin: 0;
}

/* Under a name field: the live preview and the note, hand-written. */
.ma-po-field--text .ma-po-field__help {
	color: var(--ma-po-hand);
	font-family: var(--ma-po-hand-font);
	font-size: 14px;
	line-height: 1.5;
}

.ma-po-field__error,
.ma-po__error {
	color: var(--ma-po-error);
	font-size: 13px;
	font-weight: 600;
	line-height: 1.4;
	margin: 0;
}

/* Choice pills */

.ma-po-choices {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.ma-po-choice {
	align-items: center;
	background: var(--ma-po-field-bg);
	border: 0;
	border-radius: var(--ma-po-pill);
	box-shadow: inset 0 0 0 1.5px var(--ma-po-ring);
	color: var(--ma-po-accent);
	cursor: pointer;
	display: inline-flex;
	font-family: var(--wp--preset--font-family--commissioner, inherit);
	font-size: 14px;
	font-weight: 500;
	gap: 8px;
	line-height: 1.2;
	min-height: 44px;
	padding: 0 16px;
	position: relative;
	transition: background-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
	user-select: none;
}

.ma-po-choice.has-swatch {
	padding-inline-start: 10px;
}

.ma-po-choice:hover {
	background: var(--ma-po-hover);
}

.ma-po-choice:has(.ma-po-choice__input:checked),
.ma-po-choice.is-selected {
	background: var(--ma-po-accent);
	box-shadow: inset 0 0 0 1.5px var(--ma-po-accent);
	color: var(--ma-po-on-accent);
}

.ma-po-choice:has(.ma-po-choice__input:focus-visible) {
	outline: 2px solid var(--ma-po-focus);
	outline-offset: 2px;
}

.ma-po-choice__input {
	clip-path: inset(50%);
	height: 1px;
	margin: 0;
	opacity: 0;
	overflow: hidden;
	position: absolute;
	width: 1px;
}

.ma-po-choice__swatch {
	background: var(--ma-po-swatch, transparent);
	border-radius: 50%;
	box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ma-po-accent) 25%, transparent);
	flex: none;
	height: 24px;
	width: 24px;
}

/* On the filled pill, a light ring keeps dark swatches (black, dark glitter) visible. */
.ma-po-choice:has(.ma-po-choice__input:checked) .ma-po-choice__swatch,
.ma-po-choice.is-selected .ma-po-choice__swatch {
	box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--ma-po-on-accent) 70%, transparent);
}

img.ma-po-choice__swatch {
	object-fit: cover;
}

/* Letters and numbers: a square grid. */
.ma-po-choices--grid {
	display: grid;
	gap: 6px;
	grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
}

.ma-po-choices--grid .ma-po-choice {
	border-radius: var(--wp--preset--border-radius--small, 8px);
	font-size: 15px;
	font-weight: 600;
	justify-content: center;
	padding: 0;
}

/* Text inputs */

.ma-po-input {
	background: var(--ma-po-field-bg);
	border: 1px solid var(--ma-po-divider);
	border-radius: var(--ma-po-pill);
	box-sizing: border-box;
	color: var(--ma-po-text);
	font-family: var(--wp--preset--font-family--commissioner, inherit);
	font-size: 16px;
	min-height: 50px;
	padding: 10px 18px;
	width: 100%;
}

.ma-po-input--textarea {
	border-radius: var(--wp--preset--border-radius--large, 18px);
	line-height: 1.5;
	min-height: 104px;
	resize: vertical;
}

.ma-po-input:focus-visible {
	border-color: var(--ma-po-focus);
	outline: 2px solid var(--ma-po-focus);
	outline-offset: 0;
}

.ma-po-input[aria-invalid="true"] {
	border-color: var(--ma-po-error);
}

/* Notes: "included" facts, prompts and small headings. */

.ma-po-note {
	align-items: center;
	color: var(--wp--preset--color--contrast-soft, #36403d);
	display: flex;
	font-size: 14px;
	gap: 10px;
	line-height: 1.45;
	margin: 0;
}

.ma-po-note__icon {
	background: var(--wp--preset--color--accent-soft, #dcefeb) no-repeat center / 15px 15px;
	border-radius: 50%;
	flex: none;
	height: 28px;
	width: 28px;
}

.ma-po-note--check .ma-po-note__icon {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23046b5e' stroke-width='2.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}

.ma-po-note--info {
	background: var(--ma-po-tint);
	border-radius: var(--wp--preset--border-radius--large, 18px);
	padding: 14px 18px;
}

.ma-po-note--info .ma-po-note__icon {
	background-color: var(--wp--preset--color--white, #fff);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23734a8a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7.9 20A9 9 0 1 0 4 16.1L2 22Z'/%3E%3C/svg%3E");
}

.ma-po-note--heading {
	color: var(--wp--preset--color--accent-light, #028577);
	font-family: var(--wp--preset--font-family--alegreya, inherit);
	font-size: 19px;
	font-style: italic;
	font-weight: 700;
	margin-block: 6px -8px;
}

.ma-po-note a {
	color: var(--ma-po-focus);
}

/* Added-to-cart message */

.ma-po__toast {
	align-items: center;
	background: var(--ma-po-accent);
	border-radius: var(--ma-po-pill);
	bottom: 28px;
	box-shadow: 0 12px 28px rgba(2, 58, 52, 0.3);
	color: var(--ma-po-on-accent);
	display: flex;
	font-size: 14px;
	font-weight: 500;
	gap: 14px;
	left: 50%;
	opacity: 0;
	padding: 6px 6px 6px 20px;
	pointer-events: none;
	position: fixed;
	transform: translate(-50%, 10px);
	transition: opacity 0.25s ease, transform 0.25s ease;
	white-space: nowrap;
	z-index: 100;
}

.ma-po__toast.is-visible {
	opacity: 1;
	pointer-events: auto;
	transform: translate(-50%, 0);
}

/* "View cart": a lilac pill inside the toast. */
.ma-po__toast-link,
.ma-po__toast-link:visited {
	align-items: center;
	background: var(--wp--preset--color--pink, #d4b3e2);
	border-radius: var(--ma-po-pill);
	color: var(--wp--preset--color--plum, #3b2449);
	display: flex;
	font-weight: 600;
	min-height: 40px;
	padding: 0 16px;
	text-decoration: none;
}

.ma-po__toast-link:hover {
	background: var(--wp--preset--color--pink-light, #dfc6ea);
	color: var(--wp--preset--color--plum, #3b2449);
}

@media (max-width: 781px) {
	/* Above the theme's sticky add-to-cart bar. */
	.ma-po__toast {
		bottom: calc(98px + env(safe-area-inset-bottom, 0px));
	}
}

@media (prefers-reduced-motion: reduce) {
	.ma-po-choice,
	.ma-po__toast {
		transition: none;
	}
}

/* Live price next to the product price */

.ma-po-live-price[hidden],
.wp-block-woocommerce-product-price[hidden] {
	display: none !important;
}

.ma-po-live-price {
	align-items: baseline;
	display: flex;
	flex-wrap: wrap;
	gap: 4px 10px;
	margin: 0;
}

.ma-po-live-price__amount {
	font-weight: 700;
}

.ma-po-live-price__base {
	color: var(--wp--preset--color--muted, #4f5855);
	font-size: 13px;
}

/* Total next to the add-to-cart button (the theme's add-to-cart bar). */

.ma-po-form.ma-po-has-total .ma-atc__bar {
	align-items: center;
	column-gap: 14px;
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
}

.ma-po-form.ma-po-has-total .ma-atc__bar::before,
.ma-po-form.ma-po-has-total .ma-atc__bar::after {
	grid-column: 1;
	line-height: 1.2;
	white-space: nowrap;
}

.ma-po-form.ma-po-has-total .ma-atc__bar::before {
	align-self: end;
	color: var(--wp--preset--color--muted, #4f5855);
	content: var(--ma-po-total-label, "");
	font-size: 12px;
	grid-row: 1;
}

.ma-po-form.ma-po-has-total .ma-atc__bar::after {
	align-self: start;
	color: var(--ma-po-accent);
	content: var(--ma-po-total, "");
	font-size: 18px;
	font-weight: 700;
	grid-row: 2;
}

.ma-po-form.ma-po-has-total .ma-atc__bar > * {
	grid-column: 2;
	grid-row: 1 / span 2;
	min-width: 0;
}

/* While the choices are being added. */
.ma-po-form.is-ma-po-busy .wc-block-components-product-button__button {
	cursor: progress;
	opacity: 0.6;
	pointer-events: none;
}

/* Site Editor placeholder */

.ma-po--placeholder {
	border: 1px dashed var(--ma-po-divider);
	border-radius: var(--wp--preset--border-radius--medium, 16px);
	gap: 12px;
	padding: 16px;
}

.ma-po-placeholder__title {
	font-weight: 600;
	margin: 0;
}

.ma-po-placeholder__description {
	color: var(--ma-po-muted);
	font-size: 13px;
	margin: 0;
}
