/* Use the manifesto's reading size for Persian prose. In the book these
   variables come from the actual paper dimensions, including pagination probes. */
:root {
  --fa-prose: clamp(16px, 2.1vw, 20px);
  --fa-title: calc(var(--fa-prose) * 1.7);
  --fa-subtitle: calc(var(--fa-prose) * 1.3);
}

html.js[data-page="home"] {
  --fa-prose: calc(var(--locale-reference) * var(--desktop-type-scale, 1));
}

/* Standalone articles have no book shell. Match the open desktop sheet's
   1:1.6 aspect ratio, 494px reference width and available window space. */
@media (min-width: 900px) and (hover: hover) and (pointer: fine),
       (min-width: 1101px) and (pointer: fine), (min-width: 1401px) {
  :root {
    --fa-paper-width: min(100vw - 320px, 96.5vh / 1.6, (100vh - 20px) / 1.6);
    --fa-prose: max(16px, calc(var(--fa-paper-width) * 16 / 494));
  }
  @media (max-height: 550px) {
    :root { --fa-prose: 13px; }
  }
}

/* The same rules apply to the visible sheet, the measurement copy used for
   page breaks, and the linear text shown when scripting is disabled. */
html[lang="fa"] :is(.page:not(.sample-page) .page-body, #book-source) {
  font-size: var(--fa-prose);
}
html[lang="fa"] .ace-intro { --intro-copy-size: var(--fa-prose); }
.page-body.scrollable-prose {
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y pinch-zoom;
}

html[lang="fa"] :is(.page-body, #book-source) :is(
  .headline-tagline, .review-excerpt, .pullquote, .lede, .quiet, .poem,
  .gift-description, .gift-community-description, .gift-contact, .contact-email,
  .contents-row, .score-row, .manifesto-note
) {
  font-size: var(--fa-prose);
}

html[lang="fa"] :is(.page:not(.sample-page) .page-body, #book-source > section:not([data-section="sample"]))
  :is(h2, .review-brand) {
  font-size: var(--fa-title);
}
html[lang="fa"] :is(.page:not(.sample-page) .page-body, #book-source > section:not([data-section="sample"]))
  :is(h3, h4, .gift-community-heading, h2:not(.appendix-title):where(.appendix-page *)) {
  font-size: var(--fa-subtitle);
}

/* Article, industry and legal routes share the book's reading hierarchy. */
html[lang="fa"]:not([data-page="home"]) main :is(p, li, dd, blockquote, td, address) {
  font-size: var(--fa-prose);
}
html[lang="fa"]:not([data-page="home"]) main :is(h1:not([translate="no"]), h2, .ace-hero h1 > span) {
  font-size: var(--fa-title);
}
html[lang="fa"]:not([data-page="home"]) main :is(h3, h4, h5, .ace-details--manifesto > summary) {
  font-size: var(--fa-subtitle);
}

html[lang="fa"] :is(.page:not(.sample-page) .page-body, #book-source > section:not([data-section="sample"])) :is(h1, h2):not(.headline-title) {
  font-family: var(--book-heading);
  font-size: var(--book-heading-size);
  font-style: normal;
  font-weight: var(--book-heading-weight);
  line-height: var(--book-heading-leading);
  letter-spacing: var(--book-heading-tracking);
}
html[lang="fa"] :is(.page:not(.sample-page) .page-body, #book-source > section:not([data-section="sample"])) :is(h3, h4) {
  font-family: var(--book-heading);
  font-size: var(--book-subheading-size);
  font-style: normal;
  font-weight: var(--book-heading-weight);
  line-height: var(--book-subheading-leading);
  letter-spacing: var(--book-heading-tracking);
}
