/**
 * Projects loop cards — layout hardening.
 * Keeps every card the same height and tolerant of missing / long data.
 */

/* 1) Equal-height cards: the card fills its grid cell and stacks vertically. */
.elementor-loop-container .e-loop-item,
.elementor-loop-container .e-loop-item > .e-con,
.elementor-loop-container .e-loop-item > .elementor-element {
	height: 100%;
}

.elementor-loop-container .e-loop-item > .e-con {
	display: flex;
	flex-direction: column;
}

/* Body of the card grows; the stats strip is always pinned to the bottom
   so the icon rows of all cards line up on the same baseline. */
.elementor-loop-container .e-loop-item > .e-con > .e-con:nth-child(2) {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
}

.elementor-loop-container .e-loop-item .elementor-element-fda8cd9 {
	margin-top: auto;
}

/* 2) Media box: fixed ratio so a portrait/landscape image can't resize the card. */
.elementor-loop-container .e-loop-item .elementor-widget-theme-post-featured-image img {
	aspect-ratio: 16 / 10;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* 3) Title: two lines max, consistent height. */
.elementor-loop-container .e-loop-item .elementor-widget-theme-post-title .elementor-heading-title {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	min-height: 2.6em;
	line-height: 1.3;
}

/* 4) Type badge: always ONE line — it truncates with "…" instead of wrapping,
      so a long project type can never change the card height. */
.elementor-loop-container .e-loop-item .elementor-element-cbb67c6 {
	flex-wrap: nowrap;
	align-items: center;
	min-width: 0;
}

.elementor-loop-container .e-loop-item .elementor-element-cbb67c6 > .e-con {
	min-width: 0;
	overflow: hidden;
}

.elementor-loop-container .e-loop-item .elementor-element-16bbfa6 {
	min-width: 0;
	max-width: 100%;
}

.elementor-loop-container .e-loop-item .elementor-element-7591abd {
	min-width: 0;
	max-width: 100%;
	overflow: hidden;
}

.elementor-loop-container .e-loop-item .elementor-element-7591abd,
.elementor-loop-container .e-loop-item .elementor-element-7591abd p {
	display: block;
	margin: 0;
	line-height: 1.6;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* 5) Availability + price rows: keep items on one line, no orphan symbols. */
.elementor-loop-container .e-loop-item .elementor-element-543955d,
.elementor-loop-container .e-loop-item .elementor-element-18032b5 {
	flex-wrap: nowrap;
	align-items: center;
	gap: 4px;
}

.elementor-loop-container .e-loop-item .elementor-element-543955d .elementor-widget-text-editor p,
.elementor-loop-container .e-loop-item .elementor-element-18032b5 .elementor-widget-text-editor p {
	margin: 0;
	white-space: nowrap;
}

/* 6) Stats strip: 4 equal columns that stay aligned even if one is hidden. */
.elementor-loop-container .e-loop-item .elementor-element-8c5a5ba {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
	gap: 8px;
	align-items: start;
}

.elementor-loop-container .e-loop-item .elementor-element-8c5a5ba .elementor-icon-box-description {
	font-size: 13px;
	line-height: 1.4;
	overflow-wrap: anywhere;
}

/* Long "المساحات" text (e.g. project/development areas) is clamped to 3 lines
   so one verbose project can no longer stretch the whole row. */
.elementor-loop-container .e-loop-item .elementor-element-89fd360 .elementor-icon-box-description {
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* 7) Small screens: never let the strip overflow the card. */
@media (max-width: 767px) {
	.elementor-loop-container .e-loop-item .elementor-element-8c5a5ba {
		grid-template-columns: repeat(2, 1fr);
	}
}

/* 8) Containers left empty after their fields were hidden (the green
      availability pill, the price row) collapse instead of showing a bare
      padded/coloured box. Elementor caches container markup, so this cleanup
      has to happen in CSS rather than PHP. */
.elementor-loop-container .e-loop-item .e-con:not(:has(.elementor-widget)):not(:has(img)) {
	display: none !important;
}

.elementor-loop-container .e-loop-item .elementor-element-229c457:not(:has(.elementor-widget-text-editor)),
.elementor-loop-container .e-loop-item .elementor-element-18032b5:not(:has(.elementor-widget-text-editor)) {
	display: none !important;
}

/* 9) Any other text inside a card stays on the width it is given: one line,
      trimmed with "…" rather than pushing the layout around. */
.elementor-loop-container .e-loop-item .elementor-element-543955d .elementor-widget-text-editor,
.elementor-loop-container .e-loop-item .elementor-element-18032b5 .elementor-widget-text-editor {
	min-width: 0;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* 10) The availability pill hugs its content: when only "متاح" (or only
       "مباع") survives, the pill shrinks to the text width with a comfortable
       horizontal padding instead of keeping the fixed 40% width. */
.elementor-loop-container .e-loop-item .elementor-element-543955d {
	width: fit-content !important;
	max-width: 100%;
	justify-content: center;
	white-space: nowrap;
}

/* 11) Tooltip for clamped text. Rendered on <body> (position: fixed) so the
       card's overflow:hidden can never clip it. */
.ajtha-tip {
	position: fixed;
	z-index: 99999;
	max-width: min(320px, calc(100vw - 24px));
	padding: 8px 12px;
	border-radius: 10px;
	background: rgba(28, 26, 24, 0.96);
	color: #fff;
	font-size: 13px;
	line-height: 1.6;
	text-align: center;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
	pointer-events: none;
	opacity: 0;
	transform: translateY(4px);
	transition: opacity 0.15s ease, transform 0.15s ease;
	white-space: normal;
	overflow-wrap: anywhere;
}

.ajtha-tip.is-visible {
	opacity: 1;
	transform: translateY(0);
}

.ajtha-tip::after {
	content: "";
	position: absolute;
	left: 50%;
	margin-left: -6px;
	border: 6px solid transparent;
	border-top-color: rgba(28, 26, 24, 0.96);
	top: 100%;
}

.ajtha-tip.is-below::after {
	top: auto;
	bottom: 100%;
	border-top-color: transparent;
	border-bottom-color: rgba(28, 26, 24, 0.96);
}

@media (prefers-reduced-motion: reduce) {
	.ajtha-tip {
		transition: none;
	}
}
