/*
 * Buying without leaving the page: the card's − n + stepper, the variation
 * picker and the «به سبد اضافه شد» note (cart-ui.js).
 */

.fc-step,
.fc-pick,
.fc-toast {
	--fcu-accent: var(--fs-accent, var(--fp-accent, #7b2cbf));
	--fcu-ink: #1d1730;
	--fcu-muted: #6b6580;
	--fcu-line: #ece9f2;
	--fcu-soft: #f6f5f9;
	--fcu-card: #fff;
	--fcu-ease: cubic-bezier(0.32, 0.72, 0, 1);
	font-family: var(--farin-font, inherit);
	letter-spacing: 0;
}

[data-fc-add].is-busy,
.fc-step.is-busy,
.fc-pick__add.is-busy {
	opacity: 0.6;
	pointer-events: none;
}

/* ---------- Card stepper ---------- */

.fc-step {
	display: inline-flex;
	align-items: center;
	justify-content: space-between;
	min-inline-size: 112px;
	block-size: 44px;
	padding: 4px;
	border-radius: 14px;
	background: color-mix(in srgb, var(--fcu-accent) 10%, var(--fcu-card));
	color: var(--fcu-accent);
}

/*
 * In a card the − n + stepper is wider than the button it replaces: it takes
 * its own full row under the price, so it never sits on top of it.
 */
.fs-card__foot:has(> .fc-step:not([hidden])) {
	flex-wrap: wrap;
}

/* A full width, not a flex-basis: on phones the foot is a column, where a basis would be a height. */
.fs-card__foot > .fc-step:not([hidden]) {
	flex: none;
	inline-size: 100%;
	min-inline-size: 0;
}

/* The card's own button styles set display; hidden must still win once the stepper shows. */
.fc-step[hidden],
[data-fc-add][hidden] {
	display: none !important;
}

.fc-step button {
	display: grid;
	place-items: center;
	inline-size: 36px;
	block-size: 36px;
	padding: 0;
	border: 0;
	border-radius: 10px;
	background: var(--fcu-card);
	color: inherit;
	cursor: pointer;
	transition: transform 0.15s var(--fcu-ease);
}

.fc-step button:active {
	transform: scale(0.9);
}

.fc-step span {
	min-inline-size: 28px;
	font-weight: 800;
	text-align: center;
	font-variant-numeric: tabular-nums;
}

/* ---------- «به سبد اضافه شد» ---------- */

.fc-toast {
	position: fixed;
	inset-inline: 16px;
	inset-block-end: calc(var(--fbb-h, 0px) + var(--fp-mbar-h, 0px) + 16px);
	z-index: 1200;
	display: flex;
	align-items: center;
	gap: 12px;
	inline-size: min(100% - 32px, 440px);
	margin-inline: auto;
	padding: 10px 12px;
	border: 1px solid var(--fcu-line);
	border-radius: 18px;
	background: var(--fcu-card);
	box-shadow: 0 18px 48px rgb(29 23 48 / 0.18);
	color: var(--fcu-ink);
	opacity: 0;
	transform: translateY(16px) scale(0.98);
	pointer-events: none;
	transition: opacity 0.25s var(--fcu-ease), transform 0.35s var(--fcu-ease);
}

.fc-toast.is-on {
	opacity: 1;
	transform: none;
	pointer-events: auto;
}

.fc-toast img,
.fc-toast__mark {
	flex: none;
	inline-size: 52px;
	block-size: 52px;
	border-radius: 12px;
	background: var(--fcu-soft);
	object-fit: contain;
}

.fc-toast__mark {
	display: grid;
	place-items: center;
	color: #16a34a;
}

.fc-toast.is-bad .fc-toast__mark {
	color: #dc2626;
}

.fc-toast__text {
	display: flex;
	flex: 1;
	flex-direction: column;
	min-inline-size: 0;
	line-height: 1.6;
}

.fc-toast__text b {
	font-size: 14px;
}

.fc-toast:not(.is-bad) .fc-toast__text b::before {
	content: "";
	display: inline-block;
	inline-size: 8px;
	block-size: 8px;
	margin-inline-end: 6px;
	border-radius: 50%;
	background: #16a34a;
	vertical-align: middle;
}

.fc-toast__text small {
	overflow: hidden;
	color: var(--fcu-muted);
	font-size: 12px;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.fc-toast__go {
	flex: none;
	display: inline-flex;
	align-items: center;
	min-block-size: 40px;
	padding: 0 14px;
	border-radius: 12px;
	background: var(--fcu-accent);
	color: #fff !important;
	font-size: 13px;
	font-weight: 700;
	text-decoration: none !important;
}

.fc-toast__x {
	flex: none;
	display: grid;
	place-items: center;
	inline-size: 32px;
	block-size: 32px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: var(--fcu-muted);
	cursor: pointer;
}

/* ---------- The picker ---------- */

.fc-pick {
	inline-size: min(100% - 32px, 460px);
	max-block-size: min(88dvh, 720px);
	margin: auto;
	padding: 0;
	border: 0;
	border-radius: 24px;
	background: var(--fcu-card);
	box-shadow: 0 30px 80px rgb(29 23 48 / 0.3);
	color: var(--fcu-ink);
}

.fc-pick[open] {
	animation: fc-pick-in 0.3s var(--fcu-ease);
}

.fc-pick::backdrop {
	background: rgb(20 16 40 / 0.45);
	backdrop-filter: blur(3px);
}

@keyframes fc-pick-in {
	from {
		opacity: 0;
		transform: translateY(20px) scale(0.98);
	}
}

.fc-pick__box {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 18px;
	padding: 20px;
}

.fc-pick__x {
	position: absolute;
	inset-block-start: 12px;
	inset-inline-end: 12px;
	display: grid;
	place-items: center;
	inline-size: 40px;
	block-size: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--fcu-soft);
	color: var(--fcu-ink);
	cursor: pointer;
}

.fc-pick__head {
	display: flex;
	align-items: center;
	gap: 14px;
	padding-inline-end: 44px;
}

.fc-pick__head img {
	flex: none;
	inline-size: 88px;
	block-size: 88px;
	border-radius: 16px;
	background: var(--fcu-soft);
	object-fit: contain;
}

.fc-pick__head h2 {
	margin: 0 0 6px;
	font-size: 16px;
	line-height: 1.6;
}

.fc-pick__price {
	margin: 0;
	color: var(--fcu-accent);
	font-weight: 800;
}

.fc-pick__price del {
	margin-inline-end: 6px;
	color: var(--fcu-muted);
	font-size: 12px;
	font-weight: 400;
}

.fc-pick__price ins {
	text-decoration: none;
}

.fc-pick__group p {
	margin: 0 0 10px;
	color: var(--fcu-muted);
	font-size: 13px;
}

.fc-pick__group b {
	color: var(--fcu-ink);
}

.fc-pick__group.is-need p {
	color: #dc2626;
	animation: fc-shake 0.4s;
}

@keyframes fc-shake {
	25% { transform: translateX(-4px); }
	75% { transform: translateX(4px); }
}

.fc-pick__opts {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.fc-pick__opt {
	position: relative;
	min-inline-size: 52px;
	min-block-size: 44px;
	padding: 0 14px;
	border: 1.5px solid var(--fcu-line);
	border-radius: 12px;
	background: var(--fcu-card);
	color: var(--fcu-ink);
	font: inherit;
	font-size: 14px;
	cursor: pointer;
	transition: border-color 0.15s, box-shadow 0.15s;
}

.fc-pick__opt[aria-pressed="true"] {
	border-color: var(--fcu-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--fcu-accent) 18%, transparent);
	font-weight: 700;
}

.fc-pick__opt.is-color {
	inline-size: 44px;
	min-inline-size: 0;
	padding: 4px;
	border-radius: 50%;
}

.fc-pick__opt.is-color span {
	display: block;
	inline-size: 100%;
	block-size: 100%;
	border-radius: 50%;
	background: var(--c);
	box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08);
}

/* Not in stock with what else is chosen: faded and crossed. */
.fc-pick__opt.is-out {
	opacity: 0.4;
	cursor: not-allowed;
}

.fc-pick__opt.is-out::after {
	content: "";
	position: absolute;
	inset: 50% 6px auto;
	block-size: 1.5px;
	background: currentColor;
	transform: rotate(-20deg);
}

.fc-pick__note {
	margin: 0;
	padding: 10px 12px;
	border-radius: 12px;
	background: #fef2f2;
	color: #b91c1c;
	font-size: 13px;
}

.fc-pick__note[hidden] {
	display: none;
}

.fc-pick__foot {
	display: flex;
	gap: 10px;
}

.fc-pick__qty {
	display: inline-flex;
	align-items: center;
	padding: 4px;
	border: 1px solid var(--fcu-line);
	border-radius: 14px;
}

.fc-pick__qty button {
	display: grid;
	place-items: center;
	inline-size: 40px;
	block-size: 40px;
	padding: 0;
	border: 0;
	border-radius: 10px;
	background: none;
	color: var(--fcu-ink);
	cursor: pointer;
}

.fc-pick__qty span {
	min-inline-size: 28px;
	font-weight: 800;
	text-align: center;
}

.fc-pick__add {
	display: inline-flex;
	flex: 1;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-block-size: 50px;
	border: 0;
	border-radius: 14px;
	background: var(--fcu-accent);
	color: #fff;
	font: inherit;
	font-weight: 700;
	cursor: pointer;
	transition: opacity 0.2s, transform 0.1s;
}

.fc-pick__add.is-off {
	opacity: 0.5;
}

.fc-pick__add:active {
	transform: scale(0.98);
}

.fc-pick__more {
	align-self: center;
	color: var(--fcu-muted);
	font-size: 13px;
}

.fc-pick__load {
	display: flex;
	justify-content: center;
	gap: 6px;
	padding: 48px;
}

.fc-pick__load span {
	inline-size: 10px;
	block-size: 10px;
	border-radius: 50%;
	background: var(--fcu-accent);
	animation: fc-dot 0.9s infinite alternate;
}

.fc-pick__load span:nth-child(2) { animation-delay: 0.2s; }
.fc-pick__load span:nth-child(3) { animation-delay: 0.4s; }

@keyframes fc-dot {
	to {
		opacity: 0.3;
		transform: translateY(-4px);
	}
}

/* Phones: the picker is a sheet from the bottom. */
@media (max-width: 640px) {
	.fc-pick {
		inline-size: 100%;
		max-inline-size: 100%;
		margin-block-end: 0;
		border-end-start-radius: 0;
		border-end-end-radius: 0;
	}

	.fc-pick[open] {
		animation-name: fc-sheet-in;
	}

	@keyframes fc-sheet-in {
		from {
			transform: translateY(100%);
		}
	}

	.fc-pick__box {
		padding-block-end: calc(20px + env(safe-area-inset-bottom));
	}
}

@media (prefers-reduced-motion: reduce) {
	.fc-toast,
	.fc-pick[open],
	.fc-pick__group.is-need p {
		transition: none;
		animation: none;
	}
}

/* Night mode. */
html[data-farin-theme="dark"] :is(.fc-step, .fc-pick, .fc-toast) {
	--fcu-ink: #ece9f2;
	--fcu-muted: #a59fb8;
	--fcu-line: #342d46;
	--fcu-soft: #241f31;
	--fcu-card: #1b1726;
}

html[data-farin-theme="dark"] .fc-pick__note {
	background: #3a1a1f;
	color: #fca5a5;
}
