/* RTL overrides loaded only when dir="rtl" */

/* Article shell column order: TOC right, rail left */
[dir="rtl"] .article-shell {
  grid-template-columns: 280px minmax(0, 1fr) 240px;
}
@media (max-width: 1100px) {
  [dir="rtl"] .article-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }
}

/* Pull quote — quote mark on the right */
[dir="rtl"] .pullquote::before {
  inset-inline-start: auto;
  inset-inline-end: -16px;
}

/* Reading progress grows from the right */
[dir="rtl"] .read-progress {
  left: auto;
  right: 0;
}

/* Brand mark order */
[dir="rtl"] .brand {
  flex-direction: row;
}

/* Arabic font stack override */
:root[dir="rtl"] {
  --font-display: 'Amiri', 'Noto Naskh Arabic', Georgia, serif;
  --font-body: 'Noto Naskh Arabic', Georgia, serif;
  --font-ui: 'Noto Naskh Arabic', system-ui, sans-serif;
}

/* Footnote refs and inline numbers remain LTR */
[dir="rtl"] .footnote-ref,
[dir="rtl"] .num,
[dir="rtl"] .src-link {
  direction: ltr;
  unicode-bidi: bidi-override;
}

/* Drop cap floats to the right in RTL */
[dir="rtl"] .prose .dropcap::first-letter {
  float: right;
  margin-inline-end: 0.10em;
  margin-inline-start: 0;
}

/* TOC action buttons read from the right */
[dir="rtl"] .toc-actions button {
  text-align: right;
}

/* Worked-example numeric column aligns to the start edge (right) */
[dir="rtl"] .example-row .num {
  text-align: right;
}

/* Mobile pull-quote mark sits on the right */
@media (max-width: 700px) {
  [dir="rtl"] .pullquote::before {
    left: auto;
    right: 0;
  }
}

/* Language switcher reads right-to-left (PL · EN · ES · AR mirrors) */
[dir="rtl"] .lang-toggle {
  flex-direction: row-reverse;
}

/* Latin tokens, code, prices and pair symbols stay LTR inside RTL prose */
[dir="rtl"] code,
[dir="rtl"] .kbd,
[dir="rtl"] .pair,
[dir="rtl"] .price,
[dir="rtl"] .ltr {
  direction: ltr;
  unicode-bidi: isolate;
}

/* Course page: keep module rails/progress logical; numerals isolated */
[dir="rtl"] .course-module-num,
[dir="rtl"] .course-progress {
  direction: ltr;
  unicode-bidi: isolate;
}
