/* Page layout keeps the English physical order. The document and its prose
   retain Arabic or Hebrew direction. These rules also match client rendering. */
:root[dir="rtl"]:is([lang="ar"], [lang="he"]) body {
  text-align: left;
}

/* These two sections declare logical alignment on desktop and center the
   copy below their own layout breakpoints. Keep those mobile rules intact. */
@media (width > 800px) {
  :root[dir="rtl"]:is([lang="ar"], [lang="he"]) .v2-closing {
    text-align: left;
  }
}

@media (width > 767px) {
  :root[dir="rtl"]:is([lang="ar"], [lang="he"]) .v2-download-with-screen {
    text-align: left;
  }
}

:root[dir="rtl"]:is([lang="ar"], [lang="he"]) .site-nav :is(.site-primary-nav, .site-nav-pages),
:root[dir="rtl"]:is([lang="ar"], [lang="he"]) .site-nav > :last-child > div > div[id],
:root[dir="rtl"]:is([lang="ar"], [lang="he"]) :is(
  .site-footer, .site-footer-identity, .site-footer-links, .site-footer-socials,
  .website-analytics-panel, .website-analytics-actions,
  .v2-hero, .v2-actions, .v2-trust, .v2-feature, .v2-sharing > .v2-wrap,
  .v2-pricing, .v2-price-panel, .v2-closing, .v2-closing-copy, .v2-closing-actions,
  .site-faq-columns, .v2-help-box,
  .v2-download-with-screen, .v2-download-copy, .v2-legal-contents ol, .v2-legal-resources,
  main .grid, main .flex, main .inline-flex,
  .site-blog-grid, .site-blog-card article, .site-blog-card-body,
  .site-article-image-pair, main > div:has(> a.inline-flex), .article-share-action
) {
  direction: ltr;
}

/* Return the text children of those grids and flex rows to the page language. */
:root[dir="rtl"]:is([lang="ar"], [lang="he"]) :is(
  .site-primary-nav .site-nav-link, .site-nav-page-link > span,
  .site-footer-identity > span, .site-footer-links > a,
  .website-analytics-panel > p, .website-analytics-actions > button,
  .v2-hero-copy, .v2-feature-copy, .v2-sharing > .v2-wrap > :is(h2, p),
  .v2-sharing-grid > article > :is(h3, p), .v2-pricing-intro,
  .v2-price-panel > p, .v2-price-options > div > :is(h3, p),
  .v2-closing-copy > div, .v2-trust > span, .v2-actions > a,
  .v2-closing-actions > a, .site-faq-column, .site-faq summary > span, .v2-help-box > p,
  .v2-download-copy > p, .v2-legal-contents a, .v2-legal-resources > a,
  main .grid > div, main .flex > :is(h1, h2, h3, p, time), main .inline-flex > span,
  .site-blog-card-body > :is(h2, p), .site-blog-card-body .flex > :is(span, time),
  .site-article-image-pair figcaption, .site-article-updated, article time,
  .article-share-action > span
) {
  direction: rtl;
}

:root[dir="rtl"]:is([lang="ar"], [lang="he"]) :is(
  .site-nav-page-link, .site-nav > :last-child > div > div[id] > button
) {
  direction: ltr;
  text-align: left !important; /* The client also supplies a locale-based inline style. */
}

/* The language menu contains native labels from both writing directions. */
:root[dir="rtl"]:is([lang="ar"], [lang="he"]) .site-nav > :last-child > div > div[id] > button > .flex-1 {
  unicode-bidi: plaintext;
  text-align: left;
}

/* A few controls put an icon next to bare text. Preserve the text's base
   direction and invert only the flex axis to keep the English icon position. */
:root[dir="rtl"]:is([lang="ar"], [lang="he"]) :is(
  .v2-button, .v2-text-link:has(> :is(svg, [aria-hidden="true"])), .v2-feature-points li,
  main a.inline-flex:has(> svg):not(.article-share-action)
) {
  direction: rtl;
  flex-direction: row-reverse;
}

:root[dir="rtl"]:is([lang="ar"], [lang="he"]) :is(
  .v2-legal-contents a, .v2-support a[href^="mailto:"], a[dir="ltr"]
) {
  unicode-bidi: isolate;
}

:root[dir="rtl"]:is([lang="ar"], [lang="he"]) .v2-support a[href^="mailto:"] {
  direction: ltr;
}

/* The FAQ component supplies inline direction and uses it for its arrow. */
:root[dir="rtl"]:is([lang="ar"], [lang="he"]) .site-faq summary {
  direction: ltr !important;
}

:root[dir="rtl"]:is([lang="ar"], [lang="he"]) .site-faq :is(summary, summary + div) {
  text-align: left !important;
}

:root[dir="rtl"]:is([lang="ar"], [lang="he"]) .site-faq summary > span {
  padding-left: 0 !important;
  padding-right: 16px;
}

:root[dir="rtl"]:is([lang="ar"], [lang="he"]) .skip-link {
  left: 16px;
  right: auto;
}
