/**
 * BOGO Select — gift chooser for the cart and checkout pages.
 *
 * Deliberately low-specificity and colour-neutral so it inherits the theme.
 * The same markup is used by the classic templates and by the Cart/Checkout
 * blocks, so nothing here assumes a cart table around it.
 */

/*
 * The mount point the chooser is replaced inside. It keeps the block layout
 * from collapsing when the chooser is empty, and constrains the panel to the
 * same width as the block it sits above.
 */
.bogo-select-slot:empty {
	display: none;
}

.bogo-select-slot {
	width: 100%;
	max-width: 100%;
}

.bogo-select {
	border: 2px dashed currentColor;
	border-radius: 6px;
	padding: 1.25em;
	margin: 0 0 2em;
	opacity: 1;
	transition: opacity 0.15s ease-in-out;
}

.bogo-select.is-busy {
	opacity: 0.6;
	pointer-events: none;
}

.bogo-select__header {
	margin-bottom: 1em;
}

.bogo-select__title {
	margin: 0 0 0.25em;
	font-size: 1.25em;
}

.bogo-select__subtitle {
	margin: 0;
	font-size: 0.9em;
	opacity: 0.8;
}

.bogo-select__search {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.5em;
	margin: 0 0 1em;
}

.bogo-select__search label {
	font-size: 0.9em;
	font-weight: 600;
}

.bogo-select__search-input {
	flex: 1 1 14em;
	max-width: 24em;
	padding: 0.4em 0.6em;
}

.bogo-select__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	gap: 1em;
	list-style: none;
	margin: 0;
	padding: 0;
}

.bogo-select__item {
	display: flex;
	flex-direction: column;
	gap: 0.5em;
	border: 1px solid rgba(128, 128, 128, 0.35);
	border-radius: 4px;
	padding: 0.75em;
	margin: 0;
	text-align: center;
}

.bogo-select__item.is-selected {
	border-width: 2px;
	border-style: solid;
	border-color: currentColor;
}

.bogo-select__item.is-unavailable {
	opacity: 0.55;
}

.bogo-select__thumb img {
	display: block;
	width: 100%;
	height: auto;
	margin: 0 auto;
	border-radius: 3px;
}

.bogo-select__info {
	display: flex;
	flex-direction: column;
	gap: 0.15em;
	flex: 1 1 auto;
}

.bogo-select__name {
	font-weight: 600;
	line-height: 1.3;
}

.bogo-select__price del {
	opacity: 0.6;
	margin-right: 0.35em;
}

/* The card holds a figure per variation and shows the one being quoted. Stated
   here because a theme that gives spans a display of their own would otherwise
   override the browser's own handling of [hidden] and show the whole set. */
.bogo-select__price-option[hidden] {
	display: none;
}

.bogo-select__reason {
	font-size: 0.8em;
	opacity: 0.75;
}

/* The label names the selector for screen readers; the selector itself is
   self-evident beside the product name, so the label is not shown. */
.bogo-select__variation-label {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.bogo-select__variation {
	margin-top: 0.35em;
	max-width: 100%;
	font-size: 0.9em;
}

.bogo-select__actions {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.35em;
}

.bogo-select__actions .button {
	width: 100%;
}

.bogo-select__selected {
	font-weight: 700;
	text-transform: uppercase;
	font-size: 0.8em;
	letter-spacing: 0.05em;
}

.bogo-select__remove {
	background: none;
	border: 0;
	padding: 0;
	font-size: 0.8em;
	text-decoration: underline;
	cursor: pointer;
	color: inherit;
}

.bogo-select__empty {
	margin: 1em 0 0;
	font-size: 0.9em;
	opacity: 0.8;
}

.bogo-select__pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 0.75em;
	margin: 1em 0 0;
}

.bogo-select__page-status {
	font-size: 0.9em;
	opacity: 0.8;
}

.bogo-select__pagination .button[disabled] {
	opacity: 0.5;
	cursor: default;
}

.bogo-select__message {
	margin: 1em 0 0;
	font-size: 0.9em;
}

.bogo-select__message.is-error {
	color: #b32d2e;
	font-weight: 600;
}

/*
 * Narrow screens.
 *
 * The card grid falls to a single column on a phone, which turns each gift into
 * a full-width product image — a handful of options then costs several screens
 * of scrolling before the customer reaches their own cart lines. Below the
 * breakpoint each card becomes a compact row shaped like a cart line item:
 * small thumbnail on the left, name and price beside it, the button underneath.
 * The image is the one thing that has to give, so it is the one thing capped.
 */
@media screen and (max-width: 600px) {
	.bogo-select {
		padding: 1em;
	}

	.bogo-select__grid {
		grid-template-columns: 1fr;
		gap: 0.75em;
	}

	.bogo-select__item {
		display: grid;
		grid-template-columns: 64px minmax(0, 1fr);
		grid-template-areas:
			"thumb info"
			"thumb actions";
		align-items: start;
		column-gap: 0.75em;
		row-gap: 0.5em;
		padding: 0.6em;
		text-align: left;
	}

	.bogo-select__thumb {
		grid-area: thumb;
	}

	.bogo-select__info {
		grid-area: info;
	}

	.bogo-select__actions {
		grid-area: actions;
		flex-direction: row;
		flex-wrap: wrap;
		align-items: center;
		justify-content: flex-start;
		gap: 0.5em 0.75em;
	}

	/* A full-width button is right in a column of cards and wrong in a row that
	   already gives its width to the name and price. */
	.bogo-select__actions .button {
		width: auto;
	}

	/*
	 * Touch targets.
	 *
	 * At this width these are tapped with a thumb rather than pointed at, and
	 * the theme's own button height — 21px when this was measured — is below
	 * the 24px WCAG 2.2 asks for and well below what a thumb wants. 44px is the
	 * size the platform guidelines settled on. The flex centring is what keeps
	 * the label in the middle of the taller box instead of riding at its top.
	 *
	 * "Remove gift" is styled as text rather than as a button and still has to
	 * be hit, so it gets the same target without gaining a border: its
	 * background stays transparent, so the extra height is reach rather than
	 * anything the customer sees.
	 */
	.bogo-select__actions .button,
	.bogo-select__remove {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		min-height: 44px;
	}

	.bogo-select__remove {
		padding: 0 0.25em;
	}
}

/* Cart table markers. */

.bogo-select-badge {
	display: inline-block;
	font-size: 0.75em;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	border: 1px solid currentColor;
	border-radius: 3px;
	padding: 0 0.4em;
	margin-left: 0.4em;
	vertical-align: middle;
	white-space: nowrap;
}

.bogo-select-free-price {
	font-weight: 700;
}

.bogo-select-locked-qty {
	display: inline-block;
	padding: 0 0.5em;
}
