/* Persian-language presentation layer.
   Loaded only for lang="fa" pages after the shared styles. */

html[lang="fa"],
html[dir="rtl"] {
  direction: rtl;
  scroll-padding-top: 86px;
}

body.lang-fa {
  direction: rtl;
  margin: 0;
  font-family: "Vazirmatn", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  font-size: 1.01rem;
  line-height: 1.92;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.lang-fa p,
.lang-fa li,
.lang-fa span,
.lang-fa a,
.lang-fa h1,
.lang-fa h2,
.lang-fa h3,
.lang-fa strong {
  text-rendering: optimizeLegibility;
}

.lang-fa h1,
.lang-fa h2,
.lang-fa h3,
.lang-fa p,
.lang-fa li,
.lang-fa .card-link,
.lang-fa .education-content,
.lang-fa .publication-body,
.lang-fa .topic-content {
  direction: rtl;
  text-align: right;
}

/* Header: personal identity begins at the right edge; navigation and the
   compact English switch occupy the left side in one row. */
.lang-fa .nav-inner {
  direction: rtl;
  flex-direction: row;
}

.lang-fa .brand {
  order: 0;
  direction: rtl;
  flex: 0 0 auto;
  font-weight: 800;
  letter-spacing: 0;
}

.lang-fa .nav-actions {
  order: 1;
  direction: rtl;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  min-width: 0;
}

.lang-fa .nav-links {
  direction: rtl;
  flex-direction: row;
  flex-wrap: nowrap;
  white-space: nowrap;
  gap: clamp(14px, 1.45vw, 23px);
  font-size: 0.98rem;
}

.lang-fa .language-switch {
  direction: ltr;
  flex: 0 0 auto;
  white-space: nowrap;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

/* Hero: Persian copy is physically on the right, portrait on the left. */
.lang-fa .hero {
  min-height: 770px;
}

.lang-fa .hero-content {
  direction: ltr;
  grid-template-columns: minmax(350px, 0.9fr) minmax(0, 1.1fr);
  grid-template-areas: "portrait copy";
  gap: clamp(58px, 6vw, 96px);
  padding: 106px 0 88px;
}

.lang-fa .hero-copy {
  grid-area: copy;
  direction: rtl;
  text-align: right;
  justify-self: stretch;
  max-width: 720px;
}

.lang-fa .hero-portrait {
  grid-area: portrait;
  justify-self: end;
}

.lang-fa .eyebrow {
  direction: rtl;
  width: max-content;
  max-width: 100%;
  margin-right: 0;
  margin-left: auto;
  padding: 9px 14px;
  font-size: 0.97rem;
  font-weight: 500;
  line-height: 1.55;
  letter-spacing: 0;
  text-align: right;
}

.lang-fa .hero-copy h1,
.lang-fa .topic-hero h1,
.lang-fa .paper-hero h1 {
  letter-spacing: -0.025em;
}

.lang-fa .hero-copy h1 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(3.15rem, 4.55vw, 4.85rem);
  line-height: 1.2;
  word-spacing: 0.03em;
}

.lang-fa .fa-hero-line {
  display: block;
  margin-top: 0.05em;
}

.lang-fa .gradient-text {
  background: linear-gradient(90deg, #7ee0d2 0%, #89c9ff 46%, #ffffff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lang-fa .hero-subtitle {
  max-width: 680px;
  margin: 27px 0 0 auto;
  color: #bac9dc;
  font-size: clamp(1.12rem, 1.65vw, 1.33rem);
  line-height: 2.02;
}

.lang-fa .hero-actions,
.lang-fa .hero-meta,
.lang-fa .publication-meta,
.lang-fa .publication-actions,
.lang-fa .topic-terms {
  direction: rtl;
  flex-direction: row;
  justify-content: flex-start;
}

.lang-fa .hero-meta {
  gap: 10px;
}

.lang-fa .hero-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 5px 11px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: #bfd0e4;
  font-size: 0.88rem;
  white-space: nowrap;
}

/* Section headers: the heading is the first visual element on the right,
   followed by its explanatory copy on the left. Both read right-to-left. */
.lang-fa section {
  padding-top: 92px;
  padding-bottom: 92px;
}

.lang-fa .section-heading {
  direction: ltr;
  grid-template-columns: minmax(0, 1.18fr) minmax(270px, 0.82fr);
  grid-template-areas: "description title";
  gap: 54px;
}

.lang-fa .section-heading h2 {
  grid-area: title;
  direction: rtl;
  margin: 0;
  text-align: right;
  font-size: clamp(2.15rem, 3.8vw, 3.45rem);
  line-height: 1.32;
  letter-spacing: -0.02em;
}

.lang-fa .section-heading p {
  grid-area: description;
  direction: rtl;
  margin: 0;
  text-align: right;
  line-height: 2;
}

/* Research cards: 1 starts at the right, 2 remains in the center, and
   ongoing research is the third visual item on the left. */
.lang-fa #research .grid {
  direction: ltr;
}

.lang-fa #research .research-card {
  direction: rtl;
  text-align: right;
}

.lang-fa #research .research-card:nth-child(1) { grid-column: 3; grid-row: 1; }
.lang-fa #research .research-card:nth-child(2) { grid-column: 2; grid-row: 1; }
.lang-fa #research .research-card:nth-child(3) { grid-column: 1; grid-row: 1; }

.lang-fa .research-card .card-number,
.lang-fa .research-card h3,
.lang-fa .research-card p,
.lang-fa .research-card .card-link {
  width: 100%;
  direction: rtl;
  text-align: right;
}

.lang-fa .research-card h3,
.lang-fa .card h3,
.lang-fa .education-content h3,
.lang-fa .publication h3,
.lang-fa .prose-card h2 {
  line-height: 1.58;
  letter-spacing: -0.012em;
}

.lang-fa .research-card p,
.lang-fa .card p,
.lang-fa .education-detail,
.lang-fa .topic-content > p,
.lang-fa .prose-card p,
.lang-fa .abstract {
  line-height: 2.02;
}

.lang-fa .card-number,
.lang-fa .topic-kicker,
.lang-fa .education-meta,
.lang-fa .award-badge,
.lang-fa .journal-badge,
.lang-fa .related small {
  letter-spacing: 0;
  text-transform: none;
}

.lang-fa .research-visual,
.lang-fa .publication-thumb,
.lang-fa .graphical-abstract {
  direction: ltr;
}

/* Selected publications: image begins on the right; textual information
   continues toward the left while remaining right-aligned. */
.lang-fa .publication {
  direction: ltr;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  grid-template-areas: "body thumb";
}

.lang-fa .publication-thumb {
  grid-area: thumb;
}

.lang-fa .publication-body {
  grid-area: body;
  direction: rtl;
  text-align: right;
  align-items: flex-start;
}

.lang-fa .publication-meta,
.lang-fa .publication-actions {
  justify-content: flex-start;
}

.lang-fa .publication-authors {
  direction: rtl;
  text-align: right;
}

.lang-fa .pub-journal,
.lang-fa .citation-line,
.lang-fa .official-title,
.lang-fa .journal-badge,
.lang-fa pre,
.lang-fa code,
.lang-fa .education-marker {
  direction: ltr;
  unicode-bidi: isolate;
}

.lang-fa .official-title {
  max-width: 940px;
  margin-right: 0;
  margin-left: auto;
  text-align: left;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  line-height: 1.6;
}

/* About and education follow the same physical right-to-left hierarchy. */
.lang-fa .about-grid {
  direction: ltr;
  grid-template-columns: 0.8fr 1.2fr;
  grid-template-areas: "facts narrative";
}

.lang-fa .about-grid > :first-child {
  grid-area: narrative;
  direction: rtl;
  text-align: right;
}

.lang-fa .about-grid > :last-child {
  grid-area: facts;
  direction: rtl;
  text-align: right;
}

.lang-fa .fact {
  direction: rtl;
  text-align: right;
}

.lang-fa .education-list::before {
  left: auto;
  right: 18px;
}

.lang-fa .education-item {
  direction: rtl;
  grid-template-columns: 58px minmax(0, 1fr);
  padding: 24px 0 24px 26px;
}

.lang-fa .education-item::after {
  right: auto;
  left: -90px;
}

.lang-fa .education-marker {
  margin-right: 0;
  margin-left: auto;
}

.lang-fa .education-content,
.lang-fa .education-highlight {
  text-align: right;
}

/* Persian research-topic pages. */
.lang-fa .topic-hero-inner,
.lang-fa .topic-content {
  direction: rtl;
  text-align: right;
}

.lang-fa .topic-hero h1 {
  max-width: 900px;
  font-size: clamp(2.8rem, 5.4vw, 5rem);
  line-height: 1.28;
}

.lang-fa .topic-lede {
  max-width: 850px;
  margin-right: 0;
  margin-left: auto;
  line-height: 2;
  text-align: right;
}

.lang-fa .breadcrumb {
  direction: rtl;
  text-align: right;
}

.lang-fa .topic-related-grid {
  direction: ltr;
}

.lang-fa .topic-related-grid > * {
  direction: rtl;
  text-align: right;
}

/* Persian publication pages: headings occupy the right column and content
   occupies the left column on wide screens. */
.lang-fa .paper-hero {
  direction: rtl;
  text-align: right;
}

.lang-fa .paper-hero h1 {
  max-width: 980px;
  margin-right: 0;
  margin-left: auto;
  font-size: clamp(2.65rem, 5vw, 4.85rem);
  line-height: 1.24;
}

.lang-fa .paper-hero .hero-actions {
  direction: rtl;
}

.lang-fa .section-grid {
  direction: ltr;
  grid-template-columns: minmax(0, 1.28fr) minmax(240px, 0.72fr);
  grid-template-areas: "content heading";
}

.lang-fa .section-grid > h2,
.lang-fa .section-grid > div:first-child {
  grid-area: heading;
  direction: rtl;
  text-align: right;
}

.lang-fa .section-grid > .abstract,
.lang-fa .section-grid > .citation-card,
.lang-fa .section-grid > .funding-text {
  grid-area: content;
  direction: rtl;
  text-align: right;
}

.lang-fa .cards {
  direction: ltr;
}

.lang-fa .cards > :first-child {
  grid-column: 2;
  grid-row: 1;
  direction: rtl;
  text-align: right;
}

.lang-fa .cards > :last-child {
  grid-column: 1;
  grid-row: 1;
  direction: rtl;
  text-align: right;
}

.lang-fa .method-item {
  direction: rtl;
  grid-template-columns: 150px minmax(0, 1fr);
  text-align: right;
}

.lang-fa .card ul {
  padding-right: 21px;
  padding-left: 0;
}

.lang-fa .citation-card,
.lang-fa .copy-row {
  direction: rtl;
}

.lang-fa pre {
  direction: ltr;
  text-align: left;
}

/* Contact and footer. */
.lang-fa #contact .hero-actions {
  justify-content: flex-start;
}

.lang-fa .footer-inner {
  direction: rtl;
  text-align: right;
}

/* Tablet and mobile layouts preserve semantic top-to-bottom order. */
@media (max-width: 1160px) {
  .lang-fa .nav-actions {
    gap: 10px;
  }
}

@media (max-width: 1040px) {
  .lang-fa .hero-content {
    grid-template-columns: 1fr;
    grid-template-areas: "portrait" "copy";
    text-align: center;
  }

  .lang-fa .hero-portrait {
    justify-self: center;
  }

  .lang-fa .hero-copy {
    max-width: 820px;
    margin: 0 auto;
    text-align: center;
  }

  .lang-fa .hero-copy h1,
  .lang-fa .hero-subtitle {
    margin-right: auto;
    margin-left: auto;
    text-align: center;
  }

  .lang-fa .eyebrow {
    margin-right: auto;
    margin-left: auto;
  }

  .lang-fa .hero-actions,
  .lang-fa .hero-meta {
    justify-content: center;
  }
}

@media (max-width: 900px) {
  .lang-fa .section-heading,
  .lang-fa .section-grid {
    direction: rtl;
    grid-template-columns: 1fr;
    grid-template-areas: "title" "description";
    gap: 24px;
  }

  .lang-fa .section-grid {
    grid-template-areas: "heading" "content";
  }

  .lang-fa #research .research-card:nth-child(1),
  .lang-fa #research .research-card:nth-child(2),
  .lang-fa #research .research-card:nth-child(3),
  .lang-fa .cards > :first-child,
  .lang-fa .cards > :last-child {
    grid-column: auto;
    grid-row: auto;
  }

  .lang-fa .publication {
    direction: rtl;
    grid-template-columns: 1fr;
    grid-template-areas: "thumb" "body";
  }

  .lang-fa .about-grid {
    direction: rtl;
    grid-template-columns: 1fr;
    grid-template-areas: "narrative" "facts";
  }

  .lang-fa .education-item {
    grid-template-columns: 48px minmax(0, 1fr);
    padding-left: 20px;
  }
}

@media (max-width: 560px) {
  body.lang-fa {
    font-size: 0.98rem;
  }

  .lang-fa .brand span {
    font-size: 0.92rem;
  }

  .lang-fa .language-switch {
    padding: 6px 9px;
    font-size: 0.84rem;
  }

  .lang-fa .hero-copy h1 {
    font-size: clamp(2.65rem, 13vw, 3.65rem);
    line-height: 1.24;
  }

  .lang-fa .eyebrow {
    width: auto;
    font-size: 0.88rem;
  }

  .lang-fa .hero-meta span {
    font-size: 0.82rem;
  }
}
