/*
 * The family's drop-down of a product's options (AIEO_Pick_List; 11.3.16, F36), in the multi-select's look
 * (aieo-swatches.css, .om-multi-select-dropdown): the same button, the same panel under it, the options list's rows
 * (their markup, .rc-vrow, drawn here too: F36b, the card's sheet is not loaded for this list), a search over a long
 * list and, where its caller gives one, a foot.
 *
 * Its roles are its own (F36c): every colour and corner it reads is declared on the list itself with the options
 * list's values (aieo-card.css, .rc-scope), so it reads the same with the card's sheet on the page or not. They are
 * declared with no weight (:where), so where the card's sheet is there its .rc-scope decides, with the same values.
 * The colours are the theme's presets, no colour of its own, in both schemes; the corners are the theme's shapes
 * (Rooster Zero's "Square" is square; off Rooster Zero the released 6px of a control and 12px of a panel). The panel
 * sits under the theme's header, drawers, overlays and toasts.
 *
 * The panel lies OVER what follows it: opening it moves nothing on the page.
 *
 * Byte-identical in Rooster One and its Runtime.
 */
:where(.aieo-pick) {
	--rc-color-background: var(--wp--preset--color--bg, var(--wp--preset--color--base, Canvas));
	--rc-color-text: var(--wp--preset--color--fg, var(--wp--preset--color--contrast, CanvasText));
	--rc-color-surface: var(--wp--preset--color--subtle, var(--wp--preset--color--base-2, color-mix(in srgb, CanvasText 5%, Canvas)));
	--rc-color-border: var(--wp--preset--color--line, color-mix(in srgb, CanvasText 14%, Canvas));
	--rc-color-accent: var(--wp--preset--color--accent, var(--rc-color-text));
	--rc-color-success: var(--wp--preset--color--success, var(--rc-color-text));
	--rc-color-contrast: var(--wp--preset--color--contrast, var(--rc-color-text));
	--rc-color-text-muted: var(--wp--preset--color--muted, color-mix(in srgb, CanvasText 64%, Canvas));
	--rc-color-control-line: color-mix(in srgb, var(--rc-color-text) 48%, var(--rc-color-background));
	--rc-radius-control: var(--wp--custom--rooster--shape--control, 6px);
	--rc-radius-panel: var(--wp--custom--rooster--shape--panel, 12px);
	--rc-radius-chip: var(--wp--custom--rooster--shape--chip, 999px);
	--rc-color-accent-text: var(--wp--preset--color--accent-text, var(--rc-color-accent));
	--rc-color-swatch-edge: color-mix(in srgb, var(--rc-color-text) 22%, transparent);
	--rc-font-size-small: var(--wp--preset--font-size--sm, var(--wp--preset--font-size--small, 0.875rem));
	--rc-font-size-medium: var(--wp--preset--font-size--md, var(--wp--preset--font-size--medium, 1rem));
	--rc-text-xs: calc(var(--rc-font-size-small) * 0.857);
	--rc-font-body: var(--wp--preset--font-family--body, system-ui, sans-serif);
}

.aieo-pick {
	position: relative;
	box-sizing: border-box;
	max-inline-size: 400px;
	margin-inline: 0;
	color: var(--rc-color-text);
	font-size: var(--rc-font-size-small);
	line-height: 1.5;
}

.aieo-pick__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	box-sizing: border-box;
	inline-size: 100%;
	min-block-size: 44px;
	margin: 0;
	padding: 12px 16px;
	border: 1px solid var(--rc-color-control-line);
	border-radius: var(--rc-radius-control);
	background: var(--rc-color-background);
	color: inherit;
	font: inherit;
	font-weight: 500;
	text-align: start;
	cursor: pointer;
	appearance: none;
	transition: border-color .2s ease;
}

.aieo-pick__head:hover,
.aieo-pick.is-open .aieo-pick__head {
	border-color: var(--rc-color-text);
}

.aieo-pick.is-open .aieo-pick__head {
	border-end-start-radius: 0;
	border-end-end-radius: 0;
}

/* What is chosen, on one line (the whole of it is the button's name for a screen reader). */
.aieo-pick__title {
	min-inline-size: 0;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

/* Lucide's chevron-down, as a mask in the text's colour. */
.aieo-pick__chevron {
	flex: none;
	inline-size: 16px;
	block-size: 16px;
	background: var(--rc-color-text-muted);
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
	transition: transform .2s ease;
}

.aieo-pick.is-open .aieo-pick__chevron {
	transform: rotate(180deg);
}

.aieo-pick__panel {
	position: absolute;
	inset-block-start: 100%;
	inset-inline: 0;
	z-index: calc(var(--wp--custom--rooster--z--header, 100) - 1);
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	border: 1px solid var(--rc-color-text);
	border-block-start: 0;
	border-end-start-radius: var(--rc-radius-panel);
	border-end-end-radius: var(--rc-radius-panel);
	background: var(--rc-color-background);
	box-shadow: var(--wp--preset--shadow--md, none);
}

.aieo-pick__panel[hidden],
.aieo-pick__search[hidden] {
	display: none;
}

/* The search over the rows: the options list's field, a magnifier before what is typed. */
.aieo-pick .aieo-pick__search.rc-panel__search {
	position: relative;
	padding: 10px 12px;
}

.aieo-pick .aieo-pick__search.rc-panel__search::before {
	content: "";
	position: absolute;
	inset-block-start: 22px;
	inset-inline-start: 24px;
	inline-size: 16px;
	block-size: 16px;
	background: var(--rc-color-text-muted);
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") center / contain no-repeat;
	pointer-events: none;
}

.aieo-pick .rc-field {
	box-sizing: border-box;
	inline-size: 100%;
	min-block-size: 40px;
	margin: 0;
	padding: 0 12px 0 36px;
	border: 1px solid var(--rc-color-control-line);
	border-radius: var(--rc-radius-control);
	background: var(--rc-color-background);
	color: var(--rc-color-text);
	font: 400 var(--rc-font-size-small) / 1.2 var(--rc-font-body);
}

.aieo-pick .rc-field::placeholder {
	color: var(--rc-color-text-muted);
	opacity: 1;
}

/* The rows, in the options list's markup: its box, its swatch, its name, "Out of stock" under it. A tap anywhere on a
   row ticks its box (the row's label lies over it). */
.aieo-pick .rc-vlist {
	margin: 0;
	padding: 2px 0;
	list-style: none;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.aieo-pick .rc-vrow {
	--rc-vrow-sw: 48px;
	position: relative;
	isolation: isolate;
	display: flex;
	align-items: center;
	gap: 12px;
	box-sizing: border-box;
	min-block-size: calc(var(--rc-vrow-sw) + 16px);
	padding: 8px 12px;
	cursor: pointer;
}

.aieo-pick .rc-vrow[hidden] {
	display: none;
}

.aieo-pick .rc-vrow + .rc-vrow {
	border-block-start: 1px solid color-mix(in srgb, var(--rc-color-border) 60%, transparent);
}

@media (hover: hover) and (pointer: fine) {
	.aieo-pick .rc-vrow:not(.is-disabled):not(.is-checked):hover {
		background: color-mix(in srgb, var(--rc-color-surface) 45%, transparent);
	}
}

.aieo-pick .rc-vrow.is-checked {
	background: color-mix(in srgb, var(--rc-color-surface) 70%, transparent);
}

/* Under the theme's design a ticked row is a wash of its accent, as its pressed states (the options list's rule). */
html[data-rooster-design="theme"] .aieo-pick .rc-vrow.is-checked {
	background: color-mix(in srgb, var(--rc-color-accent) 12%, transparent);
}

.aieo-pick .rc-vrow.is-disabled {
	cursor: default;
}

.aieo-pick .rc-check {
	flex: none;
	inline-size: 20px;
	block-size: 20px;
	margin: 0;
	accent-color: var(--rc-color-contrast);
	cursor: pointer;
}

.aieo-pick .rc-vrow .rc-vrow__hit {
	position: absolute;
	inset: 0;
	z-index: 1;
	margin: 0;
	cursor: inherit;
}

.aieo-pick .rc-swatch {
	flex: none;
	display: block;
	box-sizing: border-box;
	inline-size: var(--rc-vrow-sw, 48px);
	block-size: var(--rc-vrow-sw, 48px);
	border-radius: var(--rc-radius-chip);
	background: var(--rc-sw, var(--rc-color-surface)) center / cover no-repeat;
	box-shadow: inset 0 0 0 1px var(--rc-color-swatch-edge);
}

.aieo-pick .rc-vrow__text {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	gap: 1px;
	min-inline-size: 0;
}

.aieo-pick .rc-vrow__name {
	font: 500 var(--rc-font-size-medium) / 1.3 var(--rc-font-body);
	overflow-wrap: anywhere;
}

.aieo-pick .rc-vrow__price {
	color: var(--rc-color-text-muted);
	font: 400 var(--rc-font-size-small) / 1.3 var(--rc-font-body);
}

/* The price as a part of its own, when the Row layout does not put it next to the name. */
.aieo-pick .rc-vrow__amount {
	flex: none;
	font: 500 var(--rc-font-size-small) / 1.3 var(--rc-font-body);
	white-space: nowrap;
}

.aieo-pick .rc-vrow__incart {
	color: var(--rc-color-success);
	font-weight: 600;
}

/* A row's price reads as quiet text: WooCommerce's sale markup without its underline. */
.aieo-pick .rc-vrow__price ins,
.aieo-pick .rc-vrow__amount ins {
	color: var(--rc-color-accent-text);
	text-decoration: none;
}

html[data-rooster-design="theme"] .aieo-pick .rc-vrow__price ins,
html[data-rooster-design="theme"] .aieo-pick .rc-vrow__amount ins {
	color: var(--rc-color-text);
}

.aieo-pick .rc-vrow__price del,
.aieo-pick .rc-vrow__amount del {
	opacity: 0.8;
}

.aieo-pick .rc-vrow__none {
	padding: 16px 12px;
	color: var(--rc-color-text-muted);
	font-size: var(--rc-text-xs);
}

.aieo-pick .rc-vrow.is-disabled .rc-vrow__name,
.aieo-pick .rc-vrow.is-disabled .rc-swatch {
	opacity: 0.5;
}

/* While the rows come: placeholders of a row's height. */
.aieo-pick .rc-vrow--ph {
	cursor: default;
}

.aieo-pick .rc-vrow--ph::before,
.aieo-pick .rc-vrow--ph::after {
	content: "";
	display: block;
	block-size: 12px;
	border-radius: var(--rc-radius-control);
	background: var(--rc-color-surface);
}

.aieo-pick .rc-vrow--ph::before {
	inline-size: 20px;
	block-size: 20px;
}

.aieo-pick .rc-vrow--ph::after {
	flex: 0 1 60%;
}

/* A list with quantities: a ticked row's stepper (the options list's, aieo-card.css), its place kept on every row so a
   tick moves nothing; its buttons above the row's label, the rest of its place ticking the row as the row does. */
.aieo-pick .rc-vrow__step {
	position: relative;
	z-index: 2;
	display: flex;
	flex: none;
	justify-content: flex-end;
	inline-size: 96px;
	margin-inline-start: auto;
	pointer-events: none;
}

.aieo-pick .rc-vrow__step > * {
	pointer-events: auto;
}

.aieo-pick .rc-stepper {
	display: flex;
	align-items: stretch;
	box-sizing: border-box;
	min-block-size: 32px;
	border: 1px solid var(--rc-color-control-line);
	border-radius: var(--rc-radius-control);
	background: var(--rc-color-background);
	color: var(--rc-color-text);
	overflow: hidden;
}

.aieo-pick .rc-stepper__btn {
	display: grid;
	place-items: center;
	flex: none;
	inline-size: 32px;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: inherit;
	cursor: pointer;
}

.aieo-pick .rc-stepper__btn::before {
	content: "";
	inline-size: 18px;
	block-size: 18px;
	background: currentColor;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E") center / contain no-repeat;
}

.aieo-pick .rc-stepper__btn--plus::before {
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M12 6v12M6 12h12'/%3E%3C/svg%3E");
}

.aieo-pick .rc-stepper__btn:not(:disabled):hover {
	background: color-mix(in srgb, currentColor 7%, transparent);
}

.aieo-pick .rc-stepper__btn:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.aieo-pick .rc-stepper__value {
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	min-inline-size: 28px;
	font: 600 var(--rc-font-size-small) / 1 var(--rc-font-body);
	white-space: nowrap;
}

@media (prefers-reduced-motion: no-preference) {
	.aieo-pick .rc-stepper__btn {
		transition: background-color 160ms;
	}
}

/* On a touch screen the stepper's buttons are 44 px (FE-O1), and its place as wide. */
@media (pointer: coarse) {
	.aieo-pick .rc-vrow__step {
		inline-size: 118px;
	}

	.aieo-pick .rc-stepper {
		min-block-size: 46px;
	}

	.aieo-pick .rc-stepper__btn {
		inline-size: 44px;
	}

	.aieo-pick .rc-check {
		inline-size: 22px;
		block-size: 22px;
	}
}

@media (forced-colors: active) {
	.aieo-pick .rc-swatch {
		border: 1px solid CanvasText;
	}
}

/* The rows scroll between the search and the foot; the panel's own edges and the foot's line are the only rules. */
.aieo-pick__panel .rc-vlist {
	flex: 1 1 auto;
	min-block-size: 0;
	max-block-size: min(50vh, 420px);
	border-block: 0;
}

.aieo-pick__foot {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 12px 16px;
	border-block-start: 1px solid var(--rc-color-border);
}

/* The caller's sum in its foot ("3 options · 5 items"), the options list's. */
.aieo-pick .rc-panel__sum {
	display: flex;
	justify-content: space-between;
	gap: 8px;
	margin: 0;
	color: var(--rc-color-text-muted);
	font: 500 var(--rc-text-xs) / 1.3 var(--rc-font-body);
}

.aieo-pick .rc-panel__sum strong {
	color: var(--rc-color-text);
	font-weight: 700;
}

.aieo-pick__msg {
	margin-block-start: 6px;
	font-size: 13px;
}

.aieo-pick__msg:empty {
	display: none;
}

.aieo-pick__msg.is-ok {
	color: var(--rc-color-success);
}

.aieo-pick__msg.is-err {
	color: var(--aieo-color-danger, var(--wp--preset--color--danger, currentColor));
}

@media (max-width: 768px) {
	.aieo-pick {
		max-inline-size: 100%;
	}

	.aieo-pick__head {
		min-block-size: 48px;
	}

	/* A field under 16px makes iOS Safari zoom the page on focus. */
	.aieo-pick .rc-field {
		font-size: 16px;
	}
}
