/* Keep long reading, short titles and operating labels distinct in the Arabic edition. */
html[lang="ar"] body:not([data-page="home"]) main {
  --reading-size: clamp(1.16rem, 1.09rem + .32vw, 1.39rem);
  --intro-size: clamp(1.43rem, 1.2rem + 1.05vw, 2.15rem);
  --reading-measure: 34em;
  --reading-leading: 1.87;
}

html[lang="ar"] :where(body:not([data-page="home"]) main) :is(h1, h2, h3):lang(ar) {
  font-family: var(--arabic-reading);
  font-weight: 700;
  letter-spacing: normal;
  text-wrap: balance;
}

html[lang="ar"] :is(
  .bio-intro .bio-lead, .archive-intro-copy > p:last-child,
  .chapter-intro .chapter-lead, .project-intro > p:last-child,
  .sample-hub-heading > p, .sample-title-block .sample-deck,
  .ex-intro > p:not(.eyebrow), .dg-intro .dg-lead, .page-intro .lede
) {
  max-inline-size: 27em;
  font-family: var(--arabic-reading);
  font-size: var(--intro-size);
  font-weight: 400;
  line-height: 1.65;
  text-wrap: pretty;
}

html[lang="ar"] :is(
  .bio-chapter p:not(.bio-period), .bio-close p,
  .chapter-leaf > p:not(.chapter-word, .chapter-date),
  .chapter-evidence > p:not(.chapter-date),
  .chapter-section-head > p:not(.chapter-kicker),
  .archive-note p, .editorial-row p, .invitation .lede,
  .sample-origin > div > p, .sample-problem > p:last-child,
  .sample-step p, .sample-resolution p, .project-role, .project-evidence p,
  .document-row p, .document-section header > p
) {
  max-inline-size: var(--reading-measure);
  font-family: var(--arabic-reading);
  font-size: var(--reading-size);
  font-weight: 400;
  line-height: var(--reading-leading);
  text-wrap: pretty;
}

html[lang="ar"] :is(
  .archive-entry-meta, .archive-entry-theme, .chapter-kicker, .chapter-date,
  .chapter-cover figcaption, .chapter-year li time, .bio-period, .bio-nav,
  .sample-credit, .topic-facts dt, .project-category, .project-links, .project-jump,
  .practice-opening > a > span, .document-row summary, .document-row small,
  .document-jump, .sample-reading span, .reading-pairs article a
) {
  font-family: var(--arabic-ui);
}
html[lang="ar"] :is(.sample-meta time, .chapter-date, .chapter-year li time, .bio-period, .archive-entry-meta time) {
  font-variant-numeric: tabular-nums;
}

/* Keep the chronology in the margin and the paragraphs on a steady measure. */
html[lang="ar"] .bio-chapter h2 {
  max-inline-size: 17em;
  margin-block: .13em .42em;
  font-size: clamp(2.21rem, 1.82rem + 2.1vw, 4.15rem);
  line-height: 1.35;
}
html[lang="ar"] .bio-chapter p:not(.bio-period) { margin-block: 0 .78em; }
html[lang="ar"] .bio-links { margin-block-start: 1.5em; }

/* Present the question and both readings as a spread. The red initial in the original word is artwork. */
html[lang="ar"] .chapter-reading .chapter-section-head {
  padding-block-end: clamp(.7rem, 1.6vw, 1.5rem);
}
html[lang="ar"] .chapter-leaf blockquote {
  padding-block: .7rem .25rem;
  padding-inline: clamp(1rem, 1.9vw, 2rem) 0;
  margin-block-start: 1.75rem;
  border-inline-start-width: 2px;
}
html[lang="ar"] .chapter-leaf blockquote p {
  max-inline-size: 26em;
  font: 500 clamp(1.43rem, 1.18rem + .9vw, 2rem)/1.7 var(--arabic-reading);
}
html[lang="ar"] .chapter-leaf cite {
  font: 400 .94rem/1.65 var(--arabic-ui);
  margin-block-start: .9em;
}
.chapter-leaf .chapter-word:lang(ar) {
  width: 100%;
  overflow: visible;
  padding-block: .15em .21em;
  line-height: 1.14;
}
.chapter-word .type-art { vertical-align: middle; }
html[lang="ar"] .chapter-year li .chapter-source {
  display: inline-block;
  font-family: var(--arabic-reading);
  font-size: clamp(1.16rem, 1.06rem + .45vw, 1.46rem);
  font-weight: 500;
  line-height: 1.6;
}

/* The index scans in Sans at the edges, with title and abstract aligned in a single reading column. */
html[lang="ar"] .archive-entry-body h3 {
  font-size: clamp(1.52rem, 1.28rem + .92vw, 2.22rem);
  line-height: 1.42;
}
html[lang="ar"] .archive-entry-body p {
  max-inline-size: 36em;
  margin-block-start: .3em;
  font: 400 clamp(1.09rem, 1.03rem + .34vw, 1.3rem)/1.76 var(--arabic-reading);
}
html[lang="ar"] .archive-feature-type h2 {
  max-inline-size: 100%;
  line-height: 1.38;
}

html[lang="ar"] :is(.dg-section-head, .sample-origin, .sample-problem, .ex-head, .document-section, .project-family) h2,
html[lang="ar"] :is(.project-head h3, .editorial-row h2, .sample-title-block h1) {
  line-height: 1.4;
}
html[lang="ar"] :is(.project-question, .topic-facts dd, .ex-head > p:not(.ex-caption)) {
  max-inline-size: 32em;
  font: 500 clamp(1.22rem, 1.06rem + .71vw, 1.65rem)/1.72 var(--arabic-reading);
}
html[lang="ar"] .ex-scene-copy > p:not(.ex-caption) {
  font: 400 var(--reading-size)/1.78 var(--arabic-reading);
}
html[lang="ar"] .dg-intro h1 { max-width: none; }
html[lang="ar"] .page-intro h1:not(:has(.type-art)) {
  max-inline-size: 17em;
  font-size: clamp(2.75rem, 2rem + 3.9vw, 5.8rem);
  line-height: 1.4;
}

/* The archive and document library use small functional headings beside larger questions. */
html[lang="ar"] :is(.reading-pairs > h2, .document-examples > h3):lang(ar) {
  font: 600 1rem/1.6 var(--arabic-ui);
}
html[lang="ar"] .practice-opening strong,
html[lang="ar"] .reading-pairs article h3 {
  font: 700 clamp(1.42rem, 1.18rem + .75vw, 1.86rem)/1.55 var(--arabic-reading);
  text-wrap: balance;
}
html[lang="ar"] .sample-reading a {
  font-family: var(--arabic-reading);
  font-weight: 500;
  line-height: 1.63;
}
html[lang="ar"] .document-section header > p { max-inline-size: 26em; }

@media (min-width: 64rem) {
  html[lang="ar"] .chapter-reading .chapter-section-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: end;
    gap: .35rem clamp(1.5rem, 3vw, 3rem);
  }
  html[lang="ar"] .chapter-reading .chapter-kicker { grid-column: 1 / -1; }
  html[lang="ar"] .chapter-reading .chapter-section-head > p:last-child {
    margin: 0;
    padding-block-end: .18em;
  }
}

@media (max-width: 43rem) {
  html[lang="ar"] body:not([data-page="home"]) main { --reading-leading: 1.8; }
  html[lang="ar"] .bio-chapter h2 { margin-block-end: .38em; }
  html[lang="ar"] :is(.chapter-intro h1, .archive-intro h1) { margin-block: .65rem 1rem; }
  html[lang="ar"] .archive-entry-theme { justify-items: start; }
  html[lang="ar"] .speaking-examples .editorial-row + .editorial-row {
    border-block-start: 1px solid var(--rule);
    padding-block-start: 1.2rem;
  }
}

/* Without CSS masks, the cover still needs a cream headline on its dark background. */
@supports not ((mask-image: linear-gradient(black, black)) or (-webkit-mask-image: linear-gradient(black, black))) {
  .archive-feature-type .type-art { display: inline; width: auto; line-height: inherit; }
  .archive-feature-type .type-art-natural {
    position: static;
    overflow: visible;
    width: auto;
    height: auto;
    clip-path: none;
    white-space: normal;
  }
  .archive-feature-type .type-art-image { display: none; }
}
