/**
 * Article card component (hm-card-md).
 *
 * Reusable card used across the site: homepage grids, category posts,
 * archive pages, sidebar lists.
 *
 * Desktop: vertical card (image on top, content below).
 * Mobile (<768px): horizontal card (image on side, content beside).
 *
 * @package Hamechadesh
 */

/* ==========================================================================
   Base Card — 320×330px desktop (Figma)
   ========================================================================== */

.hm-card-md {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 10px;           /* gap between image and content */
	padding-bottom: 16px;
	background-color: var(--hm-color-bg-alt);
	border-radius: var(--hm-radius-xl); /* 20px */
	overflow: hidden;
}

/* Full-card stretched link — covers entire card */
.hm-card-md__link {
	position: absolute;
	inset: 0;
	z-index: 1;
}

/* Interactive children above overlay */
.hm-card-md__category,
.hm-card-md__comments,
.hm-card-md__promoted-badge {
	position: relative;
	z-index: 2;
}

/* ==========================================================================
   Image Area — fixed 157px height for equal images
   ========================================================================== */

.hm-card-md__media {
	height: 157px;
	flex-shrink: 0;
	position: relative;
	overflow: hidden;
}

.hm-card-md__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.hm-card-md__img--placeholder {
	background-color: #d9d9d9;
	width: 100%;
	height: 100%;
}

/* ==========================================================================
   Category Badge — bottom-left of image (inline-end in RTL)
   ========================================================================== */

.hm-card-md__category {
	position: absolute !important;
	bottom: 0;
	inset-inline-end: 0; /* physical LEFT in RTL */
	width: 119px;
	height: 26px;
	text-decoration: none;
	color: #ffffff;
}

.hm-card-md__category:hover {
	color: #ffffff;
}

/* Dark background SVG shape with circular cutout for the dot */
.hm-card-md__category-bg {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}

/* Red/orange dot — sits in the circular cutout */
.hm-card-md__category-dot {
	position: absolute;
	width: 12px;
	height: 12.54px;
	top: 0px;
    right: 0px;
}

/* Category name text */
.hm-card-md__category-text {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	right: 20px;
	display: flex;
	align-items: center;
	justify-content: center;
    margin-left: 10px;	padding-left: 8px;
	font-family: var(--hm-font-primary);
	font-weight: 300;
	font-size: 14px;
	line-height: 22.115px;
	white-space: nowrap;
	unicode-bidi: isolate;
}

/* ==========================================================================
   "מקודם" Promoted Badge — top-right corner (inline-start in RTL)
   ========================================================================== */

.hm-card-md__promoted-badge {
	position: absolute;
	top: 15px;
	inset-inline-start: 13px; /* physical RIGHT in RTL */
	display: flex;
	flex-direction: row;
	align-items: center;
	gap: 5px;
	height: 17px;
	padding: 0 11px;
	background-color: rgba(255, 255, 255, 0.49);
	border-radius: 100px;
	z-index: 2;
}

.hm-card-md__promoted-dot {
	flex-shrink: 0;
}

.hm-card-md__promoted-badge span {
	font-family: var(--hm-font-primary);
	font-weight: 300;
	font-size: 12px;
	line-height: 1;
	color: var(--hm-color-primary);
	white-space: nowrap;
}

/* ==========================================================================
   Text Content Area
   ========================================================================== */

.hm-card-md__content {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 7px;
	padding: 0 10px;
	justify-content: center;
	min-height: 0;
	align-items: flex-start; /* RIGHT side in RTL column flex */
}

/* Before-title badge — border + text from the post's category color
   (var --hm-cat-color, set inline on the .hm-card-md wrapper). Falls back
   to the global accent when the variable hasn't been set (defensive). */
.hm-card-md__badge {
	display: inline-block;
	border-inline-start: 0.5px solid var(--hm-cat-color, var(--hm-color-accent));
	padding: 3px 13px;
	color: var(--hm-cat-color, var(--hm-color-accent));
	font-family: var(--hm-font-primary);
	font-weight: 700;
	font-size: 14px;
	line-height: 22.115px;
	letter-spacing: 0.84px;
	white-space: nowrap;
}

/* Title + excerpt block */
.hm-card-md__text {
	display: flex;
	flex-direction: column;
	gap: 4px;
	width: 100%;
}

.hm-card-md__title {
	font-family: var(--hm-font-primary);
	font-weight: 700;
	font-size: 20px;
	line-height: 20px;
	color: var(--hm-color-primary);
	text-align: start;
	width: 100%;
	margin: 0;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.hm-card-md__title a {
	color: inherit;
	text-decoration: none;
	transition: opacity var(--hm-transition-fast);
}

.hm-card-md__title a:hover {
	opacity: 0.75;
	color: inherit;
}

.hm-card-md__excerpt {
	font-family: var(--hm-font-primary);
	font-weight: 300;
	font-size: 14px;
	line-height: 20px;
	color: var(--hm-color-primary);
	text-align: start;
	margin: 0;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* ==========================================================================
   Meta Row — time | date | author | comments
   ========================================================================== */

.hm-card-md__meta {
	display: flex;
	gap: 10px;
	align-items: center;
	flex-wrap: nowrap;
}

.hm-card-md__meta-item {
	font-family: var(--hm-font-primary);
	font-weight: 300;
	font-size: 14px;
	line-height: normal;
	color: var(--hm-color-primary);
	opacity: 0.5;
	white-space: nowrap;
	text-decoration: none;
}

.hm-card-md__meta-item:hover {
	opacity: 0.75;
	color: var(--hm-color-primary);
}

/* Vertical separator — 1.12px × 15.36px at 50% opacity */
.hm-card-md__sep {
	display: inline-block;
	width: 1.12px;
	height: 15.36px;
	background-color: rgba(33, 33, 33, 0.5);
	flex-shrink: 0;
}

.hm-card-md__comments {
	display: flex;
	gap: 3px;
	align-items: center;
}

.hm-card-md__comment-icon {
	flex-shrink: 0;
	color: var(--hm-color-primary);
}

/* ==========================================================================
   Responsive — Mobile: Horizontal Card Layout
   ========================================================================== */

@media (max-width: 767px) {
	.hm-card-md {
		flex-direction: row;
		height: 110px;
		padding-bottom: 0;
		background-color: #ffffff;
		border-radius: 10px;
		overflow: hidden;
	}

	/* Image on the RIGHT (first child in RTL flex-row) */
	.hm-card-md__media {
		width: 130px;
		height: 100%;
		flex-shrink: 0;
		border-radius: 0 10px 10px 0; /* RTL: right side of card */
	}

	/* Content on the LEFT — fills remaining space */
	.hm-card-md__content {
		flex: 1;
		min-width: 0;
		padding: 10px;
		gap: 3px;
		justify-content: center;
	}

	/* Badge — RED text + RED border on mobile */
	.hm-card-md__badge {
		color: var(--hm-color-accent);
		border-inline-start-color: var(--hm-color-accent);
		font-size: 14px;
		font-weight: 300;
		letter-spacing: 0.84px;
		line-height: 22px;
		padding: 0 13px 0 0;
		border-inline-start-width: 0.5px;
	}

	/* Title — max 2 lines */
	.hm-card-md__title {
		font-size: 17px;
		line-height: 21px;
		overflow-wrap: break-word;
		word-break: normal;
		padding-inline-end: 8px;
	}

	/* Hide excerpt on mobile */
	.hm-card-md__excerpt {
		display: none;
	}

	/* Meta — compact */
	.hm-card-md__meta {
		gap: 8px;
		flex-wrap: wrap;
		max-height: 36px;
		overflow: hidden;
	}

	.hm-card-md__meta-item {
		font-size: 13px;
	}

	/* Hide comments on mobile */
	.hm-card-md__comments,
	.hm-card-md__comments-sep {
		display: none;
	}
}
