/* --- 1. Base Article Styles --- */
body {
  font-family: var(--font-body);
  line-height: 1.8;
  color: var(--text-color);
  direction: rtl;
  background-color: #fff;
  overflow-x: hidden;
  text-align: justify;
}

/* --- */

article.single-post {
  margin-bottom: 5rem;
  padding-bottom: 2rem;
}

.post-content {
  line-height: 2;
  color: #333;
  text-align: justify;
  font-size: 1.15rem;
}

.post-content h2,
.post-content h3 {
  margin-top: 2.5rem;
  margin-bottom: 1.2rem;
  color: var(--co3);
  border-right: 5px solid var(--co1);
  padding-right: 15px;
}

.post-content p {
  margin-bottom: 1.5rem;
}

.post-content blockquote {
  background-color: #f9f9f9;
  border-right: 10px solid var(--co3);
  padding: 20px;
  margin: 2rem 0;
  font-style: italic;
  font-size: 1.2rem;
  color: #555;
}

/* --- 2. Images & Media --- */
.single-post img,
.shadow-effect {
  display: block;
  margin: 0 auto !important;
  max-width: 100% !important;
  height: auto !important;
  transition: transform 0.4s ease;
  cursor: zoom-in;
}

.single-post img:hover {
  transform: scale(1.02);
}

/* --- 3. Table of Contents (TOC) --- */
.table-of-contents {
  background-color: var(--co2);
  border-right: 4px solid var(--co3);
  padding: 12px 15px;
  margin: 1.5rem 0;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgb(0 0 0 / 5%);
  max-width: 400px;
  display: inline-block;
}

.table-of-contents ul {
  list-style: none;
  padding-right: 10px;
}

.table-of-contents li {
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.table-of-contents a {
  position: relative;
  display: inline-block;
  padding: 5px 0 3px;
  text-decoration: none;
  color: var(--co3);
  transition: all 0.3s ease;
}

.table-of-contents a:hover {
  color: var(--co1);
  padding-right: 5px;
}

.table-of-contents a::after {
  content: "";
  position: absolute;
  width: 0;
  height: 2px;
  bottom: 0;
  right: 0;
  background-color: var(--co1);
  transition: width 0.3s ease;
}

.table-of-contents a:hover::after {
  width: 100%;
}

/* Global/JS-Generated TOC */
.global-toc {
  background-color: #f0f0f0;
  max-width: 100% !important;
  margin-bottom: 40px;
}

#toc-list li {
  padding: 8px 0;
  border-bottom: 1px dashed #ddd;
}

#toc-list li:last-child {
  border-bottom: none;
}

/* --- 4. Share Section & Buttons --- */
.share-container {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px 0;
  border-top: 1px dashed #eee;
}

.share-buttons {
  display: flex;
  gap: 12px;
  align-items: center;
}

.share-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: var(--co2);
  color: var(--co3);
  cursor: pointer;
  transition: all 0.3s ease;
  padding: 0;
}

.share-btn:hover {
  transform: scale(1.1);
}

.share-btn img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.share-btn svg {
  width: 22px;
  height: 22px;
  fill: white;
}

.share-btn span {
  font-family: font-body, sans-serif;
  font-weight: bold;
}

/* Color Modifiers */
.whatsapp-share {
  background-color: #25d366 !important;
  color: white !important;
}

.telegram-share {
  background-color: #08c !important;
  color: white !important;
}

.copy-link {
  background-color: #e0e0e0 !important;
  color: #777 !important;
}

/* --- 5. Utilities & UI Elements --- */
.reading-time {
  background-color: var(--co2);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: bold;
}

.progress-container {
  position: fixed;
  top: 0;
  z-index: 1000;
  width: 100%;
  height: 5px;
  background: #ccc;
}

.progress-bar {
  height: 5px;
  background: var(--co3);
  width: 0%;
  transition: width 0.1s ease;
}

.back-to-toc-btn {
  display: inline-block;
  padding: 8px 15px;
  background-color: var(--co2);
  color: var(--co3);
  border: 1px solid var(--co3);
  border-radius: 5px;
  text-decoration: none;
  font-size: 0.85rem;
  transition: all 0.3s ease;
}

.back-to-toc-btn:hover {
  background-color: var(--co3);
  color: #fff;
  transform: translateY(-2px);
}

/* Layout Helpers */
.row.flex-center {
  display: flex !important;
  justify-content: center !important;
  align-items: center;
  text-align: center !important;
  flex-direction: column;
}

.ltr-text {
  direction: ltr;
  display: inline-block;
}

/* --- 6. Footer (Test) --- */
.test-footer-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 40px 0;
}

.test-contact-container {
  display: flex;
  gap: 50px;
  max-width: 1200px;
  align-items: center;
}

.test-info-box p {
  margin: 0 !important;
  line-height: 1.8;
  color: #333;
}

.test-social-box {
  display: flex;
  gap: 15px;
  align-items: center;
}

/* استایل دکمه بازگشت به بالا */
.back-to-top {
  position: fixed;
  bottom: 30px;
  left: 30px; /* چون سایت راست‌چین است، دکمه را سمت چپ می‌گذاریم */
  width: 50px;
  height: 50px;
  background-color: var(--co1); /* رنگ نارنجی برند شما */
  color: white;
  border-radius: 50%;
  display: none; /* در ابتدا مخفی است و با JS نمایش داده می‌شود */
  justify-content: center;
  align-items: center;
  text-decoration: none;
  font-size: 24px;
  z-index: 1000;
  box-shadow: 0 4px 10px rgb(0 0 0 / 20%);
  transition: all 0.3s ease;
}

.back-to-top:hover {
  background-color: var(--co3); /* رنگ تیره هدر هنگام هاور */
  transform: translateY(-5px);
}

#backToTop {
  display: none; /* یا استفاده از opacity برای انیمیشن */
  position: fixed;
  bottom: 30px;
  left: 30px;

  /* سایر استایل‌های دکمه */
}

#backToTop.visible {
  display: block;
}

/* --- 7. Responsive Design --- */
@media (width <= 768px) {
  .back-to-top {
    bottom: 20px;
    left: 20px;
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  .post-content {
    font-size: 1rem;
    line-height: 1.8;
  }

  .test-contact-container {
    flex-direction: column-reverse;
    gap: 25px;
    text-align: center;
  }

  .test-info-box {
    text-align: center;
  }

  .table-of-contents.compact-toc {
    display: block;
    max-width: 100%;
    margin: 1rem 0;
    padding: 10px;
  }

  .table-of-contents.compact-toc ul {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .table-of-contents.compact-toc li {
    margin-bottom: 0;
    font-size: 0.85rem;
  }
}

/* --- */

/* --- حالت موبایل (Mobile View) --- */

/* کپشن ظریف برای عکس‌ها */
.img-caption {
  font-size: 0.85rem;
  color: var(--co1);
  margin-top: 12px;
  text-align: center;
  font-weight: 300;
  line-height: 1.5;
}

/* ----------------- */

/* ---------------- */
.auto-article {
  column-count: 2;
  column-gap: 80px;
  column-rule: 1px dashed var(--co2);
  text-align: justify;
}

.post-title {
  column-span: all; /* عنوان مقاله عرض کامل بگیرد */
  font-family: var(--font-heading);
  color: var(--co3);
  margin: 30px 0;
  font-size: 2rem;
}

.article-meta-box {
  column-span: all;
  background-color: var(--co5);
  padding: 15px 25px;
  border-radius: 10px;
  margin-bottom: 30px;
  border-right: 5px solid var(--co1);
}

.local-toc-list {
  list-style: disc;
  padding-right: 25px;
  font-size: 0.9rem;
  margin-top: 10px;
}

/* جلوگیری از نصف شدن محتوا در ستون‌ها */
.auto-article h3,
.auto-article figure,
.auto-article blockquote {
  break-inside: avoid;
  margin-top: 20px;
}

.auto-article h3 {
  border-right: 4px solid var(--co1);
  padding-right: 10px;
  font-family: var(--font-heading);
  margin-bottom: 15px;
}

@media (width <= 768px) {
  .auto-article {
    column-count: 1;
  }
}
