/* Arabic homepage only: system Arabic fonts, full RTL, no external font requests. */
html[lang=ar] body { font-family: "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif; }
html[lang=ar] .nav-footer { display: none; }
.arabic-front { text-align: right; }
.arabic-front h1, .arabic-front h2, .arabic-front h3, .arabic-front .hero-subtitle, .arabic-front .study-strip > span:first-child { font-family: "Noto Naskh Arabic", "Geeza Pro", "Traditional Arabic", serif; letter-spacing: 0; }
.arabic-front h1 { line-height: 1.2; font-size: clamp(3.5rem, 6vw, 5.5rem); }
.arabic-front h2 { line-height: 1.6; }
.arabic-front .chapter-row h3 { line-height: 1.65; }
.arabic-front .eyebrow, .arabic-front .chapter-kicker, .arabic-front .chapter-materials, .arabic-front .hero-art p { letter-spacing: 0; }
.arabic-front .eyebrow { font-size: .85rem; }
.arabic-front .hero-description { font-size: 1.05rem; line-height: 2; }
.arabic-front .hero-note, .arabic-front .chapter-materials { font-size: .8rem; }
.arabic-front .chapter-kicker { font-size: .8rem; }
.arabic-front .chapter-description, .arabic-front .learning-note p:not(.eyebrow) { font-size: 1rem; line-height: 1.95; }
.arabic-front .primary-action, .arabic-front .text-action { font-size: .9rem; }
.arabic-front .text-action span { margin-left: 0; margin-right: 12px; }
.arabic-front .chapter-row { padding: 29px 0 29px 12px; }
.arabic-front .chapter-row:hover { padding-right: 15px; }
.arabic-front .chapter-number { font-family: inherit; }
.arabic-front .study-strip { font-size: .85rem; }
.translation-note { background: #eee9dc; border-right: 2px solid var(--brass); padding: 15px 20px; font-size: .9rem; line-height: 1.9; margin-bottom: 28px; }
.arabic-footer { display: flex; justify-content: space-between; padding: 25px 0; border-top: 1px solid var(--rule); font-size: .85rem; color: var(--muted); }
@media(max-width:640px) {
 .arabic-front h1 { font-size: 3.6rem; }
 .arabic-front .hero-art { right: auto; left: -5px; }
 .arabic-front .hero .eyebrow { letter-spacing: 0; font-size: .72rem; }
 .arabic-front .chapter-row { padding: 24px 0; }
 .arabic-front .hero-actions { gap: 14px; }
 .arabic-front .study-strip { font-size: .72rem; }
 .arabic-front .learning-note .note-small { font-size: .8rem !important; }
}

/* Keep the Arabic illustration caption readable beneath the astrolabe. */
.arabic-front .hero-art p {
  font-size: 1rem;
  line-height: 1.8;
  color: #806332;
  margin-top: 16px;
}

/* Arabic course pages: the grid follows RTL, while programs and formulas stay LTR. */
html[lang=ar] .course-reading { text-align: right; }
html[lang=ar] .course-reading h1,
html[lang=ar] .course-reading h2,
html[lang=ar] .course-reading h3,
html[lang=ar] .course-reading .subtitle,
html[lang=ar] .course-reading .course-rail-heading p {
  font-family: "Noto Naskh Arabic", "Geeza Pro", "Traditional Arabic", serif;
  letter-spacing: 0;
  line-height: 1.6;
}
html[lang=ar] .course-reading .folio-label,
html[lang=ar] .course-reading .section-label,
html[lang=ar] .course-reading #toc-title,
html[lang=ar] .course-reading .chapter-pagination a span { letter-spacing: 0; font-size: .8rem; }
html[lang=ar] .course-reading main.content { font-size: 1.05rem; line-height: 2; }
html[lang=ar] .course-reading main.content > p:first-of-type { font-family: inherit; font-size: 1.12rem; }
html[lang=ar] .course-reading .quarto-title .subtitle { font-size: 1.2rem; }
html[lang=ar] .course-reading #quarto-sidebar { padding: 20px 8px 20px 24px; }
html[lang=ar] .course-reading .course-rail-list a { font-size: .9rem; border-left: 0; border-right: 2px solid transparent; }
html[lang=ar] .course-reading .course-rail-list .rail-current a { border-right-color: var(--brass); }
html[lang=ar] .course-reading .rail-subtitle,
html[lang=ar] .course-reading .rail-back { font-size: .8rem; }
.untranslated-label { display: block; font-size: .7rem; color: var(--muted); }
html[lang=ar] .course-reading .chapter-material-nav a { font-size: .84rem; letter-spacing: 0; }
html[lang=ar] .course-reading .chapter-material-nav a:first-child { padding-left: 25px; padding-right: 0; }
html[lang=ar] .course-reading .material-card p,
html[lang=ar] .course-reading .material-action,
html[lang=ar] .course-reading .learning-objectives li,
html[lang=ar] .chapter-overview main.content > section li { font-size: .95rem; }
html[lang=ar] .course-reading .learning-objectives { border-left: 1px solid var(--rule); border-right: 3px solid var(--brass); }
html[lang=ar] .course-reading .learning-objectives ul { padding-left: 0; padding-right: 1.25rem; }
html[lang=ar] .course-reading #TOC { font-size: .82rem; }
html[lang=ar] .course-reading #TOC a { padding: 5px 12px 5px 0; }
html[lang=ar] .course-reading #TOC > ul { border-left: 0; border-right: 1px solid var(--rule); }
html[lang=ar] .course-reading .chapter-pagination a:last-child { text-align: left; }
html[lang=ar] .course-reading .chapter-pagination a strong { font-family: inherit; line-height: 1.8; }
html[lang=ar] .course-reading blockquote { border-left: 0; border-right: 2px solid var(--brass); font-family: inherit; font-size: 1rem; }
html[lang=ar] .course-reading pre,
html[lang=ar] .course-reading code,
html[lang=ar] .course-reading .sourceCode,
html[lang=ar] .course-reading .cell-output,
html[lang=ar] .course-reading .math { direction: ltr; text-align: left; unicode-bidi: isolate; }
html[lang=ar] .course-reading :not(pre) > code { display: inline-block; max-width: 100%; vertical-align: baseline; }
html[lang=ar] .course-reading table { text-align: right; }
html[lang=ar] .course-reading td[dir=ltr] { unicode-bidi: isolate; text-align: left; }
html[lang=ar] .course-reading .navbar-container { direction: ltr; }
@media(min-width:992px) {
  html[lang=ar] .course-reading #quarto-content { direction: rtl; }
}
@media(max-width:640px) {
  html[lang=ar] .course-reading .chapter-material-nav a,
  html[lang=ar] .course-reading .chapter-material-nav a:first-child { padding: 12px 4px; font-size: .75rem; }
  html[lang=ar] .course-reading #quarto-sidebar { padding: 20px; }
  html[lang=ar] .course-reading main.content { font-size: 1rem; }
  html[lang=ar] .course-reading .folio-label { font-size: .7rem; }
}

/* Arabic contents need room for full phrases, not deeply indented fragments. */
@media(min-width:1200px) {
  html[lang=ar] .chapter-document #quarto-content {
    grid-template-columns: 215px minmax(0, 1fr) 250px;
  }
}
html[lang=ar] .course-reading #quarto-margin-sidebar {
  padding-inline: 0;
  scrollbar-color: transparent transparent;
}
html[lang=ar] .course-reading #quarto-margin-sidebar:hover,
html[lang=ar] .course-reading #quarto-margin-sidebar:focus-within {
  scrollbar-color: #c5b99e transparent;
}
html[lang=ar] .course-reading #TOC {
  width: 100%;
  padding: 20px 8px 12px;
  font-size: .9rem;
  line-height: 1.85;
}
html[lang=ar] .course-reading #TOC ul {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 0;
}
html[lang=ar] .course-reading #TOC li { margin: 3px 0; }
html[lang=ar] .course-reading #TOC a {
  display: block;
  padding: 8px 12px;
  margin: 0;
  text-align: right;
  line-height: 1.85;
  border: 0;
  border-right: 2px solid transparent;
  overflow-wrap: normal;
  word-break: normal;
}
html[lang=ar] .course-reading #TOC a:hover { background: #eee9dc; }
html[lang=ar] .course-reading #TOC a.active {
  background: #eae5d8;
  border-left: 0;
  border-right: 2px solid var(--brass);
  color: var(--green);
}
html[lang=ar] .course-reading #toc-title {
  margin: 0 12px 16px;
  font-size: .85rem;
}

html[lang=ar] .course-reading .chapter-material-nav a,
html[lang=ar] .course-reading .chapter-material-nav a:first-child {
  font-size: 1.05rem;
  padding: 16px 24px;
}
@media(max-width:640px) {
  html[lang=ar] .course-reading .chapter-material-nav a,
  html[lang=ar] .course-reading .chapter-material-nav a:first-child {
    font-size: .9rem;
    padding: 14px 4px;
  }
}

/* A compact chapter directory, with enough width for natural Arabic phrases. */
@media(min-width:1200px) {
  html[lang=ar] .chapter-document #quarto-content {
    grid-template-columns: 260px minmax(0, 1fr) 250px;
  }
  html[lang=ar] .chapter-overview #quarto-content {
    grid-template-columns: 260px minmax(0, 1fr);
  }
  html[lang=ar] .course-reading #quarto-sidebar { width: 260px; }
}
html[lang=ar] .course-reading #quarto-sidebar {
  padding-inline: 8px 16px;
  scrollbar-color: transparent transparent;
}
html[lang=ar] .course-reading #quarto-sidebar:hover,
html[lang=ar] .course-reading #quarto-sidebar:focus-within {
  scrollbar-color: #c5b99e transparent;
}
html[lang=ar] .course-reading .course-rail-heading {
  padding: 0 12px 20px;
  margin-bottom: 16px;
}
html[lang=ar] .course-reading .rail-emblem {
  font-size: 2rem;
  margin-bottom: 14px;
}
html[lang=ar] .course-reading .course-rail-heading p {
  font-size: 1.4rem;
  margin: 8px 0 3px;
}
html[lang=ar] .course-reading .course-rail-list li { margin: 6px 0; }
html[lang=ar] .course-reading .course-rail-list a {
  grid-template-columns: 25px minmax(0, 1fr);
  gap: 10px;
  padding: 13px 12px;
  font-size: 1rem;
  line-height: 1.9;
}
html[lang=ar] .course-reading .rail-number {
  font-family: inherit;
  font-size: .85rem;
  padding-top: 3px;
}
html[lang=ar] .course-reading .untranslated-label {
  font-size: .72rem;
  line-height: 1.5;
  margin-top: 3px;
  opacity: .85;
}
html[lang=ar] .course-reading .rail-back {
  display: block;
  border-top: 1px solid var(--rule);
  padding-top: 18px;
  margin: 22px 12px 12px;
}

/* Match the English hero's visual hierarchy, with Arabic-safe line spacing. */
.arabic-front .arabic-mark { font-family: "Geeza Pro", Tahoma, serif; text-align: right; line-height: 1.75; }
.arabic-front .hero-subtitle { line-height: 1.6; }
.arabic-front .hero-description { line-height: 1.85; }
.arabic-front .hero-actions { gap: 25px; }
@media(max-width:640px) {
  .arabic-front .hero-actions { gap: 12px 20px; }
}

/* Match the revised English hero's scale, allowing for Arabic letterforms. */
.arabic-front h1 {
  font-size: clamp(3rem, 5vw, 4.5rem);
  line-height: 1.25;
}
.arabic-front .hero-subtitle { font-size: 1.5rem; line-height: 1.7; }
.arabic-front .hero-description { font-size: 1.125rem; line-height: 1.95; }
.arabic-front .hero .eyebrow { font-size: .9rem; }
.arabic-front .hero-note { font-size: .9rem; line-height: 1.85; }
.arabic-front .hero-actions a { font-size: 1rem; }
@media(max-width:640px) {
  .arabic-front h1 { font-size: clamp(2.5rem, 10vw, 3.25rem); }
  .arabic-front .hero-subtitle { font-size: 1.25rem; }
  .arabic-front .hero-description { font-size: 1.0625rem; }
  .arabic-front .hero .eyebrow { font-size: .8rem; }
  .arabic-front .hero-note { font-size: .85rem; }
}

/* Give Arabic curriculum details the same readable hierarchy as English. */
.arabic-front .section-intro > p,
.arabic-front .chapter-description {
  font-size: 1.0625rem;
  line-height: 1.95;
}
.arabic-front .chapter-kicker,
.arabic-front .chapter-materials,
.arabic-front .curriculum .eyebrow {
  font-size: .9rem;
  line-height: 1.8;
}
.arabic-front .study-strip { font-size: .95rem; line-height: 1.85; }
.arabic-front .translation-note { font-size: 1rem; line-height: 1.95; }
@media(max-width:640px) {
  .arabic-front .study-strip { font-size: .9rem; }
  .arabic-front .study-strip > span { max-width: 100%; }
}

/* Keep long equations within the reading column on narrow screens. */
html[lang=ar] .course-reading .math {
  display: inline-block;
  max-width: 100%;
  overflow-x: auto;
  vertical-align: middle;
}
html[lang=ar] .course-reading .math.display {
  display: block;
}

@media (max-width: 640px) {
  .arabic-front .chapter-row:hover { padding-inline: 0; }
  .arabic-front .arabic-footer { flex-direction: column; gap: 8px; }
  html[lang=ar] .course-reading .chapter-material-nav a,
  html[lang=ar] .course-reading .chapter-material-nav a:first-child {
    padding: 10px 8px; font-size: 1rem;
  }
}

/* Bootstrap's floated LTR divider otherwise lands after the Arabic label. */
@media (max-width: 991px) {
  html[lang=ar] .course-reading .quarto-secondary-nav .breadcrumb {
    direction: rtl;
    gap: 4px 8px;
    align-items: center;
    font-size: .85rem;
  }
  html[lang=ar] .course-reading .quarto-secondary-nav .breadcrumb-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    line-height: 1.6;
  }
  html[lang=ar] .course-reading .quarto-secondary-nav .breadcrumb-item + .breadcrumb-item::before {
    content: "";
    direction: ltr;
    unicode-bidi: isolate;
    float: none;
    padding: 0;
  }
  html[lang=ar] .course-reading .quarto-secondary-nav .breadcrumb-item a {
    unicode-bidi: isolate;
  }
}
