/**
 * DinnerlyHub - Card Component
 * Reusable recipe card used in archives, search, homepage, and single (related posts).
 * Optimized with design system variables.
 */

.dh-card {
	border-radius: var(--dh-radius-md);
	overflow: hidden;
	background: var(--dh-white);
	border: 1px solid var(--dh-green-border);
	display: flex;
	flex-direction: column;
	transition: transform 0.22s ease, box-shadow 0.22s ease;
}

@media (prefers-reduced-motion: no-preference) {
	@keyframes dh-card-in {
		from {
			opacity: 0;
			transform: translateY(14px);
		}
		to {
			opacity: 1;
			transform: translateY(0);
		}
	}

	.dh-card {
		animation: dh-card-in 0.4s ease both;
		animation-delay: var(--card-delay, 0s);
	}
}

.dh-card:hover {
	transform: translateY(-6px);
	box-shadow: var(--dh-shadow-card-hover);
}

.dh-card:focus-within {
	outline: 2px solid var(--dh-green);
	outline-offset: 2px;
}

/* Image wrapper */
.dh-card__img-wrap {
	display: block;
	position: relative;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	background: #f0f0f0;
	text-decoration: none;
	flex-shrink: 0;
}

.dh-card__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.22s ease;
}

.dh-card:hover .dh-card__img {
	transform: scale(1.05);
}

/* Lazy load image styles */
.dh-card__img.dh-img-lazy {
	opacity: 0;
	filter: blur(10px);
	transition: opacity 0.4s ease, filter 0.4s ease, transform 0.22s ease;
}

.dh-card__img.dh-img-lazy.is-loaded {
	opacity: 1;
	filter: blur(0);
}

.dh-card__img-placeholder {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, #f0f7f2, #fdf4ef);
}

/* Skeleton loading for cards */
.dh-card--skeleton .dh-card__img-wrap {
	background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
	background-size: 200% 100%;
	animation: skeleton-pulse 1.5s ease-in-out infinite;
}

@keyframes skeleton-pulse {
	0% { background-position: 200% 0; }
	100% { background-position: -200% 0; }
}

.dh-card__img-overlay {
	position: absolute;
	inset: 0;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.14) 0%, transparent 55%);
	pointer-events: none;
}

/* Category badge */
.dh-card__cat-badge {
	position: absolute;
	top: 12px;
	left: 12px;
	padding: 4px 12px;
	background: var(--dh-green);
	color: var(--dh-white);
	font-size: var(--dh-text-xs);
	font-weight: 700;
	font-family: var(--dh-font-heading);
	letter-spacing: 0.4px;
	text-transform: uppercase;
	border-radius: var(--dh-radius-pill);
	z-index: 2;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	white-space: nowrap;
}

/* Card body */
.dh-card__body {
	padding: var(--dh-space-2) var(--dh-space-2) var(--dh-space-3);
	display: flex;
	flex-direction: column;
	gap: var(--dh-space-1);
	flex: 1;
}

/* Meta info */
.dh-card__meta {
	display: flex;
	align-items: center;
	gap: var(--dh-space-1);
	font-size: var(--dh-text-xs);
	font-family: var(--dh-font-body);
	color: var(--dh-gray-meta);
}

.dh-card__meta-item {
	display: flex;
	align-items: center;
	gap: 4px;
}

.dh-card__meta-dot {
	width: 3px;
	height: 3px;
	border-radius: 50%;
	background: #ddd;
	flex-shrink: 0;
}

/* Title */
.dh-card__title {
	font-size: var(--dh-text-body);
	font-weight: 600;
	font-family: var(--dh-font-heading);
	line-height: 1.4;
	margin: 0;
	color: var(--dh-text-heading);
}

.dh-card__title-link {
	color: inherit;
	text-decoration: none;
	transition: color 0.22s ease;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.dh-card__title-link:hover {
	color: var(--dh-green);
}

/* Excerpt */
.dh-card__excerpt {
	font-size: var(--dh-text-sm);
	font-family: var(--dh-font-body);
	color: var(--dh-text-light);
	line-height: var(--dh-leading-relaxed);
	margin: 0;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* CTA link */
.dh-card__cta {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: var(--dh-text-sm);
	font-weight: 700;
	font-family: var(--dh-font-heading);
	color: var(--dh-orange);
	text-decoration: none;
	margin-top: auto;
	transition: gap 0.22s ease, color 0.22s ease;
}

.dh-card__cta:hover {
	color: var(--dh-orange-dark);
	gap: 10px;
}

.dh-card__cta:focus-visible {
	outline: 2px solid var(--dh-orange);
	outline-offset: 3px;
	border-radius: 4px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
	.dh-card {
		animation: none;
	}

	.dh-card--skeleton .dh-card__img-wrap {
		animation: none;
	}

	.dh-card__img.dh-img-lazy {
		filter: none;
		opacity: 1;
	}
}
