/* ============================================================
   RIGHT-TO-LEFT OVERRIDES — loaded only by the Arabic edition
   ============================================================

   site.css is written with physical properties (padding-left,
   border-right, text-align: left). Rewriting it to logical properties
   would touch every rule on a stylesheet that two finished editions
   already render correctly, with no way to verify the result here. So
   the base sheet is left alone and this file mirrors the ~40 rules that
   actually have a side, scoped to [dir="rtl"].

   Two things this file is careful about:

   1. Nothing here hides anything with a physical offset. `left:-9999px`
      on a skip link is the classic RTL page-killer — under dir="rtl" it
      pushes the element into a phantom overflow that some engines paint
      as a full-height black column. site.css hides the skip link with a
      transform, which is direction-safe, and this file keeps it that way.

   2. Numbers, symbols and ticker codes stay left-to-right. Arabic runs
      right-to-left but 25×, 0.01, ±2.00% and AAPLUSDT do not, and the
      bidirectional algorithm mangles them at a boundary — "±2.00%" can
      render as "%2.00±". Latin runs are isolated in markup with
      <span dir="ltr">; the rules below cover the generated cases the
      markup cannot reach.
   ============================================================ */

[dir="rtl"] {
  /* Arabic has no self-hosted face here: Libre Caslon Display carries
     latin + latin-ext only, and shipping an Arabic webfont would add a
     second large download for one edition. The system stack below is
     present on every target platform — Segoe UI on Windows, SF Arabic /
     Geeza Pro on Apple, Noto Sans Arabic on Android and Linux — and
     covers the full script including the Arabic-Indic digits we do not
     use. The editorial rhythm is carried by weight and scale instead of
     by the serif, the same compromise the display face forces on any
     non-latin edition. */
  --font-body: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif;
  --font-display: "Segoe UI", "SF Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif;
  --font-mono: "IBM Plex Mono", Consolas, monospace;
}

/* Arabic sits lower on the line and its ascenders/descenders are taller
   than latin, so headings set at the latin leading collide. */
[dir="rtl"] h1.display,
[dir="rtl"] .page-head h1,
[dir="rtl"] .doc__body h1 { line-height: 1.25; letter-spacing: 0; font-weight: 700; }

[dir="rtl"] .doc__body h2,
[dir="rtl"] .doc__body h3,
[dir="rtl"] .prose h2,
[dir="rtl"] .prose h3,
[dir="rtl"] .rule__t,
[dir="rtl"] .cell__t,
[dir="rtl"] .row__t,
[dir="rtl"] .featured__copy h2,
[dir="rtl"] .strip-statement h2 { line-height: 1.4; letter-spacing: 0; font-weight: 700; }

[dir="rtl"] .doc__body p,
[dir="rtl"] .doc__body li,
[dir="rtl"] .prose p,
[dir="rtl"] .prose li { line-height: 1.95; }

/* the split serif/grotesque hero has no serif to split against */
[dir="rtl"] h1.display .serif { display: block; font-weight: 400; }

/* uppercase micro-labels: Arabic has no case, and the wide latin tracking
   pulls the joined letterforms apart */
[dir="rtl"] .kicker,
[dir="rtl"] .strip__k,
[dir="rtl"] .cell__n,
[dir="rtl"] .row__m,
[dir="rtl"] .toc__h,
[dir="rtl"] .tool__h,
[dir="rtl"] .readout__k,
[dir="rtl"] .note__h,
[dir="rtl"] .warn__h,
[dir="rtl"] .check__h,
[dir="rtl"] .cta__h,
[dir="rtl"] .foot h2,
[dir="rtl"] .nextprev span,
[dir="rtl"] .invite__k { text-transform: none; letter-spacing: 0; }

/* ---------- shell ---------- */

/* fixed offset, mirrored. Still hidden by transform, never by offset. */
[dir="rtl"] .skip { left: auto; right: 12px; }

/* the nav underline grows from the reading edge */
[dir="rtl"] .rail a::after { transform-origin: left; }
[dir="rtl"] .rail a:hover::after,
[dir="rtl"] .rail a[aria-current="page"]::after { transform-origin: right; }

[dir="rtl"] .bar__stamp {
  padding-left: 0; padding-right: clamp(16px, 2vw, 28px);
  border-left: 0; border-right: 1px solid var(--line-strong);
}

/* ---------- spec strip ---------- */

[dir="rtl"] .strip__cell { border-left: 0; border-right: 1px solid var(--line); }
[dir="rtl"] .strip__cell:first-child { border-right: 0; padding-right: 0; padding-left: clamp(14px, 2vw, 28px); }
@media (max-width: 700px) {
  [dir="rtl"] .strip__cell:nth-child(3) { border-right: 0; padding-right: 0; }
}

/* ---------- hero / featured ---------- */

[dir="rtl"] .lede__right,
[dir="rtl"] .lede__visual { border-left: 0; border-right: 1px solid var(--line-strong); }
@media (max-width: 900px) {
  [dir="rtl"] .lede__right,
  [dir="rtl"] .lede__visual { border-right: 0; border-top: 1px solid var(--line-strong); }
}

[dir="rtl"] .featured figure { border-right: 0; border-left: 1px solid var(--line-strong); }
@media (max-width: 900px) {
  [dir="rtl"] .featured figure { border-left: 0; border-bottom: 1px solid var(--line-strong); }
}

/* ---------- entry grid ---------- */

[dir="rtl"] .cell { border-right: 0; border-left: 1px solid var(--line); }
[dir="rtl"] .grid--2 .cell:nth-child(2n),
[dir="rtl"] .grid--3 .cell:nth-child(3n),
[dir="rtl"] .grid--4 .cell:nth-child(4n) { border-left: 0; }

/* ---------- tables ---------- */

[dir="rtl"] table.data th,
[dir="rtl"] table.data td { text-align: right; }
[dir="rtl"] table.data th:first-child,
[dir="rtl"] table.data td:first-child { padding: 11px 0 11px 12px; }

/* Numeric columns keep latin digits and stay left-to-right so a leading
   sign or a decimal point cannot be flipped to the far end of the cell.
   In an RTL table the numeric column reads best flush to the left edge. */
[dir="rtl"] table.data .num,
[dir="rtl"] table.data th.num {
  text-align: left; padding-right: 0; padding-left: 0;
  direction: ltr; unicode-bidi: isolate;
}
[dir="rtl"] table.kv th { text-align: right; }

/* symbols, tickers and figures are latin runs inside Arabic prose */
[dir="rtl"] code,
[dir="rtl"] .sym,
[dir="rtl"] .mono,
[dir="rtl"] .strip__v,
[dir="rtl"] .readout__v,
[dir="rtl"] .invite__v { direction: ltr; unicode-bidi: isolate; display: inline-block; }

/* ---------- article body ---------- */

[dir="rtl"] .doc__body ul,
[dir="rtl"] .doc__body ol { padding-left: 0; padding-right: 22px; }
[dir="rtl"] .sources ol { padding-left: 0; padding-right: 20px; }

[dir="rtl"] .doc__body blockquote { border-left: 0; border-right: 3px solid var(--accent); }
[dir="rtl"] .note { border-left: 0; border-right: 3px solid var(--line-strong); }
[dir="rtl"] .warn { border-left: 0; border-right: 3px solid var(--accent); }
[dir="rtl"] .check { border-left: 0; border-right: 3px solid var(--long); }

/* numbered steps: the counter moves to the reading edge, and the number
   itself stays latin */
[dir="rtl"] ol.steps > li { padding: 22px 58px 22px 0; }
[dir="rtl"] ol.steps > li::before {
  left: auto; right: 0;
  direction: ltr; unicode-bidi: isolate;
}

/* ---------- next / previous ---------- */

[dir="rtl"] .nextprev a { border-right: 0; border-left: 1px solid var(--line); }
[dir="rtl"] .nextprev a:last-child { border-left: 0; padding-left: 0; padding-right: 26px; }

/* ---------- tools ---------- */

[dir="rtl"] .tool__in { border-right: 0; border-left: 1px solid var(--line-strong); }

/* calculator inputs hold latin numerals the reader types */
[dir="rtl"] .field input[type="number"],
[dir="rtl"] .field input[type="text"] { direction: ltr; text-align: left; }

/* ---------- misc auto margins ---------- */

[dir="rtl"] .rule__more { margin-left: 0; margin-right: auto; }
