/* ═══════════════════════════════════════════════════════════════════════════
   Article Content — Professional styling for Tiptap-generated HTML
   Scope: .article-content only — never applies globally
   RTL-first · Persian-friendly · Tailwind-compatible · Dark mode ready
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Base Container ─────────────────────────────────────────────────────── */

.article-content {
  font-family: 'Vazirmatn', system-ui, -apple-system, sans-serif;
  direction: rtl;
  text-align: right;
  color: #374151;
  line-height: 1.9;
  font-size: 1.0625rem;
}

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

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

/* ─── Headings ───────────────────────────────────────────────────────────── */

.article-content h1 {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.3;
  margin: 2.5rem 0 1rem;
  color: #111827;
  letter-spacing: -0.01em;
}

.article-content h1:first-child {
  margin-top: 0;
}

.article-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 2.25rem 0 0.875rem;
  color: #1f2937;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e5e7eb;
}

.article-content h3 {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.4;
  margin: 1.75rem 0 0.75rem;
  color: #1f2937;
}

.article-content h4 {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.45;
  margin: 1.5rem 0 0.5rem;
  color: #374151;
}

/* ─── Paragraphs ─────────────────────────────────────────────────────────── */

.article-content p {
  margin: 0.875rem 0;
}

.article-content p:first-child {
  margin-top: 0;
}

/* ─── Strong & Emphasis ──────────────────────────────────────────────────── */

.article-content strong,
.article-content b {
  font-weight: 700;
  color: #111827;
}

.article-content em,
.article-content i {
  font-style: italic;
}

/* ─── Links ──────────────────────────────────────────────────────────────── */

.article-content a {
  color: #2563eb;
  text-decoration: underline;
  text-decoration-color: rgba(37, 99, 235, 0.3);
  text-underline-offset: 2px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.article-content a:hover {
  color: #1d4ed8;
  text-decoration-color: #2563eb;
}

.article-content a:active {
  color: #1e40af;
}

/* Internal anchor links */
.article-content a[href^="#"] {
  text-decoration-style: dotted;
}

/* ─── Lists ──────────────────────────────────────────────────────────────── */

.article-content ul,
.article-content ol {
  padding-right: 1.75rem;
  padding-left: 1.75rem;
  margin: 1rem 0;
}

.article-content ul {
  list-style-type: disc;
}

.article-content ol {
  list-style-type: decimal;
}

.article-content li {
  margin: 0.375rem 0;
  padding-right: 0.25rem;
}

/* Tiptap wraps list item text in <p> — remove extra spacing */
.article-content li > p {
  margin: 0.25rem 0;
}

.article-content li > p:first-child {
  margin-top: 0;
}

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

/* Nested lists */
.article-content ul ul {
  list-style-type: circle;
  margin: 0.375rem 0;
}

.article-content ul ul ul {
  list-style-type: square;
}

.article-content ol ol {
  list-style-type: lower-alpha;
  margin: 0.375rem 0;
}

/* ─── Blockquote ─────────────────────────────────────────────────────────── */

.article-content blockquote {
  border-right: 4px solid #2563eb;
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  background: #f0f7ff;
  border-radius: 0 0.75rem 0.75rem 0;
  color: #1e40af;
  font-style: italic;
}

.article-content blockquote p {
  margin: 0.375rem 0;
}

.article-content blockquote p:first-child {
  margin-top: 0;
}

.article-content blockquote p:last-child {
  margin-bottom: 0;
}

/* ─── Horizontal Rule ────────────────────────────────────────────────────── */

.article-content hr {
  border: none;
  height: 2px;
  background: linear-gradient(to left, transparent, #d1d5db, transparent);
  margin: 2rem 0;
}

/* ─── Images ─────────────────────────────────────────────────────────────── */

.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: 0.75rem;
  margin: 1.25rem 0;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.article-content img:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

/* ─── Figure & Figcaption ────────────────────────────────────────────────── */

.article-content figure {
  margin: 1.5rem 0;
}

.article-content figure img {
  margin: 0;
}

.article-content figcaption {
  text-align: center;
  font-size: 0.875rem;
  color: #6b7280;
  margin-top: 0.625rem;
  font-style: italic;
}

/* ─── Tables ─────────────────────────────────────────────────────────────── */

.article-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5rem 0;
  font-size: 0.9375rem;
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.article-content thead {
  background: #f8fafc;
}

.article-content th {
  font-weight: 600;
  color: #1f2937;
  text-align: right;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid #e5e7eb;
}

.article-content td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  color: #374151;
}

.article-content tbody tr:last-child td {
  border-bottom: none;
}

.article-content tbody tr:hover {
  background: #f8fafc;
}

/* ─── Code (inline) ──────────────────────────────────────────────────────── */

.article-content code {
  background: #f1f5f9;
  padding: 0.15em 0.4em;
  border-radius: 0.375rem;
  font-family: 'Courier New', monospace;
  font-size: 0.875em;
  color: #dc2626;
  direction: ltr;
  unicode-bidi: isolate;
}

/* ─── Code Block (pre) ───────────────────────────────────────────────────── */

.article-content pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 1.25rem 1.5rem;
  border-radius: 0.75rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  direction: ltr;
  unicode-bidi: isolate;
  text-align: left;
  line-height: 1.6;
  font-size: 0.875rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.article-content pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
  border-radius: 0;
}

/* ─── Mark / Highlight ───────────────────────────────────────────────────── */

.article-content mark {
  background: #fef08a;
  padding: 0.1em 0.3em;
  border-radius: 0.25rem;
  color: #1f2937;
}

/* ─── Subscript & Superscript ────────────────────────────────────────────── */

.article-content sub {
  font-size: 0.75em;
  vertical-align: sub;
}

.article-content sup {
  font-size: 0.75em;
  vertical-align: super;
}

/* ─── Task Lists (Tiptap) ────────────────────────────────────────────────── */

.article-content ul[data-type="taskList"] {
  list-style: none;
  padding-right: 0;
  padding-left: 0;
}

.article-content ul[data-type="taskList"] li {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
}

.article-content ul[data-type="taskList"] li > label {
  flex-shrink: 0;
  margin-top: 0.35rem;
}

.article-content ul[data-type="taskList"] li > label input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: #2563eb;
  cursor: pointer;
  border-radius: 0.25rem;
}

.article-content ul[data-type="taskList"] li[data-checked="true"] > div > p {
  text-decoration: line-through;
  opacity: 0.55;
}

.article-content ul[data-type="taskList"] li > div {
  flex: 1;
}

/* ─── Text Alignment (Tiptap) ────────────────────────────────────────────── */

.article-content [style*="text-align: left"] {
  text-align: left;
  direction: ltr;
}

.article-content [style*="text-align: center"] {
  text-align: center;
}

.article-content [style*="text-align: right"] {
  text-align: right;
}

.article-content [style*="text-align: justify"] {
  text-align: justify;
}

/* ─── Dark Mode ──────────────────────────────────────────────────────────── */

.dark .article-content {
  color: #d1d5db;
}

.dark .article-content h1 {
  color: #f9fafb;
}

.dark .article-content h2 {
  color: #f3f4f6;
  border-bottom-color: #374151;
}

.dark .article-content h3,
.dark .article-content h4 {
  color: #e5e7eb;
}

.dark .article-content strong,
.dark .article-content b {
  color: #f9fafb;
}

.dark .article-content a {
  color: #60a5fa;
  text-decoration-color: rgba(96, 165, 250, 0.3);
}

.dark .article-content a:hover {
  color: #93bbfd;
  text-decoration-color: #60a5fa;
}

.dark .article-content blockquote {
  background: rgba(37, 99, 235, 0.1);
  border-right-color: #3b82f6;
  color: #93c5fd;
}

.dark .article-content code {
  background: #1e293b;
  color: #f87171;
}

.dark .article-content thead {
  background: #1e293b;
}

.dark .article-content th {
  color: #e5e7eb;
  border-bottom-color: #374151;
}

.dark .article-content td {
  color: #d1d5db;
  border-bottom-color: #1e293b;
}

.dark .article-content tbody tr:hover {
  background: rgba(30, 41, 59, 0.5);
}

.dark .article-content mark {
  background: #854d0e;
  color: #fef3c7;
}

.dark .article-content hr {
  background: linear-gradient(to left, transparent, #374151, transparent);
}

.dark .article-content img {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.dark .article-content img:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.dark .article-content figure {
  background: transparent;
}

.dark .article-content figcaption {
  color: #9ca3af;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .article-content {
    font-size: 1rem;
    line-height: 1.85;
  }

  .article-content h1 {
    font-size: 1.625rem;
    margin: 2rem 0 0.75rem;
  }

  .article-content h2 {
    font-size: 1.3rem;
    margin: 1.75rem 0 0.75rem;
  }

  .article-content h3 {
    font-size: 1.125rem;
  }

  .article-content img {
    border-radius: 0.5rem;
    margin: 1rem 0;
  }

  .article-content table {
    font-size: 0.8125rem;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .article-content pre {
    padding: 1rem;
    font-size: 0.8125rem;
    margin: 1rem -1rem;
    border-radius: 0;
  }

  .article-content blockquote {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
  }
}
