/**
 * The additions drawer (board SevaAddonDrawer): a dialog from the right (a sheet from the bottom on
 * phones) listing a pooja's optional additions. Shared by the product page (parts/product/addons.php,
 * assets/js/product.js) and the cart's "Edit additions" (assets/js/cart.js). The sheet itself
 * (.ms-sidesheet) is components.css, shared with the fly-cart. Tokens only.
 */

/* ---------- The additions drawer (board SevaAddonDrawer); the sheet is components.css ---------- */
.ms-addons__filters {
	display: flex;
	flex-shrink: 0;
	gap: var(--space-8);
	padding: 0 var(--space-20) var(--space-12);
	overflow-x: auto;
	scrollbar-width: none;
}

/* From 768 the chips wrap to a second row: no label cut mid-word (D-185 Q-10, amends boards 13, 18). */
@media (min-width: 768px) {
	.ms-addons__filters {
		flex-wrap: wrap;
		overflow-x: visible;
	}
}

.ms-addons__filters::-webkit-scrollbar {
	display: none;
}

.ms-addons__filter {
	flex-shrink: 0;
}

.ms-addons__count {
	font-weight: 400;
	opacity: 0.75;
}

.ms-addons__group {
	display: flex;
	flex-direction: column;
	gap: var(--space-8);
	margin: 0 0 var(--space-24);
	padding: 0;
	border: 0;
}

.ms-addons__legend {
	margin-bottom: var(--space-4);
	padding: 0;
	font-size: var(--type-label-size);
	font-weight: 600;
	line-height: var(--type-label-lh);
	color: var(--text-primary);
}

.ms-addons__hint {
	margin: calc(var(--space-4) * -1) 0 0;
	font-size: var(--type-body-sm-size);
	line-height: var(--type-label-lh);
	color: var(--text-secondary);
}

/*
 * One addition (board 13 / board 11, D-119(5)): a white row on the sheet's page ground: icon tile | name,
 * one-line summary | price | the round add control. The name's label stretches over the row, so the
 * whole row is the target; the control sits above it. Chosen: the soft band with a 1px maroon edge.
 * Under 480 the price moves under the name.
 */
.ms-addon {
	position: relative;
	display: grid;
	grid-template-columns: var(--space-40) minmax(0, 1fr) auto auto;
	grid-template-areas: "icon body price control";
	align-items: center;
	gap: var(--space-4) var(--space-12);
	padding: var(--space-12) var(--space-16);
	border: 1px solid transparent;
	border-radius: var(--radius-md);
	background-color: var(--surface-raised);
	box-shadow: var(--shadow-card);
	transition: border-color var(--duration-sm) var(--easing-standard), background-color var(--duration-sm) var(--easing-standard);
}

@media (hover: hover) {
	.ms-addon:hover {
		border-color: var(--border-control);
	}
}

.ms-addon:has(.ms-addon__input:checked) {
	border-color: var(--action-primary);
	background-color: var(--surface-soft);
}

.ms-addon.is-included {
	border-color: transparent;
	background-color: var(--surface-soft);
}

.ms-addon__icon {
	grid-area: icon;
	display: inline-flex;
	align-self: start;
	align-items: center;
	justify-content: center;
	width: var(--space-40);
	height: var(--space-40);
	border-radius: var(--radius-sm);
	background-color: var(--surface-soft);
	color: var(--icon-ritual);
}

.ms-addon:has(.ms-addon__input:checked) .ms-addon__icon {
	background-color: var(--surface-raised);
}

.ms-addon__body {
	grid-area: body;
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	min-width: 0;
}

.ms-addon__name {
	font-size: var(--type-label-size);
	font-weight: 600;
	line-height: var(--type-label-lh);
	color: var(--text-primary);
	cursor: pointer;
}

/* The label covers the row, so a tap anywhere on it ticks the control. */
.ms-addon__name::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
}

/* The one-line summary (D-134 Q-3): today's description, its first line on screen. */
.ms-addon__desc {
	display: -webkit-box;
	overflow: hidden;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 1;
	line-clamp: 1;
	font-size: var(--type-body-sm-size);
	line-height: var(--type-label-lh);
	color: var(--text-secondary);
}

.ms-addon__note {
	font-size: var(--type-body-sm-size);
	line-height: var(--type-label-lh);
	color: var(--text-secondary);
}

/* The resolver price in dark ink, 700 tabular; "Request a quote" / "Included" read as words. No
   "+ GST", no struck price (D-117). */
.ms-addon__price {
	grid-area: price;
	font-size: var(--type-price-sm-size);
	font-weight: var(--type-price-sm-weight);
	line-height: var(--type-price-sm-lh);
	font-variant-numeric: tabular-nums lining-nums;
	color: var(--text-price);
	white-space: nowrap;
	text-align: end;
}

.ms-addon:has(.ms-addon__note) .ms-addon__price {
	font-size: var(--type-label-size);
	font-weight: 600;
	line-height: var(--type-label-lh);
	color: var(--text-secondary);
}

/* The add control: a 32px round button. Off: a plus on white with a 3:1 edge. On: maroon with a white
   tick. The one-choice rows (the cab) use the same circle with a dot. */
.ms-addon__input {
	position: relative;
	z-index: 1;
	grid-area: control;
	width: var(--space-32);
	height: var(--space-32);
	margin: 0;
	border: 1px solid var(--border-control);
	border-radius: var(--radius-pill);
	background-color: var(--surface-raised);
	background-image:
		linear-gradient(var(--action-primary), var(--action-primary)),
		linear-gradient(var(--action-primary), var(--action-primary));
	background-position: center;
	background-repeat: no-repeat;
	background-size: var(--space-12) var(--space-2), var(--space-2) var(--space-12);
	appearance: none;
	cursor: pointer;
	transition: background-color var(--duration-sm) var(--easing-standard), border-color var(--duration-sm) var(--easing-standard);
}

.ms-addon__input:checked {
	border-color: var(--action-primary);
	background-color: var(--action-primary);
	background-image: none;
}

.ms-addon__input[type="checkbox"]:checked::after {
	content: "";
	position: absolute;
	top: var(--space-8);
	left: 11px; /* ppn-allow: optical centre of the tick in the 32px disc (board 11) */
	width: 7px; /* ppn-allow: tick stroke box (board 11) */
	height: var(--space-12);
	border-right: var(--space-2) solid var(--text-on-primary);
	border-bottom: var(--space-2) solid var(--text-on-primary);
	transform: rotate(45deg);
}

.ms-addon__input[type="radio"] {
	background-image: none;
}

.ms-addon__input[type="radio"]:checked {
	background-image: radial-gradient(circle, var(--text-on-primary) 0 var(--space-4), transparent calc(var(--space-4) + 1px));
	background-size: auto; /* The plus sign's 12 x 2 size would squeeze the dot into a bar (a minus). */
}

.ms-addon__input:disabled {
	cursor: default;
}

.ms-addon__input:focus-visible {
	outline: var(--focus-width) solid var(--focus-ring);
	outline-offset: var(--focus-offset);
}

/* "None for now" (the one-choice group's empty choice): a slim row, words and the control only. */
.ms-addon--none {
	grid-template-columns: minmax(0, 1fr) auto;
	grid-template-areas: "body control";
	border-color: var(--border-subtle);
	background-color: transparent;
	box-shadow: none;
}

.ms-addon--none:has(.ms-addon__input:checked) {
	border-color: var(--border-subtle);
	background-color: transparent;
}

@media (max-width: 479px) {
	.ms-addon {
		grid-template-columns: var(--space-40) minmax(0, 1fr) auto;
		grid-template-areas:
			"icon body control"
			"icon price control";
		padding: var(--space-12);
	}

	.ms-addon__price {
		text-align: start;
	}

	.ms-addon--none {
		grid-template-columns: minmax(0, 1fr) auto;
		grid-template-areas: "body control";
	}
}

@media (forced-colors: active) {
	.ms-addon:has(.ms-addon__input:checked) {
		outline: 2px solid Highlight;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ms-addon,
	.ms-addon__input {
		transition: none;
	}
}

/* The running count and subtotal over Save; the notes joined with " · " (product.js). */
.ms-addons__sum p {
	margin: 0;
}

.ms-addons__sum-row {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: var(--space-12);
	font-size: var(--type-label-size);
	line-height: var(--type-label-lh);
	color: var(--text-body);
}

.ms-addons__sum-row strong {
	font-size: var(--type-price-md-size);
	font-weight: var(--type-price-md-weight);
	line-height: var(--type-price-md-lh);
	font-variant-numeric: tabular-nums lining-nums;
	color: var(--text-price);
}

.ms-addons__sum .ms-addons__sum-note {
	margin-top: var(--space-4);
	font-size: var(--type-label-size);
	line-height: var(--type-label-lh);
	color: var(--text-secondary);
}

.ms-addons__sum-note:empty {
	display: none;
}
