/* Arabic on the desk's pages, right to left. Theme tokens only.
   Faces: Noto Naskh Arabic for reading (the report, quoted passages, answers), as the chat page already uses it;
   Noto Sans Arabic for the small interface words (labels, buttons, chart labels), because a Naskh face at 11 to 13px
   loses its dots and joins on screen and sits badly beside Geist. Both come from Google Fonts. */

:root { --ar-read: 'Noto Naskh Arabic', 'Geeza Pro', 'SF Arabic', serif; --ar-ui: 'Noto Sans Arabic', 'SF Arabic', 'Geeza Pro', var(--font, system-ui), sans-serif; }

/* ---------- the language switch ---------- */
.ar-switch { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--sunk); }
.ar-switch .ar-opt { min-block-size: 32px; padding: 4px 12px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-size: 12.5px; cursor: pointer; transition: color .18s ease-out, box-shadow .18s ease-out; }
.ar-switch .ar-opt[lang="ar"] { font-family: var(--ar-ui); font-size: 13.5px; }
.ar-switch .ar-opt[aria-pressed="true"] { color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--accent); }
.ar-switch .ar-opt:hover { color: var(--ink); }
.ar-switch .ar-opt:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* ---------- the header: the app names and the Expert input button, while the page is read in Arabic (shell.js) ---------- */
.g-nav a[lang="ar"], .x-open span[lang="ar"] { font-family: var(--ar-ui); font-size: 13.5px; letter-spacing: 0; }

/* ---------- any Arabic container ---------- */
[dir="rtl"][lang="ar"] { font-family: var(--ar-ui); }
[dir="rtl"][lang="ar"] bdi[lang="en"], [dir="rtl"][lang="ar"] [lang="en"] { font-family: var(--font, 'Geist', system-ui), sans-serif; }
[dir="rtl"][lang="ar"] code, [dir="rtl"][lang="ar"] .mono { font-family: var(--mono, 'Geist Mono', ui-monospace), monospace; direction: ltr; unicode-bidi: isolate; }

/* ---------- the report, right to left ---------- */
.r-main[dir="rtl"] .r-doc { font-family: var(--ar-read); font-size: 16px; line-height: 1.9; }
.r-main[dir="rtl"] .r-doc h1, .r-main[dir="rtl"] .r-doc h2, .r-main[dir="rtl"] .r-doc h3, .r-main[dir="rtl"] .r-doc h4 { font-family: var(--ar-read); letter-spacing: 0; line-height: 1.5; }
.r-main[dir="rtl"] .r-doc h1 { line-height: 1.45; }
.r-main[dir="rtl"] .r-marking, .r-main[dir="rtl"] .r-type, .r-main[dir="rtl"] .r-facts dt, .r-main[dir="rtl"] .r-source, .r-main[dir="rtl"] .r-table th, .r-main[dir="rtl"] .r-fig span,
.r-main[dir="rtl"] .r-fig small, .r-main[dir="rtl"] .r-toc, .r-main[dir="rtl"] figcaption, .r-main[dir="rtl"] .r-note { font-family: var(--ar-ui); letter-spacing: 0; }
.r-main[dir="rtl"] .r-side { font-family: var(--ar-ui); }
/* The few physical sides report.css sets, mirrored. */
.r-main[dir="rtl"] .r-table th { padding: 7px 0 7px 10px; }
.r-main[dir="rtl"] .r-table td { padding: 8px 0 8px 10px; }
.r-main[dir="rtl"] .r-fig { margin: 0 0 -1px -1px; }
.r-main[dir="rtl"] .r-notes li:target { box-shadow: inset -3px 0 0 var(--ink); }
.r-main[dir="rtl"] .r-side { padding: 2px 2px 2px 4px; }
.r-main[dir="rtl"] .r-mx th { padding: 5px 0 5px 8px; }
/* Recorded English inside the Arabic report: its own face, so a name or a title reads as written. */
.r-main[dir="rtl"] .r-doc [lang="en"], .r-main[dir="rtl"] .r-doc bdi[lang="en"], .r-main[dir="rtl"] .r-side bdi[lang="en"] { font-family: var(--font, 'Geist', system-ui), sans-serif; letter-spacing: 0; }
.r-main[dir="rtl"] .r-doc h1[lang="en"] { letter-spacing: -0.02em; line-height: 1.2; }
/* A recorded English title keeps its own word order but lines up with the Arabic page, on the right. */
[dir="rtl"] .r-doc :is(h1, h2, h3, h4)[lang="en"] { text-align: right; }
/* Footnote numbers sit on the right, the text runs to the left; the number stays a Western digit. */
.r-main[dir="rtl"] .r-notes li > b, .r-main[dir="rtl"] .r-doc sup { font-family: var(--font, 'Geist', system-ui), sans-serif; unicode-bidi: isolate; }
.r-main[dir="rtl"] .r-notes li > span { font-family: var(--ar-ui); line-height: 1.75; }

/* Feedback on earlier versions: recorded English (a section's name, a person, a reason) is kept as one piece, so on a
   narrow screen it moves whole to the next line rather than breaking across the Arabic label beside it; a date stays whole. */
.r-main[dir="rtl"] .r-vd-item :is(bdi[lang="en"], span[dir="auto"]:dir(ltr)) { display: inline-block; max-inline-size: 100%; }
.r-vd-when { white-space: nowrap; }

/* A quoted passage: the CBUAE's Arabic text, and the English beside it, each in its own direction. */
.r-main[dir="rtl"] .r-doc blockquote[lang="ar"] { font-family: var(--ar-read); font-size: 16.5px; line-height: 2; }
.r-main[dir="rtl"] .r-doc blockquote.beside { direction: ltr; text-align: start; border-inline-start-color: var(--line-strong); padding-inline: 16px 0; color: var(--ink-2); font-family: var(--font, 'Geist', system-ui), sans-serif; font-size: 14px; line-height: 1.6; }
.r-main[dir="rtl"] .r-doc blockquote.beside + .r-note { color: var(--muted); }
.r-live .r-main[dir="rtl"] .r-doc blockquote.official { border-inline-start-color: var(--accent-line); }

/* A part a model writes: it waits for the model, dashed, never a filled box. */
.r-doc .r-waits { color: var(--muted); border-block-end: 1px dashed var(--line-strong); }
.r-main[dir="rtl"] .r-doc p.r-note[data-waits], .r-doc .r-note .r-waits { font-style: normal; }
.r-ar-note { margin-block-start: 10px; }
.r-ar-figs { display: grid; gap: 2px; margin-block-start: 8px; }
.r-ar-figs p { margin: 0; font-size: 12.5px; }

/* A chart keeps its own geometry: time runs left to right (a build default), the labels are Arabic. */
.r-main[dir="rtl"] .r-cf-plot, .r-main[dir="rtl"] .r-bars { direction: ltr; }
.r-main[dir="rtl"] .r-cf-plot text, .r-main[dir="rtl"] .r-cf-plot .v-legend { font-family: var(--ar-ui); }
.r-main[dir="rtl"] .r-cf-plot .v-legend { direction: rtl; }

/* The drawer, the tooltip and the hint on an Arabic page. */
.v-drawer[dir="rtl"], .v-tip[dir="rtl"], .v-pop[dir="rtl"] { font-family: var(--ar-ui); }
.v-drawer[dir="rtl"] .r-dr-clause[lang="ar"] { font-family: var(--ar-read); }

/* ---------- the chat, an answer in Arabic ---------- */
.d-answer[dir="rtl"] { font-family: var(--ar-ui); }
/* The evidence charts keep their own geometry (time left to right, a build default); their words are Arabic. */
.d-answer[dir="rtl"] .d-ev-tier, .d-answer[dir="rtl"] .d-ev-pub, .d-answer[dir="rtl"] .d-ev-time { direction: ltr; }
.d-answer[dir="rtl"] .d-question bdi { font-family: var(--font, 'Geist', system-ui), sans-serif; }
#composer[dir="rtl"] { font-family: var(--ar-ui); }
.d-answer[dir="rtl"] .d-excerpt[lang="ar"] { font-family: var(--ar-read); font-size: 1.06em; line-height: 1.95; }
.d-answer[dir="rtl"] .d-excerpt[lang="en"] { direction: ltr; text-align: start; font-family: var(--font, 'Geist', system-ui), sans-serif; }
.d-twin { grid-column: 2 / 4; margin-block-start: 6px; min-inline-size: 0; }
.d-twin .d-excerpt { margin-block-start: 0; }
@media (max-width: 760px) { .d-twin { grid-column: 1 / -1; } }
.d-twin-label { display: block; font-size: 11.5px; color: var(--muted); margin-block: 6px 2px; }
.d-twin .d-excerpt { border-inline-start: 2px solid var(--line-strong); padding-inline-start: 10px; }
.d-twin .d-excerpt.official { border-inline-start-color: var(--accent-line); }
/* ---------- the briefs, in Arabic ---------- */
.b-brief[dir="rtl"], .b-lower[dir="rtl"] { font-family: var(--ar-ui); }
.b-brief[dir="rtl"] [lang="en"], .b-lower[dir="rtl"] [lang="en"] { font-family: var(--font, 'Geist', system-ui), sans-serif; }
.b-lower[dir="rtl"] .b-strands, .b-lower[dir="rtl"] .b-weights { direction: ltr; }
.d-lang-row { display: inline-flex; align-items: center; gap: 8px; }
.d-lang-row > span { font-size: 12px; color: var(--muted); }

/* ---------- the reports list, right to left ---------- */
/* Arabic joins its letters, so the spaced capitals the English labels use are set without spacing, a size up. */
.r-list[dir="rtl"] :is(h2, h3, .r-kind, .r-over-bar h3, .r-card-figs b, .pv-fig b) { letter-spacing: 0; }
.r-list[dir="rtl"] :is(.r-kind, .r-over-bar h3) { font-size: 12px; text-transform: none; }
.r-list[dir="rtl"] .r-card h3 { line-height: 1.5; }
/* A bar of parts reads from the right on an Arabic page; its rounded ends follow. */
[dir="rtl"] .pv-seg > span:first-child { border-radius: 3px 999px 999px 3px; }
[dir="rtl"] .pv-seg > span:last-child { border-radius: 999px 3px 3px 999px; }
[dir="rtl"] .pv-seg > span:only-child { border-radius: 999px; }

/* ---------- print: the Arabic PDF ---------- */
@media print {
  html[dir="rtl"] .r-doc { font-family: 'Noto Naskh Arabic', 'Geeza Pro', serif; font-size: 10.5pt; line-height: 1.75; }
  html[dir="rtl"] .r-doc h1 { font-size: 24pt; line-height: 1.45; }
  html[dir="rtl"] .r-doc [lang="en"], html[dir="rtl"] .r-doc bdi[lang="en"] { font-family: 'Geist', -apple-system, 'Helvetica Neue', Arial, sans-serif; }
  html[dir="rtl"] .r-doc h1[lang="en"] { line-height: 1.2; }
  html[dir="rtl"] .r-doc h2 { font-size: 15pt; line-height: 1.45; }
  html[dir="rtl"] .r-doc h3 { font-size: 12pt; line-height: 1.45; }
  html[dir="rtl"] .r-doc blockquote[lang="ar"] { font-size: 10.5pt; line-height: 1.8; }
  html[dir="rtl"] .r-doc blockquote.beside { font-size: 9pt; line-height: 1.5; }
  html[dir="rtl"] .r-table th { padding: 4pt 0 4pt 6pt; }
  html[dir="rtl"] .r-table td { padding: 4.5pt 0 4.5pt 6pt; }
  html[dir="rtl"] .r-notes ol { font-size: 8.3pt; line-height: 1.6; }
  html[dir="rtl"] .r-notes li { grid-template-columns: 22pt minmax(0, 1fr); }
  html[dir="rtl"] .r-facts { grid-template-columns: 42mm minmax(0, 1fr); }
  /* Line boxes tall enough that no mark above or below a letter is cut off. */
  html[dir="rtl"] .r-doc p, html[dir="rtl"] .r-doc li, html[dir="rtl"] .r-doc dd, html[dir="rtl"] .r-doc td { line-height: 1.7; }
}
