/* ==========================================================================
   RTL — right-to-left

   Load this AFTER every other stylesheet and set the direction on <html>:

     <html lang="ar" dir="rtl">
     ...
     <link rel="stylesheet" href="css/rtl.css">

   Most of the work is already done in the source: margins, padding, borders
   and text alignment use logical properties (margin-inline-start rather than
   margin-left), so they flip on their own the moment `dir` changes. Nothing
   in this file repeats those.

   What is left is the three things logical properties cannot express:

     1. Absolutely positioned offsets that pair with a transform. Converting
        `left: 50%; transform: translateX(-50%)` to an inset property alone
        would flip the offset and leave the transform pointing the wrong way,
        so those are handled as pairs here.
     2. Direction-bearing glyphs. A chevron pointing "next" points left in an
        RTL document; a phone or a suitcase does not. Only the former flip.
     3. Anything anchored to a corner: toasts, the scheme switcher, the
        back-to-top button, badges over a card.

   Everything here is scoped to [dir="rtl"], so loading the file on an LTR
   page changes nothing.
   ========================================================================== */

/* --- Cards ---------------------------------------------------------------- */
[dir="rtl"] .wu-card-badges  { left: auto; right: var(--wu-space-3); }
[dir="rtl"] .wu-card-wish    { right: auto; left: var(--wu-space-3); }
[dir="rtl"] .wu-card-price-tag { left: auto; right: var(--wu-space-3); }

/* --- Header and navigation ------------------------------------------------
   .wu-dropdown positions itself with inset-inline-start, so it needs nothing
   here: it follows the direction on its own, and the panels anchored to the
   end of the header (locale, wishlist) use inset-inline-end for the same
   reason. An override here used to force every panel to the same physical
   edge, which is what pushed the wishlist panel off an RTL viewport.
   -------------------------------------------------------------------------- */

/* The mega panel needs nothing here. It spans the container with
   inset-inline: 0 and centres itself with margin-inline: auto, both of which
   already follow the direction. The override this replaced pinned it with
   right: 50% / translateX(50%), which fought the logical positioning AND
   overwrote the translateY the open state animates on - in RTL the panel
   landed off-centre and never slid in. */

[dir="rtl"] .wu-nav-drawer { transform: translateX(100%); }
[dir="rtl"] .wu-nav-drawer.is-open { transform: none; }

/* --- Filters -------------------------------------------------------------- */
[dir="rtl"] .wu-listing-sidebar { left: auto; right: 0; transform: translateX(100%); }
[dir="rtl"] .wu-listing-sidebar.is-open { transform: none; }

/* --- Slider and carousel --------------------------------------------------
   The arrows swap sides AND swap glyphs: in an RTL document "next" is to the
   left, and an arrow that still points right would send the reader backwards.
   -------------------------------------------------------------------------- */
[dir="rtl"] .wu-slider-prev { left: auto; right: var(--wu-space-5); }
[dir="rtl"] .wu-slider-next { right: auto; left: var(--wu-space-5); }
[dir="rtl"] .wu-slider-arrow svg { transform: scaleX(-1); }
[dir="rtl"] .wu-slider-dots { left: auto; right: 50%; transform: translateX(50%); }

/* The carousel track is moved by JS in pixels; in RTL the flex row already
   starts at the right, so the sign has to flip. */
[dir="rtl"] .wu-carousel-track { transform: scaleX(-1); }
[dir="rtl"] .wu-carousel-track > [data-slide] { transform: scaleX(-1); }

/* --- Lightbox ------------------------------------------------------------- */
[dir="rtl"] .wu-lightbox-close { right: auto; left: var(--wu-space-5); }
[dir="rtl"] .wu-lightbox-prev  { left: auto; right: var(--wu-space-5); }
[dir="rtl"] .wu-lightbox-next  { right: auto; left: var(--wu-space-5); }
[dir="rtl"] .wu-lightbox-nav svg { transform: scaleX(-1); }

/* --- Itinerary and timeline ----------------------------------------------- */
[dir="rtl"] .wu-itinerary li { padding: 0 var(--wu-space-7) var(--wu-space-5) 0; }
[dir="rtl"] .wu-itinerary li::before { left: auto; right: 0; }
[dir="rtl"] .wu-itinerary li:not(:last-child)::after { left: auto; right: 15px; }

/* --- Floating chrome ------------------------------------------------------ */
[dir="rtl"] .wu-toasts { right: auto; left: var(--wu-space-5); }
[dir="rtl"] .wu-to-top { right: auto; left: var(--wu-space-5); }

/* The scheme switcher parks OFF-SCREEN and slides in, so the edge it is
   anchored to and the direction it is translated have to move together.
   Flipping only the offset left the closed panel sitting 190px inside the
   viewport, over the page, instead of hidden beyond the edge. */
[dir="rtl"] .wu-scheme-switcher {
  right: auto;
  left: 0;
  transform: translate(-100%, -50%);
}
[dir="rtl"] .wu-scheme-switcher.is-open { transform: translate(0, -50%); }

/* The toggle hangs off the outer edge of the panel, which is now the other
   one; its rounded corners follow it. */
[dir="rtl"] .wu-scheme-toggle {
  right: auto;
  left: 100%;
  border-radius: 0 var(--wu-radius) var(--wu-radius) 0;
}
[dir="rtl"] .wu-scheme-panel {
  border-radius: 0 var(--wu-radius) var(--wu-radius) 0;
}

/* --- Forms ---------------------------------------------------------------- */
[dir="rtl"] .wu-input-icon svg { left: auto; right: var(--wu-space-3); }
[dir="rtl"] .wu-input-icon .wu-input { padding-inline: 2.6rem var(--wu-space-4); }
[dir="rtl"] .wu-password-toggle { right: auto; left: 0.5rem; }
/* Mirrors the DESKTOP rule, which centres the button on a vertical seam with
   translate(-50%, -50%). Scoped to that breakpoint on purpose: this file loads
   after responsive.css, so an unscoped transform here would also replace the
   stacked-layout one below 992px and shove the button half its width sideways.
   The mobile rule needs no mirroring - it uses inset-inline-end. */
@media (min-width: 992px) {
  [dir="rtl"] .wu-swap-btn { transform: translate(50%, -50%); }
  [dir="rtl"] .wu-swap-btn:hover { transform: translate(50%, -50%) rotate(180deg); }
}

/* Native select and date arrows are drawn by the browser and already follow
   `dir`, so nothing is done to them here. */

/* --- Account -------------------------------------------------------------- */
[dir="rtl"] .wu-plan-flag { left: var(--wu-space-5); right: auto; }
[dir="rtl"] .wu-popup-close { right: auto; left: var(--wu-space-3); }
[dir="rtl"] .wu-popup-badge { left: auto; right: var(--wu-space-4); }
[dir="rtl"] .wu-video-toggle { right: auto; left: var(--wu-space-5); }

/* --- Directional glyphs ---------------------------------------------------
   Only the ones whose meaning is "forward" or "back". A phone handset, a
   suitcase and a map pin read the same in both directions and are left alone.
   -------------------------------------------------------------------------- */
[dir="rtl"] .wu-pagination button svg { transform: scaleX(-1); }

/* The breadcrumb separator is a "/" character. Flipping it would just make it
   a backslash, so it stays; the list order reverses on its own with dir. */

/* --- Tables --------------------------------------------------------------- */
[dir="rtl"] .wu-tiers th:last-child,
[dir="rtl"] .wu-tiers td:last-child,
[dir="rtl"] .wu-compare th:first-child,
[dir="rtl"] .wu-compare td:first-child { text-align: start; }

/* --- The brand name never reorders ----------------------------------------
   "Travel" and the highlighted "Way" are two inline runs, so flipping the
   paragraph direction swaps them and the footer logo reads "Way Travel". A
   proper noun is not affected by the direction of the sentence around it.

   The header logo escapes this because its "Way" is nested inside the same
   span rather than sitting beside it - which is luck, not design, so both are
   covered here.
   -------------------------------------------------------------------------- */
[dir="rtl"] .wu-logo { direction: ltr; unicode-bidi: isolate; }

/* --- Contact details ------------------------------------------------------
   A phone number contains no strongly directional character, so it inherits
   the paragraph's direction and "+1 555 0100" renders as "0100 555 1+".
   Addresses that open with a house number go the same way.

   `plaintext` on the surrounding block lets each line resolve from its own
   first strong character - Latin stays LTR, and a translated Arabic address
   still reads RTL. The phone itself has no strong character at all, so it is
   pinned explicitly.
   -------------------------------------------------------------------------- */
[dir="rtl"] .wu-footer-contact li,
[dir="rtl"] .wu-footer-office-body,
[dir="rtl"] .wu-contact-item span { unicode-bidi: plaintext; }

[dir="rtl"] a[href^="tel:"] { direction: ltr; unicode-bidi: embed; }

/* --- The countdown is one number ------------------------------------------
   Days, hours, minutes, seconds read left to right in every locale, the same
   way a clock does. Flipping the row put seconds first.
   -------------------------------------------------------------------------- */
[dir="rtl"] .wu-countdown { direction: ltr; }

/* --- Numbers stay LTR -----------------------------------------------------
   Prices, times, flight numbers and references are read left to right even in
   an RTL document. Without this, "$1,240" renders as "240,1$".
   -------------------------------------------------------------------------- */
[dir="rtl"] .wu-price-amount,
[dir="rtl"] .wu-price-was,
[dir="rtl"] .wu-route-time,
[dir="rtl"] .wu-route-code,
[dir="rtl"] .wu-booking-ref,
[dir="rtl"] .wu-countdown-unit strong,
[dir="rtl"] .wu-code input,
[dir="rtl"] [data-booking-reference],
[dir="rtl"] [data-summary-total] {
  direction: ltr;
  unicode-bidi: embed;
}

/* --- Stay card: phrases that open with a number ---------------------------
   "1.2 km from centre", "1 king bed", "1284 reviews", "1 night, 2 adults".
   A leading digit is directionally neutral, so the paragraph direction decides
   where it lands and in RTL it jumps to the end: "km from centre 1.2".

   plaintext rather than ltr: it takes the direction from the first real letter,
   so these lines flip on their own once a buyer translates them to Arabic.
   -------------------------------------------------------------------------- */
[dir="rtl"] .wu-card-place span,
[dir="rtl"] .wu-card-room span,
[dir="rtl"] .wu-card-score span,
[dir="rtl"] .wu-card-stay-note,
[dir="rtl"] .wu-card-urgency,
/* "-20%" opens with a sign and holds no letter at all, so it flipped to "20%-".
   With no strong character plaintext falls back to LTR, which is what a
   percentage wants; an Arabic badge still resolves RTL on its own. */
[dir="rtl"] .wu-badge { unicode-bidi: plaintext; }

/* plaintext also decides alignment per line, which would pull this one line to
   the left of an otherwise right-aligned card. Pin it; Arabic copy resolves
   right anyway, so the rule holds either way. */
[dir="rtl"] .wu-card-urgency { text-align: right; }
