/* Hand-written RTL corrections.
 *
 * tools/build-rtl-css.js mirrors every directional declaration in the theme automatically (see
 * css/rtl.css). This file holds only what a mechanical flip cannot know: Arabic typography, glyphs
 * that point somewhere, and the handful of layout rules that read wrong when mirrored blindly.
 * Loaded after rtl.css, and only when the page language is Arabic.
 */

/* ── Typography ──────────────────────────────────────────────────────────────────────────────
   The theme's Latin display faces have no Arabic coverage, so Arabic text falls back to whatever
   the browser picks and lands at a different optical size than the design. Cairo matches the
   theme's geometric weights; the stack degrades to the system Arabic UI faces if it cannot load,
   which also keeps the site readable offline. */
[dir="rtl"],
[dir="rtl"] body,
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3, [dir="rtl"] h4, [dir="rtl"] h5, [dir="rtl"] h6,
[dir="rtl"] p, [dir="rtl"] span, [dir="rtl"] a, [dir="rtl"] li,
[dir="rtl"] input, [dir="rtl"] textarea, [dir="rtl"] select, [dir="rtl"] button {
    font-family: "Cairo", "Tajawal", "Segoe UI", "Dubai", "Noto Kufi Arabic", Tahoma, sans-serif;
}

/* Arabic has no capital letters, so the theme's uppercasing does nothing visually but does stop
   some shaping engines from applying the right ligatures. Turn it off and restore the letter
   spacing, which is a Latin-only device that breaks Arabic joins. */
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3, [dir="rtl"] h4, [dir="rtl"] h5, [dir="rtl"] h6,
[dir="rtl"] .default__button, [dir="rtl"] .section__title span, [dir="rtl"] .btn {
    text-transform: none;
    letter-spacing: normal;
}

/* Arabic ascenders/descenders need more room than the theme's tight Latin line heights allow. */
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3 { line-height: 1.45; }
[dir="rtl"] h4, [dir="rtl"] h5, [dir="rtl"] h6 { line-height: 1.55; }
[dir="rtl"] p, [dir="rtl"] li { line-height: 1.9; }

/* ── Directional glyphs ──────────────────────────────────────────────────────────────────────
   Icon fonts and inline SVG arrows carry their direction in the artwork, not in a CSS property,
   so the generator cannot touch them. Mirror the ones that mean "forward"/"back". */
[dir="rtl"] .arrow-btn svg,
[dir="rtl"] .arrow-btn i,
[dir="rtl"] .default__button svg,
[dir="rtl"] .readmore__btn svg,
[dir="rtl"] .about__number__icon svg,
[dir="rtl"] .copyright__arrow svg,
[dir="rtl"] .icofont-simple-right,
[dir="rtl"] .icofont-simple-left,
[dir="rtl"] .icofont-long-arrow-right,
[dir="rtl"] .icofont-long-arrow-left,
[dir="rtl"] .icofont-rounded-right,
[dir="rtl"] .icofont-rounded-left {
    transform: scaleX(-1);
}

/* A scroll-to-top chevron points up in both directions - undo the blanket mirror above. */
[dir="rtl"] .back__to__top svg,
[dir="rtl"] .scroll__top svg {
    transform: none;
}

/* ── Sliders ─────────────────────────────────────────────────────────────────────────────────
   Swiper reads the container's computed direction and reverses its own axis, so the slides
   themselves need nothing here. The arrow buttons' *positions* are flipped by the generated sheet
   (they come from the theme's own left/right rules); their *glyphs* are flipped by the .arrow-btn
   svg rule above. Deliberately no transform on .swiper-button-next/prev: those elements are also
   .arrow-btn, so mirroring the button as well as the icon inside it would cancel out. */

/* ── Forms ───────────────────────────────────────────────────────────────────────────────────
   Placeholders and values inherit the page direction, but phone numbers, emails and URLs are
   always read left to right even inside Arabic text. */
[dir="rtl"] input[type="email"],
[dir="rtl"] input[type="tel"],
[dir="rtl"] input[type="url"],
[dir="rtl"] input[type="number"] {
    direction: ltr;
    text-align: right;
}

/* ── Fixed-position furniture ────────────────────────────────────────────────────────────────
   The WhatsApp button and theme switcher are pinned to the viewport in the layout's own <style>,
   which the generator never sees. Move them to the mirrored corner. */
[dir="rtl"] .whatsapp-fly-icon {
    right: auto;
    left: 30px;
}

/* Base (LTR) rule already puts this on the LEFT, opposite the WhatsApp icon - flip it to the RIGHT
   here so it stays opposite once WhatsApp itself flips to the left above. */
[dir="rtl"] .scroll-to-top-icon {
    left: auto;
    right: 30px;
}

@media (max-width: 767px) {
    [dir="rtl"] .whatsapp-fly-icon {
        right: auto;
        left: 18px;
    }

    [dir="rtl"] .scroll-to-top-icon {
        left: auto;
        right: 18px;
    }
}

/* ── Numerals ────────────────────────────────────────────────────────────────────────────────
   Keep Western digits in Arabic pages: prices, counters and dates elsewhere in the site are
   formatted as Western numerals by the API and mixing the two in one page looks like a bug. */
[dir="rtl"] {
    font-variant-numeric: lining-nums;
}

/* ── Admin-entered content ───────────────────────────────────────────────────────────────────
   Everything below is written by admins and injected by the components' own JS, so a branch can
   legitimately have an Arabic site whose project names, client names or event venues are in
   English (and vice-versa). "plaintext" makes each paragraph take its direction from its own first
   strong character instead of inheriting the page's, which is what stops a Latin title from
   rendering with its punctuation thrown to the wrong end. text-align: start then keeps it flush
   with the side that paragraph actually starts on. */
[dir="rtl"] #dmw-vision-mission,
[dir="rtl"] #dmw-banner-slides,
[dir="rtl"] #dmw-home-events-list,
[dir="rtl"] #dmw-home-projects-list,
[dir="rtl"] #dmw-home-services-list,
[dir="rtl"] #dmw-projects-list,
[dir="rtl"] #dmw-services-list,
[dir="rtl"] #dmw-project-details,
[dir="rtl"] #dmw-service-details,
[dir="rtl"] #dmw-project-title,
[dir="rtl"] #dmw-service-title,
[dir="rtl"] #dmw-project-summary,
[dir="rtl"] #dmw-service-summary,
[dir="rtl"] #dmw-team-slides,
[dir="rtl"] #dmw-testimonial-slides {
    unicode-bidi: plaintext;
}

/* Headings inside those hosts are centred by the theme in several sections; only the ones the
   theme left flush should follow the text's own direction. */
[dir="rtl"] #dmw-vision-mission p,
[dir="rtl"] #dmw-vision-mission h1, [dir="rtl"] #dmw-vision-mission h2, [dir="rtl"] #dmw-vision-mission h3,
[dir="rtl"] #dmw-vision-mission h4, [dir="rtl"] #dmw-vision-mission h5, [dir="rtl"] #dmw-vision-mission h6,
[dir="rtl"] #dmw-vision-mission li,
[dir="rtl"] #dmw-project-summary p,
[dir="rtl"] #dmw-service-summary p,
[dir="rtl"] #dmw-project-details p,
[dir="rtl"] #dmw-service-details p {
    text-align: start;
}

/* ── Bootstrap directional utilities ─────────────────────────────────────────────────────────
   The theme bundles Bootstrap 5.3.2's LTR build (bastun/css/bootstrap.min.css), where "me-*" and
   "border-start-*" compile down to physical margin-right / border-left. The generator only reads
   the theme's own sheets, and swapping in the 5.1 RTL build that ships under lib/ would downgrade
   Bootstrap by two minors. Only the handful of these utilities the views actually use are listed;
   add to this block if a view starts using another one. */
[dir="rtl"] .me-1 { margin-right: 0 !important; margin-left: 0.25rem !important; }
[dir="rtl"] .me-3 { margin-right: 0 !important; margin-left: 1rem !important; }
[dir="rtl"] .border-start { border-left: 0 !important; border-right: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color) !important; }
