/**
 * المكونات المشتركة بين أقسام الرئيسية في ثيم هدي: خلفية القسم، ورأس القسم «عنوان الفصل»
 * (template-parts/home/hd-section-head.php)، والصفحة الورقية.
 *
 * يُحمَّل مرة واحدة مع أي قسم مفعّل (association_child_enqueue_block_assets في functions.php).
 */

/* ==========================================================================
   1) القسم: خلفية الورق الكريمي، والبديلان: صفحة بيضاء دافئة وورق أغمق
   ========================================================================== */

.hd-section {
	position: relative;
	isolation: isolate;
	padding: 76px 0;
	background: var(--theme-bg-body, var(--hd-paper));
}

.hd-section--page {
	background: var(--hd-page);
}

.hd-section--deep {
	background: var(--hd-paper-deep);
}

/*
 * زخرفة الشعار (كان اسمها «مسطّر» وبقي الكلاس): كتاب الشعار ذهبياً خافتاً جداً في الزاوية السفلية اليسرى فقط،
 * لمسة واحدة خفيفة (طلب المالك). تُضاف أيضاً بـ ‎.hd-section--flow‎.
 */
.hd-section--ruled::before,
.hd-section--flow::before {
	content: '';
	position: absolute;
	z-index: -1;
	width: min(560px, 60vw);
	aspect-ratio: 3 / 2;
	background: var(--hd-gold-grad);
	opacity: 0.08;
	-webkit-mask: var(--hd-flow) center / contain no-repeat;
	mask: var(--hd-flow) center / contain no-repeat;
	pointer-events: none;
}

.hd-section--ruled::before,
.hd-section--flow::before {
	bottom: -40px;
	left: -60px;
}

.hd-section--ruled,
.hd-section--flow {
	overflow: hidden;
}

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

/* ==========================================================================
   2) رأس القسم: العنوان في البداية وجرّة القلم تحته، و«عرض الكل» في الطرف الآخر
   ========================================================================== */

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

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

.hd-head__title {
	margin: 0;
	color: var(--hd-ink);
	font-family: var(--hd-display);
	font-size: clamp(1.8rem, 1.35rem + 1.4vw, 2.5rem);
	font-weight: 800;
	line-height: 1.45;
}

.hd-head__stroke {
	margin: 2px 0 0 12px;
}

.hd-head__desc {
	margin: 12px 0 0;
	color: var(--theme-text-light, #5b6b60);
	font-size: 1rem;
	line-height: 1.85;
}

/*
 * «عرض الكل»: زر كبسولي بحلقة بالتدرّج الذهبي للشعار، والسهم في دائرة خضراء صغيرة، ويمتلئ بالأخضر عند المرور
 * (والسهم يصير ذهبياً ويتقدّم قليلاً).
 */
.hd-head__all {
	flex-shrink: 0;
	gap: 10px;
	margin-bottom: 6px;
	padding: 7px 8px 7px 18px;
	border: 1.5px solid transparent;
	border-radius: 999px;
	background: linear-gradient(var(--hd-page), var(--hd-page)) padding-box, var(--hd-gold-grad) border-box;
	box-shadow: 0 8px 18px -12px rgba(var(--hd-gold-rgb), 0.9);
	color: var(--theme-primary);
	font-size: 0.9rem;
	transition: background 0.25s ease, color 0.25s ease, box-shadow 0.25s ease, gap 0.25s ease;
}

.hd-head__all svg {
	box-sizing: content-box;
	width: 14px;
	height: 14px;
	padding: 6px;
	border-radius: 50%;
	background: var(--theme-primary);
	color: #ffffff;
	transition: background-color 0.25s ease, color 0.25s ease, transform 0.25s ease;
}

.hd-head__all:hover,
.hd-head__all:focus-visible {
	gap: 10px;
	background: linear-gradient(var(--theme-primary), var(--theme-primary)) padding-box, var(--hd-gold-grad) border-box;
	box-shadow: 0 12px 22px -12px rgba(var(--theme-primary-rgb), 0.7);
	color: #ffffff;
}

.hd-head__all:hover svg,
.hd-head__all:focus-visible svg {
	background: var(--hd-gold-grad);
	color: var(--hd-ink);
	transform: translateX(-3px);
}

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

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

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

.hd-head--light .hd-head__desc {
	color: rgba(255, 255, 255, 0.8);
}

/* فوق الخلفيات الداكنة: الزر شفاف بنص أبيض، ويمتلئ بالذهبي عند المرور */
.hd-head--light .hd-head__all {
	background: linear-gradient(var(--hd-ink), var(--hd-ink)) padding-box, var(--hd-gold-grad) border-box;
	box-shadow: none;
	color: #ffffff;
}

.hd-head--light .hd-head__all svg {
	background: var(--hd-gold-grad);
	color: var(--hd-ink);
}

.hd-head--light .hd-head__all:hover,
.hd-head--light .hd-head__all:focus-visible {
	background: var(--hd-gold-grad) padding-box, var(--hd-gold-grad) border-box;
	color: var(--hd-ink);
}

.hd-head--light .hd-head__all:hover svg,
.hd-head--light .hd-head__all:focus-visible svg {
	background: var(--hd-ink);
	color: #ffffff;
}

@media (max-width: 767px) {
	.hd-section {
		padding: 56px 0;
	}

	.hd-head {
		flex-direction: column;
		align-items: flex-start;
		margin-bottom: 28px;
	}

	.hd-head--center {
		align-items: center;
	}

	.hd-head__all {
		margin-bottom: 0;
	}
}

/* ==========================================================================
   3) الصفحة الورقية: ورق أبيض دافئ بحافة صفحات خلفه (للرسالة والدفتر والبطاقات)
   ========================================================================== */

.hd-paper {
	position: relative;
	border: 1px solid var(--hd-page-edge);
	border-radius: 4px;
	background: var(--hd-page);
	box-shadow: var(--hd-shadow-page);
}

/* ورقتان خلف الصفحة تظهر حافتاهما أسفلها */
.hd-paper--stack::before,
.hd-paper--stack::after {
	content: '';
	position: absolute;
	right: 10px;
	left: 10px;
	bottom: -6px;
	z-index: -1;
	height: 20px;
	border: 1px solid var(--hd-page-edge);
	border-radius: 0 0 4px 4px;
	background: var(--hd-page);
}

.hd-paper--stack::after {
	right: 20px;
	left: 20px;
	bottom: -11px;
	z-index: -2;
}

/* سطور الدفتر داخل الصفحة وخط الهامش الذهبي (يمين) */
.hd-paper--ruled {
	background-image: linear-gradient(to left, transparent 44px, var(--hd-margin) 44px, var(--hd-margin) 45px, transparent 45px), var(--hd-ruled);
}

/* ==========================================================================
   4) الشريط الأفقي (.hd-rail): بطاقات تُسحب، وزرّا التنقل تحته في الطرف الأيسر
   (template-parts/home/hd-rail-nav.php وassets/js/blocks/hd-rail.js). عدد الأعمدة الظاهرة ‎--hd-rail-cols‎.
   ========================================================================== */

.hd-rail {
	--hd-rail-cols: 4;
	--hd-rail-gap: 22px;
	position: relative;
}

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

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

.hd-rail__track > * {
	min-width: 0;
	scroll-snap-align: start;
}

.hd-rail__nav {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	margin-top: 4px;
}

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

.hd-rail__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	padding: 0;
	border: 1px solid var(--hd-line);
	border-radius: 50%;
	background: var(--hd-page);
	color: var(--theme-primary);
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

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

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

/* فوق خلفية داكنة */
.hd-rail--light .hd-rail__btn {
	border-color: rgba(var(--hd-gold-rgb), 0.45);
	background: transparent;
	color: #ffffff;
}

.hd-rail--light .hd-rail__btn:hover,
.hd-rail--light .hd-rail__btn:focus-visible {
	border-color: var(--hd-gold);
	background: var(--hd-gold);
}

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

@media (max-width: 640px) {
	.hd-rail {
		--hd-rail-cols: 1.25;
		--hd-rail-gap: 14px;
	}
}

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

	.hd-head__all:hover svg,
	.hd-head__all:focus-visible svg {
		transform: none;
	}
}
