/* ---------------------------------------------------------------------------
   RTL adjustments.
   The layout uses logical properties throughout, so it mirrors on its own.
   Only what cannot be expressed logically is corrected here.
   --------------------------------------------------------------------------- */

html[dir="rtl"] body {
  /* Persian wants looser lines and no negative tracking. */
  letter-spacing: 0;
  line-height: var(--lh-loose);
}

html[dir="rtl"] h1,
html[dir="rtl"] h2,
html[dir="rtl"] h3,
html[dir="rtl"] h4,
html[dir="rtl"] h5,
html[dir="rtl"] h6,
html[dir="rtl"] .aps-title__text,
html[dir="rtl"] .aps-hero__titles,
html[dir="rtl"] .aps-hero__title {
  /* Negative tracking is a latin device; in Persian it collides the joined
     letterforms. Leading is tuned per level below rather than with one blanket
     value: a single 1.45 left display headings loose and detached from the text
     under them. The values were measured against the English side; Vazirmatn
     and Estedad came out within ~3% on em box, so the same numbers suit both
     and they were kept unchanged when Vazirmatn was chosen. */
  letter-spacing: 0;
  line-height: 1.35;
}
/* Display sizes need proportionally less leading than text sizes. Measured
   against English, this brings the FA/EN rendered-height ratio down from
   1.35 (hero) and 1.21 (section title) to roughly 1.10. */
html[dir="rtl"] h1,
html[dir="rtl"] .aps-hero__titles,
html[dir="rtl"] .aps-hero__title { line-height: 1.18; }
html[dir="rtl"] h2,
html[dir="rtl"] .aps-title__text { line-height: 1.28; }

/* Vazirmatn runs visually heavier than Inter at the same numeric weight, so
   the display weights are pulled back a step rather than reused as-is. */
html[dir="rtl"] h1,
html[dir="rtl"] .aps-hero__titles { font-weight: 600; }
html[dir="rtl"] h2,
html[dir="rtl"] .aps-title__text  { font-weight: 600; }
html[dir="rtl"] h3, html[dir="rtl"] h4 { font-weight: 500; }

/* Persian body text wants the looser measure, not the latin 1.7. */
html[dir="rtl"] .aps-hero__sub,
html[dir="rtl"] .aps-overview__text p { line-height: var(--lh-loose); }


/* Uppercase does nothing in Persian and hurts legibility. */
html[dir="rtl"] .aps-nav__list a,
html[dir="rtl"] .aps-footer__heading,
html[dir="rtl"] .aps-footer__label,
html[dir="rtl"] .aps-lang__item,
html[dir="rtl"] .aps-sub,
html[dir="rtl"] .aps-contact__label,
html[dir="rtl"] .aps-project__meta dt,
html[dir="rtl"] .aps-project__ref,
html[dir="rtl"] .aps-hero__cue,
html[dir="rtl"] .aps-todo,
html[dir="rtl"] h6 {
  text-transform: none;
  letter-spacing: 0;
}

html[dir="rtl"] .aps-title__rule,
html[dir="rtl"] .aps-footer__heading::after,
html[dir="rtl"] .aps-vm__label::after {
  margin-inline-start: 0;
  margin-inline-end: auto;
}

/* The burger bars are drawn with transforms, which do not flip on their own. */
html[dir="rtl"] .aps-burger__bar::before,
html[dir="rtl"] .aps-burger__bar::after { inset-inline-start: auto; inset-inline-end: 0; }

/* Numerals stay LTR so phone numbers and refs remain readable and dialable. */
html[dir="rtl"] .aps-footer__contact a,
html[dir="rtl"] .aps-num {
  direction: ltr;
  unicode-bidi: embed;
  display: inline-block;
}

/* Progress bar grows from the right. */
html[dir="rtl"] .aps-progress {
  inset-inline-start: auto;
  inset-inline-end: 0;
}
