/**
 * المكونات المشتركة بين أقسام الرئيسية في ثيم تنمية العرضية: خلفية القسم وزخرفته، ورأس القسم
 * (template-parts/home/tn-section-head.php)، والشريط الأفقي بزرّي تنقل
 * (template-parts/home/tn-rail-nav.php وassets/js/blocks/tn-rail.js).
 *
 * يُحمَّل مرة واحدة مع أي قسم مفعّل (association_child_enqueue_block_assets في functions.php).
 */

/* ==========================================================================
   1) القسم: خلفية الصفحة، والبديل أبيض أو أخضر فاتح، وتركوازي عميق بنقش البذور
   ========================================================================== */

.tn-section {
	position: relative;
	isolation: isolate;
	padding: 84px 0;
	background: var(--theme-bg-body, var(--tn-stone));
}

.tn-section--white {
	background: #ffffff;
}

.tn-section--sand {
	background: var(--tn-sand);
}

/* نقش البذور الخفيف على الخلفية الفاتحة، يتلاشى نحو الوسط */
.tn-section--grid::before {
	content: '';
	position: absolute;
	inset: 0;
	z-index: -1;
	--tn-grid-color: rgba(var(--theme-primary-rgb), 0.07);
	background: var(--tn-grid);
	-webkit-mask: radial-gradient(ellipse at 50% 40%, transparent 30%, #000 85%);
	mask: radial-gradient(ellipse at 50% 40%, transparent 30%, #000 85%);
	pointer-events: none;
}

/* القسم الداكن: تركوازي عميق بنقش البذور الأبيض الخافت (اسم الصنف باقٍ من التصميم الأول) */
.tn-section--deep {
	--tn-grid-color: rgba(255, 255, 255, 0.07);
	background: var(--tn-grid), linear-gradient(160deg, var(--theme-primary), var(--tn-deep));
	color: #ffffff;
}

/* خطوط مدرجات خضراء خفيفة على حافة القسم السفلية (زخرفة اختيارية) */
.tn-section--rows::after {
	content: '';
	position: absolute;
	inset: auto 0 0;
	height: 96px;
	z-index: -1;
	background: var(--theme-secondary);
	opacity: 0.12;
	-webkit-mask: var(--tn-rows) 0 0 / var(--tn-rows-size), linear-gradient(transparent, #000);
	-webkit-mask-composite: source-in;
	mask: var(--tn-rows) 0 0 / var(--tn-rows-size), linear-gradient(transparent, #000);
	mask-composite: intersect;
	pointer-events: none;
}

.tn-section > .container {
	position: relative;
}

/* ==========================================================================
   2) رأس القسم: العنوان في البداية (يمين)، و«عرض الكل» في الطرف المقابل
   ========================================================================== */

.tn-head {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 18px 32px;
	margin-bottom: 42px;
}

.tn-head__main {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	max-width: 760px;
}

.tn-head__eyebrow {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 8px;
	color: var(--tn-leaf-deep);
	font-size: 0.85rem;
	font-weight: 800;
	letter-spacing: 0;
}

/* ورقة صغيرة قبل السطر العلوي */
.tn-head__eyebrow::before {
	content: '';
	width: 14px;
	height: 14px;
	border-radius: 10px 2px 10px 2px;
	background: currentColor;
	opacity: 0.85;
}

.tn-head__title {
	margin: 0 0 12px;
	color: var(--tn-ink);
	font-size: clamp(1.55rem, 1.15rem + 1.25vw, 2.25rem);
	font-weight: 800;
	line-height: 1.3;
}

.tn-head__desc {
	margin: 14px 0 0;
	color: var(--theme-text-light);
	font-size: 1rem;
	line-height: 1.85;
}

/* «عرض الكل»: كبسولة بحد رفيع، يتحرك سهمه نحو اليسار عند المرور */
.tn-head__all {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 10px 20px;
	border: 1.5px solid var(--tn-line-strong);
	border-radius: 999px;
	color: var(--theme-primary);
	font-size: 0.92rem;
	font-weight: 700;
	text-decoration: none;
	transition: color 0.25s ease, border-color 0.25s ease, background-color 0.25s ease;
}

.tn-head__all svg {
	color: var(--theme-secondary);
	transition: transform 0.25s var(--tn-ease), color 0.25s ease;
}

.tn-head__all:hover,
.tn-head__all:focus-visible {
	border-color: var(--theme-primary);
	background: var(--theme-primary);
	color: #ffffff;
}

.tn-head__all:hover svg,
.tn-head__all:focus-visible svg {
	color: #ffffff;
	transform: translateX(-4px);
}

.tn-head--center {
	justify-content: center;
	text-align: center;
}

.tn-head--center .tn-head__main {
	align-items: center;
}

.tn-head--light .tn-head__title {
	color: #ffffff;
}

.tn-head--light .tn-head__desc {
	color: rgba(255, 255, 255, 0.78);
}

.tn-head--light .tn-head__all {
	border-color: rgba(255, 255, 255, 0.35);
	color: #ffffff;
}

.tn-head--light .tn-head__all:hover,
.tn-head--light .tn-head__all:focus-visible {
	border-color: var(--theme-secondary);
	background: var(--theme-secondary);
}

@media (max-width: 767px) {
	.tn-head {
		margin-bottom: 30px;
	}
}

/* ==========================================================================
   3) الشريط الأفقي: بطاقات تتمرر، وزرّا تنقل متلاصقان أسفله
   ========================================================================== */

.tn-rail {
	--tn-rail-cols: 4;
	--tn-rail-gap: 24px;
	position: relative;
}

.tn-rail__track {
	display: grid;
	grid-auto-columns: calc((100% - (var(--tn-rail-cols) - 1) * var(--tn-rail-gap)) / var(--tn-rail-cols));
	grid-auto-flow: column;
	gap: var(--tn-rail-gap);
	overflow-x: auto;
	padding: 6px 2px 22px;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
}

.tn-rail__track::-webkit-scrollbar {
	display: none;
}

.tn-rail__track > * {
	scroll-snap-align: start;
}

.tn-rail__nav {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	margin-top: 6px;
}

.tn-rail__nav[hidden] {
	display: none;
}

.tn-rail__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 46px;
	height: 46px;
	padding: 0;
	border: 1.5px solid var(--tn-line-strong);
	border-radius: 50%;
	background: #ffffff;
	color: var(--theme-primary);
	cursor: pointer;
	transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease, opacity 0.25s ease;
}

.tn-rail__btn:hover,
.tn-rail__btn:focus-visible {
	position: relative;
	z-index: 1;
	border-color: var(--theme-primary);
	background: var(--theme-primary);
	color: #ffffff;
}

.tn-rail__btn[disabled] {
	opacity: 0.4;
	cursor: default;
	pointer-events: none;
}

/* الشريط فوق خلفية داكنة */
.tn-section--deep .tn-rail__btn {
	border-color: rgba(255, 255, 255, 0.3);
	background: transparent;
	color: #ffffff;
}

.tn-section--deep .tn-rail__btn:hover,
.tn-section--deep .tn-rail__btn:focus-visible {
	border-color: var(--theme-secondary);
	background: var(--theme-secondary);
}

@media (max-width: 1024px) {
	.tn-rail {
		--tn-rail-cols: 2.4;
	}
}

@media (max-width: 640px) {
	.tn-section {
		padding: 60px 0;
	}

	.tn-rail {
		--tn-rail-cols: 1.2;
		--tn-rail-gap: 14px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tn-rail__btn,
	.tn-head__all svg {
		transition: none;
	}
}
