/* ====================================================================
   RTL / Arabic overrides. Loaded ONLY by ar/index.html, after
   styles.css and desktop.css, so everything here is additive: the
   English page never loads this file and is completely unaffected.

   Technique: `html`/`body` get `direction: rtl` below, and that alone
   is enough to mirror every flex row and grid in styles.css/desktop.css
   (title+logo, badge+text, footer icons, the mandate/fluent/credential/
   arc grids): `flex-direction: row` and CSS Grid's column order are
   both direction-aware, so a plain `row`/grid with no extra CSS already
   lays the DOM-first child out on the right under direction: rtl. Adding
   `row-reverse` on top (an earlier mistake here, caught by testing) is
   a DOUBLE reversal that puts things back in LTR order, so none of
   these two-sided layouts need touching at all. What direction: rtl
   does NOT fix automatically is anything using a physical left/right
   property (position: absolute; left: ...) or an explicit text-align:
   left in the base stylesheet, since neither is direction-aware; those
   are overridden individually below. Native Unicode bidi handles the
   English-in-parentheses case (e.g. "جامعة بنسلفانيا (University of
   Pennsylvania)") automatically: no extra markup needed either.
   ==================================================================== */

:root {
  --serif: "Noto Serif Arabic", Georgia, serif;
  --sans: "IBM Plex Sans Arabic", -apple-system, BlinkMacSystemFont, sans-serif;
}

html {
  direction: rtl;
  /* Arabic needs slightly larger body text for legibility; this bumps
     every rem-based size in styles.css proportionally (desktop.css's
     px-based sizes are bumped individually further down). */
  font-size: 17px;
}

body {
  direction: rtl;
}

/* .track's children (the 9 frames) are positioned by JS
   (translateX(-current * viewportWidth)) on the assumption that they
   lay out physically left-to-right, frame0 first - exactly like the
   English page. Direction is inherited, so without this the frames
   would re-stack right-to-left under the page's direction: rtl,
   silently breaking that math (advancing would translate into empty
   space instead of the next frame). Keeping .track itself ltr
   preserves the physical layout the carousel math depends on; .frame
   immediately resets to rtl so each frame's OWN content (text, pills,
   icon rows) still reads and mirrors correctly for Arabic. */
.track {
  direction: ltr;
}

.frame {
  direction: rtl;
}

p,
li,
h1,
h2,
h3 {
  text-align: right;
}

/* ---------- Mobile: Frame 1 cover ---------- */
.tap-hint {
  right: auto;
  left: 24px;
}

/* ---------- Mobile: Frame 7 vertical timeline. The connector line and
   dot are a physical border-left + left: -5px in styles.css, which
   direction: rtl does not touch (same category of fix as .tap-hint
   above): left as-is, the line stays pinned to the screen's left edge
   while the now-right-aligned Arabic text sits far away from it,
   stranding the marker from the text it belongs to. Flipping both to
   the right edge puts the line and dot immediately beside the text,
   matching how they hug it in the English version. ---------- */
.arc-item {
  border-left: none;
  border-right: 2px solid var(--line);
  padding-left: 0;
  padding-right: 14px;
}

.arc-item::before {
  left: auto;
  right: -5px;
}

/* ---------- Arabic pill component for Frames 2-4 (mobile and
   desktop): the pill is a callout for the FIGURE only (e.g. "30%",
   "3 سنوات"); the rest of the line is ordinary prose next to it, not
   wrapped inside the pill. A grid, not a flex row, for the same
   reason as the English desktop pills it's modeled on: a plain
   row gives each pill only its own content's width, so a short "10%"
   pill and a long "6 مليون دولار" pill in the same frame would end up
   different sizes; a shared "auto" grid column sizes to the WIDEST
   pill in that frame and (via Grid's default justify-items: stretch)
   stretches every pill in the list to that same shared width, which
   is what makes them read as one clean column instead of a ragged
   row of differently-sized pills. .ar-pill-row is `display: contents`
   so its pill + prose land directly in the parent grid's two columns.
   Column order: with the list inheriting direction: rtl from the
   page, grid column 1 (the pill, placed first in DOM) lands on the
   RIGHT and column 2 (the prose) on the left, with no row-reverse
   needed (same lesson learned elsewhere in this file: row-reverse on
   an already-rtl container double-reverses). Each pill's own `dir`
   is set per-string in the markup: digit-first figures ("30%", "$2.5
   مليون") get dir="ltr" so the number and any symbol stay anchored in
   reading order; Arabic-led or grammatically word-first figures
   ("سنة واحدة", "٤ سنوات") get dir="rtl" with any embedded Western
   digit wrapped in its own dir="ltr" span. */
.ar-pill-list {
  list-style: none;
  margin: 22px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 16px;
  row-gap: 20px;
  align-items: center;
}

.ar-pill-row {
  display: contents;
}

.ar-pill {
  grid-column: 1;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-width: 120px;
  box-sizing: border-box;
  background: #15284b;
  color: #faf7f2;
  font-family: var(--sans);
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 999px;
  white-space: nowrap;
  font-variant-numeric: lining-nums;
}

.ar-pill-prose {
  grid-column: 2;
  font-size: 1.1rem;
  color: #1a1a1a;
  line-height: 1.7;
  text-align: right;
}

.ar-pill-prose strong {
  color: var(--navy);
  font-weight: 700;
}

/* ---------- Mobile: Frame 5 Fluent Across, simplified for Arabic (no
   single-word word-stack display; Arabic headers are full phrases).
   Spacing model is deliberately just these three margin rules (plus
   the first-pillar override below): each pillar's own margin-top is
   the ONLY source of the gap BETWEEN pillars (generous, 32px), the
   header's margin-bottom is the ONLY source of the gap from a header
   to its own body (tight, 12px, so the pair reads as one unit), and
   the body itself carries no margin at all. Nothing else on these
   three elements sets margin or padding. */
.pillar-header {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.3rem;
}

.pillar-body {
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--charcoal);
}

.ar-frame-5 .pillar {
  margin-top: 32px;
  margin-bottom: 0;
}

.ar-frame-5 .pillar-header {
  margin-top: 0;
  margin-bottom: 12px;
}

.ar-frame-5 .pillar-body {
  margin-top: 0;
  margin-bottom: 0;
}

/* The first pillar (Clinical) needs its own, larger gap from the hero
   title above it rather than the standard inter-pillar gap. */
.ar-frame-5 .pillar:first-of-type {
  margin-top: 40px;
}

/* ---------- Mobile: Frame 9 connect grid header (explicit
   text-align: left in styles.css, which doesn't auto-flip) ---------- */
.connect-cta {
  text-align: right;
  margin-bottom: clamp(12px, 2vh, 20px);
}

/* ---------- Mobile: Frame 9 spacing. The English frame packs title,
   tagline, the three mandate blocks and the contact section close
   together at the top, which reads as cramped once this much Arabic
   text (longer than the English originals line for line) is stacked
   on a tall phone, leaving a block of unused space below the contact
   grid. clamp() grows each gap with viewport height (vh) up to a cap,
   so a tall device spreads the rhythm out instead of bunching it at
   the top; .frame-work switching from flex-start to space-between
   (the base .frame already defaults to space-between, Frame 9 opts
   out of it in styles.css) then pushes the header block and the
   contact section apart to use whatever vertical room the clamps
   didn't already claim, which is what actually reaches the bottom of
   a very tall screen rather than just capping the internal gaps. */
.frame-work {
  justify-content: space-between;
}

.work-tagline {
  margin-top: clamp(24px, 6vh, 44px);
}

.frame-work .mandate-list {
  margin-top: clamp(32px, 7vh, 56px);
  gap: clamp(20px, 4vh, 32px);
}

.contact-section {
  margin-top: clamp(28px, 6vh, 48px);
}

.cred-logo img {
  object-position: right center;
}

/* ---------- Mobile: Frame 8 credential cards. Two stacked lines per
   card: the degree name (line 1, bold navy) and the institution name
   (line 2, grey), each line itself bilingual, Arabic and English
   together separated by a pipe, rather than splitting the two
   languages across separate lines. Both scripts share the one
   Arabic-page font (var(--sans), IBM Plex Sans Arabic) and no
   explicit direction is set, same as every other Arabic-plus-English
   pairing in this file (e.g. "جامعة بنسلفانيا (University of
   Pennsylvania)"): native Unicode bidi handles a short Latin run
   embedded in the page's inherited RTL context on its own. */
.cred-cards {
  gap: clamp(16px, 3vh, 24px);
}

.cred-line-1,
.d-cred-line-1 {
  display: block;
  font-family: var(--sans);
  font-weight: 700;
  color: var(--navy);
  font-size: 1.1rem;
  line-height: 1.3;
  text-align: right;
}

.cred-line-2,
.d-cred-line-2 {
  display: block;
  font-family: var(--sans);
  font-weight: 400;
  color: #999999;
  font-size: 0.95rem;
  line-height: 1.3;
  text-align: right;
  margin-top: 4px;
}

.d-cred-line-1 {
  margin: 20px 0 0;
}

@media (min-width: 1024px) {
  /* Arabic pill list reads larger on desktop, matching the 1-2px bump
     applied to the rest of the desktop body copy below. */
  .ar-pill-list {
    margin-top: 48px;
    row-gap: 22px;
  }

  .ar-pill {
    font-size: 1.1rem;
    padding: 12px 24px;
  }

  .ar-pill-prose {
    font-size: 17px;
  }

  .d-closing {
    font-size: 19px;
  }

  /* ---------- Desktop Fluent Across: the column order already
     mirrors automatically (inherited direction: rtl), but the
     divider border is a physical border-left, so it needs flipping
     to border-right to keep landing BETWEEN columns, not on the
     outer edges. The base rule's own :first-child/:last-child zero
     out padding-left/padding-right respectively (correct for LTR,
     where those are each column's OUTER edge); under RTL those are
     each column's INNER, divider-facing edge instead, so left
     uncorrected the outer-column text sits flush against the divider
     with no breathing room at all. Restoring the padding on the
     opposite side here (same 48px the base rule already uses
     everywhere else) is what actually fixes that, not just flipping
     the border and the outer-edge reset. */
  .d-fluent-col {
    border-left: none;
    border-right: 1px solid rgba(21, 40, 75, 0.2);
  }

  .d-fluent-col:first-child {
    border-right: none;
    padding-right: 0;
    padding-left: 48px;
  }

  .d-fluent-col:last-child {
    padding-left: 0;
    padding-right: 48px;
  }

  .d-fluent-body,
  .d-mandate-desc,
  .d-number-text,
  .d-meta {
    font-size: 17px;
  }

  .d-fluent-head {
    font-size: 33px;
  }

  .d-mandate-title {
    font-size: 25px;
  }

  .d-cred-logo-wrap img {
    object-position: right center;
  }

  /* ---------- Desktop timeline: the grid's column order already
     mirrors automatically (2005 lands on the right end, 2026 on the
     left, matching the spec), but each dot marker is positioned with
     a physical `left: 0`, which needs flipping to `right: 0` to stay
     at its item's start edge (the right edge, in RTL). ---------- */
  .d-arc-dot {
    left: auto;
    right: 0;
  }

  .d-arc-years,
  .d-arc-desc {
    font-size: 17px;
  }
}
