/* =========================================================================
 * Portfolio Grid — Elementor Widget (prefix: tp-)
 * ========================================================================= */

.tp-portfolio-widget {
	--tp-gap: 24px;
	--tp-col-gap: 24px;
	--tp-slides: 3;
}

/* ----------------------------- Header ---------------------------------- */

.tp-portfolio-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 16px;
	margin-bottom: 40px;
}

.tp-portfolio-filters-wrap {
	position: relative;
}

.tp-portfolio-filters {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 28px;
}

/* Mobile dropdown toggle — hidden on desktop/tablet. */
.tp-portfolio-filters-toggle {
	display: none;
}

.tp-portfolio-widget .tp-portfolio-filter {
	appearance: none;
	-webkit-appearance: none;
	background-color: transparent !important;
	background-image: none !important;
	border: 0;
	box-shadow: none;
	margin: 0;
	padding: 6px 2px;
	border-radius: 0;
	cursor: pointer;
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	color: #034773;
	line-height: 1.2;
	transition: color 0.2s ease;
}

.tp-portfolio-widget .tp-portfolio-filter:hover,
.tp-portfolio-widget .tp-portfolio-filter.is-active {
	background-color: transparent !important;
	color: #f05022;
}

.tp-portfolio-widget .tp-portfolio-filter:focus-visible {
	outline: 2px solid #f05022;
	outline-offset: 3px;
}

.tp-portfolio-all-link {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 14px;
	font-weight: 600;
	color: #e8552d;
	text-decoration: underline;
	text-underline-offset: 6px;
	text-decoration-thickness: 1px;
	white-space: nowrap;
	transition: color 0.2s ease, gap 0.2s ease;
}

.tp-portfolio-all-link:hover {
	gap: 12px;
}

.tp-portfolio-all-link:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 4px;
}

/* ------------------------------ List ----------------------------------- */

.tp-portfolio-list {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	column-gap: var(--tp-col-gap);
	row-gap: 32px;
}

/* ------------------------------ Card ----------------------------------- */

.tp-portfolio-card {
	position: relative;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	border-radius: 14px;
	padding: 16px 16px 20px;
	background-color: #fff;
	transition: transform 0.3s, box-shadow 0.3s;
	transform: translateY(0);
	box-shadow: 0 10px 50px #0000001a;
	will-change: transform;
}

.tp-portfolio-card:hover {
	transform: translateY(-4px);
}

/* Full-card clickable overlay — the ONLY link inside the card. */
.tp-portfolio-card__link {
	position: absolute;
	inset: 0;
	z-index: 10;
	text-indent: -9999px;
	overflow: hidden;
	border-radius: inherit;
}

.tp-portfolio-card__link:focus-visible {
	outline: 3px solid #e8552d;
	outline-offset: -3px;
}

/* Browser dots */
.tp-portfolio-card__dots {
	display: flex;
	align-items: center;
	gap: 5px;
	padding: 6px 0 6px 4px;
}

.tp-portfolio-card__dots span {
	display: block;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background-color: #d6dbe3;
}

/* Image */
.tp-portfolio-card__image-wrap {
	position: relative;
	overflow: hidden;
	height: 200px;
	border-radius: 10px;
}

.tp-portfolio-card__image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 300ms ease;
	will-change: transform;
}

.tp-portfolio-card:hover .tp-portfolio-card__image {
	transform: scale(1.06);
}

/* Hover gradient overlay (optional) */
.tp-has-hover-gradient .tp-portfolio-card__image-wrap::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 2;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.35s ease;
	background: linear-gradient(
		var(--tp-grad-angle, 180deg),
		var(--tp-grad-color2, rgba(240, 80, 34, 0)),
		var(--tp-grad-color, rgba(240, 80, 34, 0.75))
	);
}

.tp-has-hover-gradient .tp-portfolio-card:hover .tp-portfolio-card__image-wrap::after {
	opacity: 1;
}

/* Content */
.tp-portfolio-card__content {
	padding-top: 4px;
}

.tp-portfolio-card__title {
	margin: 14px 0 10px;
	font-size: 18px;
	line-height: 1.35;
	color: #0d3b66;
	transition: color 0.2s ease;
}

.tp-portfolio-card:hover .tp-portfolio-card__title {
	color: #e8552d;
}

.tp-portfolio-card__category {
	margin-top: 4px;
	font-size: 13px;
	color: #8a93a3;
}

/* --------------------------- Filtering --------------------------------- */

.tp-portfolio-card.is-hidden {
	display: none;
}

/* Cards animate position (FLIP), opacity and scale during filtering. */
.tp-portfolio-list:not(.tp-is-carousel) .tp-portfolio-card {
	transition: opacity 0.45s cubic-bezier(0.22, 0.61, 0.36, 1),
		transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1);
	will-change: transform, opacity;
}

/* Exit state (fade + sink) applied just before the card is removed. */
.tp-portfolio-card.is-filtering {
	opacity: 0;
	transform: translateY(14px) scale(0.95);
}

/* --------- Centered row (fewer items than columns) --------------------- *
 * Each card keeps its column width (via --tp-slides) but the row is        *
 * centered instead of left-aligned. Disabled in carousel mode.            */
.tp-portfolio-list.tp-is-centered:not(.tp-is-carousel) {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	grid-template-columns: none;
}

.tp-portfolio-list.tp-is-centered:not(.tp-is-carousel) .tp-portfolio-card {
	flex: 0 0 calc(
		(100% - (var(--tp-col-gap, 24px) * (var(--tp-slides, 3) - 1))) / var(--tp-slides, 3)
	);
	max-width: calc(
		(100% - (var(--tp-col-gap, 24px) * (var(--tp-slides, 3) - 1))) / var(--tp-slides, 3)
	);
}

/* --------------------------- Carousel ---------------------------------- *
 * The list is a CSS grid by default. When the JS activates carousel mode for
 * the current viewport it adds .tp-is-carousel, which switches the same
 * container to a horizontal scroll-snap track. --tp-slides = visible cards.   */

.tp-portfolio-list.tp-is-carousel {
	display: flex;
	grid-template-columns: none;
	flex-wrap: nowrap;
	gap: var(--tp-gap, 24px);
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	-ms-overflow-style: none;
	scroll-behavior: smooth;
}

.tp-portfolio-list.tp-is-carousel::-webkit-scrollbar {
	display: none;
}

.tp-portfolio-list.tp-is-carousel .tp-portfolio-card {
	flex: 0 0 calc(
		(100% - (var(--tp-gap, 24px) * (var(--tp-slides, 3) - 1))) / var(--tp-slides, 3)
	);
	scroll-snap-align: start;
}

.tp-portfolio-list.tp-is-carousel.tp-dragging {
	scroll-behavior: auto;
	cursor: grabbing;
	scroll-snap-type: none;
}

.tp-portfolio-list.tp-is-carousel.tp-dragging .tp-portfolio-card__link {
	pointer-events: none;
}

/* Slider controls */
.tp-portfolio-slider-controls {
	display: flex;
	gap: 12px;
	justify-content: center;
	margin-top: 28px;
}

.tp-portfolio-slider-controls[hidden] {
	display: none;
}

.tp-portfolio-slider-controls button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: 50%;
	background-color: #e8552d;
	color: #fff;
	cursor: pointer;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.tp-portfolio-slider-controls button:hover {
	transform: scale(1.06);
}

.tp-portfolio-slider-controls button:disabled {
	opacity: 0.35;
	cursor: default;
	transform: none;
}

.tp-portfolio-slider-controls button:focus-visible {
	outline: 2px solid #0d3b66;
	outline-offset: 2px;
}

/* Dots */
.tp-portfolio-dots {
	display: flex;
	align-items: center;
	gap: 8px;
	justify-content: center;
	margin-top: 20px;
}

.tp-portfolio-dots[hidden] {
	display: none;
}

.tp-portfolio-dots button {
	width: 7px;
	height: 7px;
	padding: 0;
	border: 0;
	border-radius: 5em;
	background-color: #cccccc;
	cursor: pointer;
	transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.35s ease;
}

/* Active dot stretches into a "liquid" pill (à la Flickity style-4). */
.tp-portfolio-dots button.is-active {
	width: 24px;
	background-color: #e8552d;
}

.tp-portfolio-dots button:focus-visible {
	outline: 2px solid #0d3b66;
	outline-offset: 2px;
}

/* --------------------------- Responsive -------------------------------- */

/* Fallback column counts (Elementor's per-device "Columns" control overrides these). */
@media (max-width: 1024px) {
	.tp-portfolio-list:not(.tp-is-carousel) {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 767px) {
	.tp-portfolio-list:not(.tp-is-carousel) {
		grid-template-columns: repeat(1, minmax(0, 1fr));
	}

	.tp-portfolio-header {
		flex-direction: row;
		flex-wrap: nowrap;
		align-items: center;
		justify-content: space-between;
		gap: 16px;
	}

	.tp-portfolio-filters-wrap {
		width: auto;
	}

	/* Toggle button becomes the visible control. */
	.tp-portfolio-filters-toggle {
		display: inline-flex;
		align-items: center;
		justify-content: space-between;
		gap: 10px;
		min-width: 180px;
		padding: 8px 2px;
		background: none;
		border: 0;
		border-bottom: 2px solid #f05022;
		color: #f05022;
		font-size: 14px;
		font-weight: 600;
		line-height: 1.2;
		cursor: pointer;
	}

	.tp-portfolio-filters-toggle__icon {
		display: inline-flex;
		transition: transform 0.2s ease;
	}

	.tp-portfolio-filters-wrap.is-open .tp-portfolio-filters-toggle__icon {
		transform: rotate(180deg);
	}

	/* The button list becomes a dropdown panel. */
	.tp-portfolio-filters {
		position: absolute;
		top: calc(100% + 6px);
		left: 0;
		z-index: 30;
		display: none;
		flex-direction: column;
		flex-wrap: nowrap;
		gap: 0;
		min-width: 220px;
		padding: 6px 0;
		background: #fff;
		border-radius: 4px;
		box-shadow: 0 10px 30px rgba(13, 59, 102, 0.18);
	}

	.tp-portfolio-filters-wrap.is-open .tp-portfolio-filters {
		display: flex;
	}

	/* List items (override the desktop pill look). */
	.tp-portfolio-widget .tp-portfolio-filter {
		width: 100%;
		text-align: left;
		padding: 12px 18px;
		border-radius: 0;
		color: #1f1f1f !important;
		background-color: transparent !important;
	}

	.tp-portfolio-widget .tp-portfolio-filter:hover {
		background-color: #f5f5f5 !important;
		color: #1f1f1f !important;
	}

	.tp-portfolio-widget .tp-portfolio-filter.is-active {
		background-color: #eeeeee !important;
		color: #1f1f1f !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tp-portfolio-card,
	.tp-portfolio-card__image,
	.tp-portfolio-all-link,
	.tp-portfolio-slider-controls button,
	.tp-portfolio-dots button {
		transition: none !important;
	}
}
