/* Hami Product Addons — storefront */

.hpa-addons {
	--hpa-primary: #2e7d32;
	--hpa-price: #d6004c;
	--hpa-text: #1f2937;
	--hpa-muted: #6b7280;
	--hpa-border: #d1d5db;
	--hpa-bg: #ffffff;
	--hpa-radius: 10px;
	--hpa-swatch: 44px;
	--hpa-swatch-shape: 50%;
	--hpa-focus: 0 0 0 3px color-mix(in srgb, var(--hpa-primary) 30%, transparent);

	display: flex;
	flex-direction: column;
	gap: 22px;
	margin: 4px 0 24px;
	color: var(--hpa-text);
	font-size: 15px;
	line-height: 1.6;
	clear: both;
	width: 100%;
}

.hpa-addons [hidden] { display: none !important; }

.hpa-addons *,
.hpa-addons *::before,
.hpa-addons *::after { box-sizing: border-box; }

/* Field ------------------------------------------------------------- */

.hpa-field { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.hpa-field.hpa-appear { animation: hpa-in .25s ease-out; }
@keyframes hpa-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.hpa-field-label {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 4px;
	margin: 0;
	font-size: 1.07em;
	font-weight: 700;
	color: var(--hpa-text);
	cursor: default;
}
.hpa-field-label::after { content: ":"; order: 1; font-weight: 700; }
.hpa-req { order: 2; color: var(--hpa-price); font-weight: 700; }
.hpa-selected-name { order: 3; font-weight: 500; color: var(--hpa-muted); font-size: .9em; margin-inline-start: 4px; }

.hpa-field-desc { margin: -4px 0 0; color: var(--hpa-muted); font-size: .9em; }

/* Swatches (color / image) ----------------------------------------- */

.hpa-swatches { display: flex; flex-wrap: wrap; gap: 12px; }

.hpa-swatch {
	position: relative;
	display: inline-flex;
	margin: 0;
	cursor: pointer;
	border-radius: var(--hpa-swatch-shape);
}

.hpa-swatch input {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: pointer;
}

.hpa-swatch-ui {
	display: block;
	width: var(--hpa-swatch);
	height: var(--hpa-swatch);
	border-radius: var(--hpa-swatch-shape);
	background: #eee;
	border: 1px solid rgba(0, 0, 0, .12);
	box-shadow: 0 0 0 3px var(--hpa-bg), 0 0 0 4px var(--hpa-border);
	overflow: hidden;
	transition: box-shadow .15s ease, transform .15s ease;
}
.hpa-swatch-ui img { display: block; width: 100%; height: 100%; object-fit: cover; }

.hpa-swatch:hover .hpa-swatch-ui { transform: scale(1.05); }

.hpa-swatch input:checked + .hpa-swatch-ui {
	box-shadow: 0 0 0 3px var(--hpa-bg), 0 0 0 5px var(--hpa-primary);
}
.hpa-swatch input:focus-visible + .hpa-swatch-ui {
	box-shadow: 0 0 0 3px var(--hpa-bg), 0 0 0 5px var(--hpa-primary), 0 0 0 9px color-mix(in srgb, var(--hpa-primary) 25%, transparent);
}
.hpa-swatch input:disabled + .hpa-swatch-ui { opacity: .4; cursor: not-allowed; }

/* Radio / checkbox choices ----------------------------------------- */

.hpa-choices { display: flex; flex-direction: column; gap: 10px; }

.hpa-choice {
	position: relative;
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 6px 10px;
	margin: 0;
	padding: 2px 0;
	cursor: pointer;
	font-weight: 500;
}

.hpa-choice input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
	margin: 0;
	pointer-events: none;
}

.hpa-check {
	position: relative;
	flex: 0 0 auto;
	width: 22px;
	height: 22px;
	border: 1.5px solid var(--hpa-text);
	border-radius: 6px;
	background: var(--hpa-bg);
	transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.hpa-check::after {
	content: "";
	position: absolute;
	inset: 0;
	margin: auto;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--hpa-text);
	transform: scale(0);
	transition: transform .15s ease;
}
.hpa-check-checkbox::after {
	width: 6px;
	height: 11px;
	border-radius: 0;
	background: transparent;
	border: solid #fff;
	border-width: 0 2px 2px 0;
	margin-top: 3px;
	transform: rotate(45deg) scale(0);
}

.hpa-choice:hover .hpa-check { border-color: var(--hpa-primary); }
.hpa-choice input:checked + .hpa-check { border-color: var(--hpa-text); }
.hpa-choice input:checked + .hpa-check::after { transform: scale(1); }
.hpa-choice input:checked + .hpa-check-checkbox { background: var(--hpa-primary); border-color: var(--hpa-primary); }
.hpa-choice input:checked + .hpa-check-checkbox::after { transform: rotate(45deg) scale(1); }
.hpa-choice input:focus-visible + .hpa-check { box-shadow: var(--hpa-focus); border-color: var(--hpa-primary); }
.hpa-choice.is-selected .hpa-choice-label { font-weight: 700; }

.hpa-price {
	color: var(--hpa-price);
	font-weight: 700;
	font-size: .93em;
	white-space: nowrap;
}
.hpa-price .amount, .hpa-price bdi { color: inherit; font-weight: inherit; }
.hpa-hide-prices .hpa-choice .hpa-price,
.hpa-hide-prices .hpa-text-meta .hpa-price { display: none; }

/* Select / text ---------------------------------------------------- */

.hpa-select-wrap { position: relative; max-width: 420px; }

.hpa-addons select.hpa-select,
.hpa-addons input.hpa-text,
.hpa-addons textarea.hpa-text {
	width: 100%;
	max-width: 100%;
	margin: 0;
	padding: 10px 14px;
	font: inherit;
	color: var(--hpa-text);
	background: var(--hpa-bg);
	border: 1px solid var(--hpa-border);
	border-radius: var(--hpa-radius);
	box-shadow: none;
	transition: border-color .15s ease, box-shadow .15s ease;
}
.hpa-addons textarea.hpa-text { min-height: 130px; resize: vertical; }
.hpa-addons select.hpa-select:focus,
.hpa-addons .hpa-text:focus {
	outline: none;
	border-color: var(--hpa-primary);
	box-shadow: var(--hpa-focus);
}

.hpa-text-meta {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 10px;
	margin-top: -4px;
	font-size: .82em;
	color: var(--hpa-muted);
}
.hpa-count b { font-weight: 700; color: var(--hpa-text); }
.hpa-count.is-low b { color: var(--hpa-price); }

/* Errors ----------------------------------------------------------- */

.hpa-error {
	display: flex;
	align-items: center;
	gap: 6px;
	color: #c62828;
	font-size: .88em;
	font-weight: 500;
}
.hpa-error::before {
	content: "!";
	display: inline-grid;
	place-items: center;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #c62828;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
}
.hpa-field.has-error .hpa-check,
.hpa-field.has-error .hpa-text,
.hpa-field.has-error .hpa-select { border-color: #c62828; }
.hpa-field.has-error .hpa-swatch-ui { box-shadow: 0 0 0 3px var(--hpa-bg), 0 0 0 4px #c62828; }

/* Totals ----------------------------------------------------------- */

.hpa-totals {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-top: 8px;
	padding-top: 18px;
	border-top: 1px dashed var(--hpa-border);
}
.hpa-total-row { display: flex; flex-direction: column; gap: 2px; }
.hpa-total-label { font-size: .9em; font-weight: 600; color: var(--hpa-text); }
.hpa-total-value { color: var(--hpa-price); font-weight: 800; font-size: 1.12em; }
.hpa-total-row.is-final .hpa-total-value { font-size: 1.45em; }
.hpa-total-value .amount { color: inherit; }

/* Make room before the qty / add-to-cart row */
form.cart .hpa-addons + .quantity,
form.cart .hpa-addons ~ .single_add_to_cart_button { margin-top: 4px; }
form.cart > .hpa-addons { flex-basis: 100%; }

/* Mobile ----------------------------------------------------------- */

@media (max-width: 480px) {
	.hpa-addons { gap: 18px; }
	.hpa-swatches { gap: 10px; }
	.hpa-swatch-ui { width: calc(var(--hpa-swatch) * .9); height: calc(var(--hpa-swatch) * .9); }
	.hpa-select-wrap { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
	.hpa-addons * { transition: none !important; animation: none !important; }
}
