/* GetSettle UK - Persian, Arabic and Urdu typography + RTL
   Load AFTER elevate.css on any page that carries Persian content.

   Two jobs:
     1. Give non-Latin scripts a face that can actually render them. Inter has no
        Persian glyphs, so without this the browser falls back to whatever it has
        and the page looks broken on exactly the audience we built it for.
     2. Undo the physical left/right assumptions in the shared CSS. Everything
        here uses logical properties so one rule serves both directions.

   Mobile first throughout: base rules target the phone, and the only media
   queries widen things for larger screens. */

/* ---- 1. Faces ---------------------------------------------------------- */

[lang="fa"],
[lang="ar"],
[lang="ur"],
.fa {
    font-family: 'Vazirmatn', 'Noto Naskh Arabic', 'Tahoma', sans-serif;
    /* Persian and Arabic sit lower and need more room between lines than Latin */
    line-height: 2;
}

/* Persian digits keep their proportions; stop Inter's tabular figures fighting them */
[lang="fa"],
[lang="ar"],
[lang="ur"] {
    font-variant-numeric: normal;
}

/* Latin words inside Persian text (GOV.UK, Right to Rent, share code) must not
   flip. Isolation keeps the bidi algorithm from reordering the line. */
[lang="fa"] a[href^="http"],
[lang="ar"] a[href^="http"],
.fa a[href^="http"],
.ltr-inline {
    unicode-bidi: isolate;
}

/* ---- 2. Direction ------------------------------------------------------ */

html[dir="rtl"] body {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .container,
[dir="rtl"] .prose,
[dir="rtl"] .narrow-prose {
    text-align: right;
}

/* Lists: elevate.css sets padding-left, which puts the bullets on the wrong
   side in RTL. Logical properties fix both directions at once. */
[dir="rtl"] .prose ul,
[dir="rtl"] .prose ol,
.fa ul,
.fa ol {
    padding-left: 0;
    padding-inline-start: 1.35rem;
}

[dir="rtl"] .become-buddy-benefits ul li,
[dir="rtl"] .product-list li,
[dir="rtl"] .premium-upsell ul li {
    padding-left: 0;
    padding-inline-start: 1.7rem;
}

[dir="rtl"] .become-buddy-benefits ul li::before,
[dir="rtl"] .product-list li::before,
[dir="rtl"] .premium-upsell ul li::before {
    left: auto;
    right: 0;
}

/* Blockquotes and accent rails follow the reading direction */
[dir="rtl"] .lp-quote,
[dir="rtl"] .partner-caution,
.fa .partner-caution {
    border-left: none;
    border-inline-start: 3px solid var(--accent-gold, #d4af37);
    padding-left: 0;
    padding-inline-start: .7rem;
}

/* The article date line and meta */
[dir="rtl"] .article-meta,
[dir="rtl"] .article-disclaimer {
    text-align: right;
}

/* ---- 2b. The off-canvas menu ------------------------------------------- */
/* responsive.css parks the mobile drawer at `left: -100%`. In LTR that is the
   inline-start side, which browsers do not turn into scrollable overflow. Flip
   the document to RTL and the same rule pushes it past the inline-END edge, so
   every Persian page gained a full viewport of horizontal scroll.
   Anchor it to the right instead, which is inline-start in RTL. */
@media (max-width: 968px) {

    /* Mirrors the transform-based drawer in elevate.css section 18. Sliding it
       off to the right keeps it on the inline-start side in RTL, which does not
       create horizontal scroll. Anchoring it off to the left would. */
    [dir="rtl"] #ev-header #nav-links {
        left: 0;
        right: auto;
        transform: translateX(100%);
    }

    [dir="rtl"] #ev-header #nav-links.active {
        transform: translateX(0);
    }

    [dir="rtl"] body.dark-mode .nav-links {
        border-right: none;
        border-left: 1px solid var(--border-subtle);
    }
}


/* ---- 3. Readability on a phone ----------------------------------------- */
/* Persian at Latin sizes is genuinely hard to read on a small screen. */

.fa,
[lang="fa"] {
    font-size: 1.02rem;
}

[dir="rtl"] .prose p,
.fa p {
    line-height: 2.05;
    font-size: 1.05rem;
}

[dir="rtl"] .prose h2,
.fa h2 {
    line-height: 1.6;
    letter-spacing: 0;
    /* -.02em tracking from elevate.css crushes Persian letterforms together */
}

[dir="rtl"] .prose h3,
.fa h3 {
    line-height: 1.7;
    letter-spacing: 0;
}

@media (min-width: 768px) {

    [dir="rtl"] .prose p,
    .fa p {
        font-size: 1.08rem;
    }
}

/* ---- 4. Language switch link ------------------------------------------- */

.lang-switch {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .9rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--brand-teal, #1e7f7f);
    border: 1px solid currentColor;
    border-radius: 999px;
    padding: .3rem .85rem;
    margin-bottom: 1.2rem;
}

.lang-switch:hover,
.lang-switch:focus-visible {
    background: var(--brand-teal, #1e7f7f);
    color: #fff;
}

.lang-switch:focus-visible {
    outline: 2px solid var(--accent-gold, #d4af37);
    outline-offset: 2px;
}

body.dark-mode .lang-switch,
[data-theme="dark"] .lang-switch {
    color: #6FD8CC;
}

body.dark-mode .lang-switch:hover,
[data-theme="dark"] .lang-switch:hover {
    background: #6FD8CC;
    color: #0d1615;
}
