/**
 * Medad Framework — أنماط البطاقة الموحّدة والأقسام.
 * الألوان تعتمد على المتغيّرين --medad-primary و --medad-accent
 * (يُحقنان من config.php).
 */

:root {
	--medad-primary: #1e6b47;
	--medad-accent: #c9a227;
	--medad-dark: #18293b;
	--medad-radius: 12px;
	--medad-border: rgba(0, 0, 0, .08);
}

/* ---------- الشبكة ---------- */
.medad-grid {
	display: grid;
	gap: 18px;
	margin: 0 0 24px;
}
.medad-cols-1 { grid-template-columns: 1fr; }
.medad-cols-2 { grid-template-columns: repeat(2, 1fr); }
.medad-cols-3 { grid-template-columns: repeat(3, 1fr); }
.medad-cols-4 { grid-template-columns: repeat(4, 1fr); }
.medad-cols-5 { grid-template-columns: repeat(5, 1fr); }
.medad-cols-6 { grid-template-columns: repeat(6, 1fr); }

@media (max-width: 1024px) {
	.medad-cols-4, .medad-cols-5, .medad-cols-6 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
	.medad-cols-3, .medad-cols-4, .medad-cols-5, .medad-cols-6 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
	.medad-grid { grid-template-columns: 1fr !important; }
}

/* ---------- البطاقة العامة ---------- */
.medad-card {
	background: #fff;
	border: 1px solid var(--medad-border);
	border-radius: var(--medad-radius);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	transition: box-shadow .2s ease, transform .2s ease;
}
.medad-card:hover {
	box-shadow: 0 6px 20px rgba(0, 0, 0, .1);
	transform: translateY(-2px);
}

.medad-card__media {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	height: 168px;
	background-color: #eef2ef;
	background-size: cover;
	background-position: center;
	color: var(--medad-primary);
	text-decoration: none;
}

.medad-card__tag {
	position: absolute;
	top: 10px;
	inset-inline-end: 10px;
	background: var(--medad-primary);
	color: #fff;
	font-size: 12px;
	line-height: 1;
	padding: 5px 11px;
	border-radius: 6px;
	z-index: 2;
}
.medad-card__tag--accent { color: #3a2e00; background: var(--medad-accent); }

.medad-card__play {
	width: 54px; height: 54px;
	border-radius: 50%;
	background: rgba(255, 255, 255, .92);
	color: #12352a;
	display: flex; align-items: center; justify-content: center;
	padding-inline-start: 4px;
}
.medad-card__media--video { background-color: #12352a; }

.medad-card__duration,
.medad-card__count {
	position: absolute;
	bottom: 10px;
	inset-inline-start: 10px;
	background: rgba(0, 0, 0, .7);
	color: #fff;
	font-size: 12px;
	padding: 3px 8px;
	border-radius: 5px;
	display: inline-flex;
	align-items: center;
	gap: 4px;
}


.medad-card__body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.medad-card__title { font-size: 16px; margin: 0; line-height: 1.6; }
.medad-card__title a { color: inherit; text-decoration: none; }
.medad-card__title a:hover { color: var(--medad-primary); }

.medad-card__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 14px;
	font-size: 13px;
	color: #6b6b6b;
}
.medad-card__meta-item { display: inline-flex; align-items: center; gap: 5px; }

.medad-card__action { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.medad-btn {
	display: inline-flex; align-items: center; gap: 6px;
	background: var(--medad-primary);
	color: #fff !important;
	font-size: 13px;
	padding: 8px 15px;
	border-radius: 8px;
	text-decoration: none;
	transition: filter .2s ease;
}
.medad-btn:hover { filter: brightness(1.1); }
.medad-btn--gold { background: var(--medad-accent); color: var(--medad-dark) !important; font-weight: 600; }
.medad-btn--dark { background: var(--medad-dark); }

/* ---------- المكتبة: بطاقة الكتاب (رفّ + مميّز) ---------- */
.medad-book__stage {
	position: relative;
	display: flex; align-items: center; justify-content: center;
	padding: 26px 16px 22px;
	background: #eef1f4;
	background: color-mix(in srgb, var(--medad-dark) 7%, #fff);
	text-decoration: none;
}
/* الغلاف ككتاب 2:3 — الكعب على اليمين (كتب عربية) */
.medad-book__book {
	position: relative;
	display: block;
	width: 118px;
	aspect-ratio: 2 / 3;
	overflow: hidden;
	border-start-start-radius: 3px; border-end-start-radius: 3px;
	border-start-end-radius: 7px;  border-end-end-radius: 7px;
	box-shadow: 0 12px 20px -10px rgba(24, 41, 59, .55), 0 2px 5px rgba(24, 41, 59, .12);
	transition: transform .3s ease, box-shadow .3s ease;
}
.medad-book__book::after {
	content: "";
	position: absolute; inset-block: 0; inset-inline-start: 0; width: 9px;
	background: linear-gradient(to left, rgba(0, 0, 0, .28), rgba(255, 255, 255, .12) 55%, transparent);
	pointer-events: none;
}
.medad-book__img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* غلاف تلقائي عند غياب الصورة */
.medad-book__auto {
	position: absolute; inset: 0;
	display: flex; flex-direction: column; justify-content: space-between;
	padding-block: 16px 12px; padding-inline: 16px 12px;
	background: var(--medad-dark);
	color: var(--medad-accent);
	border-top: 3px solid var(--medad-accent);
}
.medad-book__auto b { font-size: 14px; line-height: 1.45; font-weight: 700; }
.medad-book__auto i { font-style: normal; font-size: 10.5px; color: rgba(255, 255, 255, .72); }
.medad-card--library:hover .medad-book__book {
	transform: translateY(-5px) rotate(-1.5deg);
	box-shadow: 0 18px 26px -12px rgba(24, 41, 59, .6), 0 3px 6px rgba(24, 41, 59, .14);
}

.medad-book .medad-card__body { gap: 6px; flex: 1; }
.medad-book__author { margin: 0; display: flex; align-items: center; gap: 5px; font-size: 13px; color: #6b6b6b; }
.medad-book__author svg { flex-shrink: 0; }
/* في الرفّ: عنوان حتى 3 أسطر وكاتب بسطر واحد لتتساوى ارتفاعات البطاقات */
.medad-book:not(.medad-book--featured) .medad-card__title a {
	display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.medad-book:not(.medad-book--featured) .medad-book__author span {
	min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.medad-book__meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: #8a8a8a; font-variant-numeric: tabular-nums; }
.medad-book__meta span { display: inline-flex; align-items: center; gap: 4px; }
.medad-book__actions { display: flex; gap: 8px; margin-top: auto; padding-top: 8px; }
.medad-book__actions .medad-btn { flex: 1; justify-content: center; padding: 8px 10px; }

/* النمط المميّز (أفقي) */
.medad-book--featured { flex-direction: row; }
.medad-book--featured .medad-book__stage { flex: 0 0 210px; padding: 28px 20px; }
.medad-book--featured .medad-book__book { width: 138px; }
.medad-book--featured .medad-card__body { padding: 22px 24px; gap: 8px; }
.medad-book--featured .medad-card__title { font-size: 21px; line-height: 1.5; }
.medad-book__chips { display: flex; gap: 6px; flex-wrap: wrap; }
.medad-book__chip {
	font-size: 12px; font-weight: 500;
	padding: 3px 10px; border-radius: 6px;
	background: #f6efd9;
	background: color-mix(in srgb, var(--medad-accent) 18%, #fff);
	color: var(--medad-dark);
}
.medad-book__excerpt { margin: 0; color: #555; font-size: 14px; line-height: 1.85; max-width: 62ch; }
.medad-book--featured .medad-book__actions .medad-btn { flex: 0 0 auto; padding: 10px 22px; }

@media (max-width: 600px) {
	.medad-book--featured { flex-direction: column; }
	.medad-book--featured .medad-book__stage { flex-basis: auto; }
	.medad-book--featured .medad-card__body { padding: 16px; }
	.medad-book--featured .medad-book__actions .medad-btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
	.medad-book__book { transition: none; }
	.medad-card--library:hover .medad-book__book { transform: none; }
}

/* ---------- سؤال وجواب (accordion) ---------- */
.medad-card--qa { padding: 0; }
.medad-qa { width: 100%; }
.medad-qa__q {
	list-style: none;
	cursor: pointer;
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 16px;
	position: relative;
}
.medad-qa__q::-webkit-details-marker { display: none; }
.medad-qa__q-text { font-size: 16px; font-weight: 600; line-height: 1.6; flex: 1; }
.medad-qa__chevron { color: #888; transition: transform .2s ease; flex-shrink: 0; margin-top: 2px; }
.medad-qa[open] .medad-qa__chevron { transform: rotate(180deg); }
.medad-qa__a {
	padding: 0 16px 16px;
	color: #444;
	line-height: 1.9;
	border-top: 1px solid var(--medad-border);
	margin-top: 4px;
	padding-top: 14px;
}

/* ---------- أقوال ---------- */
.medad-card--saying { padding: 16px; }
.medad-saying__head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.medad-saying__avatar {
	width: 52px; height: 52px; border-radius: 50%;
	object-fit: cover; flex-shrink: 0;
	border: 2px solid var(--medad-accent);
}
.medad-saying__avatar--ph {
	display: flex; align-items: center; justify-content: center;
	background: #eef2ef; color: var(--medad-primary); border-color: #eef2ef;
}
.medad-saying__author { margin: 6px 0 0; font-size: 14px; font-weight: 600; }
.medad-saying__text {
	font-family: Georgia, "Times New Roman", serif;
	font-size: 15px; line-height: 1.9; color: #555;
	text-decoration: none; display: block;
}
.medad-saying__text:hover { color: var(--medad-primary); }

/* ---------- أزرار المشاركة ---------- */
.medad-share { display: flex; gap: 14px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--medad-border); }
.medad-share button.medad-share__btn,
.medad-share a.medad-share__btn {
	-webkit-appearance: none; appearance: none;
	background: none; border: 0; box-shadow: none; cursor: pointer; padding: 0;
	color: #777; display: inline-flex; align-items: center;
	text-decoration: none; transition: color .2s ease;
}
.medad-share__btn svg { fill: currentColor; }
.medad-share button.medad-share__btn:hover,
.medad-share a.medad-share__btn:hover { color: var(--medad-primary); background: none; }

/* ---------- روابط التواصل ---------- */
.medad-social { display: flex; gap: 10px; flex-wrap: wrap; }
.medad-social__link {
	display: inline-flex; align-items: center; justify-content: center;
	width: 40px; height: 40px; border-radius: 8px;
	background: var(--medad-primary); color: #fff;
	transition: transform .2s ease, filter .2s ease;
}
.medad-social__link:hover { transform: translateY(-2px); filter: brightness(1.1); }
.medad-social--sm .medad-social__link { width: 32px; height: 32px; }
.medad-social--lg .medad-social__link { width: 48px; height: 48px; }

.medad-social--floating {
	position: fixed;
	inset-inline-start: 0;
	top: 50%;
	transform: translateY(-50%);
	flex-direction: column;
	gap: 0;
	z-index: 999;
}
.medad-social--floating .medad-social__link { border-radius: 0; }

/* ---------- رأس الأرشيف ---------- */
.medad-archive-header { text-align: center; margin: 0 0 24px; }
.medad-archive-header h1 { color: var(--medad-primary); margin: 0 0 6px; }
.medad-filter { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 16px 0 0; }
.medad-filter a {
	font-size: 14px; padding: 6px 16px; border-radius: 20px;
	border: 1px solid var(--medad-border); color: #444; text-decoration: none;
}
.medad-filter a.is-active,
.medad-filter a:hover { background: var(--medad-primary); color: #fff; border-color: var(--medad-primary); }

.medad-empty { text-align: center; color: #888; padding: 30px 0; }

/* ---------- الاستطلاعات ---------- */
.medad-polls-list,
.medad-polls-results { display: flex; flex-direction: column; gap: 18px; max-width: 720px; margin-inline: auto; }

.medad-poll {
	background: #fff;
	border: 1px solid var(--medad-border, rgba(0, 0, 0, .08));
	border-radius: 12px;
	padding: 18px 20px;
}
.medad-poll__q { margin: 0 0 14px; font-size: 17px; line-height: 1.6; color: var(--medad-primary); }

/* نموذج التصويت */
.medad-poll__form { display: flex; flex-direction: column; gap: 10px; }
.medad-poll__option {
	display: flex; align-items: center; gap: 10px;
	padding: 11px 14px;
	border: 1px solid var(--medad-border, rgba(0, 0, 0, .1));
	border-radius: 8px;
	cursor: pointer;
	transition: border-color .15s ease, background .15s ease;
}
.medad-poll__option:hover { border-color: var(--medad-primary); background: #f5f9f7; }
.medad-poll__option input { accent-color: var(--medad-primary); width: 17px; height: 17px; flex-shrink: 0; }
.medad-poll__option-text { font-size: 15px; }
.medad-poll__actions { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.medad-poll__submit { border: 0; cursor: pointer; }
.medad-poll__submit.is-loading { opacity: .6; pointer-events: none; }
.medad-poll__msg { font-size: 13px; color: #c0392b; }

/* النتائج */
.medad-poll__results { display: flex; flex-direction: column; gap: 14px; }
.medad-poll__result-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.medad-poll__opt-label { font-size: 15px; color: #333; }
.medad-poll__opt-pct { font-size: 14px; font-weight: 600; color: var(--medad-primary); }
.medad-poll__bar { position: relative; height: 10px; background: #eef2ef; border-radius: 6px; overflow: hidden; }
.medad-poll__bar span {
	position: absolute; inset-inline-start: 0; top: 0; height: 100%;
	background: var(--medad-primary);
	border-radius: 6px;
	width: 0;
	transition: width .6s cubic-bezier(.2, .8, .2, 1);
}
.medad-poll__opt-count { display: block; margin-top: 4px; font-size: 12px; color: #888; }
.medad-poll__total { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--medad-border, rgba(0, 0, 0, .08)); font-size: 13px; color: #666; font-weight: 500; }
.medad-poll__note { margin: 12px 0 0; font-size: 13px; color: #999; }
.medad-poll__preview { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--medad-border, rgba(0, 0, 0, .12)); }
.medad-poll__preview .medad-poll__total { border: 0; padding-top: 6px; }

/* ---------- المفردة ---------- */
.medad-single-embed { position: relative; padding-bottom: 56.25%; height: 0; margin: 0 0 20px; border-radius: var(--medad-radius); overflow: hidden; }
.medad-single-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.medad-lightbox-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.medad-lightbox-grid img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; cursor: pointer; aspect-ratio: 1 / 1; }
@media (max-width: 600px) { .medad-lightbox-grid { grid-template-columns: repeat(2, 1fr); } }

/* ============================================================
   بلوكات Publisher كبطاقات موحّدة (Thumbnail 1 و 2)
   يعيد تنسيق مخرجات البلوك دون تعديل منطقه، فتبقى تحكّمات
   لوحة القالب (الكاتب/التاريخ/الميتا) تعمل كما هي.
   ★ لإضافة بلوك جديد: أضف صنف حاويته إلى قوائم :is() أدناه.
   ============================================================ */
:is(.listing-tb-1, .listing-tb-2) {
	display: grid;
	gap: 18px;
	margin: 0 0 24px;
}
/* إبطال pseudo-elements الخاصة بـ clearfix حتى لا تُحتسب كخلايا شبكة */
:is(.listing-tb-1, .listing-tb-2)::before,
:is(.listing-tb-1, .listing-tb-2)::after { content: none !important; display: none !important; }
:is(.listing-tb-1, .listing-tb-2):is(.scolumns-1, .columns-1) { grid-template-columns: 1fr; }
:is(.listing-tb-1, .listing-tb-2):is(.scolumns-2, .columns-2) { grid-template-columns: repeat(2, 1fr); }
:is(.listing-tb-1, .listing-tb-2):is(.scolumns-3, .columns-3) { grid-template-columns: repeat(3, 1fr); }
:is(.listing-tb-1, .listing-tb-2):is(.scolumns-4, .columns-4) { grid-template-columns: repeat(4, 1fr); }
:is(.listing-tb-1, .listing-tb-2):is(.scolumns-5, .columns-5) { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1024px) {
	:is(.listing-tb-1, .listing-tb-2):is(.scolumns-4, .columns-4),
	:is(.listing-tb-1, .listing-tb-2):is(.scolumns-5, .columns-5) { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
	:is(.listing-tb-1, .listing-tb-2) { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 480px) {
	:is(.listing-tb-1, .listing-tb-2) { grid-template-columns: 1fr !important; }
}

/* البطاقة (العنصر مشترك: .listing-item-thumbnail) */
:is(.listing-tb-1, .listing-tb-2) .listing-item-thumbnail {
	width: auto !important;
	float: none !important;
	margin: 0 !important;
	padding: 0 !important;
	background: #fff;
	border: 1px solid var(--medad-border, rgba(0, 0, 0, .08));
	border-radius: 12px;
	overflow: hidden;
	transition: box-shadow .2s ease, transform .2s ease;
}
:is(.listing-tb-1, .listing-tb-2) .listing-item-thumbnail:hover {
	box-shadow: 0 6px 20px rgba(0, 0, 0, .1);
	transform: translateY(-2px);
}
:is(.listing-tb-1, .listing-tb-2) .item-inner { padding: 0; margin: 0; border: 0; }

/* الوسائط (الصورة) */
:is(.listing-tb-1, .listing-tb-2) .featured {
	position: relative;
	width: 100%;
	float: none;
	display: block;
	height: 168px;
	margin: 0;
	padding: 0;
	overflow: hidden;
	background: #eef2ef;
}
:is(.listing-tb-1, .listing-tb-2) .featured .img-holder {
	display: block;
	width: 100%;
	height: 100%;
	background-size: cover !important;
	background-position: center !important;
}

/* وسم التصنيف بشكل بطاقتنا (متوفّر في tb-2؛ tb-1 بلا وسم افتراضاً) */
:is(.listing-tb-1, .listing-tb-2) .term-badges.floated {
	position: absolute;
	top: 10px;
	inset-inline-end: 10px;
	margin: 0;
	z-index: 2;
}
:is(.listing-tb-1, .listing-tb-2) .term-badges.floated .term-badge {
	background: var(--medad-primary, #1e6b47) !important;
	border-radius: 6px;
	box-shadow: none;
}
:is(.listing-tb-1, .listing-tb-2) .term-badges.floated .term-badge a {
	background: var(--medad-primary, #1e6b47) !important;
	background-color: var(--medad-primary, #1e6b47) !important;
	color: #fff !important;
	font-size: 12px;
	line-height: 1;
	padding: 5px 11px;
	display: inline-block;
	border-radius: 6px;
}

/* العنوان */
:is(.listing-tb-1, .listing-tb-2) .title {
	padding: 14px 16px 0;
	margin: 0;
	font-size: 16px;
	line-height: 1.6;
}
:is(.listing-tb-1, .listing-tb-2) .title:last-child { padding-bottom: 14px; }
:is(.listing-tb-1, .listing-tb-2) .title a { color: inherit; }
:is(.listing-tb-1, .listing-tb-2) .title a:hover,
:is(.listing-tb-1, .listing-tb-2) .title a:hover .post-title { color: var(--medad-primary, #1e6b47); }

/* صف الميتا (يظهر عند تفعيله من لوحة القالب) */
:is(.listing-tb-1, .listing-tb-2) .post-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 14px;
	padding: 8px 16px 14px;
	margin: 0;
	font-size: 13px;
	color: #6b6b6b;
	border: 0;
}
:is(.listing-tb-1, .listing-tb-2) .post-meta > * { margin: 0 !important; }
:is(.listing-tb-1, .listing-tb-2) .post-meta a,
:is(.listing-tb-1, .listing-tb-2) .post-meta i,
:is(.listing-tb-1, .listing-tb-2) .post-meta time { color: #6b6b6b; font-style: normal; }
:is(.listing-tb-1, .listing-tb-2) .post-meta .bf-icon,
:is(.listing-tb-1, .listing-tb-2) .post-meta i.fa { margin-inline-end: 4px; opacity: .75; }

/* المقتطف (يظهر عند تفعيله من لوحة القالب) */
:is(.listing-tb-1, .listing-tb-2) .post-summary {
	padding: 0 16px 14px;
	margin: 0;
	color: #555;
	line-height: 1.7;
}

/* اسم الكاتب المخصّص (بايلاين): يظهر عند تعبئته فقط، ويُخفى الافتراضي عند الفراغ */
:is(.listing-tb-1, .listing-tb-2) .post-meta .post-author-a:not(:has(.medad-byline)) { display: none; }
:is(.listing-tb-1, .listing-tb-2) .post-meta .medad-byline { font-style: normal; }
