/* =========================================================
   متغیرهای برند
   ========================================================= */
:root {
  --brand: #198754;
  --brand-dark: #146c43;
  --brand-light: #e8f5e9;
  --text-main: #222;
  --text-muted: #6c757d;
  --radius-sm: 8px;
  --radius-md: 14px;
  --shadow-soft: 0 4px 16px rgba(0, 0, 0, .06);
  --shadow-hover: 0 14px 28px rgba(0, 0, 0, .12);
  --transition: .3s ease;
}

/* =========================================================
   دسترس‌پذیری عمومی
   ========================================================= */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* =========================================================
   لایه‌بندی کلی
   ========================================================= */
.single-wrapper { display: flex; flex-wrap: wrap; gap: 2rem; }
.single-main { flex: 1 1 66%; border-radius: var(--radius-md); }
.single-sidebar { flex: 1 1 30%; }
.single-sidebar .sticky { position: sticky; top: 100px; }

/* =========================================================
   Breadcrumb
   ========================================================= */
.breadcrumb {
  font-size: .9rem;
  color: var(--text-muted);
  display: flex;
  gap: .35rem;
  flex-wrap: nowrap;
  margin-bottom: 1rem;
}
.breadcrumb a { text-decoration: none; color: var(--brand); font-weight: 500; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .active { color: var(--text-muted); font-size: .85rem; }

/* =========================================================
   عنوان و متا
   ========================================================= */
.single-post-title {
  font-weight: 700;
  margin-bottom: 1rem;
  line-height: 1.5;
  font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.25rem);
}
.single-post-meta {
  font-size: .9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: center;
}
.single-post-meta .reading-time { color: var(--brand); font-weight: 600; }

/* =========================================================
   تصویر شاخص
   ========================================================= */
.single-thumbnail { display: flex; justify-content: center; margin-bottom: 2rem; }
.single-thumbnail img {
  width: 100%;
  max-width: 850px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  transition: transform var(--transition), box-shadow var(--transition);
}
.single-thumbnail img:hover {
  transform: scale(1.015);
  box-shadow: var(--shadow-hover);
}

/* =========================================================
   محتوای مقاله
   ========================================================= */
.single-content {
  font-size: 1.05rem;
  line-height: 2.1;
  color: var(--text-main);
  text-align: justify;
}
.single-content p { margin-bottom: 1.4rem; }
.single-content a { text-decoration: underline; transition: color var(--transition); }
.single-content a:hover { color: var(--brand-dark); text-decoration: none; }
.single-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.5rem auto;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-soft);
  transition: transform var(--transition), box-shadow var(--transition);
}
.single-content img:hover { transform: scale(1.015); box-shadow: var(--shadow-hover); }
.single-content h2,
.single-content h3,
.single-content h4 {
  color: var(--brand);
  margin: 2rem 0 1rem;
  font-weight: 600;
  line-height: 1.6;
  scroll-margin-top: 90px; /* برای لینک‌های فهرست مطالب */
}
.single-content table { width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; }
.single-content table th,
.single-content table td { border: 1px solid #e2e2e2; padding: .6rem .8rem; }
.single-content table thead { background: var(--brand-light); }

/* =========================================================
   فهرست مطالب (TOC)
   ========================================================= */
.toc-widget .toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-inline-start: 2px solid var(--brand-light);
}
.toc-widget .toc-list li { margin-bottom: .5rem; padding-inline-start: .75rem; }
.toc-widget .toc-list a {
  text-decoration: none;
  color: var(--text-main);
  font-size: .9rem;
  transition: color var(--transition);
}
.toc-widget .toc-list a:hover { color: var(--brand); }
.toc-widget .toc-level-3 { padding-inline-start: 1.5rem; font-size: .85rem; }

/* =========================================================
   اشتراک‌گذاری
   ========================================================= */
.share-box {
  margin-top: 2rem;
  border-top: 1px solid #eee;
  padding-top: 1.2rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.share-box span { font-weight: 700; color: var(--brand); margin-inline-end: 10px; }
.share-box a,
.share-box button {
  font-size: .9rem;
  padding: .5rem 1rem;
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 6px;
  color: var(--text-main);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.share-box a:hover,
.share-box button:hover {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* =========================================================
   باکس نویسنده
   ========================================================= */
.author-box {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
  padding: 1.25rem;
  background: var(--brand-light);
  border-radius: var(--radius-md);
}
.author-avatar { border-radius: 50%; flex-shrink: 0; }
.author-info p { color: var(--text-muted); font-size: .9rem; }

/* =========================================================
   ناوبری مطلب قبلی/بعدی
   ========================================================= */
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}
.post-nav > div { flex: 1 1 200px; }
.post-nav a {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  padding: 1rem;
  border: 1px solid #eee;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  height: 100%;
}
.post-nav a:hover { border-color: var(--brand); box-shadow: var(--shadow-soft); }
.post-nav-label { font-size: .75rem; color: var(--text-muted); }
.post-nav-title { font-weight: 600; color: var(--text-main); }
.post-nav-next { text-align: end; }
.post-nav-next a { align-items: flex-end; }

/* =========================================================
   مطالب مرتبط
   ========================================================= */
.related-posts { margin-top: 4rem; padding-top: 2rem; border-top: 1px solid #eee; }
.related-posts h2 { color: var(--brand); font-size: 1.3rem; }

.related-card {
  display: flex;
  flex-direction: column;
  background-color: #fff;
  border-radius: var(--radius-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}
.related-card:hover,
.related-card:focus-visible {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover);
}
.related-card-img-wrapper { width: 100%; height: 200px; overflow: hidden; }
.related-card-img-wrapper img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform var(--transition);
}
.related-card:hover .related-card-img-wrapper img { transform: scale(1.05); }
.related-card-img-placeholder {
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-light); font-size: 2rem;
}
.related-card-body { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
.related-card-title { font-size: 1.05rem; color: var(--text-main); }

/* =========================================================
   سایدبار
   ========================================================= */
.sidebar-widget {
  background: #fff;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}
.sidebar-widget h2 { margin-bottom: 1rem; color: var(--brand); font-size: 1.05rem; }
.sidebar-widget ul { list-style: none; padding: 0; margin: 0; }
.sidebar-widget li { margin-bottom: .6rem; }
.sidebar-widget a { text-decoration: none; color: var(--text-main); transition: color var(--transition); }
.sidebar-widget a:hover { color: var(--brand); }

/* =========================================================
   نظرات
   ========================================================= */
.comments-area { padding-top: 2rem; }
.comments-area h3 { color: var(--brand); margin-bottom: 1.5rem; }
.comment { margin-bottom: 1.5rem; }
.comment-author { font-weight: 700; margin-bottom: .3rem; }
.comment-content { background: #f4f4f4; padding: 1rem; border-radius: var(--radius-sm); }

/* =========================================================
   دکمه بازگشت به بالا
   ========================================================= */
.back-to-top {
  position: fixed;
  inset-inline-end: 20px;
  bottom: 20px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--brand);
  color: #fff;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-hover);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
  z-index: 999;
}
.back-to-top.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { background: var(--brand-dark); }

/* =========================================================
   ریسپانسیو
   ========================================================= */
@media (max-width: 768px) {
  .single-wrapper { flex-direction: column-reverse; }
  .single-content { font-size: 1rem; line-height: 1.95; }
  .single-thumbnail img { max-width: 100%; border-radius: var(--radius-sm); aspect-ratio: auto; }
  .post-nav { flex-direction: column; }
  .post-nav-next { text-align: start; }
  .post-nav-next a { align-items: flex-start; }
  .author-box { flex-direction: column; text-align: center; }
}
