/* Interface direction comes from html[dir] and changes with the selected language.
   Hebrew, romanisation, numbers, email, and media use their own semantic boundaries. */
:root { --interface-inline-step: 1; }
:root[dir='rtl'] { --interface-inline-step: -1; }
/* The separate scale property composes with an existing next-arrow rotation. */
html[dir='rtl'] :is(.brand-icon--directional, [data-directional='true'], .pub-mobile-sheet__back > svg, .pub-mobile-sheet__language > svg) { scale: -1 1; }

/* Arabic shaping uses the bundled StoryOlive Sans Arabic subset. Tight Latin
   display tracking and line heights do not leave enough room for its marks. */
html[lang='ar'] :is(h1, h2, h3, button, label, input, .reference-selector a):lang(ar) { letter-spacing: normal; }
html[lang='ar'] :is(h1, h2, h3):lang(ar) { line-height: 1.5; }
html[lang='ar'] :is(p, li):lang(ar) { line-height: 1.65; }
html[lang='ar'] .reader__roman:dir(rtl) { line-height: 1.6; }

/* Playback order and elapsed-time geometry are invariant across UI languages. */
.reader-audio__controls, audio, video { direction: ltr; }
.reader-audio__load { unicode-bidi: plaintext; }
html[dir='rtl'] :is(.account-switch, .reader__switch) { scale: -1 1; }
/* These decorative, looping strips animate in physical coordinates. */
.onboarding-story-track { direction: ltr; }
.onboarding-story-set :is(h2, h3, p) { unicode-bidi: plaintext; }

html[dir='rtl'] :is(.pub-nav-dropdown ul, .public-site .pub-language-selector ul) { left: auto; right: -16px; }
html[dir='rtl'] .public-site .pub-language-selector ul { right: 0; }
html[dir='rtl'] .public-site .pub-filter-menu .pub-filter-group { left: auto; right: 0; }
html[dir='rtl'] :is(.learning-language ul, .native-level-picker__error, .library-continue-info > div) { left: auto; right: 0; }
html[dir='rtl'] :is(.vocabulary-set-filter__menu, .vocabulary-save-cell .save-word-error) { left: 0; right: auto; }
html[dir='rtl'] .vocab-undo-stack { left: 24px; right: auto; }
html[dir='rtl'] .public-site .pub-preview-close { left: 15px; right: auto; }
html[dir='rtl'] .public-site .pub-bottom-carousel { margin-left: 0; margin-right: calc(50% - 50vw); }
html[dir='rtl'] .public-site .pub-bottom-carousel .pub-carousel-control { margin-left: 24px; margin-right: 0; }

/* Dialog controls sit at the trailing edge; geometry-positioned word popovers
   still use their measured viewport coordinates. */
html[dir='rtl'] .mobile-word-sheet__close { left: 10px; right: auto; }
html[dir='rtl'] .mobile-word-sheet__details { padding-right: 0; padding-left: 40px; }
html[dir='rtl'] :is(.mobile-native-close, .reader-float__close) { left: 12px; right: auto; }
html[dir='rtl'] .mobile-native-document :is(.mobile-native-meaning, .mobile-native-definition) { text-align: start; }
@media (min-width: 761px) {
    html[dir='rtl'] body:has(.numbers-page) dialog.mobile-native-tray.desktop-word-dialog { inset-inline: auto 24px; }
    html[dir='rtl'] .reader--public:not(.reader--demo) > .mobile-word-dock { left: 16px; right: auto; }
}
@media (max-width: 760px) {
    html[dir='rtl'] .vocab-undo-stack { left: 16px; right: 16px; }
    html[dir='rtl'] .vocabulary-set-filter__menu { left: auto; right: 0; }
}
