/* =====================================================================
   Urdu / RTL support
   The layout mirrors through logical properties; this file only adjusts
   typography, line-height and the handful of physical rules that remain.
   ===================================================================== */

[lang='ur'], [dir='rtl'] {
  font-family: var(--font-ur);
  line-height: 2.05;                 /* Nastaliq needs generous leading */
  letter-spacing: 0;
}

[dir='rtl'] body { font-family: var(--font-ur); }

/* Keep Latin/numeric content readable inside an RTL page */
[dir='rtl'] .mono,
[dir='rtl'] .num,
[dir='rtl'] .kpi-value,
[dir='rtl'] .m-cell,
[dir='rtl'] code,
[dir='rtl'] input[type='email'],
[dir='rtl'] input[type='password'],
[dir='rtl'] input[type='tel'],
[dir='rtl'] input[type='number'],
[dir='rtl'] input[type='date'],
[dir='rtl'] input[type='month'],
[dir='rtl'] .dp-input,
[dir='rtl'] .dp-day {
  font-family: var(--font);
  line-height: 1.5;
  direction: ltr;
  text-align: start;
}
[dir='rtl'] td.num, [dir='rtl'] th.num { direction: ltr; text-align: end; }

/* Headings and labels need slightly tighter leading than body Nastaliq */
[dir='rtl'] h1, [dir='rtl'] h2, [dir='rtl'] h3, [dir='rtl'] h4 { line-height: 1.85; }
[dir='rtl'] .label,
[dir='rtl'] .kpi-label,
[dir='rtl'] table.tbl th,
[dir='rtl'] .badge,
[dir='rtl'] .tab,
[dir='rtl'] .nav-item { line-height: 1.9; letter-spacing: 0; }

/* Uppercase transforms are meaningless in Urdu */
[dir='rtl'] .label,
[dir='rtl'] .kpi-label,
[dir='rtl'] .upper,
[dir='rtl'] table.tbl th,
[dir='rtl'] .card-head .sub,
[dir='rtl'] .nav-group-label { text-transform: none; letter-spacing: 0; }

/* Form controls and text blocks flip */
[dir='rtl'] .input,
[dir='rtl'] .textarea,
[dir='rtl'] .select { text-align: right; }
[dir='rtl'] .input.ltr, [dir='rtl'] .input[type='email'] { text-align: left; direction: ltr; }

/* Elements that must not mirror */
[dir='rtl'] .chart-box canvas,
[dir='rtl'] .qr,
[dir='rtl'] .receipt-sheet .qr { direction: ltr; }

/* Timeline marker sits on the right in RTL */
[dir='rtl'] .timeline { padding-inline-start: var(--sp-5); }

/* Arabic scripture always renders RTL with the Amiri face */
.arabic, .sidebar-quote, .quote-card .arabic {
  font-family: var(--font-arabic);
  direction: rtl;
  line-height: 2.1;
}

/* Calendar chrome: Nastaliq month and weekday names need their own leading,
   while the day numbers stay Latin (handled above). */
/* Nastaliq is too tall for a native <select> and for a 36px weekday cell —
   Chrome clips the ascenders whatever the height. These two spots fall back to
   a naskh face, which is compact and still reads as Urdu. */
[dir='rtl'] .dp-title, [dir='rtl'] .dp-week, [dir='rtl'] .dp-cell {
  font-family: 'Segoe UI', 'Noto Naskh Arabic', 'Noto Sans Arabic', var(--font);
  line-height: 1.4;
}
[dir='rtl'] .dp-title { font-size: .9rem; }
[dir='rtl'] .dp-week { text-transform: none; letter-spacing: 0; font-size: .7rem; }
[dir='rtl'] .dp-week span { min-height: 20px; display: grid; place-items: center; }
[dir='rtl'] .dp-link { line-height: 1.9; }

/* The trilingual constitution blocks: the Urdu body stays Nastaliq, but the
   small language chip switches to a naskh face, which stays legible at 11px. */
[dir='rtl'].tri-part .tri-tag, .tri-part[dir='rtl'] .tri-tag {
  font-family: 'Segoe UI', 'Noto Naskh Arabic', 'Noto Sans Arabic', var(--font);
  font-size: .72rem;
  line-height: 1.6;
}

/* Urdu name rendering inside otherwise-English tables */
.ur-text { font-family: var(--font-ur); direction: rtl; display: inline-block; line-height: 1.9; }

/* Mixed-direction safety for phone numbers and IDs */
.ltr { direction: ltr; unicode-bidi: isolate; }
.rtl { direction: rtl; unicode-bidi: isolate; }

/* Larger tap/reading size for Urdu body copy on small screens */
@media (max-width: 620px) {
  [dir='rtl'] body { font-size: 15px; }
  [dir='rtl'] .text-sm { font-size: .86rem; }
}
