/* Gift Box Builder — page-scoped styling, brand palette only (see
 * scripts/apply-design-tokens.php for the source hex values, exposed here as
 * Kadence's own --global-paletteN CSS custom properties). */

.po-gift-box-builder {
	max-width: 720px;
	margin: 0 auto;
	padding: 1rem 0 6rem;
}

.po-gift-box {
	background: var(--global-palette9, #fff);
	border: 1px solid var(--global-palette5, #bcbc94);
	border-radius: 16px;
	box-shadow: 0 2px 12px rgba(60, 52, 35, 0.08);
	padding: 1.75rem;
	margin-bottom: 2rem;
	animation: po-box-in 0.25s ease;
}

@keyframes po-box-in {
	from {
		opacity: 0;
		transform: scale(0.98) translateY(6px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.po-gift-box__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 1rem;
}
.po-gift-box__header h3 {
	margin: 0;
	color: var(--global-palette3, #3c3423);
}
.po-gift-box__remove {
	background: none;
	border: none;
	font-size: 1.5rem;
	line-height: 1;
	cursor: pointer;
	color: var(--global-palette2, #54543c);
	padding: 0.25rem 0.5rem;
}
.po-gift-box__remove:hover {
	color: var(--global-palette13, #d02f2e);
}

.po-product-search {
	width: 100%;
	box-sizing: border-box;
	padding: 0.75rem 1rem;
	border: 1px solid var(--global-palette5, #bcbc94);
	border-radius: 10px;
	font-size: 1rem;
}

.po-search-results {
	position: relative;
	background: var(--global-palette9, #fff);
	border: 1px solid var(--global-palette5, #bcbc94);
	border-top: none;
	border-radius: 0 0 10px 10px;
	box-shadow: 0 8px 20px rgba(60, 52, 35, 0.12);
	margin-top: -1px;
	/* Raised from 260px on 01/10. The list now carries one row per size rather
	 * than one per product, so at 260px roughly five of some seventy rows were
	 * visible — which is why Diana concluded the olive oil and the honey sizes
	 * were missing rather than simply further down. */
	max-height: 60vh;
	min-height: 18rem;
	overflow-y: auto;
	overscroll-behavior: contain;
}

/* Category heading inside the picker. Sticky so the shopper can see which
 * group they are scrolling through. */
.po-search-group {
	position: sticky;
	top: 0;
	z-index: 1;
	padding: 0.45rem 1rem;
	background: var(--global-palette8, #dbdbce);
	border-bottom: 1px solid var(--global-palette5, #bcbc94);
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

/* The size, shown inline on the row rather than behind a second click. */
.po-search-result__variant {
	display: inline-block;
	margin-left: 0.35rem;
	padding: 0.05rem 0.4rem;
	border-radius: 999px;
	background: var(--global-palette8, #dbdbce);
	font-size: 0.78em;
	white-space: nowrap;
}

/* --- greeting message per box -------------------------------------------- */

.po-box-message {
	display: block;
	margin-top: 0.85rem;
}

.po-box-message > span {
	display: block;
	margin-bottom: 0.3rem;
	font-size: 0.85rem;
	font-weight: 500;
}

.po-box-message__input {
	display: block;
	width: 100%;
	padding: 0.5rem 0.65rem;
	border: 1px solid var(--global-palette5, #bcbc94);
	border-radius: 8px;
	background: var(--global-palette9, #fff);
	font-family: inherit;
	font-size: 0.92rem;
	line-height: 1.4;
	resize: vertical;
}
.po-search-loading {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	padding: 0.75rem 1rem;
	color: var(--global-palette2, #54543c);
}
.po-spinner {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	border: 2px solid var(--global-palette5, #bcbc94);
	border-top-color: var(--global-palette1, #747c34);
	animation: po-spin 0.7s linear infinite;
	flex-shrink: 0;
}
@keyframes po-spin {
	to {
		transform: rotate(360deg);
	}
}

.po-search-result {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.6rem 1rem;
	cursor: pointer;
}
.po-search-result:hover {
	background: var(--global-palette8, #dbdbce);
}
.po-search-result__thumb {
	width: 40px;
	height: 40px;
	object-fit: cover;
	border-radius: 6px;
	flex-shrink: 0;
}
/* Same reasoning as .po-box-item__name — size from content, never from zero,
 * so a long product name can't collapse into a one-letter column. */
.po-search-result__name {
	flex: 1 1 auto;
	min-width: 5rem;
}
.po-search-result__price {
	color: var(--global-palette2, #54543c);
	font-weight: 600;
	white-space: nowrap;
}

.po-variation-picker {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
	background: var(--global-palette8, #dbdbce);
	border-radius: 10px;
	padding: 0.75rem 1rem;
	margin-top: 0.5rem;
}
.po-variation-select {
	padding: 0.4rem 0.6rem;
	border-radius: 6px;
	border: 1px solid var(--global-palette5, #bcbc94);
}

.po-box-empty {
	color: var(--global-palette2, #54543c);
	font-style: italic;
	margin: 1rem 0;
}

.po-box-items {
	margin: 1rem 0;
}
.po-box-item {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.5rem 0;
	border-bottom: 1px solid var(--global-palette7, #d2d2c2);
}
.po-box-item:last-child {
	border-bottom: none;
}
.po-box-item__thumb {
	width: 44px;
	height: 44px;
	object-fit: cover;
	border-radius: 8px;
	flex-shrink: 0;
}
/* `flex: 1` (i.e. flex-basis: 0) collapsed this to zero width once the
 * thumbnail, quantity stepper, subtotal and remove button had taken the row.
 * Normally min-width:auto would stop a flex item shrinking past its
 * min-content width, but WordPress/Kadence set overflow-wrap:break-word
 * globally, which makes min-content a SINGLE CHARACTER — so the product name
 * rendered as one letter per line on narrow screens. Sizing from content
 * (basis auto) plus an explicit floor prevents that. */
.po-box-item__name {
	flex: 1 1 auto;
	min-width: 6rem;
}
.po-box-item__qty {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	background: var(--global-palette8, #dbdbce);
	border-radius: 999px;
	padding: 0.2rem;
}

/* `display` and `padding` MUST be declared here.
 *
 * Kadence's global stylesheet styles every <button> with
 * `padding:.4em 1em; line-height:1.6; display:inline-block`. The earlier rule
 * set a fixed 24px box and a line-height but left padding and display alone,
 * so that inherited padding shoved the - / + glyph out of the fixed box and it
 * rendered off-centre toward the top-left. Zeroing the padding and centring
 * with flex makes the glyph position independent of whatever the theme does to
 * buttons. */
.po-qty-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	width: 28px;
	height: 28px;
	flex-shrink: 0;
	border-radius: 50%;
	border: 1px solid var(--global-palette1, #747c34);
	background: var(--global-palette9, #fff);
	color: var(--global-palette1, #747c34);
	cursor: pointer;
	line-height: 1;
	font-size: 1.05rem;
	font-weight: 600;
	transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.po-qty-btn:hover {
	background: var(--global-palette1, #747c34);
	color: var(--global-palette9, #fff);
}
.po-qty-btn:active {
	transform: scale(0.92);
}
.po-qty-btn:focus-visible {
	outline: 2px solid var(--global-palette1, #747c34);
	outline-offset: 2px;
}
.po-qty-value {
	min-width: 1.75rem;
	text-align: center;
	font-weight: 600;
	/* Keeps the pill from jiggling as the number changes width. */
	font-variant-numeric: tabular-nums;
}
.po-box-item__subtotal {
	min-width: 5rem;
	text-align: right;
	font-weight: 600;
}
/* Icon-only button: same reason as .po-qty-btn for the explicit display and
 * padding — otherwise Kadence's global button padding makes it far wider than
 * the glyph and knocks it off-centre. */
.po-box-item__remove {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	width: 26px;
	height: 26px;
	flex-shrink: 0;
	background: none;
	border: none;
	line-height: 1;
	font-size: 1.25rem;
	cursor: pointer;
	color: var(--global-palette2, #54543c);
	transition: color 0.15s ease;
}
.po-box-item__remove:hover {
	color: var(--global-palette13, #d02f2e);
}

/* On a phone the five columns (thumbnail, name, stepper, subtotal, remove)
 * cannot share one line legibly — even with the floor above, the row would
 * overflow. Lay it out as a small grid instead: name beside the thumbnail,
 * controls on a second line. */
@media (max-width: 560px) {
	.po-box-item {
		display: grid;
		grid-template-columns: 44px minmax(0, 1fr) auto;
		grid-template-areas:
			"thumb name   remove"
			"thumb qty    subtotal";
		column-gap: 0.75rem;
		row-gap: 0.5rem;
		align-items: center;
	}
	.po-box-item__thumb {
		grid-area: thumb;
		align-self: start;
	}
	.po-box-item__name {
		grid-area: name;
		min-width: 0;
	}
	.po-box-item__remove {
		grid-area: remove;
		justify-self: end;
	}
	.po-box-item__qty {
		grid-area: qty;
		justify-self: start;
	}
	.po-box-item__subtotal {
		grid-area: subtotal;
		justify-self: end;
		min-width: 0;
	}
}

.po-wrap-toggle {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-top: 1rem;
	cursor: pointer;
}
.po-wrap-toggle input {
	width: 1.15rem;
	height: 1.15rem;
	accent-color: var(--global-palette1, #747c34);
}

.po-box-subtotal {
	text-align: right;
	margin-top: 1rem;
	padding-top: 0.75rem;
	border-top: 1px solid var(--global-palette7, #d2d2c2);
	color: var(--global-palette3, #3c3423);
}

.po-btn {
	display: inline-block;
	border-radius: 0;
	padding: 0.75rem 1.75rem;
	font-weight: 600;
	cursor: pointer;
	border: 2px solid var(--global-palette1, #747c34);
	transition: background 0.2s ease, color 0.2s ease;
}
.po-btn--outline {
	background: transparent;
	color: var(--global-palette1, #747c34);
}
.po-btn--outline:hover {
	background: var(--global-palette1, #747c34);
	color: var(--global-palette9, #fff);
}
.po-btn--primary {
	background: var(--global-palette1, #747c34);
	color: var(--global-palette9, #fff);
	width: 100%;
	border: none;
}
.po-btn--primary:hover:not(:disabled) {
	background: var(--global-palette4, #181812);
}
.po-btn--primary:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}
.po-btn--small {
	padding: 0.4rem 0.9rem;
	font-size: 0.85rem;
}
.po-btn--text {
	background: transparent;
	border-color: transparent;
	color: var(--global-palette2, #54543c);
}

.po-add-box-btn {
	display: block;
	margin: 0 auto 2rem;
}

.po-gift-box-summary {
	position: sticky;
	bottom: 0;
	background: var(--global-palette9, #fff);
	border-top: 1px solid var(--global-palette5, #bcbc94);
	padding: 1.25rem 1.75rem;
	border-radius: 16px 16px 0 0;
	box-shadow: 0 -4px 20px rgba(60, 52, 35, 0.1);
}
.po-gift-box-summary__row {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	margin-bottom: 1rem;
}
.po-gift-box-summary__label {
	font-size: 1rem;
	color: var(--global-palette2, #54543c);
}
.po-grand-total {
	font-family: var(--global-heading-font-family, inherit);
	font-size: 1.75rem;
	font-weight: 700;
	color: var(--global-palette3, #3c3423);
}
.po-gift-box-warning {
	color: var(--global-palette13, #d02f2e);
	margin: 0 0 0.75rem;
	text-align: center;
}
