/*
 * ZidniHAJJ: right-to-left pages (Urdu, Arabic).
 * Loaded after style.css only when the page language is ur or ar (<html lang="ur|ar" dir="rtl">); English and
 * Indonesian pages never load it. Contract: content/site-i18n/SPEC.md.
 *
 * How it is built
 * - Faces and line spacing follow each element's own language (:lang), so English fragments inside a page
 *   (an untranslated answer or post marked lang="en" dir="ltr") keep the English look.
 * - Margins, paddings, borders and text alignment are mirrored with logical properties (inline-start/-end).
 *   Those follow each element's own direction, so an English fragment with dir="ltr" falls back to style.css.
 * - Positions, transforms and gradients have no logical form; they are mirrored under [dir="rtl"]. They all
 *   belong to the page frame (header, film, rail, guide), never to an English fragment.
 * - Numbers stay Western digits (1, 2, 3); nothing here changes them.
 */

/* ==========================================================================================================
   1. Faces
   Urdu: Nastaliq for reading text and headings (--urdu, declared in style.css).
   Arabic: the device's own Arabic face for reading text (--arabic), Amiri for headings (--arab, served from
   this site). Any element with a lang attribute takes the faces of its own language; English and Indonesian
   fragments get the site's Latin faces back (the same stacks as --body and --head in style.css).
   ========================================================================================================== */
[lang]:lang(ur){--body:var(--urdu);--head:var(--urdu)}
[lang]:lang(ar){--body:var(--arabic);--head:var(--arab)}
[lang]:not(:lang(ur)):not(:lang(ar)){--body:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,sans-serif;--head:'Marcellus',Georgia,'Times New Roman',serif}
/* zero specificity: any rule in style.css that names a face still wins, and resolves to the right language */
:where([lang]){font-family:var(--body)}
:where([lang]:not(:lang(ur)):not(:lang(ar))){line-height:1.6}

/* ==========================================================================================================
   2. Line spacing and sizes
   Nastaliq is tall and slanted: reading text needs a line height of about 2, and headings read larger than
   their size, so Urdu headings are set a little smaller. Arabic needs room for its marks above and below.
   ========================================================================================================== */
body:lang(ur){line-height:2}
body:lang(ar){line-height:1.8}
:is(h1,h2,h3,h4):lang(ur){line-height:1.75}
:is(h1,h2,h3,h4):lang(ar){line-height:1.5}
/* Amiri is served in bold only: ask for it, so no browser tries to thin it */
:is(h1,h2):lang(ar),:is(.chapter h3,.rules h3,.ask h3,.ag-box h3,.ag-help h3,.ag-stage__head h3,.cat>summary,.yt__title):lang(ar){font-weight:700}
/* Numbers in circles (booking steps, guide chips, screen numbers) keep the Latin display face: they are Western digits */
:is(.step__n,.ag-chip i,.ag-screen>h4 span){font-family:'Marcellus',Georgia,'Times New Roman',serif}
/* Arabic pages load the full Amiri for their other headings anyway: the stage names use it too, rather than
   also fetching the small 'Amiri Names' cut that style.css gives them on the other pages. Urdu pages keep the small cut. */
:root:lang(ar) :is(.chapter__ar,.chapter h3 span){font-family:var(--arab)}

/* Urdu headings, about 85% of the English sizes */
.hero h1:lang(ur){font-size:calc(clamp(40px,7.2vw,88px) * .82);line-height:1.6}
.hero h1:lang(ar){line-height:1.35}
/* The Arabic hero title (the page's LCP) in a 43 KB cut of Amiri (Arabic letters, vowel marks, punctuation, and the Latin digits and
   punctuation), which header.php preloads (zh_font_preloads()). It arrives before the first paint even on a slow phone, so the title
   shows in Amiri at once and does not reflow when the 100 KB file lands (that reflow moved it by 0.05-0.14 of the screen). Same
   glyphs as Amiri; a character outside the cut falls back to the full Amiri. Made as in content/seo/BUILD-C.md. */
@font-face{font-family:'Amiri Hero';font-style:normal;font-weight:700;font-display:swap;src:url(../fonts/amiri-700-hero.woff2) format('woff2');unicode-range:U+0020,U+00A0,U+060C,U+061B,U+061F,U+0621-063A,U+0640-0652,U+0660-066D,U+0670,U+200C-200F}
@font-face{font-family:'Amiri Hero';font-style:normal;font-weight:700;font-display:swap;src:url(../fonts/amiri-700-hero-latin.woff2) format('woff2');unicode-range:U+0021,U+0028-0029,U+002C-002E,U+0030-003A,U+003F,U+00B7,U+2013-2014}
.hero h1:lang(ar){font-family:'Amiri Hero',var(--arab)}
/* The Arabic title now has "Zidni" in Latin letters (batch 1123), which the two cuts above do not hold: take them from a serif already on
   the device, so the title neither waits for the full Amiri nor shifts when it lands. Where none of these is installed, the full Amiri
   sets them, as before. */
@font-face{font-family:'Amiri Hero';font-style:normal;font-weight:700;font-display:swap;src:local('Times New Roman Bold'),local('TimesNewRomanPS-BoldMT'),local('Georgia Bold'),local('Georgia-Bold'),local('Noto Serif Bold'),local('NotoSerif-Bold'),local('Liberation Serif Bold'),local('LiberationSerif-Bold');unicode-range:U+0041-005A,U+0061-007A}
:is(.head h2,.join h2):lang(ur){font-size:calc(clamp(31px,4.4vw,52px) * .86)}
.journey__intro h2:lang(ur){font-size:calc(clamp(36px,5.6vw,70px) * .84)}
.chapter h3:lang(ur){font-size:calc(clamp(36px,5vw,58px) * .84)}
.comm h2:lang(ur){font-size:calc(clamp(25px,3vw,36px) * .88)}
.feat__body h2:lang(ur){font-size:calc(clamp(27px,3.2vw,40px) * .88);line-height:1.7}
:is(.qlib h1,.prose h1):lang(ur){font-size:calc(clamp(32px,5vw,54px) * .85)}
.upd h1:lang(ur){font-size:calc(clamp(28px,4.2vw,44px) * .86)}
:is(.qlib__h,.prose h2):lang(ur){font-size:calc(clamp(22px,2.8vw,30px) * .9)}
:is(.rules h3,.ag-box h3,.ag-help h3,.ask h3):lang(ur){font-size:calc(clamp(22px,2.3vw,29px) * .88)}
.ag-stage__head h3:lang(ur){font-size:calc(clamp(26px,3vw,38px) * .86)}
.yt__title:lang(ur){font-size:calc(clamp(26px,4vw,48px) * .84)}
:is(.card h3,.step h3,.season h3):lang(ur){font-size:18px}

/* Small print: Nastaliq under 14px is hard to read (style.css sets 12.5 to 14px on these) */
:is(.card__when,.chapter__cap,.person small,.season .note,.join .note,.foot__fine,.foot__base,.qtopic span,.crumbs,.filmbtn,
    .vid figcaption span,.ag-chip small,.ag-shot figcaption,.ag-tile,.ag-lb__hint,.ag__meta):lang(ur){font-size:14.5px}

/* Reading text: Urdu at 2, Arabic at 1.8 (style.css sets 1.3 to 1.55 on these) */
:is(.status,.hero__lead,.rules li,.ag-do li,.ag-why li,.ag-ready label,.ag-fields dd,.ag-ex,.ag-call,.ag-note,.ag-shot figcaption,.fiqhnote,.qa__a,.ag__meta):lang(ur){line-height:2}
:is(.status,.rules li,.ag-do li,.ag-why li,.ag-ready label,.ag-fields dd,.ag-ex,.ag-call,.ag-note,.ag-shot figcaption):lang(ar){line-height:1.8}
/* Titles and one-line labels: a little tighter */
:is(.qa summary,.qa--s h2,.card h3,.step h3,.person strong,.ag-chip,.ag-tile,.ag-screen>h4,.ag-fields dt,.cat>summary,.ask h3,.ag-lb__bar,.vid figcaption strong):lang(ur){line-height:1.8}
:is(.qa summary,.qa--s h2,.card h3,.step h3,.person strong,.ag-chip,.ag-tile,.ag-screen>h4,.ag-fields dt,.cat>summary,.ask h3):lang(ar){line-height:1.6}
@media (max-width:700px){.hero__cta .btn:lang(ur){line-height:1.7}.hero__cta .btn:lang(ar){line-height:1.5}}

/* Small labels: style.css sets them at 10.5 to 12px in spaced capitals. Arabic script has no capitals and must
   not be spaced (the letters join), so they lose both and grow a little to stay readable. */
:is(.eyebrow,.chapter__no,.group__t,.ag-stage__n):is(:lang(ur),:lang(ar)){font-size:14px}
:is(.pill,.rail a,.person span,.qa__meta,.fsel,.tag,.ag-fields__h dt,.ag-fields__h dd,.ag-ex b,.tag-en):is(:lang(ur),:lang(ar)){font-size:12.5px}
.beta:is(:lang(ur),:lang(ar)){font-size:12px}
.beta--sm:is(:lang(ur),:lang(ar)){font-size:10px}
:is(.eyebrow,.chapter__no,.group__t,.ag-stage__n,.pill,.rail a,.person span,.qa__meta,.fsel,.tag,.beta,.ag-fields__h dt,.ag-fields__h dd,.ag-ex b,.tag-en,.cat__n):lang(ur){line-height:1.9}
:is(.eyebrow,.chapter__no,.group__t,.ag-stage__n,.pill,.rail a,.person span,.qa__meta,.fsel,.tag,.beta,.ag-fields__h dt,.ag-fields__h dd,.ag-ex b,.tag-en):lang(ar){line-height:1.6}
.lang__cur[data-short]:lang(ur)::before{font-size:15px}

/* ==========================================================================================================
   3. No spaced capitals, no slanted letters
   letter-spacing breaks the joins between Arabic-script letters, and capitals do not exist (they would only
   turn a Latin word inside, like "Nusuk", into "NUSUK"). Italic is not used in Arabic script.
   ========================================================================================================== */
:is(h1,h2,h3,h4,.eyebrow,.pill,.chapter__no,.rail a,.group__t,.person span,.qa__meta,.fsel,.fsel select,.tag,.beta,
    .ag-stage__n,.ag-stage__n span,.ag-stage__head h3,.ag-fields .ag-fields__h dt,.ag-fields .ag-fields__h dd,.ag-ex b,
    .qa--s h2,.btn,.ftab,.flink,.tag-en,.cat__n,.lang__btn,.res__host):is(:lang(ur),:lang(ar)){letter-spacing:0;text-transform:none}
:is(em,i,cite,dfn,var,address,.qa__note):is(:lang(ur),:lang(ar)){font-style:normal}

/* ==========================================================================================================
   4. Mirrored boxes (logical properties: they follow each element's own direction)
   Each rule clears the physical side style.css set and puts the same value on the logical side (or sets both
   sides at once with padding-inline), so a dir="ltr" fragment still gets the original.
   ========================================================================================================== */
/* questions: the "Fiqh" tag before a question, a topic's chevron, the scholars' note, the topic filters */
.tag{margin-right:0;margin-inline-end:10px}
.cat>summary .ico{margin-left:0;margin-inline-start:auto}
.fiqhnote{border-left:0;border-inline-start:3px solid var(--gold);border-radius:0;border-start-end-radius:10px;border-end-end-radius:10px}
.fsel select{padding-inline:14px 40px}
/* breadcrumbs: the slash after each link */
.crumbs a::after{margin-left:0;margin-inline-start:8px}
/* "Beta" next to the simulator links */
.beta{margin-left:0;margin-inline-start:8px}
.beta--sm{margin-left:0;margin-inline-start:5px}
/* page and post text: lists indent from the start */
.prose ul{padding-left:0;padding-inline-start:1.2em}
/* team on phones: photo then name, aligned to the start */
@media (max-width:560px){.person{text-align:start}}
/* the guide (#apply): step chips, the time after "Step 1 of 9", the screen number, the bullet lists */
.ag-chip{padding-inline:5px 14px;text-align:start}
.ag-stage__n span{margin-left:0;padding-left:0;border-left:0;margin-inline-start:14px;padding-inline-start:14px;border-inline-start:1px solid var(--hair)}
.ag-screen>h4 span{margin-right:0;margin-inline-end:10px}
.ag-do li{padding-left:0;padding-inline-start:22px}

/* ==========================================================================================================
   5. Mirrored positions, transforms and gradients (page frame only)
   ========================================================================================================== */
/* skip link: parked off the right edge, which is not the scrollable side in RTL */
[dir="rtl"] .skip{left:auto;right:-999px}
[dir="rtl"] .skip:focus{right:8px}
/* header: the switcher's list opens from its left edge (the switcher sits at the left end of the bar) */
[dir="rtl"] .lang__menu{right:auto;left:0}
/* hero: the shade sits behind the text, which now starts on the right (phones keep the top-to-bottom shade) */
@media (min-width:701px){[dir="rtl"] .hero::before{background:linear-gradient(270deg,rgba(18,14,13,.74) 0%,rgba(18,14,13,.38) 55%,rgba(18,14,13,0) 100%)}}
/* film pause button: bottom left */
[dir="rtl"] .filmbtn{right:auto;left:14px}
/* journey: the stage rail on the left edge, labels slide in from the left; the big Arabic word on the left,
   away from the chapter card, which now starts on the right */
[dir="rtl"] .rail{right:auto;left:16px}
[dir="rtl"] .rail a span{transform:translateX(-6px)}
[dir="rtl"] .rail a:hover span,[dir="rtl"] .rail a.is-on span{transform:none}
@media (max-width:700px){[dir="rtl"] .rail{left:10px}}
[dir="rtl"] .chapter__ar{right:auto;left:var(--pad)}
/* community and "ask us" panels: the gold light comes from the start side */
[dir="rtl"] .comm,[dir="rtl"] .ask{background:linear-gradient(240deg,rgba(242,200,121,.11),rgba(242,200,121,.02))}
/* films: the playlist title starts on the right; the "In English" label on a thumbnail moves with it.
   The play triangle is not mirrored, so its small optical nudge (margin-left) stays. */
[dir="rtl"] .yt__title{left:24px;right:clamp(18px,3vw,32px);text-align:right}
[dir="rtl"] .yt>.tag-en{left:auto;right:12px}
/* topic filters: the select's chevron on the left */
[dir="rtl"] .fsel select{background-position:left 12px center}
/* resources: the "opens elsewhere" arrow points up and to the left (the arrow inside is mirrored, see 6) */
[dir="rtl"] .res__go{transform:rotate(45deg)}
/* guide: list diamonds and the "Enlarge" badge */
[dir="rtl"] .ag-do li::before{left:auto;right:3px}
[dir="rtl"] .ag-zoom::after{right:auto;left:8px}
/* offer bar on larger screens: under the header at the left end */
@media (min-width:701px){[dir="rtl"] .langbar{right:auto;left:max(var(--pad),calc((100% - 1560px) / 2 + var(--pad)))}}

/* ==========================================================================================================
   6. Direction icons
   Arrows (and the paper plane) point the way the page reads. Not mirrored: the down chevron, play, pause, the
   check mark, search. Inside an English fragment (dir="ltr") they point right again.
   ========================================================================================================== */
[dir="rtl"] :is(.ico--arrow,.ico--send){transform:scaleX(-1)}
:is([dir="ltr"],[lang|="en"]) :is(.ico--arrow,.ico--send){transform:none}

/* ==========================================================================================================
   7. English stays left to right
   Untranslated answers, posts and pages come with lang="en" dir="ltr". Anything marked lang="en" without a dir
   (a name, a web address) is still isolated and runs left to right.
   ========================================================================================================== */
[dir="rtl"] [lang|="en"]:not([dir]){direction:ltr;unicode-bidi:isolate}
/* The WordPress toolbar (signed-in editors only) is styled left to right unless WordPress itself runs in a
   right-to-left locale (then it adds body.rtl and its own right-to-left styles). */
body:not(.rtl) #wpadminbar{direction:ltr}

/* ==========================================================================================================
   8. Media and zoom stay usable
   - The film button, the video thumbnails and the YouTube players work as in English (players draw their own
     controls); only the film button's corner is mirrored (5).
   - The screenshot lightbox pans a large picture: it keeps left-to-right scrolling so "zoom to the middle"
     lands in the middle. Its caption bar stays right-to-left.
   - Screenshots of the English Nusuk site keep their left-to-right crop in the step chips (style.css, unchanged).
   ========================================================================================================== */
.ag-lb__pan{direction:ltr}
/* - The drawn passport and photo examples in the guide are pictures with SVG text (the passport's bottom lines):
     SVG text follows the page direction, so they stay left-to-right or the lines run off the drawing. */
.ag-tile svg{direction:ltr}

/* Guide field tables: a Nusuk label is kept in English with the translation in brackets after it ("Previously received a visa
   to enter KSA? (…)"): let each label take its direction from its own first letters, so a final "?" stays where it belongs. */
[dir="rtl"] .ag-fields dt{unicode-bidi:plaintext}
