/* ==========================================================================
   XPAC Industries Panel — Horizontal Accordion with Diagonal Clip
   ========================================================================== */

/*
 * --xpac-skew (px)         : controls panel border steepness
 * --xpac-label-angle (deg) : controls title tilt, independent of skew
 */
.xpac-industries-track {
	--xpac-skew:        165px;
	--xpac-label-angle: -55deg;
}

/* ── Wrapper ────────────────────────────────────────────────────────────── */
.xpac-industries-panel {
	position: relative;
	width: 100%;
	background: #0a0a0a;
}

/* ── Section Heading ────────────────────────────────────────────────────── */
.xpac-industry-heading {
	position: absolute;
    padding: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 20px;
}

/* ── Track ──────────────────────────────────────────────────────────────── */
.xpac-industries-track {
	display: flex;
	width: 100%;
	height: 750px;
	overflow: visible; /* panels overlap visually via clip-path */
}

/* ── Individual Panel ───────────────────────────────────────────────────── */
.xpac-industry-item {
	position: relative;
	flex: 1;
	min-width: 0;
	cursor: pointer;
	text-decoration: none;
	display: block;
	outline: none;
	z-index: 1;

	/* Remove 300ms tap delay on iOS/Android — click fires instantly */
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;

	/* Parallelogram clip — middle panels */
	clip-path: polygon(
		var(--xpac-skew) 0%,
		100% 0%,
		calc(100% - var(--xpac-skew)) 100%,
		0% 100%
	);

	/* +2px overlap để lấp sub-pixel gap giữa các panel */
	margin-right: calc(-1 * var(--xpac-skew) - 2px);

	/* GPU rendering → clip-path mịn hơn, bớt răng cưa */
	transform: translateZ(0);

	transition: flex 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* First panel: straight left edge */
.xpac-industry-item:first-child {
	clip-path: polygon(
		0% 0%,
		100% 0%,
		calc(100% - var(--xpac-skew)) 100%,
		0% 100%
	);
}

/* Last panel: straight right edge, no negative margin */
.xpac-industry-item:last-child {
	clip-path: polygon(
		var(--xpac-skew) 0%,
		100% 0%,
		100% 100%,
		0% 100%
	);
	margin-right: 0;
}

.xpac-industry-item:focus-visible {
	outline: 2px solid #e02020;
	outline-offset: -2px;
}

/* Active: expand + bring to front */
.xpac-industry-item.is-active {
	flex: 5;
	z-index: 10;
}

/* ── Background image ───────────────────────────────────────────────────── */
.xpac-industry-bg {
	position: absolute;
	inset: 0;
	z-index: 1;
	background-size: cover;
	background-position: center;
	transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
	will-change: transform;
}

.xpac-industry-item:hover .xpac-industry-bg {
	transform: scale(1.04);
}

/* ── Dark overlay ───────────────────────────────────────────────────────── */
.xpac-industry-overlay {
	position: absolute;
	inset: 0;
	z-index: 2;
	background: rgba(0, 0, 0, 0.58);
	transition: background 0.5s ease;
	pointer-events: none;
}

.xpac-industry-item.is-active .xpac-industry-overlay {
	background: rgba(0, 0, 0, 0.28);
}

/* ── Content layer ──────────────────────────────────────────────────────── */
.xpac-industry-content {
	position: absolute;
	inset: 0;
	z-index: 3;
}

/* ── Industry name ──────────────────────────────────────────────────────── */
/*
 * Inactive: bottom-centre, rotated diagonally.
 * Active:   bottom-right corner (20px gap), horizontal.
 */
.xpac-industry-name {
	position: absolute;
	bottom: 20px;
	left: 50%;
	transform: translateX(-50%) rotate(var(--xpac-label-angle, -55deg));
	transform-origin: center center;
	width: 320px;
	text-align: left;
	bottom: 180px;
	margin: 0;
	font-size: clamp(1rem, 1.5vw, 1.35rem);
	font-weight: 700;
	color: #ffffff;
	letter-spacing: 0.06em;
	line-height: 1;
	text-transform: uppercase;
	white-space: nowrap;
	transition:
		transform 0.4s cubic-bezier(0.4, 0, 0.2, 1) 0.1s,
		left      0.4s cubic-bezier(0.4, 0, 0.2, 1) 0.1s,
		right     0.4s cubic-bezier(0.4, 0, 0.2, 1) 0.1s;
}

/* Active: bottom-right, horizontal */
.xpac-industry-item.is-active .xpac-industry-name {
	transform: translateX(0) rotate(var(--xpac-label-angle, -55deg));
    right: -50px;
    left: auto;
	z-index: 1;
}
.xpac-industry-item.is-active .xpac-industry-desc {
	clip-path: polygon(5% 0, 100% 0, 95% 100%, 0 100%);
    right: 50px;
}

.xpac-industry-item.is-active:last-child .xpac-industry-name,
.xpac-industry-item.is-active:last-of-type .xpac-industry-name {
	transform: translateX(0) rotate(var(--xpac-label-angle, -55deg));
	right: -100px;
	z-index: 1;
}

.xpac-industry-item.is-active:last-child .xpac-industry-desc,
.xpac-industry-item.is-active:last-of-type .xpac-industry-desc {
	right: -50px;
}

/* ── Description box — full width, pinned to bottom ─────────────────────── */
.xpac-industry-desc {
	position: absolute;
	left: auto;
	right: 0;
	bottom: 0;
	width: 100%;
	max-width: 768px;
	padding: 40px 120px 20px 90px;
	background: rgba(10, 10, 10, 0.82);
	min-height: 320px;
	opacity: 0;
	transform: translateY(12px);
	pointer-events: none;
	transition:
		opacity   0.4s ease 0.15s,
		transform 0.4s ease 0.15s;
}

/* Reveal on active */
.xpac-industry-item.is-active .xpac-industry-desc {
	opacity: 1;
	transform: translateY(0);
	pointer-events: auto;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media only screen and (max-width: 1024px) {
	.xpac-industries-track {
		--xpac-skew: 60px;
	}

	.xpac-industry-desc {
		max-width: calc(100% - 120px);
		min-height: 240px;
	}
	.xpac-industry-item.is-active:last-child .xpac-industry-name, 
	.xpac-industry-item.is-active:last-of-type .xpac-industry-name {
		right: -120px;
	}
	
}

/* Mobile: vertical stack — CSS :hover drives expand/collapse (tap = hover) */
@media only screen and (max-width: 767px) {

	/* ── Track ────────────────────────────────────────────────────────────── */
	.xpac-industries-track {
		flex-direction: column;
		height: auto !important;
		overflow: visible;  /* items may grow; don't clip them */
	}

	/* ── Item — collapsed by default, expands on :hover or .is-active ──────── */
	.xpac-industry-item {
		flex: none;
		min-height: 168px;
		max-height: 168px;          /* collapsed height                    */
		margin-right: 0 !important;
		clip-path: none !important;
		overflow: hidden;            /* clips content when collapsed        */
		transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
	}

	/* Expanded: tap on mobile triggers :hover; keyboard uses .is-active */
	.xpac-industry-item:hover,
	.xpac-industry-item.is-active {
		max-height: 620px;
	}

	/* No zoom on BG when hovering on mobile */
	.xpac-industry-item:hover .xpac-industry-bg {
		transform: scale(1) !important;
	}

	/* ── Content — put back into normal flow so item grows with it ──────── */
	/*
	 * Desktop sets position:absolute;inset:0. On mobile we need it in-flow
	 * so the item's max-height expansion actually shows the content.
	 * .xpac-industry-bg and .xpac-industry-overlay are siblings (not children)
	 * of content, so they remain absolute and still cover the full item.
	 */
	.xpac-industry-content {
		position: relative !important;
		inset: auto !important;
		z-index: 3;
		display: flex;
		flex-direction: column;
		justify-content: flex-end;
		min-height: 168px;      /* match item collapsed height */
		padding: 16px;
		transition: background-color 0.3s ease;
	}

	.xpac-industry-item:hover .xpac-industry-content,
	.xpac-industry-item.is-active .xpac-industry-content {
		background-color: rgba(6, 6, 6, 0.6);
	}

	/* ── Title — in flow, horizontal ─────────────────────────────────────── */
	.xpac-industry-name {
		position: relative !important;
		top: auto !important; bottom: auto !important;
		left: auto !important; right: auto !important;
		transform: none !important;
		width: auto !important;
		max-width: 100% !important;
		font-size: 1rem !important;
		line-height: 1.3 !important;
		writing-mode: horizontal-tb !important;
		white-space: normal !important;
		margin: 0 0 8px !important;
	}

	/* ── Description — hidden when collapsed, revealed on hover/active ───── */
	.xpac-industry-desc {
		position: relative !important;
		inset: auto !important;
		width: 100% !important;
		max-width: 100% !important;
		min-height: auto !important;
		padding: 0 !important;
		clip-path: none !important;
		background: transparent !important;
		transform: none !important;

		/* Animate opacity; max-height is already handled by parent item */
		opacity: 0;
		transition: opacity 0.3s ease 0.15s !important;
	}

	.xpac-industry-item:hover .xpac-industry-desc,
	.xpac-industry-item.is-active .xpac-industry-desc {
		opacity: 1 !important;
		clip-path: none !important;
	}

	/* ── Section heading ─────────────────────────────────────────────────── */
	.xpac-industry-heading {
		position: relative;
		left: auto;
		transform: none;
		display: block;
		padding: 20px;
		white-space: normal;
	}
}

/* ==========================================================================
   Elementor Editor — disable transitions for accurate live preview
   ========================================================================== */
.elementor-editor-active .xpac-industry-item,
.elementor-editor-active .xpac-industry-bg,
.elementor-editor-active .xpac-industry-overlay,
.elementor-editor-active .xpac-industry-name,
.elementor-editor-active .xpac-industry-desc {
	transition: none !important;
}
