/*
 * Right-to-left corrections for the GHS theme (Arabic and other RTL locales).
 *
 * Loaded only when is_rtl() is true — see ghs_enqueue_assets() in functions.php.
 *
 * WHY THIS FILE EXISTS
 * --------------------
 * The templates are built with Tailwind v3 via the CDN, whose directional
 * utilities (pl-*, ml-*, left-*, right-*, text-left, border-l-*) are physical,
 * not logical: `pl-6` always means padding-left, regardless of text direction.
 * Tailwind v3 has no automatic RTL flipping, so under dir="rtl" the layout
 * would keep its left-hand padding, left-anchored decorative glows and
 * left-aligned text while the text itself ran right-to-left — visibly broken.
 *
 * Each rule below re-maps one physical utility to its logical equivalent.
 * `[dir="rtl"] .class` outranks a bare `.class` on specificity, so none of
 * this needs !important.
 *
 * MAINTENANCE
 * -----------
 * If you add a new directional utility to a template, add its mirror here.
 * To find anything missed:
 *   grep -rhoE '\b(ml|mr|pl|pr)-[a-z0-9.]+|\b-?(left|right)-[a-z0-9.]+' --include=*.php .
 */

/* ---------------------------------------------------------------
   Text alignment
   --------------------------------------------------------------- */
[dir="rtl"] .text-left  { text-align: right; }
[dir="rtl"] .text-right { text-align: left; }

@media (min-width: 1024px) {
  [dir="rtl"] .lg\:text-left  { text-align: right; }
  [dir="rtl"] .lg\:text-right { text-align: left; }
}

/* ---------------------------------------------------------------
   Padding / margin
   Lists inside post content use `pl-0` to strip the default indent;
   in RTL the indent comes from the right instead.
   --------------------------------------------------------------- */
[dir="rtl"] .pl-0 { padding-left: revert; padding-right: 0; }
[dir="rtl"] .pl-4 { padding-left: 0; padding-right: 1rem; }
[dir="rtl"] .pl-6 { padding-left: 0; padding-right: 1.5rem; }
[dir="rtl"] .pr-4 { padding-right: 0; padding-left: 1rem; }
[dir="rtl"] .pr-6 { padding-right: 0; padding-left: 1.5rem; }

[dir="rtl"] .ml-4 { margin-left: 0; margin-right: 1rem; }
[dir="rtl"] .mr-4 { margin-right: 0; margin-left: 1rem; }

/* Bulleted/numbered lists in translated post content */
[dir="rtl"] .legal-content ul,
[dir="rtl"] .legal-content ol {
  padding-left: 0;
  padding-right: 1.25rem;
}

/* ---------------------------------------------------------------
   Borders
   The accent bar on callouts and quotes must sit on the start edge.
   --------------------------------------------------------------- */
[dir="rtl"] .border-l-4 {
  border-left-width: 0;
  border-right-width: 4px;
}

/* ---------------------------------------------------------------
   Absolute positioning — decorative glows and badges
   These are the large blurred brand orbs and the corner badges. If they
   are not mirrored, the lighting falls on the wrong side of a mirrored
   layout and the composition reads as a mistake.
   --------------------------------------------------------------- */
[dir="rtl"] .left-0   { left: auto;  right: 0; }
[dir="rtl"] .right-0  { right: auto; left: 0; }
[dir="rtl"] .left-1   { left: auto;  right: 0.25rem; }
[dir="rtl"] .right-6  { right: auto; left: 1.5rem; }
[dir="rtl"] .left-20  { left: auto;  right: 5rem; }
[dir="rtl"] .right-10 { right: auto; left: 2.5rem; }
[dir="rtl"] .right-16 { right: auto; left: 4rem; }
[dir="rtl"] .right-20 { right: auto; left: 5rem; }
[dir="rtl"] .right-24 { right: auto; left: 6rem; }
[dir="rtl"] .left-32  { left: auto;  right: 8rem; }

/* Negative offsets: the off-canvas blurred orbs */
[dir="rtl"] .-left-20  { left: auto;  right: -5rem; }
[dir="rtl"] .-left-32  { left: auto;  right: -8rem; }
[dir="rtl"] .-right-6  { right: auto; left: -1.5rem; }
[dir="rtl"] .-right-10 { right: auto; left: -2.5rem; }
[dir="rtl"] .-right-16 { right: auto; left: -4rem; }
[dir="rtl"] .-right-20 { right: auto; left: -5rem; }
[dir="rtl"] .-right-24 { right: auto; left: -6rem; }

/* ---------------------------------------------------------------
   Component-level corrections
   --------------------------------------------------------------- */

/* Nav underline animation grows from the start edge */
[dir="rtl"] .nav-link::after {
  left: auto;
  right: 0;
  background: linear-gradient(270deg, #e6affc, #4f1964);
}

/* Blog thumbnail wordmark sits bottom-start */
[dir="rtl"] .thumb-tag {
  left: auto;
  right: 16px;
  letter-spacing: 0; /* tracking harms Arabic legibility — see typography note */
}

/* Grid/mesh overlays are masked toward one side; mirror the mask */
[dir="rtl"] .grid-overlay {
  -webkit-mask-image: radial-gradient(ellipse 60% 60% at 30% 30%, black, transparent 80%);
          mask-image: radial-gradient(ellipse 60% 60% at 30% 30%, black, transparent 80%);
}

/* ---------------------------------------------------------------
   Arabic typography
   --------------------------------------------------------------- */

/*
 * Sora and Manrope have no Arabic coverage, so Arabic text would fall back to
 * whatever the OS supplies — inconsistent across devices. Cairo (body) and
 * Tajawal (display) are loaded as webfonts whenever the request is under
 * /ar/ (see ghs_enqueue_assets()), so name them first; the Noto/system stack
 * remains as a fallback for the rare case that load fails. The Latin fonts
 * still apply to any Latin characters mixed in (framework names like
 * "NCA ECC" stay on-brand).
 */
[dir="rtl"] body {
  font-family: 'Cairo', 'Noto Sans Arabic', 'Segoe UI', Tahoma, 'Manrope', sans-serif;
}

[dir="rtl"] h1,
[dir="rtl"] h2,
[dir="rtl"] h3,
[dir="rtl"] h4,
[dir="rtl"] .font-display {
  font-family: 'Tajawal', 'Noto Kufi Arabic', 'Noto Sans Arabic', 'Segoe UI', 'Sora', sans-serif;
  /* The Latin headings use -0.03em tracking. Negative tracking breaks the
     connected strokes of Arabic script, so reset it. */
  letter-spacing: normal;
}

/* Uppercase transforms and wide tracking are meaningless in Arabic — it has
   no letter case, and spacing out the glyphs severs their joins. */
[dir="rtl"] .uppercase {
  text-transform: none;
  letter-spacing: normal;
}

[dir="rtl"] .tracking-wide,
[dir="rtl"] .tracking-\[0\.15em\],
[dir="rtl"] .tracking-\[-0\.03em\] {
  letter-spacing: normal;
}

/* Arabic glyphs need a little more vertical room than Latin at the same size */
[dir="rtl"] body,
[dir="rtl"] p {
  line-height: 1.9;
}
