/* =========================================================
   Language support: the EN | اردو switch, Urdu typography and right-to-left layout.
   Nothing here applies to English (dir="ltr"), except the small language switch.
   ========================================================= */

/* ---------- Language switch (same look as the ghost buttons) ---------- */
.lang-switch { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface, #fff); border: 1.5px solid var(--line); }
.lang-switch[hidden] { display: none; }
.lang-switch__btn { min-width: 38px; min-height: 30px; padding: 0 10px; border-radius: 999px; font-size: 13px; font-weight: 800; color: var(--muted); line-height: 1; transition: background .2s, color .2s; }
.lang-switch__btn[lang="ur"] { font-family: "Noto Nastaliq Urdu", var(--font-body); font-weight: 600; font-size: 14px; line-height: 1.6; padding-bottom: 2px; }
.lang-switch__btn:hover { color: var(--ink); }
.lang-switch__btn.is-active { background: var(--ink); color: #fff; }
/* Small phones: show only the language you can switch TO, so the header keeps its layout */
@media (max-width: 520px) {
  .lang-switch { padding: 2px; }
  .lang-switch__btn.is-active { display: none; }
}

/* ---------- Urdu typography ---------- */
/* Latin text (names, numbers, English lessons) keeps the existing fonts; Urdu letters use Nastaliq. */
html[lang="ur"] {
  --font-body: "Plus Jakarta Sans", "Noto Nastaliq Urdu", "Segoe UI", system-ui, sans-serif;
  --font-display: "Fredoka", "Noto Nastaliq Urdu", ui-rounded, "Segoe UI", system-ui, sans-serif;
}
/* Nastaliq is tall: give Urdu lines more room so letters are not clipped */
html[lang="ur"] body { line-height: 1.9; }
html[lang="ur"] h1, html[lang="ur"] h2, html[lang="ur"] h3 { line-height: 1.6; letter-spacing: 0; }
html[lang="ur"] .nav__links a, html[lang="ur"] .panel__title, html[lang="ur"] .btn { letter-spacing: 0; }

/* ---------- Right-to-left layout (dir="rtl") ---------- */
/* Flex and grid already follow the document direction. These rules fix the places that
   use physical left/right in styles.css and learning.css. */
[dir="rtl"] .nav__links { margin-left: 0; margin-right: auto; }
[dir="rtl"] .nav__links .is-active::after { left: auto; right: 50%; margin-left: 0; margin-right: -9px; }
[dir="rtl"] .skip-link { left: auto; right: 12px; }
[dir="rtl"] .academy-card,
[dir="rtl"] .progress-row__btn,
[dir="rtl"] .pv__list,
[dir="rtl"] .login__form,
[dir="rtl"] .footer li a,
[dir="rtl"] .footer li button { text-align: right; }
[dir="rtl"] .academy-card__glow,
[dir="rtl"] .next-card::after,
[dir="rtl"] .zone__glow { right: auto; left: -90px; }
[dir="rtl"] .step__num { right: auto; left: 24px; }
[dir="rtl"] .io--out { text-align: left; }
[dir="rtl"] .modal__close { right: auto; left: 16px; }
[dir="rtl"] .am__tag { padding-right: 0; padding-left: 30px; }
[dir="rtl"] .toasts { right: auto; left: 20px; }
[dir="rtl"] .demo-tag { left: auto; right: 16px; }
[dir="rtl"] .sim__tip { border-left: 0; border-right: 4px solid #FF7A1A; }
[dir="rtl"] .ac-pager__link--next { text-align: left; }
[dir="rtl"] .welcome__art .speech { right: auto; left: 100%; margin: 0 0 0 -40px; }
[dir="rtl"] .switch::after { left: auto; right: 3px; }
@media (max-width: 960px) {
  [dir="rtl"] .nav__links a, [dir="rtl"] .nav__links button { text-align: right; }
  [dir="rtl"] .nav__actions { margin-left: 0; margin-right: auto; }
  [dir="rtl"] .ac-pager__link--next { text-align: right; }
}
/* Decorative background shapes stay where they are: they carry no meaning. */
/* Arrows that mean "next" point the other way in right-to-left reading */
[dir="rtl"] .icon-arrow-right, [dir="rtl"] [data-dir-flip] { transform: scaleX(-1); }
/* Code, prompts the learner types and numbers stay left-to-right inside Urdu pages */
[dir="rtl"] code, [dir="rtl"] pre, [dir="rtl"] input[type="number"], [dir="rtl"] .pill { direction: ltr; unicode-bidi: isolate; }

/* Mixed Urdu + English: each text block takes its direction from its own first letter.
   Untranslated English sentences keep their punctuation and numbers in the right place
   ("0 / 300 XP", "You're ... Explorer."), and Urdu text stays right-to-left. */
[dir="rtl"] :is(p, h1, h2, h3, h4, h5, h6, li, dt, dd, td, th, label, figcaption, blockquote, small, strong, em, b, span, a, button, summary, legend, option) {
  unicode-bidi: plaintext;
}
/* Translated pieces (data-i18n) must stay part of their sentence, so a heading such as
   "خوش آمدید، {name}!" keeps its Urdu (right-to-left) direction. */
[dir="rtl"] [data-i18n] { unicode-bidi: normal; }
/* The welcome banner keeps its text on the right in Urdu, clear of AIBO's speech bubble */
[dir="rtl"] .welcome__copy :is(.welcome__hello, .welcome__title, .welcome__sub) { text-align: right; }
