/* Right-to-left pages (Arabic: <html dir="rtl">, docs/LOCALIZATION.md).
   Layout and components use logical properties (margin-inline-start, inset-inline-end, text-align: start …), so most of the
   UI mirrors by itself: the sidebar is on the right, drawers, menus and toasts open from the mirrored side. This file holds
   what logical properties cannot express: mirrored directional icons and transforms, and content that stays left-to-right
   (code, paths, identifiers, numbers in tables, the graph canvas and chart plots) inside right-to-left pages. */

/* Arabic script: no letter spacing anywhere (it would tear the joined letters apart; component styles set it for Latin
   headings and labels, hence !important), slightly taller lines for the Arabic glyphs. */
[dir="rtl"] body { line-height: 1.6; }
[dir="rtl"] body :not(:is(code, kbd, samp, pre, .ci-mono, .ci-mono *)) { letter-spacing: 0 !important; }
/* The wordmark stays Latin ("ContextIndex", docs/brand) and keeps its letter spacing. */
[dir="rtl"] body :is(.ci-wordmark, .ci-wordmark *) { letter-spacing: -0.035em !important; }

/* Directional icons (arrows, chevrons, collapse/expand, send, sign-out) and the breadcrumb separator point the other way. */
[dir="rtl"] .ci-icon-flip { transform: scaleX(-1); }
[dir="rtl"] :is(.ci-crumb-sep, .ci-flip-rtl) { display: inline-block; transform: scaleX(-1); }

/* Left-to-right content: code, keyboard keys, paths and identifiers (monospace), numbers in tables, graph canvas, charts.
   unicode-bidi: isolate keeps them as one unit in the surrounding Arabic text. */
[dir="rtl"] :is(code, kbd, samp, pre, .ci-mono, .ci-ltr, .ci-sysind-metric) { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] :is(div, p, dd, dt, td, li).ci-mono { text-align: right; }
[dir="rtl"] pre { text-align: left; }
/* Source views and code blocks: line numbers on the left, code left-to-right. */
[dir="rtl"] :is(.ci-codeblock, .ci-source) { direction: ltr; }
/* Excerpts and source lines can be code or prose in any language: each line takes the direction of its text. */
[dir="rtl"] :is(.ci-result-excerpt, .ci-result-excerpt > *, .ci-lc) { unicode-bidi: plaintext; text-align: start; }
[dir="rtl"] .ci-num { direction: ltr; unicode-bidi: isolate; text-align: left; }
[dir="rtl"] :is(input, textarea):is([type="url"], [type="email"], [type="password"], [type="number"], [type="tel"], .ci-mono, [data-ci-ltr]) { direction: ltr; text-align: left; }

/* Graph canvases and chart plots keep their left-to-right geometry (axes, pan/zoom, layout); toolbars and legends mirror. */
[dir="rtl"] :is(.gx-canvas-host, .ci-dgraph-viewport, .ci-barchart-plot, .ci-barchart-xaxis, .ci-linechart-plot, .ci-linechart-xaxis, .ci-sparkline) { direction: ltr; }

/* Native select: the chevron is on the left. */
[dir="rtl"] .ci-select { background-position: 12px 50%, 17px 50%; }

/* Switch: the knob starts on the right and moves to the left. */
[dir="rtl"] .ci-check input[role="switch"]:checked::after { transform: translateX(-14px); }

/* Sidebar drawer (below 1024 px) slides in from the right. */
@media (max-width: 1023.98px) {
    [dir="rtl"] .ci-shell-sidebar { transform: translateX(102%); }
    [dir="rtl"] .ci-shell[data-drawer="open"] .ci-shell-sidebar { transform: none; }
}

/* Indeterminate progress runs from right to left. */
@keyframes ci-indeterminate-rtl { 0% { transform: translateX(100%); } 100% { transform: translateX(-260%); } }
@media (prefers-reduced-motion: no-preference) {
    [dir="rtl"] .ci-progress-indeterminate .ci-progress-fill { animation-name: ci-indeterminate-rtl; }
}
