/* Shared physical layout, independent of the language used to read the text.
   Structural containers remain LTR in both languages. A physical base alignment
   keeps Arabic paragraphs at the same side as French paragraphs; component
   rules and native button centering retain their own explicit alignment. */
html:lang(ar) {
  text-align: left;
}

/* Original Arabic prose can also appear on a French page. Its reading direction
   stays RTL, while its alignment follows the shared physical presentation.
   Zero specificity lets explicit component centre/right alignments win. */
:where(
  :is(h1, h2, h3, h4, h5, h6, p, li, dt, dd, summary, figcaption, blockquote, a)[dir="rtl"],
  .op-description[dir="rtl"], .work-original-body[dir="rtl"]
) {
  text-align: left;
}

/* plaintext resolves the reading order of each text paragraph without changing
   the direction used by flex, grid, positioning, or logical box properties.
   The whole selector has zero specificity so explicit component isolation wins.
   Explicit LTR values (email, numbers, dates) and bdi contents stay isolated. */
:where(html:lang(ar) :is(
  h1, h2, h3, h4, h5, h6, p, li, dt, dd, label, legend,
  span, strong, small, a, button, option, input, textarea, output, th, td,
  [role="status"], [role="alert"]
):not([dir="ltr"], bdi *, input:is(
  [type="email"], [type="url"], [type="tel"], [type="number"],
  [type="password"], [type="date"], [type="time"], [type="datetime-local"],
  [type="month"], [type="week"]
))) {
  unicode-bidi: plaintext;
}

/* Keep technical values readable in their native order, including fields added
   by client code. No text alignment is imposed on the control. */
html:lang(ar) :where(input:is(
  [type="email"], [type="url"], [type="tel"], [type="number"],
  [type="password"], [type="date"], [type="time"], [type="datetime-local"],
  [type="month"], [type="week"]
)) {
  direction: ltr;
  unicode-bidi: isolate;
}
