/**
 * Toqri Product Configurator – product page styles.
 * Colours come from the Avanam theme palette variables, with Toqri's values as fallbacks,
 * so changing the theme palette restyles the configurator too.
 */

.tpc {
	--tpc-brand: var(--global-palette1, #23a455);
	--tpc-brand-dark: #1b8a46;
	--tpc-heading: var(--global-palette3, #222222);
	--tpc-text: var(--global-palette4, #353535);
	--tpc-muted: var(--global-palette6, #676767);
	--tpc-line: #dfe3dd;
	--tpc-surface: var(--global-palette9, #ffffff);
	--tpc-soft: var(--global-palette8, #f7f7f7);
	--tpc-tint: #eff4ed;
	--tpc-tint-strong: #e5f5e0;
	--tpc-error: #c62828;
	--tpc-radius: 8px;

	width: 100%;
	flex: 1 1 100%; /* the theme lays form.cart out as a row */
	margin: 4px 0 20px;
	padding-top: 18px;
	border-top: 1px solid var(--tpc-line);
	color: var(--tpc-text);
}

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

/* If the theme makes the add-to-cart form a flex row, let the configurator take a full line. */
form.cart:has(> .tpc) {
	flex-wrap: wrap;
}

/* ---------- heading ---------- */

.tpc__head {
	margin-bottom: 18px;
}

.tpc__title {
	margin: 0 0 2px;
	font-family: var(--e-global-typography-secondary-font-family, "Work Sans"), sans-serif;
	font-size: 18px;
	font-weight: 600;
	line-height: 1.3;
	color: var(--tpc-heading);
}

.tpc__hint {
	margin: 0;
	font-size: 14px;
	line-height: 1.5;
	color: var(--tpc-muted);
}

/* ---------- groups ---------- */

.tpc .tpc-group {
	min-width: 0;
	margin: 0 0 20px;
	padding: 0;
	background: none;
	border: 0;
	box-shadow: none;
}

.tpc-group[hidden] {
	display: none !important;
}

.tpc .tpc-group__label {
	float: none;
	background: none;
	display: block;
	width: 100%;
	margin: 0 0 10px;
	padding: 0;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.4;
	color: var(--tpc-heading);
}

.tpc-group__req {
	margin-left: 2px;
	color: var(--tpc-brand);
	text-decoration: none;
	border: 0;
}

.tpc-group__value {
	font-weight: 400;
	color: var(--tpc-muted);
}

.tpc-group__value:not(:empty)::before {
	content: ": ";
}

.tpc-group__error {
	margin: 8px 0 0;
	font-size: 13px;
	color: var(--tpc-error);
}

.tpc-group.has-error .tpc-group__label {
	color: var(--tpc-error);
}

.tpc-group.has-error .tpc-choice__body,
.tpc-group.has-error .tpc-select {
	border-color: var(--tpc-error);
}

/* ---------- choices (shared) ---------- */

.tpc-choices {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.tpc-choice {
	position: relative;
	display: flex;
	margin: 0;
	cursor: pointer;
}

/* Real inputs stay in the page for keyboard and screen-reader users. */
.tpc-choice input {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: 0;
	padding: 0;
	opacity: 0;
	pointer-events: none;
}

.tpc-choice__body {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	min-height: 46px;
	padding: 9px 14px;
	background: var(--tpc-surface);
	border: 1.5px solid var(--tpc-line);
	border-radius: var(--tpc-radius);
	transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.tpc-choice:hover .tpc-choice__body {
	border-color: var(--tpc-brand);
}

.tpc-choice input:checked + .tpc-choice__body {
	background: var(--tpc-tint);
	border-color: var(--tpc-brand);
	box-shadow: inset 0 0 0 1px var(--tpc-brand);
}

.tpc-choice input:focus-visible + .tpc-choice__body {
	outline: 2px solid var(--tpc-brand);
	outline-offset: 2px;
}

.tpc-choice input:disabled + .tpc-choice__body {
	cursor: not-allowed;
	opacity: 0.5;
}

.tpc-choice__text {
	display: flex;
	flex-direction: column;
	min-width: 0;
	line-height: 1.3;
}

.tpc-choice__name {
	font-size: 14px;
	font-weight: 500;
	color: var(--tpc-heading);
}

.tpc-choice__price {
	margin-top: 2px;
	font-size: 12.5px;
	font-weight: 600;
	color: var(--tpc-brand-dark);
}

.tpc-choice__dot {
	flex: 0 0 auto;
	width: 26px;
	height: 26px;
	overflow: hidden;
	border-radius: 50%;
	box-shadow: 0 0 0 1px var(--tpc-line);
}

.tpc-choice__dot img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* ---------- image cards ---------- */

.tpc-choices--image {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
}

.tpc-choices--image .tpc-choice__body {
	flex-direction: column;
	align-items: stretch;
	gap: 8px;
	padding: 6px 6px 10px;
	text-align: center;
}

.tpc-choices--image .tpc-choice__text {
	align-items: center;
}

.tpc-choice__media {
	position: relative;
	display: block;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	background: var(--tpc-soft);
	border-radius: calc(var(--tpc-radius) - 3px);
}

.tpc-choice__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.tpc-choice__initial {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	font-size: 22px;
	font-weight: 600;
	color: var(--tpc-muted);
}

/* Tick on the chosen card. */
.tpc-choices--image .tpc-choice input:checked + .tpc-choice__body .tpc-choice__media::after {
	content: "";
	position: absolute;
	top: 6px;
	right: 6px;
	width: 22px;
	height: 22px;
	background: var(--tpc-brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 14px no-repeat;
	border-radius: 50%;
	box-shadow: 0 0 0 2px var(--tpc-surface);
}

/* ---------- checkboxes ---------- */

.tpc-choices--checkbox {
	flex-direction: column;
	gap: 8px;
}

.tpc-choices--checkbox .tpc-choice__body::before {
	content: "";
	flex: 0 0 auto;
	width: 18px;
	height: 18px;
	background: var(--tpc-surface) center / 12px no-repeat;
	border: 1.5px solid var(--tpc-line);
	border-radius: 4px;
}

.tpc-choices--checkbox .tpc-choice input:checked + .tpc-choice__body::before {
	background-color: var(--tpc-brand);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
	border-color: var(--tpc-brand);
}

.tpc-choices--checkbox .tpc-choice__text {
	flex-direction: row;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	flex: 1 1 auto;
	gap: 4px 12px;
}

.tpc-choices--checkbox .tpc-choice__price {
	margin-top: 0;
}

/* ---------- dropdown ---------- */

.tpc-select {
	width: 100%;
	max-width: 440px;
	height: 46px;
	padding: 0 40px 0 14px;
	font: inherit;
	font-size: 14px;
	color: var(--tpc-heading);
	background: var(--tpc-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23676767' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") right 14px center / 16px no-repeat;
	border: 1.5px solid var(--tpc-line);
	border-radius: var(--tpc-radius);
	appearance: none;
	-webkit-appearance: none;
	cursor: pointer;
}

.tpc-select:hover,
.tpc-select:focus {
	border-color: var(--tpc-brand);
}

.tpc-select:focus-visible {
	outline: 2px solid var(--tpc-brand);
	outline-offset: 2px;
}

/* ---------- price summary ---------- */

.tpc-summary {
	margin-top: 6px;
	padding: 14px 16px;
	background: var(--tpc-tint);
	border-radius: var(--tpc-radius);
}

.tpc-summary__lines {
	margin: 0 0 10px;
	padding: 0;
	list-style: none;
}

.tpc-summary__lines li {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	margin: 0;
	padding: 2px 0;
	font-size: 13.5px;
	color: var(--tpc-muted);
}

.tpc-summary__lines li > span:last-child {
	flex: 0 0 auto;
	color: var(--tpc-text);
}

.tpc-summary__total {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	padding-top: 10px;
	border-top: 1px solid var(--tpc-tint-strong);
	border-top-color: rgba(35, 164, 85, 0.25);
}

.tpc-summary__label {
	font-size: 15px;
	font-weight: 600;
	color: var(--tpc-heading);
}

.tpc-summary__amount {
	font-size: 22px;
	font-weight: 700;
	line-height: 1.2;
	color: var(--tpc-brand-dark);
	text-align: right;
}

.tpc-summary__amount del {
	margin-right: 6px;
	font-size: 15px;
	font-weight: 400;
	color: var(--tpc-muted);
	opacity: 1;
}

.tpc-summary__amount ins {
	text-decoration: none;
	background: none;
}

/* ---------- misc ---------- */

.tpc-gallery-bridge {
	display: none !important;
}

.tpc-from {
	font-size: 0.85em;
	font-weight: 400;
	opacity: 0.8;
}

@media (max-width: 767px) {
	.tpc-choices--image {
		grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
		gap: 8px;
	}

	.tpc-choices:not(.tpc-choices--image):not(.tpc-choices--checkbox) .tpc-choice {
		flex: 1 1 calc(50% - 5px);
	}

	.tpc-select {
		max-width: none;
	}

	.tpc-summary__amount {
		font-size: 20px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tpc-choice__body {
		transition: none;
	}
}
