/* ══════════════════════════════════════════════
   Wireless 101 — RTL Overrides (Arabic)
   Load AFTER theme.css
   ══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&family=Noto+Kufi+Arabic:wght@400;500;600;700;800&display=swap');

html[dir="rtl"] {
  --font-display: 'Noto Kufi Arabic', 'Bricolage Grotesque', serif;
  --font-body: 'IBM Plex Sans Arabic', 'Libre Franklin', sans-serif;
}

html[dir="rtl"] body {
  font-family: var(--font-body);
  direction: rtl;
  text-align: right;
}

/* ── Navbar ── */
html[dir="rtl"] .nav-links { flex-direction: row-reverse; }

html[dir="rtl"] .nav-links a:not(.nav-cta)::after {
  left: auto;
  right: 0;
}

/* ── Section labels ── */
html[dir="rtl"] .section-label {
  flex-direction: row-reverse;
}

/* ── Hero ── */
html[dir="rtl"] .hero {
  direction: rtl;
}

html[dir="rtl"] .hero-text {
  text-align: right;
}

html[dir="rtl"] .hero-eyebrow {
  justify-content: flex-start;
  flex-direction: row-reverse;
}

html[dir="rtl"] .hero-text h1 {
  letter-spacing: 0;
}

html[dir="rtl"] .hero-buttons {
  justify-content: flex-start;
}

/* ── Course cards ── */
html[dir="rtl"] .course-header-row {
  flex-direction: row-reverse;
}

html[dir="rtl"] .course-meta {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

html[dir="rtl"] .course-meta-item {
  flex-direction: row-reverse;
}

html[dir="rtl"] .course-topic {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

html[dir="rtl"] .course-cta {
  flex-direction: row-reverse;
}

html[dir="rtl"] .course-cta-arrow svg {
  transform: scaleX(-1);
}

html[dir="rtl"] .course-cta:hover .course-cta-arrow svg {
  transform: scaleX(-1) translateX(2px);
}

/* ── Steps ── */
html[dir="rtl"] .steps-grid {
  direction: rtl;
}

html[dir="rtl"] .step-item {
  text-align: center;
}

/* ── Testimonials ── */
html[dir="rtl"] .testimonial-card::before {
  left: auto;
  right: 16px;
}

html[dir="rtl"] .testimonial-author {
  flex-direction: row-reverse;
  text-align: right;
}

html[dir="rtl"] .testimonial-stars {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

/* ── Footer ── */
html[dir="rtl"] .footer-grid {
  direction: rtl;
}

html[dir="rtl"] .footer-brand-name {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

/* ── Breadcrumb ── */
html[dir="rtl"] .breadcrumb {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

/* ── Course hero ── */
html[dir="rtl"] .course-hero-grid {
  direction: rtl;
}

html[dir="rtl"] .course-hero-meta {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

html[dir="rtl"] .course-hero-meta-item {
  flex-direction: row-reverse;
}

html[dir="rtl"] .course-hero-tags {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

/* ── Sidebar ── */
html[dir="rtl"] .sidebar-stats {
  direction: rtl;
}

/* ── Modules ── */
html[dir="rtl"] .module-header {
  flex-direction: row-reverse;
}

html[dir="rtl"] .module-meta {
  flex-direction: row-reverse;
}

html[dir="rtl"] .module-body {
  padding: 0 4.75rem 1.25rem 1.5rem;
}

html[dir="rtl"] .lesson-item {
  flex-direction: row-reverse;
}

/* ── Outcomes ── */
html[dir="rtl"] .outcome-card {
  flex-direction: row-reverse;
  text-align: right;
}

/* ── Prerequisites ── */
html[dir="rtl"] .prereq-list li {
  flex-direction: row-reverse;
}

/* ── Buttons with arrows ── */
html[dir="rtl"] .btn-primary,
html[dir="rtl"] .btn-secondary,
html[dir="rtl"] .btn-amber {
  flex-direction: row-reverse;
}

/* ── Origin quote ── */
html[dir="rtl"] .origin-quote {
  border-left: none;
  border-right: 3px solid var(--amber);
  padding-left: 0;
  padding-right: 1rem;
}

/* ── Landing page: Arabic small-label readability ── */
html[dir="rtl"] .course-topics-label,
html[dir="rtl"] .course-meta-item {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ── Landing page position flips ── */
html[dir="rtl"] .course-header::after {
  right: auto;
  left: -40px;
}

html[dir="rtl"] .cta-box::before {
  right: auto;
  left: -80px;
}

html[dir="rtl"] .cta-box::after {
  left: auto;
  right: -60px;
}

/* ── Lesson timeline (course overview) ── */
html[dir="rtl"] .timeline-track {
  padding-left: 0;
  padding-right: 2rem;
}

html[dir="rtl"] .timeline-track::before {
  left: auto;
  right: 0;
}

html[dir="rtl"] .timeline-dot {
  left: auto;
  right: -6px;
}

/* ── Lesson article timeline ── */
html[dir="rtl"] .timeline-item::before {
  left: auto;
  right: -2rem;
}

/* ── Lesson article generations arrows ── */
html[dir="rtl"] .gen-item:not(:last-child)::after {
  right: auto;
  left: -1px;
  border-left: none;
  border-right: 8px solid var(--border);
}

/* ── Lesson nav ── */
html[dir="rtl"] .lesson-nav-btn {
  flex-direction: row-reverse;
}

html[dir="rtl"] .lesson-nav-prev {
  justify-self: end;
}

html[dir="rtl"] .lesson-nav-next {
  justify-self: start;
}

html[dir="rtl"] .lesson-nav-next svg,
html[dir="rtl"] .lesson-nav-prev svg {
  transform: scaleX(-1);
}

/* ── Mathematics (KaTeX) ──
   Mathematical notation is written left-to-right in every language, including Arabic.
   KaTeX lays its atoms out in document order and relies on the inline direction to place
   them, so inheriting `direction: rtl` from <html> reverses the whole expression:
   `P₂ = { a + bx + cx² : a,b,c ∈ ℝ }` renders as `{ ℝ ∋ a,b,c : ²cx + bx + a } = ₂P`.

   This affected every Arabic article on the platform — 620 katex.render call sites across
   334 files — because neither theme.css nor theme-rtl.css carried a single .katex rule.
   Three AR decks had already patched it locally
   (ar/courses/la101/lessons/m7-l1-slides.html:101 and two siblings), which is how the
   defect was finally noticed: someone hit it, fixed their own file, and never generalised.

   NOTE: this rule covers the 172 AR *articles*, which all link this sheet. The 180 AR
   *decks* link no external CSS at all (self-contained by design), so they need the same
   rule injected inline — see scripts/fix-rtl-katex.py. Do not assume this file fixes them. */
html[dir="rtl"] .katex,
html[dir="rtl"] .katex-display {
  direction: ltr;
}

/* Display equations stay centred; KaTeX's own rule is overridden by the RTL text-align
   inherited from the page, which would otherwise push them to the right edge. */
html[dir="rtl"] .katex-display {
  text-align: center;
}

/* ── Mobile overrides ── */
@media (max-width: 900px) {
  html[dir="rtl"] .hero-text {
    text-align: center;
  }

  html[dir="rtl"] .hero-eyebrow {
    justify-content: center;
  }

  html[dir="rtl"] .hero-buttons {
    justify-content: center;
  }

}

@media (max-width: 768px) {
  html[dir="rtl"] .step-item {
    grid-template-columns: 1fr 64px;
    text-align: right;
  }

  html[dir="rtl"] .step-num {
    order: 2;
  }

  html[dir="rtl"] .module-body {
    padding: 0 1.5rem 1.25rem 1.5rem;
  }
}

/* ── Acronym glossary (article pages) ─────────────────────────────────────
   theme.css uses logical properties throughout, so only the latin-run and
   digit direction inside the panel needs stating here. The panel's slide-in
   direction is already handled by the html[dir="rtl"] .ag-panel transform. */
html[dir="rtl"] .ag-a span[lang="en"],
html[dir="rtl"] .ag-full { direction: ltr; unicode-bidi: isolate; }
html[dir="rtl"] .ag-count { direction: rtl; }
