/* Core RTL Direction & Right Alignment Enforcement */
html {
  direction: rtl;
}

body {
  direction: rtl;
  text-align: right;
}

h1, h2, h3, h4, h5, h6, p, ul, ol, dl, input, textarea, select {
  text-align: right;
  direction: rtl;
}

/* 1. Global Container & Grid Constraints */
.blog-container {
  width: 100%;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

@media (min-width: 640px) {
  .blog-container {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .blog-container {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

/* Two-Column Editorial Layout (Desktop) */
.editorial-layout {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

@media (min-width: 1024px) {
  .editorial-layout {
    flex-direction: row; /* In RTL: first child is right, second child is left */
    gap: 2.25rem; /* ~36px */
    align-items: flex-start;
  }

  .editorial-main-col {
    flex: 1 1 0%;
    max-width: 780px;
    min-width: 0;
  }

  .editorial-sidebar-col {
    width: 320px;
    flex-shrink: 0;
  }

  #sidebar-sticky-inner {
    will-change: transform;
    transition: transform 0.08s ease-out;
  }
}

/* Editorial Article Header & Hero Architecture */
.editorial-article-header {
  margin-bottom: 1.5rem;
}

.editorial-category-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #8b5cf6;
  background-color: #f5f3ff;
  padding: 0.25rem 0.875rem;
  border-radius: 9999px;
  transition: all 0.2s ease;
  margin-bottom: 0.875rem;
}

.editorial-category-badge:hover {
  background-color: #ede9fe;
  color: #7c3aed;
}

.editorial-article-title {
  font-size: 1.625rem;
  font-weight: 900;
  color: #0f172a;
  line-height: 1.45;
  margin-bottom: 1.25rem;
}

@media (min-width: 640px) {
  .editorial-article-title {
    font-size: 2rem;
    line-height: 1.4;
  }
}

@media (min-width: 1024px) {
  .editorial-article-title {
    font-size: 2.375rem;
    line-height: 1.35;
  }
}

/* Editorial Featured Image Container (Height-Fitted with Blurred Ambient Background Fill) */
.editorial-featured-image {
  position: relative;
  width: 100%;
  border-radius: 1.25rem;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 20px -4px rgba(15, 23, 42, 0.08);
  background-color: #f8fafc;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (min-width: 768px) {
  .editorial-featured-image {
    aspect-ratio: 21 / 9;
    max-height: 440px;
    border-radius: 1.5rem;
  }
}

/* 1. Ambient Blurred Background Fill (Vibrant, colorful matching the image) */
.editorial-featured-image-bg {
  position: absolute;
  inset: -25px; /* Bleeds outside container to avoid blur edge clipping */
  overflow: hidden;
  pointer-events: none;
  user-select: none;
  z-index: 1;
}

.editorial-featured-image-bg picture,
.editorial-featured-image-bg img,
.editorial-featured-image-bg-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(22px);
  transform: scale(1.18);
  opacity: 0.95;
}

/* 2. Main Foreground Image: Fits exact frame height, preserves aspect ratio, centered */
.editorial-featured-image-main {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.editorial-featured-image-main picture {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: auto;
  max-width: 100%;
}

.editorial-featured-image-img {
  display: block;
  height: 100%;
  width: auto;
  max-width: 100%;
  object-fit: cover;
  margin-left: auto;
  margin-right: auto;
  filter: drop-shadow(0 10px 25px rgba(0, 0, 0, 0.4));
}

/* Editorial Metadata & Utilities Bar (Directly BELOW Featured Image) */
.editorial-meta-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  margin-top: 1rem;
  margin-bottom: 2rem;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04);
}

.editorial-meta-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8125rem;
  color: #64748b;
}

.editorial-meta-utilities {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Editorial Article Reading Container (Elevated White Reading Canvas) */
.editorial-article-paper {
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 1.5rem;
  box-shadow: 0 4px 25px -4px rgba(15, 23, 42, 0.05);
  padding: 2.25rem 1.75rem;
  margin-bottom: 2.5rem;
}

@media (min-width: 640px) {
  .editorial-article-paper {
    padding: 2.5rem 2.25rem;
  }
}

@media (min-width: 1024px) {
  .editorial-article-paper {
    padding: 3rem 2.75rem;
  }
}

/* 2. Article Typography & Reading Comfort (Persian Knowledge Engine) */
.blog-prose {
  font-size: 1.0625rem; /* ~17px desktop */
  line-height: 2.15;
  color: #1e293b; /* Deep slate-800 for maximum readability */
  font-weight: 400;
}

@media (max-width: 640px) {
  .blog-prose {
    font-size: 1rem; /* ~16px mobile */
    line-height: 2.05;
  }
}

.blog-prose h1,
.blog-prose h2,
.blog-prose h3,
.blog-prose h4 {
  color: #0f172a; /* Deep slate-900 */
  font-weight: 900;
  scroll-margin-top: 110px; /* offset for sticky navbar */
}

.blog-prose h2 {
  font-size: 1.5rem; /* ~24px */
  line-height: 1.5;
  margin-top: 2.75rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid #f1f5f9;
  position: relative;
}

.blog-prose h2::after {
  content: '';
  position: absolute;
  bottom: -2px;
  right: 0;
  width: 50px;
  height: 2px;
  background-color: #8b5cf6;
  border-radius: 9999px;
}

@media (min-width: 768px) {
  .blog-prose h2 {
    font-size: 1.625rem; /* ~26px */
  }
}

.blog-prose h3 {
  font-size: 1.25rem; /* ~20px */
  line-height: 1.6;
  margin-top: 2rem;
  margin-bottom: 0.875rem;
}

@media (min-width: 768px) {
  .blog-prose h3 {
    font-size: 1.3125rem; /* ~21px */
  }
}

.blog-prose p {
  color: #1e293b;
  margin-bottom: 1.75rem;
  text-align: justify;
  text-align-last: right;
}

.blog-prose strong {
  color: #0f172a;
  font-weight: 800;
}

.blog-prose ul,
.blog-prose ol {
  margin-bottom: 1.5rem;
  padding-right: 1.5rem;
}

.blog-prose ul {
  list-style-type: disc;
}

.blog-prose ol {
  list-style-type: decimal;
}

.blog-prose li {
  margin-bottom: 0.625rem;
  line-height: 1.9;
}

/* Callout Alert & Instructional Boxes */
.blog-callout {
  border-radius: 1rem;
  padding: 1.25rem 1.5rem;
  margin: 1.875rem 0;
  border-right-width: 4px;
}

.blog-callout-info {
  background-color: #f5f3ff;
  border-color: #8b5cf6;
  color: #4c1d95;
}

.blog-callout-warning {
  background-color: #fffbeb;
  border-color: #f59e0b;
  color: #78350f;
}

.blog-callout-success {
  background-color: #ecfdf5;
  border-color: #10b981;
  color: #064e3b;
}

.blog-callout-tip {
  background-color: #eff6ff;
  border-color: #3b82f6;
  color: #1e3a8a;
}

/* Step-by-step Instructional Cards */
.step-item {
  position: relative;
  padding-right: 3rem;
  margin-bottom: 1.5rem;
}

.step-badge {
  position: absolute;
  right: 0;
  top: 0;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  background-color: #8b5cf6;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.875rem;
}

/* Responsive Table in Prose */
.blog-table-container {
  overflow-x: auto;
  margin: 1.75rem 0;
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  background-color: #ffffff;
}

.blog-table {
  min-width: 700px;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.875rem;
}

.blog-table th {
  background-color: #f8fafc;
  color: #0f172a;
  font-weight: 700;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid #e2e8f0;
}

.blog-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
  font-weight: 500;
}

.blog-table tr:last-child td {
  border-bottom: none;
}

/* 3. Reading Progress Bar */
#reading-progress-bar {
  position: fixed;
  top: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #7c3aed, #8b5cf6, #a78bfa);
  width: 0%;
  z-index: 9999;
  transition: width 0.1s ease-out;
}

/* 4. Table of Contents & Sidebar Sticky Behavior */
#article-toc {
  max-height: min(340px, 42vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-left: 0.25rem;
  padding-right: 0.125rem;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

#article-toc::-webkit-scrollbar {
  width: 4px;
}

#article-toc::-webkit-scrollbar-track {
  background: transparent;
}

#article-toc::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 4px;
}

#article-toc::-webkit-scrollbar-thumb:hover {
  background-color: #94a3b8;
}

.toc-link {
  display: block;
  font-size: 0.875rem;
  color: #64748b;
  padding: 0.4rem 0.75rem;
  border-right: 2px solid transparent;
  transition: all 0.2s ease;
  line-height: 1.5;
}

.toc-link:hover {
  color: #8b5cf6;
  background-color: #f5f3ff;
  border-radius: 0.5rem 0 0 0.5rem;
}

.toc-link.active {
  color: #7c3aed;
  font-weight: 700;
  border-right-color: #8b5cf6;
  background-color: #ede9fe;
  border-radius: 0.5rem 0 0 0.5rem;
}

.toc-link-h3 {
  padding-right: 1.5rem;
  font-size: 0.8125rem;
}

/* Sticky sidebar container */
.sticky-sidebar {
  position: sticky;
  top: 92px; /* offset below header */
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.sticky-sidebar::-webkit-scrollbar {
  width: 4px;
}

.sticky-sidebar::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 4px;
}

/* 5. Interactive Rating Stars */
.star-btn {
  color: #cbd5e1;
  cursor: pointer;
  transition: transform 0.15s ease, color 0.15s ease;
}

.star-btn:hover,
.star-btn.hovered {
  color: #fbbf24; /* amber-400 */
  transform: scale(1.15);
}

.star-btn.selected {
  color: #f59e0b; /* amber-500 */
}

.star-btn:focus-visible {
  outline: 2px solid #8b5cf6;
  outline-offset: 3px;
  border-radius: 4px;
}

/* 6. Custom Card Transitions */
.article-card-hover {
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.article-card-hover:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px -6px rgba(139, 92, 246, 0.12), 0 4px 6px -2px rgba(15, 23, 42, 0.05);
  border-color: rgba(139, 92, 246, 0.3);
}

/* 7. Responsive Advertising Slot System (.blog-ad-slot) */
.blog-ad-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px dashed #cbd5e1;
  background-color: #f8fafc;
  border-radius: 1.25rem;
  text-align: center;
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.blog-ad-slot:hover {
  border-color: #94a3b8;
}

.blog-ad-slot__badge {
  position: absolute;
  top: 0.625rem;
  right: 0.875rem;
  font-size: 0.6875rem;
  font-weight: 700;
  color: #94a3b8;
  background-color: #ffffff;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  border: 1px solid #e2e8f0;
  letter-spacing: 0;
}

.blog-ad-slot__content {
  padding: 1.5rem;
  color: #64748b;
  max-width: 28rem;
}

.blog-ad-slot__title {
  font-size: 0.875rem;
  font-weight: 700;
  color: #475569;
  margin-bottom: 0.25rem;
}

.blog-ad-slot__caption {
  font-size: 0.75rem;
  color: #94a3b8;
  line-height: 1.6;
}

/* Horizontal Ad Slot (Homepage, Category, In-Article) */
.blog-ad-slot--horizontal {
  width: 100%;
  min-height: 110px;
  margin: 2rem 0;
}

@media (min-width: 640px) {
  .blog-ad-slot--horizontal {
    min-height: 130px;
  }
}

/* Vertical Ad Slot (Desktop Sidebar) */
.blog-ad-slot--vertical {
  width: 100%;
  min-height: 280px;
  margin: 1.25rem 0;
}

@media (max-width: 1023px) {
  /* In mobile/tablet, vertical ads become compact horizontal slots */
  .blog-ad-slot--vertical {
    min-height: 100px;
  }
}

/* 8. Social Sharing Button Controls */
.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0 0.85rem;
  height: 32px;
  min-height: 32px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  box-sizing: border-box;
  user-select: none;
}

.share-btn i {
  font-size: 0.8125rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.share-btn:focus-visible {
  outline: 2px solid #8b5cf6;
  outline-offset: 2px;
}

.share-btn-telegram {
  background-color: #eff6ff;
  color: #0284c7;
  border-color: #bfdbfe;
}
.share-btn-telegram:hover {
  background-color: #0284c7;
  color: #ffffff;
}

.share-btn-whatsapp {
  background-color: #f0fdf4;
  color: #16a34a;
  border-color: #bbf7d0;
}
.share-btn-whatsapp:hover {
  background-color: #16a34a;
  color: #ffffff;
}

.share-btn-copy {
  background-color: #f1f5f9;
  color: #475569;
  border-color: #e2e8f0;
}
.share-btn-copy:hover {
  background-color: #e2e8f0;
  color: #0f172a;
}

/* 9. Search Filter UI */
.blog-search-input {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.blog-search-input:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

/* 10. Editorial Visual Mockup Graphics (No fake banks, real local assets) */
.editorial-cover-frame {
  position: relative;
  width: 100%;
  border-radius: 1.5rem;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

/* 11. Comments Interactivity & Reaction Polish */
.reply-comment-btn,
.like-comment-btn {
  user-select: none;
  -webkit-user-select: none;
}

.like-comment-btn:hover i {
  transform: scale(1.15);
  transition: transform 0.15s ease;
}

.like-comment-btn.text-primary i {
  color: #8b5cf6;
}

#reply-to-indicator {
  transition: all 0.25s ease;
}

/* 12. Utility: Hide scrollbar for clean horizontal snap sliders */
.scrollbar-none::-webkit-scrollbar {
  display: none;
}
.scrollbar-none {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* 13. Existing Article Markup Helpers */
.blog-prose .cta-box {
  border-radius: 1rem;
  margin: 2rem 0;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.06);
  background-color: #faf5ff;
  padding: 1.25rem 1.5rem;
  border-right: 4px solid #8b5cf6;
}

.blog-prose .cta-box p {
  margin-bottom: 0;
  color: #4c1d95;
  font-weight: 500;
}

.blog-prose .cta-box a,
.blog-prose a{
  color: #7c3aed;
  font-weight: 700;
  text-decoration: underline;
}

.blog-prose .faq-section {
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 1.25rem;
  padding: 1.5rem;
  margin-top: 2rem;
  margin-bottom: 2rem;
}

.blog-prose .faq-section h3 {
  margin-top: 0.5rem;
  font-size: 1.125rem;
  color: #6d28d9;
}

.blog-prose .faq-section p {
  margin-bottom: 1rem;
  font-size: 0.95rem;
  line-height: 1.85;
}

.step-image {
  margin-top: 1rem;
  margin-bottom: 1rem;
  border-radius: 1rem;
  max-width: 100%;
  height: auto;
  border: 1px solid #e2e8f0;
}

/* Mobile Sticky App CTA Bar */
#mobile-sticky-cta {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 45;
  padding: 0.75rem;
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
  transform: translateY(125%);
  opacity: 0;
  pointer-events: none;
}

#mobile-sticky-cta.is-visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

@media (min-width: 1024px) {
  #mobile-sticky-cta {
    display: none !important;
  }
}

/* Article Card Hover & Micro-interactions */
.article-card-hover {
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease, border-color 0.25s ease;
}

.article-card-hover:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px -6px rgba(15, 23, 42, 0.08);
  border-color: #cbd5e1;
}


