/* World Green bilingual display repair v23.2
 * Loaded after all v23 design styles. No redesign and no content changes.
 * Fixes physical carousel direction, bidi isolation and mirrored whole links.
 */

/* Only the marquee MOTION is LTR. The surrounding section remains Arabic RTL. */
html[dir="rtl"] #clients.wg-train-section .wg-logo-train,
html[dir="rtl"] #clients.wg-train-section .wg-logo-train__track,
html[dir="rtl"] #clients.wg-train-section .wg-logo-train__group {
    direction: ltr !important;
}
html[dir="rtl"] #clients.wg-train-section .wg-logo-train {
    margin-inline: 0;
    max-width: none;
}
html[dir="rtl"] #clients .wg-logo-train__card {
    direction: rtl;
}
html[dir="rtl"] #clients .wg-logo-train__name {
    unicode-bidi: plaintext;
    text-align: center;
    overflow-wrap: anywhere;
}

/* Carousel's original JS calculates scrollLeft in LTR coordinates.
   Force LTR for the moving rail AND its arrows; keep content RTL. */
html[dir="rtl"] #projects .wg-projects__viewport,
html[dir="rtl"] #projects .wg-projects__track,
html[dir="rtl"] #projects .wg-projects__navigation {
    direction: ltr !important;
}
html[dir="rtl"] #projects .wg-project-card__body {
    direction: rtl;
    text-align: right;
}

/* V23 had transform:scaleX(-1) on the whole anchor, mirroring Arabic text.
   Undo it entirely; the arrow glyph can be mirrored in isolation. */
html[dir="rtl"] #projects a.wgpp-home-view,
html[dir="rtl"] #projects .wg-project-card__footer a {
    transform: none !important;
    direction: rtl;
    unicode-bidi: isolate;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: .45rem;
    white-space: normal;
    overflow-wrap: anywhere;
    text-decoration: none;
}
html[dir="rtl"] #projects .wgpp-home-view > span[aria-hidden="true"] {
    display: inline-block;
    transform: scaleX(-1);
    line-height: 1;
}

/* Project NAMES are English company records even on Arabic pages. */
html[dir="rtl"] #projects .wg-project-card__details h3,
html[dir="rtl"] .wgpp-card__content h3,
html[dir="rtl"] .wgpp-hero--detail h1,
html[dir="rtl"] .wgpp-detail__aside dd.wg23r-project-name {
    direction: ltr;
    unicode-bidi: isolate;
    text-align: left;
    overflow-wrap: anywhere;
    word-break: normal;
}
html[dir="rtl"] #projects .wg-project-card__details h3 {
    font-size: clamp(22px, 2.4vw, 34px);
    line-height: 1.22;
    max-width: 100%;
}
html[dir="rtl"] .wgpp-card__content h3 { font-size: clamp(24px, 2.25vw, 32px); }
html[dir="rtl"] #projects .wg-project-card__footer strong,
html[dir="rtl"] .wgpp-card__bottom strong,
html[dir="rtl"] .wgpp-detail-meta strong {
    unicode-bidi: isolate;
    overflow-wrap: anywhere;
}

/* Keep project filter control direction predictable and ensure click targets.
   Button text stays Arabic and the scroll controls remain physical left/right. */
html[dir="rtl"] #projects .wg-projects__controls { align-items: center; }
html[dir="rtl"] #projects .wg-projects__navigation button { flex: 0 0 46px; }
html[dir="rtl"] #projects .wg-projects__filters { direction: rtl; }
html[dir="rtl"] #projects .wg-project-card__footer { direction: rtl; }

/* Phone numbers, email and other technical data must NOT reverse visually. */
html[dir="rtl"] .wg23r-bidi {
    direction: ltr !important;
    unicode-bidi: isolate;
    display: inline-block;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
html[dir="rtl"] .wgn21-utility a,
html[dir="rtl"] .wgn21-drawer-contact a,
html[dir="rtl"] .wgf15-footer__contact-link { min-width: 0; }
html[dir="rtl"] .wgf15-footer__contact-link { gap: 8px; }

/* Preserve centered copyright regardless of page language. */
.wgf15-footer .wgf15-footer__bottom {
    display: flex;
    justify-content: center;
    text-align: center;
}
.wgf15-footer .wg23r-copyright {
    display: inline-block;
    direction: ltr;
    unicode-bidi: isolate;
    line-height: 1.7;
}
.wgf15-footer .wg23r-copyright bdi { unicode-bidi: isolate; }

/* Even for project-list pages, protect Latin company names from RTL reordering. */
html[dir="rtl"] .wgpp-detail__aside .wg23r-project-name {
    direction: ltr;
    text-align: left;
}

/* No sideways page scroll from a wide marquee or a filter toolbar. */
html[dir="rtl"] body { max-width: 100%; }
html[dir="rtl"] #clients { min-width: 0; }
html[dir="rtl"] .wgpp-toolbar,
html[dir="rtl"] .wg-projects__heading { min-width: 0; }

@media (max-width: 650px) {
    html[dir="rtl"] #projects .wg-projects__navigation button { flex-basis: 42px; width: 42px; height: 42px; }
    html[dir="rtl"] #projects .wg-project-card__details h3 { font-size: clamp(21px, 5.6vw, 29px); }
    html[dir="rtl"] .wgpp-card__content h3 { font-size: clamp(21px, 5.8vw, 29px); }
    html[dir="rtl"] .wgf15-footer__contact-link { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    html[dir="rtl"] #projects .wg-projects__viewport { scroll-behavior: auto; }
}

/* Critical: position:relative + left:50% + translateX(-50%) centers the
   edge-to-edge train only when its containing block uses LTR block origin.
   RTL on the SECTION made the rail start off-screen to the left. */
html[dir="rtl"] #clients.wg-train-section { direction: ltr; }
html[dir="rtl"] #clients .wg-train-heading {
    direction: rtl;
    text-align: right;
}
