/* Arabic (RTL) layer, loaded after page styles on /ar/ pages only (see Base.astro).
   Arabic type is Readex Pro (SIL OFL, assets/fonts/readex-pro-OFL.txt), cut to the Arabic blocks and set as two
   static instances: wght 320 (its stroke matches Ataero 400) serves weights up to 450, wght 500 serves 451 and up.
   Rules here are either typography for every Arabic page or RTL fixes for the shared chrome (header, menus,
   footers, skip link). Page-specific Arabic overrides belong to the page: prefix them with :root[lang=ar] plus a
   page class and they outrank everything below (the strongest selectors here are 0,2,3). */

/* The regular Arabic face is also registered under Ataero at weight 400, limited to Arabic code points. Faces with
   identical descriptors form one composite family, so every existing rule that says font-family:Ataero draws Arabic
   in Readex Pro and Latin in Ataero without any selector changing. (It must be exactly 400 like the Latin face: a
   weight range would split the set and Latin would drop to Arial. Ataero text set bolder than 450 therefore gets
   synthetic bold Arabic; use var(--font-arabic) where a heavier Arabic weight matters.) */
@font-face { font-family:Ataero;src:url('/assets/fonts/readex-pro-arabic-regular.woff2') format('woff2');font-weight:400;font-style:normal;font-display:swap;
  unicode-range:U+0600-06FF,U+0750-077F,U+0870-08FF,U+FB50-FDFF,U+FE70-FEFF,U+200C-200F,U+25CC; }
@font-face { font-family:"Bahr Arabic";src:url('/assets/fonts/readex-pro-arabic-regular.woff2') format('woff2');font-weight:100 450;font-style:normal;font-display:swap;
  unicode-range:U+0600-06FF,U+0750-077F,U+0870-08FF,U+FB50-FDFF,U+FE70-FEFF,U+200C-200F,U+25CC; }
@font-face { font-family:"Bahr Arabic";src:url('/assets/fonts/readex-pro-arabic-medium.woff2') format('woff2');font-weight:451 900;font-style:normal;font-display:swap;
  unicode-range:U+0600-06FF,U+0750-077F,U+0870-08FF,U+FB50-FDFF,U+FE70-FEFF,U+200C-200F,U+25CC; }

:root[lang=ar] {
  --font-arabic:"Bahr Arabic",Ataero,"Geeza Pro","Segoe UI",Tahoma,sans-serif;
  /* Arabic needs more room between lines than Latin: tall ascenders (ا ل ك), deep tails (ي ج ع) and dots. */
  --ar-leading-display:1.32;
  --ar-leading-heading:1.45;
  --ar-leading-body:1.85;
}
/* Beats the old html[lang=ar] body { font-family:Tahoma } in styles.css. */
:root[lang=ar] body { font-family:var(--font-arabic);line-height:var(--ar-leading-body); }
:root[lang=ar] :is(input,textarea,select,button) { font-family:inherit; }

/* Arabic letters join, so tracking breaks words apart; Arabic has no case, and text-transform only mangles the
   Latin brand names inside it. This holds for every element that inherits lang=ar; an explicit lang=en island keeps
   its tracking. Synthetic italics slant Arabic badly, so emphasis stays upright. */
:root[lang=ar] :lang(ar) { letter-spacing:0 !important;text-transform:none !important; }
:root[lang=ar] :lang(ar) :is(em,i,cite) { font-style:normal; }

html:root[lang=ar] body :is(h1,.display) { line-height:var(--ar-leading-display); }
html:root[lang=ar] body :is(h2,h3,h4) { line-height:var(--ar-leading-heading); }
html:root[lang=ar] body :is(p,li,dd,blockquote,figcaption) { line-height:var(--ar-leading-body); }
/* English headings break anywhere to avoid overflow; that would split Arabic words mid-join, so break only
   words that cannot fit a line at all. */
:root[lang=ar] :is(body,main,h1,h2,h3) { overflow-wrap:break-word; }
/* Email addresses and phone numbers keep their own direction inside Arabic sentences. */
:root[lang=ar] :is(a[href^="mailto:"],a[href^="tel:"]) { unicode-bidi:plaintext; }

/* ---------- Shared chrome ---------- */

/* Skip link starts at the reading edge (styles.css and service-pages.css pin it to the left). */
:root[dir=rtl] .skip-link { left:auto;inset-inline-start:1rem; }

/* Header: the bar is flex, so it mirrors by itself. The nav labels need Arabic-sized type. */
:root[dir=rtl] .bahr-header .nav-heading { font-size:.8125rem; }
:root[dir=rtl] .bahr-header .header-nav .nav-panel a { padding-inline:.5rem .75rem; }
@media(min-width:701px) {
  /* The arrow that slides in on the chosen row points and travels toward the reading end. */
  :root[dir=rtl] .bahr-header .header-nav .nav-panel a::after { content:"←";translate:6px 0; }
  :root[dir=rtl] .bahr-header .header-nav .nav-panel a:is(:hover,:focus-visible)::after,
  :root[dir=rtl] .bahr-header .header-nav .nav-panel .nav-overview::after { translate:0 0; }
}
/* Header crest: brand-system.css already flips the crest (::before) and moves it with logical insets. The water
   behind it (::after) grows from the start edge; flipping it too anchors its pattern at the right and makes the
   drift run with the crest instead of against it. */
@supports (animation-timeline:scroll()) {
  @media (prefers-reduced-motion:no-preference) and (not (forced-colors:active)) {
    :root[dir=rtl] .bahr-header::after { transform:scaleX(-1); }
  }
}

/* Footers. Home footer copy uses a system-ui stack in redesign.css and right alignment for the copyright. */
:root[dir=rtl] .bahr-home .home-footer { font-family:var(--font-arabic);font-size:.8125rem; }
:root[dir=rtl] .bahr-home .home-footer>span { text-align:end; }
:root[dir=rtl] .footer-top a:last-child { text-align:end; }
@media(max-width:900px) { :root[dir=rtl] .footer-top a:last-child { text-align:start; } }

/* Arrows. Arabic markup writes the mirrored glyph itself (← for →, ↖ for ↗, ↙ for ↘; ↑ ↓ stay), so only
   motion needs flipping here: hover nudges travel up and toward the reading end. */
:root[dir=rtl] .bahr-home .home-pathways a:hover .home-arrow,
:root[dir=rtl] .home-pathways a:focus-visible .home-arrow,:root[dir=rtl] .home-link:focus-visible span,
:root[dir=rtl] :is(.portfolio-card,.portfolio-contact-link):is(:hover,:focus-visible) .arrow-icon { transform:translate(-2px,-2px); }

/* service-pages.css nudges .action arrows 3px right on hover; in Arabic the arrow points left, so it moves left. */
@media (hover:hover) and (pointer:fine) and (prefers-reduced-motion:no-preference) {
  :root[dir=rtl] .action:hover > span[aria-hidden="true"] { transform:translateX(-3px); }
}
