/**
 * Pop Commerce builder: pc-survey.css (R5).
 * Contract: docs/forms-builder/F2-contracts.md sections 3.6, 5.1, 5.8, 5.9.
 * Mirrors css/custom-multiselect.css plus measured prod leaks (option row 40.8 px,
 * label weight 700). Variables (defaults = legacy): --pc-ms-icon-color, --pc-ms-check-color,
 * --pc-ms-option-bg, --pc-ms-hover-bg, --pc-ms-selected-bg, --pc-ms-chevron, --pc-ms-chevron-open,
 * --pc-cat-color-1..6 (per option via data-cat).
 */

/* Wrapper (the survey field carries data-pc-open). */
:where(.pc-field[data-pc-open]) {
	z-index: 100;
	user-select: none;
}

/* Select button (geometry, colors and type come from the node styles). */
:where(.pc-ms-btn) {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	text-align: left;
	cursor: pointer;
	transition: box-shadow 0.2s ease;
}

:where(.pc-ms-text) {
	flex: 1;
	margin-right: 10px;
	overflow: hidden;
	line-height: 1.5;
	text-align: left;
	text-overflow: ellipsis;
	white-space: nowrap;
}

:where(.pc-ms-chev) {
	display: flex;
	flex-direction: column;
	gap: 2px;
	font-size: 10px;
	line-height: 1;
	color: var(--pc-ms-chevron, #d1dede);
}

:where(.pc-ms-chev > svg) {
	display: block;
	width: 10px;
	height: 10px;
	fill: currentcolor;
}

:where(.pc-field.is-open .pc-ms-chev) {
	color: var(--pc-ms-chevron-open, #333333);
}

/* Option list: closed by max-height 0, opacity 0 and visibility hidden. */
:where(.pc-ms-list) {
	position: absolute;
	right: 0;
	left: 0;
	z-index: 10000;
	max-height: 0;
	overflow: hidden;
	border-radius: 0;
	background-color: var(--pc-ms-option-bg, #ffffff);
	box-shadow: 0 4px 12px rgb(0 0 0 / 15%);
	opacity: 0;
	visibility: hidden;
	transition: max-height 0.3s ease, opacity 0.2s ease, visibility 0s linear 0.3s;
}

:where(.pc-field[data-pc-open="up"] > .pc-ms-list) {
	bottom: 40px;
}

:where(.pc-field[data-pc-open="down"] > .pc-ms-list) {
	top: 100%;
}

:where(.pc-field.is-open > .pc-ms-list) {
	max-height: 300px;
	opacity: 1;
	visibility: visible;
	transition: max-height 0.3s ease, opacity 0.2s ease, visibility 0s linear 0s;
}

/* Option row = label (padding 10 0 12.8 14 + label/check offsets gives the measured 40.8 px row). */
.pc-popup .pc-ms-opt {
	position: relative;
	display: flex;
	align-items: flex-start;
	width: 100%;
	margin: 0;
	padding: 10px 0 12.8px 14px;
	overflow: hidden;
	border: 0 none;
	border-radius: 0;
	background: none;
	font: inherit;
	font-size: 12px;
	font-weight: 700;
	line-height: 1;
	letter-spacing: normal;
	text-transform: none;
	color: var(--pc-ms-text-color, #000000);
	cursor: pointer;
	transition: all 0.3s ease;
}

:where(.pc-ms-opt:has(.pc-ms-cb:focus-visible)) {
	outline: 2px solid currentcolor;
	outline-offset: -2px;
}

/* Hidden native checkbox. */
:where(.pc-ms-cb) {
	position: absolute;
	width: 0;
	height: 0;
	margin: 0;
	opacity: 0;
	pointer-events: none;
}

/* Hover and selected background. */
:where(.pc-ms-bg) {
	position: absolute;
	top: 0;
	right: 0;
	left: 0;
	z-index: 1;
	height: 100%;
	background-color: var(--pc-ms-hover-bg, rgb(0 0 0 / 4%));
	opacity: 0;
	transition: opacity 0.2s ease;
	pointer-events: none;
}

:where(.pc-ms-list > .pc-ms-opt:first-child .pc-ms-bg) {
	border-radius: 4px 4px 0 0;
}

:where(.pc-ms-list > .pc-ms-opt:last-child .pc-ms-bg) {
	border-radius: 0 0 4px 4px;
}

:where(.pc-ms-opt:hover .pc-ms-bg) {
	opacity: 1;
}

:where(.pc-ms-opt.is-selected .pc-ms-bg) {
	background-color: var(--pc-ms-selected-bg, rgb(0 0 0 / 6%));
	opacity: 1;
}

/* Icon, label, check above the background. */
:where(.pc-ms-ico, .pc-ms-label, .pc-ms-check) {
	position: relative;
	z-index: 2;
}

:where(.pc-ms-ico) {
	display: flex;
	flex-shrink: 0;
	align-items: center;
	justify-content: center;
	width: 20px;
	height: 16px;
	margin-right: 10px;
	font-size: 16px;
	color: var(--pc-ms-icon-color, #d24dc6);
	transition: transform 0.3s ease, color 0.2s ease;
}

:where(.pc-ms-ico:empty) {
	display: none;
}

:where(.pc-ms-ico > svg) {
	width: auto;
	height: 16px;
	fill: currentcolor;
}

:where(.pc-ms-opt[data-cat="1"] .pc-ms-ico) {
	color: var(--pc-cat-color-1, var(--pc-ms-icon-color, #d24dc6));
}

:where(.pc-ms-opt[data-cat="2"] .pc-ms-ico) {
	color: var(--pc-cat-color-2, var(--pc-ms-icon-color, #d24dc6));
}

:where(.pc-ms-opt[data-cat="3"] .pc-ms-ico) {
	color: var(--pc-cat-color-3, var(--pc-ms-icon-color, #d24dc6));
}

:where(.pc-ms-opt[data-cat="4"] .pc-ms-ico) {
	color: var(--pc-cat-color-4, var(--pc-ms-icon-color, #d24dc6));
}

:where(.pc-ms-opt[data-cat="5"] .pc-ms-ico) {
	color: var(--pc-cat-color-5, var(--pc-ms-icon-color, #d24dc6));
}

:where(.pc-ms-opt[data-cat="6"] .pc-ms-ico) {
	color: var(--pc-cat-color-6, var(--pc-ms-icon-color, #d24dc6));
}

/* Label and check offsets (T2 verified geometry), 0,2,0 like the option row. */
.pc-popup .pc-ms-label {
	margin: 1px 0 0 3px;
	line-height: 17px;
}

.pc-popup .pc-ms-check {
	margin: 3px 10px 0 3px;
}

:where(.pc-ms-opt.is-selected .pc-ms-label) {
	font-weight: 600;
}

/* Check: transparent until selected; sits right after the text (F0 measurement). */
:where(.pc-ms-check) {
	display: block;
	flex-shrink: 0;
	width: 20px;
	height: 13px;
	fill: currentcolor;
	color: transparent;
	transition: color 0.2s ease;
}

:where(.pc-ms-opt.is-selected .pc-ms-check) {
	color: var(--pc-ms-check-color, #3498db);
}

/* Icon bounce on hover: odd rows down, even rows up. */
:where(.pc-ms-opt:hover .pc-ms-ico) {
	animation: pcBounceDown 0.3s ease forwards;
}

:where(.pc-ms-opt:nth-child(even):hover .pc-ms-ico) {
	animation: pcBounceUp 0.3s ease forwards;
}

/* Reduced motion: list opens instantly, no icon movement (F7-D15). */
@media (prefers-reduced-motion: reduce) {
	:where(.pc-ms-list),
	:where(.pc-field.is-open > .pc-ms-list) {
		transition: none;
	}

	.pc-popup .pc-ms-opt {
		transition-property: color, background-color, border-color, box-shadow, opacity;
	}

	:where(.pc-ms-ico) {
		transition: color 0.2s ease;
	}

	:where(.pc-ms-opt:hover .pc-ms-ico),
	:where(.pc-ms-opt:nth-child(even):hover .pc-ms-ico) {
		animation: none;
	}
}
