/* ==========================================================================
   Harbour, right to left (docs/decisions/0026-right-to-left.md)

   A right-to-left page (its language's culture says so) gets BootstrapBlazor's RTL bundle, which
   mirrors every Bootstrap rule and utility: ms-/me-, ps-/pe-, text-start/-end, float-start/-end,
   start-0/end-0, offcanvas-start/-end and dropdown-menu-end all flip on their own. What it cannot
   know are Harbour's own rules that say left or right, so this file mirrors them, one block per
   source file, in that file's order.

   Every rule needs an element with dir="rtl", so this file is inert on a left-to-right page. It applies
   inside an element that carries dir="rtl" on a left-to-right page, which is how an Arabic tab in
   an English editor types right to left.

   A new rule in theme.css, admin.css, effects.css or cms.css that says left or right, or moves
   something along the x axis, needs its mirror here.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Type: Arabic in IBM Plex Sans Arabic (lib/fonts/fonts.css, an Arabic unicode-range only, so
   Latin text in the same page keeps Inter and Sora). Letter-spacing breaks the joined letters of
   Arabic script, so it is off everywhere in a right-to-left page; Harbour spaces its eyebrows,
   badges, headings and table heads, at every specificity, hence the !important.
   -------------------------------------------------------------------------- */
[dir=rtl] {
  --bs-body-font-family: "IBM Plex Sans Arabic", "Inter", system-ui, -apple-system, sans-serif;
  --hb-display: "IBM Plex Sans Arabic", var(--hb-display-latin);
  /* the moss theme's captions and serif accents (css/moss/theme.css); unused under Harbour, which has no such tokens */
  --hb-mono: "IBM Plex Sans Arabic", ui-monospace, SFMono-Regular, Menlo, monospace;
  --hb-serif: "IBM Plex Sans Arabic", Georgia, serif;
}
[dir=rtl],
[dir=rtl] * { letter-spacing: normal !important; }
/* The Arabic face has no italic, and a synthesized slant breaks the joined letters: a serif accent (moss) stays upright. */
[dir=rtl] :is(h1, h2, h3, .display-5, .display-6) em, [dir=rtl] .serif { font-style: normal; }

/* --------------------------------------------------------------------------
   Icons that point: forward is to the left. The glyph is mirrored on ::before, so it composes with
   any transform effects.css puts on the icon itself.
   -------------------------------------------------------------------------- */
[dir=rtl] :is(.bi-arrow-left, .bi-arrow-right, .bi-arrow-left-short, .bi-arrow-right-short,
  .bi-arrow-up-right, .bi-arrow-up-left, .bi-arrow-down-right, .bi-arrow-down-left,
  .bi-arrow-bar-left, .bi-arrow-bar-right, .bi-arrow-left-circle, .bi-arrow-right-circle,
  .bi-chevron-left, .bi-chevron-right, .bi-chevron-double-left, .bi-chevron-double-right,
  .bi-caret-left, .bi-caret-right, .bi-caret-left-fill, .bi-caret-right-fill,
  .bi-box-arrow-left, .bi-box-arrow-right, .bi-box-arrow-up-right, .bi-box-arrow-in-left,
  .bi-box-arrow-in-right, .bi-reply, .bi-send)::before { transform: scaleX(-1); }

/* --------------------------------------------------------------------------
   Values that read left to right in any language: e-mail addresses, phone numbers and web
   addresses keep their order, aligned to the start of the right-to-left form.
   -------------------------------------------------------------------------- */
[dir=rtl] :is(input[type=email], input[type=tel], input[type=url]) { direction: ltr; text-align: right; }

/* --------------------------------------------------------------------------
   A language tab of the other direction (TranslationTabs gives each panel its language's dir):
   its fields type that way, but the labels and help texts are the admin's own, so they keep the
   admin's direction. The two rules are the two cases: an Arabic tab in an English admin, and an
   English tab in an Arabic one.
   -------------------------------------------------------------------------- */
[dir=ltr] .hb-tabs [dir=rtl] :is(.form-label, .form-text, .alert) { direction: ltr; text-align: left; display: block; }
[dir=rtl] .hb-tabs [dir=ltr] :is(.form-label, .form-text, .alert) { direction: rtl; text-align: right; display: block; }

/* --------------------------------------------------------------------------
   BootstrapBlazor's <Table> pins a Fixed column with an inline "right: 0" whatever the direction,
   which in right to left pushes it off the scrolled edge. Every admin list pins only its last
   column, the Action column (AGENTS.md, Conventions), so that one is pinned to the left edge. A
   table with more than one fixed column would need their offsets mirrored too.
   -------------------------------------------------------------------------- */
[dir=rtl] .table .fixed-right { right: auto !important; left: 0 !important; }

/* --------------------------------------------------------------------------
   theme.css
   -------------------------------------------------------------------------- */
[dir=rtl] .dropdown-menu .dropdown-item > .bi.me-2 { margin-right: 0; }
[dir=rtl] .blob-1 { left: auto; right: -3.5rem; }
[dir=rtl] .blob-2 { right: auto; left: -5rem; }
[dir=rtl] .blob-3 { left: auto; right: 38%; }
[dir=rtl] .console-cell { border-right: 0; border-left: 1px solid var(--hb-line-soft); }
[dir=rtl] .console-cell:last-of-type { border-left: 0; }
[dir=rtl] .avatars img + img { margin-left: 0; margin-right: -.625rem; }
[dir=rtl] .media-tag { right: auto; left: .625rem; }
[dir=rtl] .plan-flag { left: auto; right: 1.75rem; }
[dir=rtl] .alert { border-left-width: var(--bs-border-width); border-right-width: 3px; }
[dir=rtl] .alert-primary { border-left-color: var(--bs-alert-border-color); border-right-color: var(--bs-primary); }
[dir=rtl] .alert-success { border-left-color: var(--bs-alert-border-color); border-right-color: var(--hb-mint-ink); }
[dir=rtl] .alert-warning { border-left-color: var(--bs-alert-border-color); border-right-color: var(--hb-lemon-ink); }
[dir=rtl] .alert-danger { border-left-color: var(--bs-alert-border-color); border-right-color: var(--hb-rose-ink); }
/* The select's arrow sits at the right edge (theme.css); in RTL that is where the text starts, so move it and the room it
   needs to the left. */
[dir=rtl] .form-select { background-position: left .75rem center; padding-left: 2.25rem; padding-right: .75rem; }
[dir=rtl] .cta-panel .blob-1 { left: auto; right: -2.5rem; }
[dir=rtl] .cta-panel .blob-2 { right: auto; left: -7.5rem; }
@media (max-width: 991.98px) {
  [dir=rtl] .console-cell { border-left: 0; }
}

/* --------------------------------------------------------------------------
   admin.css
   -------------------------------------------------------------------------- */
[dir=rtl] .adm-sidebar { left: auto; right: 0; border-right: 0; border-left: 1px solid var(--bs-border-color); }
[dir=rtl] .adm-link .badge { margin-left: 0; margin-right: auto; }
[dir=rtl] .adm-main { margin-left: 0; margin-right: var(--adm-sidebar); }
[dir=rtl] .adm-search .bi { left: auto; right: .75rem; }
[dir=rtl] .adm-search .form-control { padding-left: .75rem; padding-right: 2.25rem; }
[dir=rtl] .adm-timeline { padding-left: 0; padding-right: 1.125rem; }
[dir=rtl] .adm-timeline::before { left: auto; right: .3125rem; }
[dir=rtl] .adm-timeline li::before { left: auto; right: -.9375rem; }
@media (max-width: 1199.98px) {
  [dir=rtl] .adm-sidebar { transform: translateX(100%); }
  [dir=rtl] .adm-shell.is-nav-open .adm-sidebar { transform: none; }
  [dir=rtl] .adm-main { margin-right: 0; }
}

/* --------------------------------------------------------------------------
   effects.css
   -------------------------------------------------------------------------- */
[dir=rtl] .scroll-progress { left: auto; right: 0; background: linear-gradient(270deg, var(--hb-progress-1), var(--hb-progress-2) 50%, var(--hb-progress-3)); }
[dir=rtl] .to-top { right: auto; left: 1.25rem; }
[dir=rtl] .mega-link::after { right: auto; left: .875rem; transform: translate(.375rem, -50%) scaleX(-1); }
[dir=rtl] .mega-link:hover::after { transform: translate(0, -50%) scaleX(-1); }
[dir=rtl] :is(.btn-primary, .btn-dark, .btn-danger, .btn-light)::before { left: auto; right: -75%; transform: skewX(20deg); transition: right .8s var(--hb-ease); }
[dir=rtl] :is(.btn-primary, .btn-dark, .btn-danger, .btn-light):hover::before { left: auto; right: 125%; }
[dir=rtl] .btn:hover :is(.bi-arrow-right, .bi-chevron-right) { transform: translateX(-.1875rem); }
[dir=rtl] .btn:hover :is(.bi-arrow-left, .bi-chevron-left) { transform: translateX(.1875rem); }
[dir=rtl] .cat-tile::after { right: auto; left: 1.125rem; transform: translateX(.5rem) scaleX(-1); }
[dir=rtl] .cat-tile:hover::after { transform: scaleX(-1); }
[dir=rtl] .plan:hover .plan-list li:nth-child(odd) { transform: translateX(-.125rem); }
[dir=rtl] .marquee-track { animation-name: marquee-rtl; }
@keyframes marquee-rtl { from { transform: translateX(0); } to { transform: translateX(50%); } }
[dir=rtl] .site-foot a:hover { transform: translateX(-.1875rem); }
[dir=rtl] .adm-link:hover { transform: translateX(-.1875rem); }

/* --------------------------------------------------------------------------
   cms.css
   -------------------------------------------------------------------------- */
[dir=rtl] #blazor-error-ui .dismiss { float: left; }
