/* ============================================
   SJ FX — transparent section, rich cards
   ============================================ */

.sj-fx {
	--sj-fx-gold-line: rgba(183, 149, 103, 0.22);
	--sj-fx-card: rgba(255, 255, 255, 0.92);
	--sj-fx-card-hover: #ffffff;
	--sj-fx-ink: #1c1916;
	--sj-fx-ink-soft: #5c5650;
	--sj-fx-green-deep: #062018;
	--sj-fx-green-mid: #145940;
	/* Responsive tokens — overridden per breakpoint below */
	--sj-fx-cols: 4;
	--sj-fx-gap: clamp(0.85rem, 2vw, 1.25rem);
	--sj-fx-cell-min-h: clamp(11rem, 24vmin, 14rem);
	--sj-fx-section-pad-y: clamp(4rem, 11vw, 7.5rem);
	--sj-fx-section-margin-y: clamp(0.75rem, 2.5vw, 1.75rem);
	--sj-fx-board-mode: grid;
}

.sj-fx.sj-section {
	position: relative;
	isolation: isolate;
	overflow: visible;
	min-height: 0;
	display: flex;
	flex-direction: column;
	justify-content: center;
	box-sizing: border-box;
	/* فاصله بیشتر با سکشن قبل/بعد — بدون ارتفاع اجباری تمام‌صفحه */
	padding-block: var(--sj-fx-section-pad-y);
	margin-block: var(--sj-fx-section-margin-y);
	padding-inline: max(0px, env(safe-area-inset-left)) max(0px, env(safe-area-inset-right));
	box-shadow: none;
	background: transparent;
}

.sj-fx__container {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: clamp(1.75rem, 4.5vmin, 2.75rem);
	width: 100%;
}

/* Header */
.sj-fx__head {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 1.25rem 1.75rem;
	padding-bottom: clamp(0.5rem, 1.5vw, 1rem);
	border-bottom: 1px solid color-mix(in srgb, var(--sj-fx-gold-line) 70%, transparent);
}

.sj-fx__title {
	margin: 0 0 0.4rem;
	padding-bottom: 0.55rem;
	font-size: clamp(1.4rem, 3.4vw, 2.1rem);
	font-weight: 800;
	letter-spacing: -0.035em;
	line-height: 1.2;
	color: var(--sj-fx-ink);
	position: relative;
}

.sj-fx__title::after {
	content: '';
	position: absolute;
	inset-inline-start: 0;
	bottom: 0;
	width: clamp(2.75rem, 12vw, 4.5rem);
	height: 3px;
	border-radius: 999px;
	background: linear-gradient(90deg, var(--sj-fx-green-mid), var(--sj-color-primary));
	opacity: 0.9;
}

.sj-fx__sub {
	margin: 0;
	max-width: 46ch;
	font-size: clamp(0.8rem, 1.35vw, 0.92rem);
	font-weight: 500;
	line-height: 1.7;
	color: var(--sj-fx-ink-soft);
}

.sj-fx__pulse {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0;
	padding: 0.42rem 0.9rem 0.42rem 0.7rem;
	border-radius: 999px;
	font-size: 0.72rem;
	font-weight: 700;
	color: var(--sj-fx-ink-soft);
	border: 1px solid var(--sj-fx-gold-line);
	background: linear-gradient(145deg, var(--sj-fx-green-deep), var(--sj-fx-green-mid));
	color: #f0d690;
	box-shadow: 0 4px 16px rgba(6, 32, 24, 0.12);
}

.sj-fx__pulse-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #4ade80;
	box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5);
	animation: sj-fx-pulse 2.2s ease-out infinite;
}

.sj-fx__pulse-label {
	font-weight: 800;
}

.sj-fx__pulse-time {
	font-variant-numeric: tabular-nums;
	direction: ltr;
	unicode-bidi: isolate;
	opacity: 0.88;
	font-weight: 600;
}

@keyframes sj-fx-pulse {
	0% {
		box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.45);
	}
	70% {
		box-shadow: 0 0 0 10px rgba(74, 222, 128, 0);
	}
	100% {
		box-shadow: 0 0 0 0 rgba(74, 222, 128, 0);
	}
}

@media (prefers-reduced-motion: reduce) {
	.sj-fx__pulse-dot {
		animation: none;
		box-shadow: none;
	}
}

/* Board */
.sj-fx__board {
	container-type: inline-size;
	container-name: sj-fx-board;
	display: grid;
	grid-template-columns: repeat(var(--sj-fx-cols), minmax(0, 1fr));
	gap: var(--sj-fx-gap);
	align-items: stretch;
}

.sj-fx__cell {
	position: relative;
	display: grid;
	grid-template-rows: auto 1fr auto;
	gap: 0.65rem;
	min-height: var(--sj-fx-cell-min-h);
	padding: clamp(1.1rem, 2.6vw, 1.5rem);
	border-radius: clamp(20px, 2.8vw, 26px);
	background: var(--sj-fx-card);
	border: 1px solid rgba(183, 149, 103, 0.14);
	box-shadow:
		0 1px 0 rgba(255, 255, 255, 0.9) inset,
		0 16px 44px rgba(60, 48, 32, 0.07),
		0 2px 10px rgba(6, 32, 24, 0.04);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	isolation: isolate;
	overflow: hidden;
	transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.35s ease, border-color 0.25s ease;
}

.sj-fx__cell::before {
	content: '';
	position: absolute;
	inset-inline: 0;
	top: 0;
	height: 3px;
	background: linear-gradient(90deg, var(--sj-fx-green-deep), var(--sj-fx-green-mid), var(--sj-color-primary));
	opacity: 0;
	transition: opacity 0.3s ease;
}

@media (hover: hover) and (pointer: fine) {
	.sj-fx__cell:hover {
		transform: translateY(-6px);
		background: var(--sj-fx-card-hover);
		border-color: rgba(20, 89, 64, 0.22);
		box-shadow:
			0 1px 0 rgba(255, 255, 255, 1) inset,
			0 24px 52px rgba(6, 32, 24, 0.1),
			0 6px 18px rgba(183, 149, 103, 0.14);
	}

	.sj-fx__cell:hover::before {
		opacity: 1;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.sj-fx__cell {
		animation: sj-fx-enter 0.65s cubic-bezier(0.22, 1, 0.36, 1) backwards;
	}

	.sj-fx__cell:nth-child(1) {
		animation-delay: 0.05s;
	}

	.sj-fx__cell:nth-child(2) {
		animation-delay: 0.12s;
	}

	.sj-fx__cell:nth-child(3) {
		animation-delay: 0.19s;
	}

	.sj-fx__cell:nth-child(4) {
		animation-delay: 0.26s;
	}
}

@keyframes sj-fx-enter {
	from {
		opacity: 0;
		transform: translateY(18px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.sj-fx__cell-no {
	position: absolute;
	top: 0.75rem;
	inset-inline-start: 0.85rem;
	z-index: 2;
	font-family: ui-monospace, monospace;
	font-size: 0.58rem;
	font-weight: 800;
	letter-spacing: 0.12em;
	color: var(--sj-color-primary);
	opacity: 0.45;
}

.sj-fx__water {
	position: absolute;
	inset-inline-end: 0.25rem;
	bottom: 0.15rem;
	z-index: 0;
	font-family: ui-monospace, 'Cascadia Mono', monospace;
	font-size: clamp(3.5rem, 10vw, 5rem);
	font-weight: 700;
	line-height: 1;
	color: var(--sj-fx-green-mid);
	opacity: 0.06;
	pointer-events: none;
	user-select: none;
}

/* Cell head */
.sj-fx__cell-head {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	position: relative;
	z-index: 1;
}

.sj-fx__mark {
	display: grid;
	place-items: center;
	flex-shrink: 0;
	width: clamp(2.75rem, 6vw, 3.25rem);
	height: clamp(2.75rem, 6vw, 3.25rem);
	border-radius: 14px;
	color: #f0d690;
	background: linear-gradient(145deg, #062018 0%, #0c3d2c 45%, #145940 100%);
	border: 1px solid rgba(240, 214, 144, 0.2);
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, 0.12),
		0 6px 16px rgba(6, 32, 24, 0.2);
	font-size: 1.35rem;
}

.sj-fx__meta {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
	min-width: 0;
}

.sj-fx__iso {
	align-self: flex-start;
	font-family: ui-monospace, monospace;
	font-size: 0.62rem;
	font-weight: 800;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	padding: 0.22rem 0.5rem;
	border-radius: 6px;
	color: #f0d690;
	background: linear-gradient(145deg, #062018 0%, #0c3d2c 38%, #145940 72%, #0c3d2c 100%);
	border: 1px solid rgba(240, 214, 144, 0.2);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.sj-fx__name {
	font-size: 0.74rem;
	font-weight: 600;
	color: var(--sj-fx-ink-soft);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Price */
.sj-fx__price-block {
	display: flex;
	align-items: flex-end;
	flex: 1;
	position: relative;
	z-index: 1;
	padding-block: 0.25rem 0.35rem;
}

.sj-fx__mid {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.45rem 0.55rem;
}

.sj-fx__value {
	font-variant-numeric: tabular-nums;
	font-size: clamp(1.35rem, 3.2vw, 1.85rem);
	font-weight: 800;
	letter-spacing: -0.05em;
	color: var(--sj-fx-ink);
	line-height: 1;
	direction: ltr;
	unicode-bidi: isolate;
	transition: color 0.2s ease, transform 0.2s ease;
}

.sj-fx__value.is-tick {
	animation: sj-fx-tick 0.48s ease;
}

@keyframes sj-fx-tick {
	0% {
		transform: scale(1);
		color: var(--sj-fx-green-mid);
	}

	45% {
		transform: scale(1.04);
	}

	100% {
		transform: scale(1);
	}
}

@media (prefers-reduced-motion: reduce) {
	.sj-fx__cell {
		animation: none;
	}

	.sj-fx__value.is-tick {
		animation: none;
	}
}

.sj-fx__rial {
	font-size: 0.68rem;
	font-weight: 700;
	color: var(--sj-color-primary-dark);
	opacity: 0.8;
}

/* Foot — delta + meter + spark */
.sj-fx__foot {
	display: grid;
	grid-template-columns: auto 1fr;
	grid-template-rows: auto auto;
	gap: 0.4rem 0.65rem;
	align-items: center;
	position: relative;
	z-index: 1;
	padding-top: 0.65rem;
	border-top: 1px solid rgba(183, 149, 103, 0.14);
}

.sj-fx__delta {
	grid-column: 1;
	grid-row: 1;
	display: inline-flex;
	align-items: center;
	gap: 0.2rem;
	padding: 0.28rem 0.55rem;
	border-radius: 8px;
	font-variant-numeric: tabular-nums;
	font-size: 0.72rem;
	font-weight: 800;
	direction: ltr;
	unicode-bidi: isolate;
	color: var(--sj-fx-ink-soft);
	background: rgba(0, 0, 0, 0.04);
}

.sj-fx__delta.is-positive {
	color: #15803d;
	background: rgba(21, 128, 61, 0.1);
}

.sj-fx__delta.is-negative {
	color: #c2410c;
	background: rgba(194, 65, 12, 0.1);
}

.sj-fx__meter {
	grid-column: 2;
	grid-row: 1;
	height: 4px;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.06);
	overflow: hidden;
}

.sj-fx__meter-fill {
	display: block;
	height: 100%;
	width: 0;
	border-radius: inherit;
	background: linear-gradient(90deg, var(--sj-fx-green-mid), var(--sj-color-primary));
	transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.sj-fx__cell.is-up .sj-fx__meter-fill {
	background: linear-gradient(90deg, #15803d, #4ade80);
}

.sj-fx__cell.is-down .sj-fx__meter-fill {
	background: linear-gradient(90deg, #c2410c, #fb923c);
}

.sj-fx__spark {
	grid-column: 1 / -1;
	grid-row: 2;
	width: 100%;
	height: 22px;
	opacity: 0.55;
}

.sj-fx__spark-line {
	stroke: var(--sj-color-primary);
	transition: stroke 0.3s ease, d 0.4s ease;
}

.sj-fx__cell.is-up .sj-fx__spark-line {
	stroke: #15803d;
}

.sj-fx__cell.is-down .sj-fx__spark-line {
	stroke: #c2410c;
}

/* ============ Responsive — advanced ============ */

/* Large desktop */
@media (min-width: 1280px) {
	.sj-fx {
		--sj-fx-gap: 1.35rem;
		--sj-fx-cell-min-h: 15rem;
	}

	.sj-fx__value {
		font-size: clamp(1.5rem, 2vw, 2rem);
	}

	.sj-fx__mark {
		width: 3.5rem;
		height: 3.5rem;
		font-size: 1.5rem;
	}
}

/* Laptop / small desktop */
@media (max-width: 1199px) {
	.sj-fx {
		--sj-fx-cols: 4;
		--sj-fx-gap: clamp(0.75rem, 1.6vw, 1rem);
		--sj-fx-cell-min-h: clamp(10.5rem, 22vmin, 13rem);
	}
}

@media (max-width: 1100px) {
	.sj-fx {
		--sj-fx-cols: 2;
		--sj-fx-cell-min-h: clamp(10rem, 20vmin, 12.5rem);
	}
}

/* Tablet landscape & medium */
@media (max-width: 900px) {
	.sj-fx {
		--sj-fx-section-pad-y: clamp(3.25rem, 9vw, 5.5rem);
		--sj-fx-gap: 0.85rem;
	}

	.sj-fx__container {
		gap: clamp(1.35rem, 3.5vw, 2rem);
	}

	.sj-fx__head {
		align-items: flex-end;
	}

	.sj-fx__head-text {
		flex: 1 1 auto;
		min-width: 0;
	}

	.sj-fx__pulse {
		flex-shrink: 0;
		align-self: flex-end;
	}
}

/* Tablet portrait — horizontal snap rail (peek next card) */
@media (max-width: 768px) and (min-width: 561px) {
	.sj-fx {
		--sj-fx-board-mode: scroll;
	}

	.sj-fx__board {
		display: flex;
		flex-wrap: nowrap;
		gap: var(--sj-fx-gap);
		overflow-x: auto;
		overflow-y: hidden;
		overscroll-behavior-x: contain;
		scroll-snap-type: x mandatory;
		scroll-padding-inline: var(--sj-container-padding, 1.5rem);
		-webkit-overflow-scrolling: touch;
		padding-block: 0.25rem 0.65rem;
		margin-inline: calc(-1 * var(--sj-container-padding, 1.5rem));
		padding-inline: var(--sj-container-padding, 1.5rem);
		scrollbar-width: thin;
		scrollbar-color: rgba(183, 149, 103, 0.45) transparent;
	}

	.sj-fx__board::-webkit-scrollbar {
		height: 5px;
	}

	.sj-fx__board::-webkit-scrollbar-thumb {
		border-radius: 999px;
		background: rgba(183, 149, 103, 0.4);
	}

	.sj-fx__board {
		mask-image: linear-gradient(
			90deg,
			transparent 0%,
			#000 6%,
			#000 92%,
			transparent 100%
		);
		-webkit-mask-image: linear-gradient(
			90deg,
			transparent 0%,
			#000 6%,
			#000 92%,
			transparent 100%
		);
	}

	.sj-fx__cell {
		flex: 0 0 min(19rem, calc(100% - 2.5rem));
		min-height: clamp(9.5rem, 28vw, 11.5rem);
		scroll-snap-align: start;
		scroll-snap-stop: always;
	}

	.sj-fx__board::after {
		content: '';
		flex: 0 0 0.35rem;
	}
}

/* Mobile — stacked cards, horizontal inner layout */
@media (max-width: 560px) {
	.sj-fx {
		--sj-fx-cols: 1;
		--sj-fx-gap: 0.7rem;
		--sj-fx-cell-min-h: 0;
		--sj-fx-section-pad-y: clamp(2.75rem, 11vw, 4.5rem);
		--sj-fx-section-margin-y: clamp(0.5rem, 3vw, 1.25rem);
	}

	.sj-fx__head {
		flex-direction: row;
		flex-wrap: nowrap;
		align-items: flex-end;
		justify-content: space-between;
		gap: 0.65rem 1rem;
	}

	.sj-fx__head-text {
		flex: 1 1 auto;
		min-width: 0;
	}

	.sj-fx__title {
		font-size: clamp(1.15rem, 4.8vw, 1.5rem);
	}

	.sj-fx__sub {
		max-width: none;
		font-size: 0.78rem;
		line-height: 1.55;
	}

	.sj-fx__pulse {
		flex: 0 0 auto;
		align-self: flex-end;
		font-size: 0.65rem;
		padding: 0.34rem 0.65rem;
		white-space: nowrap;
	}

	.sj-fx__board {
		display: grid;
		grid-template-columns: 1fr;
		overflow: visible;
		margin-inline: 0;
		padding-inline: 0;
		scroll-snap-type: none;
	}

	.sj-fx__cell {
		display: grid;
		grid-template-columns: auto 1fr;
		grid-template-rows: auto auto;
		grid-template-areas:
			'head price'
			'foot foot';
		column-gap: 0.85rem;
		row-gap: 0.55rem;
		align-items: center;
		padding: 1rem 1rem 0.95rem;
		min-height: 0;
	}

	.sj-fx__cell::before {
		opacity: 0.35;
	}

	.sj-fx__cell-no {
		top: 0.55rem;
		inset-inline-start: 0.65rem;
		font-size: 0.52rem;
	}

	.sj-fx__water {
		inset-inline-end: 0.35rem;
		top: 50%;
		bottom: auto;
		transform: translateY(-50%);
		font-size: clamp(3rem, 20vw, 4.25rem);
	}

	.sj-fx__cell-head {
		grid-area: head;
		min-width: 0;
	}

	.sj-fx__mark {
		width: 2.65rem;
		height: 2.65rem;
		border-radius: 12px;
		font-size: 1.15rem;
	}

	.sj-fx__name {
		white-space: normal;
		line-height: 1.35;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		overflow: hidden;
	}

	.sj-fx__price-block {
		grid-area: price;
		justify-content: flex-end;
		padding-block: 0;
	}

	.sj-fx__mid {
		justify-content: flex-end;
		text-align: end;
	}

	.sj-fx__value {
		font-size: clamp(1.2rem, 5.5vw, 1.45rem);
	}

	.sj-fx__foot {
		grid-area: foot;
		grid-template-columns: auto 1fr;
		grid-template-rows: auto auto;
		padding-top: 0.55rem;
		margin-top: 0.15rem;
	}

	.sj-fx__spark {
		height: 20px;
	}
}

/* Extra small */
@media (max-width: 380px) {
	.sj-fx__cell {
		grid-template-columns: 1fr;
		grid-template-areas:
			'head'
			'price'
			'foot';
		row-gap: 0.65rem;
	}

	.sj-fx__price-block,
	.sj-fx__mid {
		justify-content: flex-start;
		text-align: start;
	}

	.sj-fx__mark {
		width: 2.5rem;
		height: 2.5rem;
	}
}

/* Short landscape — compact grid (not in snap-rail band) */
@media (max-height: 520px) and (orientation: landscape) and (min-width: 769px) and (max-width: 1100px) {
	.sj-fx {
		--sj-fx-section-pad-y: clamp(2rem, 6vh, 3rem);
		--sj-fx-cell-min-h: 8.5rem;
		--sj-fx-cols: 2;
	}

	.sj-fx__sub {
		display: none;
	}

	.sj-fx__board {
		display: grid;
		overflow: visible;
		margin-inline: 0;
		padding-inline: 0;
		mask-image: none;
		-webkit-mask-image: none;
	}

	.sj-fx__cell {
		min-height: 8.5rem;
		flex: unset;
	}
}

/* Touch — accent always visible, no hover lift */
@media (hover: none), (pointer: coarse) {
	.sj-fx__cell::before {
		opacity: 0.25;
	}

	.sj-fx__cell:hover {
		transform: none;
	}
}

/* Container query — narrow board inside container */
@container sj-fx-board (max-width: 520px) {
	.sj-fx__value {
		font-size: clamp(1.1rem, 4.5cqi, 1.4rem);
	}
}

@container sj-fx-board (max-width: 280px) {
	.sj-fx__cell-head {
		flex-direction: column;
		align-items: flex-start;
		gap: 0.5rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.sj-fx__board {
		scroll-behavior: auto;
		mask-image: none !important;
		-webkit-mask-image: none !important;
	}
}

@supports not (background: color-mix(in srgb, white 50%, black)) {
	.sj-fx__head {
		border-bottom-color: var(--sj-color-border-light);
	}
}
