/* Hallmark · macrostructure: Long Document (المقال) · nav: N1b · footer: Ft1 (موروثان)
 * theme: brand-locked (nexcode brand guide) · genre: editorial · tone: technical
 * axes — paper-band: light · display-style: humanist-sans-arabic · accent-hue: cool
 * pre-emit critique: P4 H5 E4 S4 R4 V4
 *
 * nexcode — المدونة والدورات. يُحمَّل بعد pages.css.
 * كل قيمة من tokens.css — لا ألوان ولا خطوط جديدة.
 * ════════════════════════════════════════════════════════════ */

/* ── شبكة البطاقات ─────────────────────────────────────── */

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: var(--space-lg);
}
.post-empty { padding-block: var(--space-xl); color: var(--text-secondary); }

/* سطح فاتح بظل ناعم على خلفية الصفحة — القسم ٥ من الدليل. البطاقة كلها تُضغط عبر رابط العنوان */
.post-card,
.post-feature {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}
.post-card { display: flex; flex-direction: column; }

.post-card h3 a,
.post-feature h3 a {
  color: var(--ink);
  text-decoration: none;
  transition: color var(--dur-short) var(--ease-out);
}
.post-card h3 a::after,
.post-feature h3 a::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius-card);
}
.post-card h3 a:focus-visible,
.post-feature h3 a:focus-visible { outline: none; }
.post-card h3 a:focus-visible::after,
.post-feature h3 a:focus-visible::after { outline: 2px solid var(--blue); outline-offset: -2px; }

.post-cover { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: var(--ink); }
.post-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--dur-long) var(--ease-out);
}
@media (hover: hover) {
  .post-card:hover h3 a,
  .post-feature:hover h3 a { color: var(--blue); }
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .post-card:hover .post-cover img,
  .post-feature:hover .post-cover img { transform: scale(1.02); }
}

/* غلاف بهوية الموقع لما ما فيه صورة: العلامة مكبّرة ومقصوصة على الداكن، وخط الهوية تحتها */
.post-cover.is-default { background: var(--grad-dark); }
.post-cover.is-default::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 3px;
  background: var(--grad-accent);
}
.post-cover.is-default svg { position: absolute; width: 130%; aspect-ratio: 1; }
.post-cover.crop-0 svg { top: 50%; left: 5%; transform: translateY(-50%); }
.post-cover.crop-1 svg { top: -95%; left: 50%; transform: translateX(-50%); }
.post-cover.crop-2 svg { bottom: -95%; left: 50%; transform: translateX(-50%); }

.post-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-lg);
}
.post-card h3 { font-size: 20px; line-height: 1.55; }
.post-summary {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-secondary);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.post-card .post-meta { margin-top: auto; padding-top: var(--space-sm); }

/* أحدث مقال: بطاقة عريضة */
.post-feature {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  margin-bottom: var(--space-lg);
}
.post-feature .post-cover { aspect-ratio: auto; min-height: 340px; }
.post-feature .post-cover img { position: absolute; inset: 0; }
.post-feature .post-cover.is-default svg { width: 80%; }
.post-feature-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-xl);
}
.post-feature h3 { font-size: clamp(24px, 2.7vw, 32px); line-height: 1.45; overflow-wrap: anywhere; min-width: 0; }
.post-feature .post-summary { font-size: 16px; -webkit-line-clamp: 4; }
.post-more { margin: var(--space-xs) 0 0; font-size: 15px; font-weight: 700; color: var(--blue); }

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3xs) var(--space-xs);
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}
.post-meta > span + span::before {
  content: "·";
  margin-inline-end: var(--space-xs);
  color: var(--text-faint);
}
.post-kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs);
  margin: 0;
  font-size: 13px;
}
.post-cat { font-weight: 700; color: var(--blue); }
.post-pin {
  padding: var(--space-3xs) var(--space-xs);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-btn);
  font-size: 12px;
  color: var(--text-secondary);
}
.page-hero .post-meta { color: var(--on-dark); margin-bottom: var(--space-sm); }

/* ── رأس المدونة ───────────────────────────────────────── */

.blog-head h1 { letter-spacing: 0; }

/* ── التصنيفات والترقيم ────────────────────────────────── */

.chips, .pager, .tags { display: flex; flex-wrap: wrap; gap: var(--space-xs); margin-bottom: var(--space-lg); }
.chip {
  padding: var(--space-2xs) var(--space-md);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-btn);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color var(--dur-short) var(--ease-out);
}
.chip.is-active { border-color: var(--blue); color: var(--blue); font-weight: 700; }
@media (hover: hover) { .chip:hover { border-color: var(--blue); } }
.chip:active { background: var(--bg); }
.pager { margin: var(--space-xl) 0 0; }
.tags { margin: var(--space-xl) 0 0; }

/* ── صفحة المقال ───────────────────────────────────────── */

/* عمود واحد للقراءة: العنوان والنص وما بعده يبدأ من نفس الحافة، والغلاف وحده أعرض */
.post {
  --post-col: 680px;
  --post-wide: 960px;
  --cover-rise: clamp(72px, 15vw, 190px);
}
.post .page-hero-inner { max-width: calc(var(--post-col) + 2 * var(--gutter)); }
.post-hero-cover, .post-body, .attachments, .share, .tags, .related, .post-back, .course-facts, .form-hint,
.post > .section .hero-cta, .post-main > .wrap > .callout { max-width: var(--post-col); margin-inline: auto; }

.post-head h1 { font-size: clamp(30px, 4.2vw, 44px); line-height: 1.42; letter-spacing: 0; text-wrap: balance; }

.post-crumb {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
  font-size: 14px;
  color: var(--on-dark-soft);
}
.post-crumb a { color: inherit; text-decoration: none; white-space: nowrap; transition: color var(--dur-short) var(--ease-out); }
.post-crumb a:hover { color: var(--white); }

.post-byline {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}
.post-byline-mark {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-btn);
}
.post-byline-mark svg { width: 28px; height: 28px; }
.post-byline-name {
  margin: 0;
  font-family: var(--font-en);
  font-size: 15px;
  font-weight: 700;
  text-align: end;
  color: var(--white);
}
.post-head .post-meta { margin: 0; color: var(--on-dark-soft); }
.post-head .post-meta > span + span::before { color: var(--glass-line-strong); }

/* الغلاف يتراكب على حافة الهيدر الداكن: أعرض من النص وهو أول ما تراه العين */
.post-head.has-cover .page-hero-inner { padding-block-end: calc(var(--cover-rise) + var(--space-xl)); }
.post-main.has-cover { padding-block-start: 0; }
.post-hero-cover { margin-bottom: var(--space-xl); border-radius: var(--radius-card); overflow: hidden; background: var(--ink); }
.post-hero-cover img { display: block; width: 100%; height: auto; }
.post-main.has-cover .post-hero-cover {
  position: relative;
  z-index: 1;
  max-width: var(--post-wide);
  margin-block: calc(var(--cover-rise) * -1) var(--space-2xl);
  box-shadow: 0 0 0 1px var(--glass-line), var(--shadow-card);
}
.post-main.has-cover .post-hero-cover img { max-height: 560px; object-fit: cover; }

/* ── نص المقال ─────────────────────────────────────────── */

.post-body p, .post-body li { font-size: 18px; line-height: 1.95; color: var(--ink); }
.post-body p { margin-bottom: var(--space-lg); }
/* الفقرة الأولى مدخل المقال */
.post-body > p:first-of-type:not(.link-card) { font-size: 21px; line-height: 1.85; font-weight: 500; }
.post-body h2 {
  margin: var(--space-2xl) 0 var(--space-sm);
  font-size: clamp(23px, 2.6vw, 28px);
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.post-body h3 { margin: var(--space-xl) 0 var(--space-xs); font-size: 21px; font-weight: 700; line-height: 1.55; }
.post-body h4 { margin: var(--space-lg) 0 var(--space-2xs); font-size: 18px; font-weight: 700; }
.post-body > :first-child { margin-top: 0; }
.post-body a {
  overflow-wrap: anywhere;
  text-decoration-color: color-mix(in srgb, var(--blue) 40%, transparent);
  text-decoration-thickness: 1px;
  transition: text-decoration-color var(--dur-short) var(--ease-out);
}
.post-body a:hover { text-decoration-color: var(--blue); }

/* القوائم: علامة مربعة صغيرة بلون الهوية، وأرقام بخط الأرقام */
.post-body ul, .post-body ol { margin: 0 0 var(--space-lg); padding: 0; list-style: none; }
.post-body ol { counter-reset: post-ol; }
.post-body li { position: relative; margin-bottom: var(--space-sm); padding-inline-start: 1.6em; }
.post-body ul > li::before {
  content: "";
  position: absolute;
  inset-inline-start: 0.2em;
  top: 0.8em;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--blue);
}
.post-body ol > li { counter-increment: post-ol; }
.post-body ol > li::before {
  content: counter(post-ol);
  position: absolute;
  inset-inline-start: 0;
  font-family: var(--font-en);
  font-weight: 700;
  color: var(--blue);
}

/* رابط في سطر لوحده: بطاقة واضحة للضغط */
.post-body .link-card { margin: var(--space-lg) 0; }
.post-body .link-card a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--ink);
  border-radius: var(--radius-tile);
  text-align: left;
  text-decoration: none;
  transition: background-color var(--dur-short) var(--ease-out);
}
@media (hover: hover) { .post-body .link-card a:hover { background: var(--navy); } }
.post-body .link-card a:active { background: var(--navy); }
.link-card-text { display: grid; gap: var(--space-3xs); min-width: 0; }
.link-card-host { font-family: var(--font-en); font-size: 17px; font-weight: 700; line-height: 1.5; color: var(--white); }
.link-card-path { font-family: var(--font-mono); font-size: 13px; line-height: 1.6; color: var(--on-dark-soft); overflow-wrap: anywhere; }
.link-card-arrow { width: 22px; height: 22px; fill: none; stroke: var(--teal-on-dark); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.post-body img { display: block; max-width: 100%; height: auto; margin-inline: auto; border-radius: var(--radius-tile); }
.post-body figure { margin: var(--space-xl) 0; }
.post-body > figure:first-child { margin-top: 0; }
.post-body figcaption { margin-top: var(--space-sm); font-size: 14px; line-height: 1.7; color: var(--text-secondary); }
.post-body blockquote {
  margin: var(--space-xl) 0;
  padding-block: var(--space-md);
  border-block: 1px solid var(--line);
}
.post-body blockquote p { margin: 0; font-size: 21px; line-height: 1.8; font-weight: 500; }
/* الفاصل: خط الهوية القصير، والمسافة حوله هي الفاصل الحقيقي */
.post-body hr {
  width: 48px;
  height: 3px;
  margin: var(--space-2xl) auto;
  border: 0;
  border-radius: var(--radius-btn);
  background: var(--grad-accent);
}
/* كتل الكود مونو فتصير LTR — تُرجَع لليسار صراحةً ويُحفظ التمرير الأفقي داخلها */
.post-body pre {
  margin: var(--space-lg) 0;
  padding: var(--space-md);
  overflow-x: auto;
  direction: ltr;
  text-align: left;
  background: var(--ink);
  color: var(--white);
  border-radius: var(--radius-tile);
  font-size: 14px;
  line-height: 1.7;
}
.post-body code { font-family: var(--font-mono); font-size: 0.92em; }
.post-body p code, .post-body li code { padding: 0 var(--space-2xs); background: var(--bg); border-radius: var(--radius-btn); }
.post-body pre code { padding: 0; background: none; }
/* زر النسخ فوق الكتلة، والبرومت العربي يقرأ من اليمين ويلتف بدل التمرير */
.code-block { position: relative; margin: var(--space-lg) 0; }
.code-block pre { margin: 0; padding-top: 68px; }
.code-copy {
  position: absolute;
  top: var(--space-xs);
  inset-inline-end: var(--space-xs);
  min-height: 44px;
  padding: 0 var(--space-md);
  border: 0;
  border-radius: var(--radius-btn);
  background: var(--blue);
  color: var(--white);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.code-copy:active { opacity: 0.85; }
.post-body pre[dir="rtl"] { direction: rtl; text-align: right; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font-ar); font-size: 15px; line-height: 1.9; }
.post-body pre[dir="rtl"] code { font-family: inherit; font-size: inherit; }

.video-embed { position: relative; aspect-ratio: 16 / 9; margin: var(--space-xl) 0; border-radius: var(--radius-tile); overflow: hidden; background: var(--ink); }
.video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ── ما بعد النص ───────────────────────────────────────── */

.attachments { margin-top: var(--space-xl); }
.attachments h2 { margin-bottom: var(--space-sm); font-size: 18px; }
.attachments ul { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.attachments li { border-bottom: 1px solid var(--line); }
.attachments a { display: block; padding-block: var(--space-sm); color: var(--blue); font-weight: 500; overflow-wrap: anywhere; }

.related { margin-top: var(--space-xl); }
.related h2 { margin-bottom: var(--space-sm); font-size: 18px; }

/* المشاركة: سطر هادئ بين خطين، مو قسم بعنوان كبير */
.share {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm) var(--space-lg);
  margin-top: var(--space-2xl);
  padding-block: var(--space-md);
  border-block: 1px solid var(--line);
}
.share h2 { margin: 0; font-size: 15px; font-weight: 500; color: var(--text-secondary); }
.share-links { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
button.chip { font: inherit; font-size: 14px; cursor: pointer; }

.post-back { margin-top: var(--space-md); font-size: 15px; color: var(--text-secondary); }
.post-back a { color: var(--blue); }

.more-posts h2 { margin-bottom: var(--space-lg); font-size: clamp(23px, 2.6vw, 28px); font-weight: 700; }

/* ── الدورة ────────────────────────────────────────────── */

.course-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-md);
  max-width: 860px;
  margin: 0 auto var(--space-xl);
  padding: var(--space-md);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-card);
}
.course-facts dt { font-size: 12px; color: var(--text-secondary); }
.course-facts dd { margin: 0; font-size: 16px; font-weight: 700; }
.outline { display: grid; gap: var(--space-xs); }
.form-hint { max-width: 72ch; margin: var(--space-lg) auto; font-size: 14px; color: var(--text-secondary); }
.post .hero-cta { margin-top: var(--space-lg); }

/* تحت هذا العرض ما يكفي العمود لصورة الغلاف بدون قصّ نصها: البطاقة العريضة تصير فوق بعض */
@media (max-width: 1100px) {
  .post-feature { grid-template-columns: minmax(0, 1fr); }
  .post-feature .post-cover { min-height: 0; aspect-ratio: 1200 / 630; }
  .post-feature-body { padding: var(--space-lg); }
}

@media (max-width: 640px) {
  .post-card-body { padding: var(--space-md); }
  .post-body p, .post-body li { font-size: 17px; line-height: 1.9; }
  .post-body > p:first-of-type:not(.link-card) { font-size: 19px; }
  .post-body blockquote p { font-size: 19px; }
  .post-body h3 { font-size: 19px; }
  .post-body .link-card a { padding: var(--space-md); }
  .post-main.has-cover .post-hero-cover { margin-block-end: var(--space-xl); border-radius: var(--radius-tile); }
}
