/*
 * blog/blog.css
 * -----------------------------------------
 * استایل اختصاصی بخش Blog، ساخته‌شده در v4.2 برای هماهنگی ظاهری
 * blog/index.php و blog/post.php با Frontend اصلی سایت.
 *
 * این فایل به‌جای تعریف رنگ/فاصله/شعاع گوشه‌ی جدید، فقط از همان
 * متغیرهای CSS تعریف‌شده در css/style.css استفاده می‌کند
 * (مثل var(--bg-surface), var(--border-color), var(--radius-md),
 * var(--text-heading), var(--sky-500) و ...)، تا هم در حالت روشن
 * و هم در حالت تیره (html[data-theme="dark"]) به‌درستی هماهنگ بماند.
 *
 * کلاس‌های عمومی سایت (container, page-hero, eyebrow, section-head,
 * empty-state, btn, btn-primary/outline/ghost-light) از css/style.css
 * بدون تغییر استفاده می‌شوند؛ این فایل فقط اجزای مخصوص Blog را
 * اضافه می‌کند: لیست کارت‌های مقاله و نمای تک مقاله.
 */

/* ---------- v4.20: Search form ---------- */
.blog-search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.blog-search-input {
  flex: 1;
  min-width: 220px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-heading);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 16px;
}

.blog-search-input:focus {
  outline: none;
  border-color: var(--sky-500);
}

.blog-search-submit {
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: var(--sky-500);
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 22px;
  cursor: pointer;
}

.blog-search-submit:hover {
  opacity: 0.92;
}

/* ---------- v4.16: Category filter bar + badges ---------- */
.blog-filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 28px;
  padding: 14px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.blog-filter-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.blog-filter-label strong {
  color: var(--text-heading);
}

.blog-filter-clear {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-text);
  margin-inline-start: auto;
}

.blog-filter-clear:hover {
  text-decoration: underline;
}

/* v4.20/v4.22: لینک‌های «پاک کردن/حذف» یک فیلتر مشخص (جستجو، دسته یا
   برچسب) — هرکدام فقط همان فیلتر را پاک می‌کند، نه بقیه را؛ به همین
   دلیل استایل ساده‌تر و کم‌رنگ‌تری از .blog-filter-clear دارند (که هر
   سه فیلتر را با هم پاک می‌کند). */
.blog-filter-clear-search,
.blog-filter-clear-category,
.blog-filter-clear-tag {
  font-size: 13px;
  color: var(--accent-text);
}

.blog-filter-clear-search:hover,
.blog-filter-clear-category:hover,
.blog-filter-clear-tag:hover {
  text-decoration: underline;
}

.post-card-category,
.post-article-category {
  display: inline-flex;
  align-items: center;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--sky-500);
  background: rgba(14, 165, 233, 0.1);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  margin-inline-start: 8px;
}

.post-card-category:hover,
.post-article-category:hover {
  text-decoration: underline;
}

/* ---------- v4.18/v4.19: Tag chips (link to blog/index.php?tag=slug) ---------- */
.post-card-tags,
.post-article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
}

.post-tag-chip {
  display: inline-flex;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  text-decoration: none;
}

.post-tag-chip:hover {
  color: var(--sky-500);
  border-color: var(--sky-500);
  text-decoration: none;
}

/* ---------- Post list (blog/index.php) ---------- */
.post-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.post-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  transition:
    transform 0.35s var(--ease),
    box-shadow 0.35s var(--ease),
    border-color 0.35s var(--ease);
}

.post-card:hover {
  border-color: var(--sky-500);
  transform: translateY(-3px);
  box-shadow: 0 10px 20px -12px rgba(11, 22, 38, 0.14);
}

.post-card-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.post-card h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-heading);
  margin-bottom: 12px;
  line-height: 1.6;
}

.post-card-excerpt {
  font-size: 14.5px;
  color: var(--text-copy);
  line-height: 1.9;
  margin-bottom: 20px;
  flex-grow: 1;
}

.post-card .btn-arrow {
  align-self: flex-start;
}

@media (max-width: 900px) {
  .post-list {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Single post (blog/post.php) — v5.8 redesign
   --------------------------------------------------------------------------
   ساختار صفحه: .post-article شامل چهار بخش مجزاست:
     .post-header           → دسته، تاریخ، عنوان، خلاصه، برچسب‌ها
     .post-hero             → تصویر شاخص (در صورت وجود)
     .post-article-content  → بدنه‌ی مقاله (خروجی Sanitizer)
     .post-article-footer   → برچسب‌ها + بازگشت به فهرست مقالات

   همه‌ی رنگ‌ها/شعاع‌ها/زمان‌بندی‌ها از همان متغیرهای css/style.css
   می‌آیند، بنابراین Dark Mode بدون قانون اختصاصی اضافه به‌درستی کار
   می‌کند. عرض ستون متن (--post-measure) عمداً محدود نگه داشته شده تا
   خطوط بلند و خسته‌کننده نشوند.
   ========================================================================== */

:root {
  --post-measure: 760px;
}

/* فاصله‌ی بالای صفحه: Header سایت position: fixed است، بنابراین اولین
   بخش صفحه باید به‌اندازه‌ی کافی از بالا فاصله بگیرد تا زیر آن نرود
   (همان کاری که .hero در سایر صفحات با padding بالا انجام می‌دهد). */
.post-page-section {
  padding: 140px 0 0;
}

.post-article {
  max-width: var(--post-measure);
  margin: 0 auto 72px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 48px 44px;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* ---------- Article header ---------- */
.post-header {
  margin-bottom: 32px;
}

.post-article-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* دسته و تاریخ اکنون در یک ردیف Flex هستند؛ فاصله با gap کنترل می‌شود،
   بنابراین margin قدیمی chip اینجا خنثی می‌شود تا ترازبندی به‌هم نریزد. */
.post-article-meta .post-article-category {
  margin-inline-start: 0;
}

.post-article-date {
  display: inline-flex;
  align-items: center;
}

.post-article-title {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-heading);
  line-height: 1.55;
  letter-spacing: -0.01em;
  margin: 0 0 18px;
}

.post-article-excerpt {
  font-size: 16.5px;
  color: var(--text-secondary);
  border-inline-start: 3px solid var(--sky-500);
  padding-inline-start: 16px;
  margin: 0 0 20px;
  line-height: 2;
}

.post-header-tags {
  margin-bottom: 0;
}

/* ---------- Featured image ---------- */
.post-hero {
  margin: 0 0 36px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-elevated);
}

.post-hero-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

/* ---------- Article body ---------- */
.post-article-content {
  font-size: 16px;
  color: var(--text-body);
  line-height: 2.1;
}

.post-article-content > *:first-child {
  margin-top: 0;
}

.post-article-content > *:last-child {
  margin-bottom: 0;
}

.post-article-content p {
  margin: 0 0 1.35em;
}

.post-article-content h1,
.post-article-content h2,
.post-article-content h3,
.post-article-content h4,
.post-article-content h5,
.post-article-content h6 {
  color: var(--text-heading);
  font-weight: 800;
  line-height: 1.6;
  margin: 2em 0 0.75em;
}

.post-article-content h1 {
  font-size: 25px;
}

.post-article-content h2 {
  font-size: 22px;
}

.post-article-content h3 {
  font-size: 19px;
}

.post-article-content h4 {
  font-size: 17px;
}

.post-article-content h5,
.post-article-content h6 {
  font-size: 16px;
  color: var(--text-copy);
}

.post-article-content ul,
.post-article-content ol {
  margin: 0 0 1.35em;
  padding-inline-start: 1.6em;
}

.post-article-content li {
  margin-bottom: 0.5em;
}

.post-article-content li:last-child {
  margin-bottom: 0;
}

/* لیست تودرتو نباید فاصله‌ی پایین اضافه بگیرد */
.post-article-content li > ul,
.post-article-content li > ol {
  margin: 0.5em 0 0;
}

.post-article-content a {
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.post-article-content a:hover {
  color: var(--sky-500);
}

.post-article-content strong,
.post-article-content b {
  font-weight: 800;
  color: var(--text-heading);
}

.post-article-content u {
  text-underline-offset: 3px;
}

.post-article-content blockquote {
  margin: 1.8em 0;
  padding: 18px 22px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-inline-start: 3px solid var(--sky-500);
  border-radius: var(--radius-sm);
  color: var(--text-copy);
  font-size: 15.5px;
  line-height: 2;
}

.post-article-content blockquote > *:first-child {
  margin-top: 0;
}

.post-article-content blockquote > *:last-child {
  margin-bottom: 0;
}

/* ---------- Article footer ---------- */
.post-article-footer {
  margin-top: 40px;
  padding-top: 26px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.post-footer-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.post-footer-tags-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

.post-footer-tags .post-article-tags {
  margin-bottom: 0;
}

.post-footer-back {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-text);
  margin-inline-start: auto;
}

.post-footer-back:hover {
  text-decoration: underline;
}

/* ---------- Comments (v5.10 نمایش + v5.11 فرم ارسال) ---------- */
.post-comments {
  max-width: var(--post-measure);
  margin: 0 auto 72px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 40px 44px;
}

.post-comments-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.post-comments-title {
  font-size: 19px;
  font-weight: 800;
  color: var(--text-heading);
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.post-comments-open-btn {
  padding: 10px 22px;
  font-size: 14px;
}

.post-comments-count {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}

.post-comments-empty {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.9;
}

.post-comments-list {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.post-comments-list:not(:empty) {
  margin-top: 4px;
}

.post-comment-item {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border-color);
}

.post-comment-item:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.post-comment-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.post-comment-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-heading);
}

.post-comment-date {
  font-size: 12px;
  color: var(--text-secondary);
}

.post-comment-content {
  font-size: 14.5px;
  line-height: 1.9;
  color: var(--text-body);
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* ---------- Admin reply under a comment (v5.3) ----------
   کادر بازخورد مدیر که در admin/mailbox.php ثبت می‌شود و اینجا
   تورفته (indent) زیر همان نظر نمایش داده می‌شود. */
.post-comment-reply {
  margin-top: 12px;
  margin-inline-start: 18px;
  padding: 12px 14px;
  border-inline-start: 3px solid var(--primary-color, #1d4ed8);
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.06);
}

.post-comment-reply-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.post-comment-reply-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--primary-color, #1d4ed8);
}

.post-comment-reply-date {
  font-size: 12px;
  color: var(--text-secondary);
}

.post-comment-reply-content {
  margin: 0;
  font-size: 14px;
  line-height: 1.9;
  color: var(--text-body);
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* ---------- Comment modal (v5.11) ----------
   ساختار و رنگ‌ها از همان الگوی .contact-form (css/style.css) و
   متغیرهای طراحی مشترک پروژه پیروی می‌کنند تا مودال با بقیه‌ی سایت
   یک‌دست باشد. */
.comment-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 22, 38, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.comment-modal-overlay[hidden] {
  display: none;
}

.comment-modal {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 32px;
  box-shadow: 0 24px 48px -20px rgba(11, 22, 38, 0.4);
}

.comment-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.comment-modal-header h3 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-heading);
}

.comment-modal-close {
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
}

.comment-modal-close:hover {
  color: var(--text-heading);
}

.comment-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.comment-form-field {
  margin-bottom: 18px;
}

.comment-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-copy);
  margin-bottom: 8px;
}

.comment-required {
  color: #c0392b;
}

.comment-optional {
  font-weight: 400;
  color: var(--text-muted);
}

.comment-form input,
.comment-form textarea {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  color: var(--text-body);
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  transition: border-color var(--dur-fast) var(--ease);
}

.comment-form input:focus,
.comment-form textarea:focus {
  outline: 2px solid var(--sky-400);
  outline-offset: 2px;
  border-color: var(--sky-400);
}

.comment-form textarea {
  resize: vertical;
  min-height: 110px;
}

.comment-field-error {
  display: block;
  font-size: 12.5px;
  color: #c0392b;
  margin-top: 6px;
  min-height: 1px;
}

.comment-form-general-error {
  font-size: 13.5px;
  color: #c0392b;
  background: rgba(192, 57, 43, 0.08);
  border: 1px solid rgba(192, 57, 43, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 18px;
}

.comment-form-general-error[hidden] {
  display: none;
}

/* reCAPTCHA: ویجت گوگل عرض ثابت ۳۰۴px دارد و همیشه LTR رندر می‌شود
   (خودِ گوگل این کار را می‌کند)؛ اینجا فقط فاصله‌گذاری و راست‌چین بودن
   کادر آن در فرم RTL را تنظیم می‌کنیم. */
.comment-form-recaptcha {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-bottom: 18px;
}

.comment-form-recaptcha .g-recaptcha {
  direction: ltr;
}

@media (max-width: 360px) {
  .comment-form-recaptcha {
    align-items: center;
  }
}

.comment-form-actions {
  display: flex;
  justify-content: flex-end;
}

/* Honeypot: کاملاً از دید و دسترسی کاربر واقعی مخفی است؛ فقط
   ربات‌های ساده که فرم را به‌صورت خودکار پر می‌کنند به آن دسترسی
   دارند. display:none هم کافی بود، اما این روش برای Screen Reader
   و Autofill مرورگر مقاوم‌تر است. */
.comment-form-honeypot {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 640px) {
  .comment-form-row {
    grid-template-columns: 1fr;
  }

  .comment-modal {
    padding: 24px 20px;
  }
}

/* ---------- Reserved slot: Related posts (فعلاً پیاده‌سازی نشده) ---------- */
.post-related {
  max-width: var(--post-measure);
  margin: 0 auto 72px;
}

/* ---------- Error / not found ---------- */
.post-not-found {
  max-width: 640px;
  margin: 0 auto 72px;
  text-align: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 64px 40px;
}

.post-not-found h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-heading);
  margin-bottom: 14px;
}

.post-not-found p {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.9;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .post-article {
    padding: 40px 32px;
  }

  .post-article-title {
    font-size: 27px;
  }
}

@media (max-width: 640px) {
  .post-page-section {
    padding-top: 110px;
  }

  .post-article {
    padding: 28px 20px;
    margin-bottom: 48px;
  }

  .post-article-title {
    font-size: 22px;
    line-height: 1.6;
  }

  .post-article-excerpt {
    font-size: 15px;
    padding-inline-start: 13px;
  }

  .post-hero {
    margin-bottom: 26px;
  }

  .post-article-content {
    font-size: 15.5px;
    line-height: 2;
  }

  .post-article-content h1 {
    font-size: 21px;
  }

  .post-article-content h2 {
    font-size: 19px;
  }

  .post-article-content h3 {
    font-size: 17.5px;
  }

  .post-article-content blockquote {
    padding: 14px 16px;
  }

  .post-article-footer {
    margin-top: 32px;
    align-items: flex-start;
  }

  .post-footer-back {
    margin-inline-start: 0;
  }

  .post-not-found {
    padding: 44px 24px;
  }

  .post-comments {
    padding: 28px 20px;
  }

  .post-comments-header {
    align-items: flex-start;
  }

  .post-comments-open-btn {
    width: 100%;
    justify-content: center;
  }
}

/* ---------- v4.21: Pagination عمومی Blog ---------- */
.blog-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 36px;
}

.blog-page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-body);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

a.blog-page-link:hover {
  border-color: var(--sky-500);
  color: var(--text-heading);
}

.blog-page-current {
  color: #fff;
  background: var(--sky-500);
  border-color: var(--sky-500);
}

.blog-page-disabled {
  color: var(--text-muted);
  cursor: default;
  opacity: 0.6;
}

.blog-page-nav {
  padding: 0 20px;
}

.blog-page-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 40px;
  color: var(--text-secondary);
  font-weight: 700;
}

@media (max-width: 640px) {
  .blog-page-link {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    font-size: 13px;
  }

  .blog-page-nav {
    padding: 0 14px;
  }
}
