/* =====================================================================
   Tech stack marquee (includes/tech-stack.php, js/tech-stack.js)
   ===================================================================== */
.tech-stack {
	overflow: hidden;
}

.ts-stage {
	position: relative;
	margin-top: 10px;
	perspective: 1300px;
}

.ts-rows {
	display: flex;
	flex-direction: column;
	gap: 22px;
	padding: 20px 0;
	transform-style: preserve-3d;
	/* --ts-tilt is driven by scroll position (js/tech-stack.js). */
	transform: rotateX(var(--ts-tilt, 0deg));
	transition: transform 0.2s linear;
}

/* Crossing-ribbon look: alternate rows lean opposite ways, at different depths. */
.ts-animated .ts-row:nth-child(odd) {
	transform: rotateZ(-1.6deg) translateZ(20px);
}

.ts-animated .ts-row:nth-child(even) {
	transform: rotateZ(1.6deg) translateZ(-30px);
}

.ts-row {
	position: relative;
}

.ts-row-label {
	position: absolute;
	top: -12px;
	left: max(16px, calc((100vw - 1140px) / 2 + 15px));
	z-index: 3;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 12px;
	border-radius: 20px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: #ffffff;
	background: var(--grad-primary);
	box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
}

.ts-row[data-direction="rtl"] .ts-row-label {
	left: auto;
	right: max(16px, calc((100vw - 1140px) / 2 + 15px));
	background: linear-gradient(135deg, #9b51e0, #2563eb);
}

.ts-viewport {
	overflow: hidden;
	padding: 18px 0 14px;
	/* Fade both edges so items glide in and out of nowhere. */
	-webkit-mask-image: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent);
	mask-image: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent);
	cursor: grab;
	touch-action: pan-y; /* keep vertical page scrolling on touch screens */
	user-select: none;
	-webkit-user-select: none;
}

.ts-row.is-dragging .ts-viewport {
	cursor: grabbing;
}

.ts-track {
	display: flex;
	gap: 18px;
	width: max-content;
	margin: 0;
	padding: 0 9px;
	list-style: none;
	will-change: transform;
}

/* Static fallback (no JS / reduced motion): a centred, wrapped list. */
.tech-stack:not(.ts-animated) .ts-track {
	flex-wrap: wrap;
	justify-content: center;
	width: auto;
	max-width: 1140px;
	margin: 0 auto;
}

.tech-stack:not(.ts-animated) .ts-viewport {
	-webkit-mask-image: none;
	mask-image: none;
	cursor: default;
}

.tech-stack:not(.ts-animated) .ts-hint {
	display: none;
}

/* ---- Items: glossy 3D chips with a brand-colour glow ---- */
.ts-item {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 12px;
	flex: 0 0 auto;
	padding: 14px 24px 14px 16px;
	border-radius: 18px;
	background: linear-gradient(145deg, #ffffff, #f3f7fd);
	border: 1px solid rgba(17, 24, 39, 0.06);
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, 0.9),
		0 10px 24px rgba(17, 24, 39, 0.07);
	transform-style: preserve-3d;
	transition: transform 0.35s var(--ease-premium), box-shadow 0.35s ease, border-color 0.35s ease;
}

.ts-logo {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border-radius: 12px;
	color: var(--brand);
	background: color-mix(in srgb, var(--brand) 12%, transparent);
	transition: transform 0.35s var(--ease-premium), box-shadow 0.35s ease;
}

.ts-logo svg {
	width: 24px;
	height: 24px;
}

.ts-logo .bi {
	font-size: 22px;
	line-height: 1;
}

.ts-name {
	font-family: "Poppins", sans-serif;
	font-size: 15px;
	font-weight: 600;
	white-space: nowrap;
	color: var(--ink-900);
}

.ts-item:hover {
	transform: perspective(600px) translateZ(36px) rotateX(10deg) translateY(-4px);
	border-color: color-mix(in srgb, var(--brand) 55%, transparent);
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, 0.9),
		0 18px 40px color-mix(in srgb, var(--brand) 32%, transparent);
}

.ts-item:hover .ts-logo {
	transform: translateZ(22px) rotateY(-14deg) scale(1.08);
	box-shadow: 0 8px 18px color-mix(in srgb, var(--brand) 35%, transparent);
}

.ts-hint {
	margin: 18px 0 0;
	text-align: center;
	font-size: 13px;
	color: var(--ink-500);
}

.ts-hint .bi {
	margin-right: 4px;
}

/* ---- Dark theme ---- */
html[data-theme="dark"] .ts-item {
	background: linear-gradient(145deg, #142039, #0f1930);
	border-color: rgba(148, 163, 184, 0.14);
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, 0.06),
		0 12px 28px rgba(0, 0, 0, 0.4);
}

html[data-theme="dark"] .ts-logo {
	color: var(--brand-dark);
	background: color-mix(in srgb, var(--brand-dark) 14%, transparent);
}

html[data-theme="dark"] .ts-item:hover {
	border-color: color-mix(in srgb, var(--brand-dark) 60%, transparent);
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, 0.08),
		0 18px 44px color-mix(in srgb, var(--brand-dark) 30%, transparent);
}

@media (max-width: 767px) {
	.ts-rows {
		gap: 16px;
	}

	.ts-item {
		padding: 10px 18px 10px 12px;
		gap: 10px;
	}

	.ts-logo {
		width: 36px;
		height: 36px;
	}

	.ts-logo svg {
		width: 20px;
		height: 20px;
	}

	.ts-name {
		font-size: 14px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ts-rows,
	.ts-item,
	.ts-logo {
		transform: none !important;
		transition: none !important;
	}
}
