/**
 * قسم آخر الأخبار في ثيم هدي: «الخبر وما حوله» (template-parts/home/home-news.php).
 */

/* ==========================================================================
   1) الشبكة: الخبر الرئيسي في البداية (يميناً) بطول صفّين، وحوله البطاقات الصغيرة ٢×٢،
   وتتكيّف مع عدد الأخبار (‎.hd-news__grid--N‎) بلا فراغات
   ========================================================================== */

.hd-news__grid {
	display: grid;
	grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr);
	gap: 24px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.hd-news__cell {
	display: flex;
	min-width: 0;
}

.hd-news__cell--lead {
	grid-row: span 2;
}

/* خبر واحد: بطاقة عريضة */
.hd-news__grid--1 {
	grid-template-columns: minmax(0, 1fr);
}

.hd-news__grid--1 .hd-news__cell--lead {
	grid-row: auto;
}

.hd-news__grid--1 .hd-news__card--lead {
	min-height: 440px;
}

/* خبران: بطاقتان متساويتان */
.hd-news__grid--2 {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.hd-news__grid--2 .hd-news__cell--lead {
	grid-row: auto;
}

/* ثلاثة: الرئيسي وبجانبه بطاقتان فوق بعض */
.hd-news__grid--3 {
	grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
}

/* أربعة: الأخيرة بعرض العمودين صفاً أفقياً */
.hd-news__grid--4 .hd-news__cell:last-child {
	grid-column: span 2;
}

/* ==========================================================================
   2) البطاقة: مستديرة بظل ناعم، ترتفع عند المرور وتقترب صورتها، وخط ذهبي متدرّج أعلاها
   ========================================================================== */

.hd-news__card {
	position: relative;
	display: flex;
	flex: 1;
	flex-direction: column;
	min-width: 0;
	overflow: hidden;
	border: 1px solid var(--hd-line-soft);
	border-radius: var(--hd-radius-lg);
	background: var(--hd-page);
	box-shadow: var(--hd-shadow);
	transition: transform 0.35s ease, box-shadow 0.35s ease;
}

.hd-news__card::before {
	content: '';
	position: absolute;
	top: 0;
	right: 0;
	left: 0;
	z-index: 3;
	height: 4px;
	background: var(--hd-gold-grad);
	transform: scaleX(0);
	transform-origin: right;
	transition: transform 0.4s ease;
}

.hd-news__card:hover,
.hd-news__card:focus-within {
	box-shadow: var(--hd-shadow-hover);
	transform: translateY(-6px);
}

.hd-news__card:hover::before,
.hd-news__card:focus-within::before {
	transform: scaleX(1);
}

.hd-news__media {
	position: relative;
	display: block;
	overflow: hidden;
	background: var(--hd-paper-deep);
}

.hd-news__media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.7s ease;
}

.hd-news__card:hover .hd-news__media img {
	transform: scale(1.06);
}

/* الصورة الغائبة: كتاب مفتوح ذهبي في الوسط */
.hd-news__placeholder {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: radial-gradient(circle at 50% 45%, var(--hd-page) 0%, var(--hd-paper-deep) 75%);
	color: rgba(var(--hd-gold-rgb), 0.8);
}

.hd-news__placeholder-icon {
	width: 34%;
	max-width: 96px;
	height: auto;
}

.hd-news__date {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--theme-text-light, #5b6b60);
	font-size: 0.84rem;
	line-height: 1.5;
}

.hd-news__date svg {
	flex-shrink: 0;
	color: var(--hd-gold);
}

/* ==========================================================================
   3) بطاقة الخبر الرئيسي: الصورة تملؤها، وتدرّج أخضر في أسفلها يحمل النص بالأبيض
   ========================================================================== */

.hd-news__card--lead {
	justify-content: flex-end;
	min-height: 480px;
	border: 0;
	background: var(--hd-ink);
}

.hd-news__card--lead .hd-news__media {
	position: absolute;
	inset: 0;
	z-index: 0;
}

/* الغطاء الأخضر: يمرّر النقر إلى رابط الصورة خلفه، إلا رابط العنوان */
.hd-news__overlay {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 10px;
	padding: 120px 30px 28px;
	background: linear-gradient(to top, rgba(var(--theme-primary-rgb), 0.97) 0%, rgba(var(--theme-primary-rgb), 0.86) 38%, rgba(var(--theme-primary-rgb), 0.35) 72%, transparent 100%);
	color: #ffffff;
	pointer-events: none;
}

.hd-news__overlay::after {
	content: '';
	position: absolute;
	inset: 0;
	z-index: -1;
	background: linear-gradient(to top, rgba(4, 20, 10, 0.35), transparent 60%);
}

.hd-news__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 14px;
}

.hd-news__pill {
	display: inline-flex;
	padding: 4px 14px;
	border-radius: 999px;
	background: var(--hd-gold-grad);
	color: var(--hd-ink);
	font-size: 0.8rem;
	font-weight: 800;
	line-height: 1.6;
}

.hd-news__overlay .hd-news__date {
	color: rgba(255, 255, 255, 0.88);
}

.hd-news__overlay .hd-news__date svg {
	color: var(--hd-gold-light);
}

.hd-news__lead-title {
	margin: 0;
	font-family: var(--hd-display);
	font-size: clamp(1.4rem, 1.1rem + 0.9vw, 1.9rem);
	font-weight: 800;
	line-height: 1.55;
}

.hd-news__lead-title a {
	color: #ffffff;
	text-decoration: none;
	background: linear-gradient(var(--hd-gold-light), var(--hd-gold-light)) right bottom / 0 2px no-repeat;
	pointer-events: auto;
	transition: background-size 0.35s ease;
}

.hd-news__lead-title a:hover,
.hd-news__lead-title a:focus-visible {
	background-size: 100% 2px;
}

.hd-news__lead-text {
	display: -webkit-box;
	max-width: 640px;
	margin: 0;
	overflow: hidden;
	color: rgba(255, 255, 255, 0.86);
	font-size: 0.96rem;
	line-height: 1.9;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
}

.hd-news__read {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-top: 4px;
	color: var(--hd-gold-light);
	font-size: 0.9rem;
	font-weight: 700;
	transition: gap 0.2s ease;
}

.hd-news__card--lead:hover .hd-news__read {
	gap: 10px;
}

/* ==========================================================================
   4) البطاقات الصغيرة: صورة 16:10 ثم التصنيف والعنوان في سطرين والتاريخ
   ========================================================================== */

.hd-news__card--compact .hd-news__media {
	aspect-ratio: 16 / 10;
}

.hd-news__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	align-items: flex-start;
	gap: 6px;
	padding: 16px 18px 18px;
}

.hd-news__cat {
	display: inline-flex;
	padding: 2px 12px;
	border-radius: 999px;
	background: rgba(var(--theme-primary-rgb), 0.08);
	color: var(--theme-primary);
	font-size: 0.76rem;
	font-weight: 800;
	line-height: 1.7;
}

.hd-news__title {
	display: -webkit-box;
	margin: 0 0 auto;
	overflow: hidden;
	font-size: 1.02rem;
	font-weight: 800;
	line-height: 1.65;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

.hd-news__title a {
	color: var(--hd-ink);
	text-decoration: none;
	transition: color 0.2s ease;
}

.hd-news__title a:hover,
.hd-news__title a:focus-visible {
	color: var(--theme-primary);
}

.hd-news__body .hd-news__date {
	padding-top: 6px;
}

/* البطاقة الصغيرة صفاً أفقياً: الصورة في البداية والنص بجانبها (الأخيرة من أربعة، وعلى الجوال) */
.hd-news__grid--4 .hd-news__cell:last-child .hd-news__card--compact {
	display: grid;
	grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}

.hd-news__grid--4 .hd-news__cell:last-child .hd-news__media {
	aspect-ratio: auto;
	min-height: 160px;
}

.hd-news__grid--4 .hd-news__cell:last-child .hd-news__body {
	justify-content: center;
	padding: 20px 22px;
}

/* ==========================================================================
   5) الأجهزة اللوحية والجوال
   ========================================================================== */

@media (max-width: 1024px) {
	.hd-news__grid,
	.hd-news__grid--3 {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 20px;
	}

	.hd-news__grid--1 {
		grid-template-columns: minmax(0, 1fr);
	}

	/* الرئيسي بعرض الشبكة فوق البطاقات */
	.hd-news__grid--3 .hd-news__cell--lead,
	.hd-news__grid--4 .hd-news__cell--lead,
	.hd-news__grid--5 .hd-news__cell--lead {
		grid-column: 1 / -1;
		grid-row: auto;
	}

	.hd-news__card--lead {
		min-height: 400px;
	}
}

@media (max-width: 640px) {
	.hd-news__grid,
	.hd-news__grid--2,
	.hd-news__grid--3 {
		grid-template-columns: minmax(0, 1fr);
		gap: 16px;
	}

	.hd-news__grid .hd-news__cell,
	.hd-news__grid--4 .hd-news__cell:last-child {
		grid-column: auto;
	}

	.hd-news__card--lead,
	.hd-news__grid--1 .hd-news__card--lead {
		min-height: 360px;
	}

	.hd-news__overlay {
		padding: 90px 20px 22px;
	}

	.hd-news__lead-text {
		-webkit-line-clamp: 2;
	}

	/* البطاقات الصغيرة صفوفاً أفقية: صورة صغيرة ونص */
	.hd-news__card--compact,
	.hd-news__grid--4 .hd-news__cell:last-child .hd-news__card--compact {
		display: grid;
		grid-template-columns: 112px minmax(0, 1fr);
		align-items: stretch;
	}

	.hd-news__card--compact .hd-news__media,
	.hd-news__grid--4 .hd-news__cell:last-child .hd-news__media {
		aspect-ratio: auto;
		min-height: 104px;
	}

	.hd-news__body,
	.hd-news__grid--4 .hd-news__cell:last-child .hd-news__body {
		justify-content: center;
		gap: 4px;
		padding: 12px 14px;
	}

	.hd-news__title {
		margin: 0;
		font-size: 0.95rem;
	}

	.hd-news__body .hd-news__date {
		padding-top: 2px;
		font-size: 0.8rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.hd-news__card,
	.hd-news__card::before,
	.hd-news__media img,
	.hd-news__lead-title a,
	.hd-news__title a,
	.hd-news__read {
		transition: none;
	}

	.hd-news__card:hover,
	.hd-news__card:focus-within,
	.hd-news__card:hover .hd-news__media img {
		transform: none;
	}
}
