/**
 * AVIX — right-to-left corrections
 *
 * The theme is built with logical properties (inline-start/inline-end,
 * padding-inline, margin-inline), so the great majority of the layout mirrors
 * automatically. This file only handles the cases logical properties cannot
 * express, and — just as importantly — stops things mirroring that must not:
 * product photography, logos, numbers, prices, phone numbers and SKUs.
 *
 * Loaded by inc/enqueue.php when is_rtl() is true.
 */

/* -------------------------------------------------------------------------
 * Things that must NOT mirror.
 * ---------------------------------------------------------------------- */

/* Media keeps its real orientation. A photographed garment or a logo must
   never be flipped. */
img,
video,
picture,
.avx-card__img,
.avx-gallery__img,
.avx-cat-tile__img,
.avx-logo img,
.custom-logo,
.wp-block-image img,
.wp-block-cover__image-background {
	transform: none !important;
}

/* Numbers, currency amounts, phone numbers, SKUs and order numbers stay
   left-to-right so digits read correctly inside Arabic text. */
.woocommerce-Price-amount,
.avx-card__price,
.avx-pdp__price,
.avx-sticky-atc__price,
.avx-checkout__due strong,
.avx-thankyou__fact dd,
.avx-filter-option__count,
.avx-gallery__counter,
.avx-cart-count,
.avx-toolbar__badge,
.avx-pdp__meta dd,
.woocommerce-order-overview__order,
.woocommerce-order-overview__total,
a[href^="tel:"],
.avx-qty__input,
input[type="tel"],
input[type="number"],
input[type="email"],
input[type="url"] {
	direction: ltr;
	unicode-bidi: isolate;
}

/* The gallery counter is given direction: ltr above so its digits read
   correctly. That also makes its own inset-inline-start resolve against LTR,
   which would leave it on the left under RTL — on top of the zoom button, which
   does mirror. Pin both to physical sides here so they stay apart. */
.avx-gallery__counter {
	inset-inline-start: auto;
	inset-inline-end: auto;
	left: auto;
	right: 0.75rem;
}

.avx-gallery__zoom {
	inset-inline-start: auto;
	inset-inline-end: auto;
	left: 0.75rem;
	right: auto;
}

/* Amounts inside an otherwise right-aligned cell still sit on the correct
   side of the cell. */
.cart_item .product-subtotal,
.cart_totals table td,
.woocommerce-checkout-review-order-table td {
	text-align: end;
}

/* -------------------------------------------------------------------------
 * Directional icons.
 * ---------------------------------------------------------------------- */

/* Arrows and chevrons point the other way in RTL; the check, close, plus,
   search and status icons must not flip. */
.avx-icon--arrow-right,
.avx-icon--arrow-left,
.avx-icon--chevron-right,
.avx-icon--chevron-left {
	transform: scaleX(-1);
}

/* Already handled explicitly elsewhere — do not double-flip. */
.avx-breadcrumbs__sep .avx-icon--chevron-right,
.avx-gallery__nav .avx-icon--chevron-left,
.avx-gallery__nav .avx-icon--chevron-right {
	transform: none;
}

.avx-breadcrumbs__sep svg {
	transform: scaleX(-1);
}

/* -------------------------------------------------------------------------
 * Layout corrections.
 * ---------------------------------------------------------------------- */

.avx-nav__link::after {
	transform-origin: right;
}

.avx-carousel__track,
.avx-gallery__track,
.avx-gallery__thumbs,
.avx-hslider__viewport {
	direction: rtl;
}

/* The marquee slides towards the end of the line, which is the other way
   round here. One sign flip rather than a second set of keyframes. */
.avx-marquee {
	--avx-marquee-direction: 1;
}

/* Native horizontal scroll containers start from the inline-start edge, which
   the browser resolves correctly once direction is inherited. */

.avx-mega {
	inset-inline-start: auto;
	inset-inline-end: 50%;
	transform: translateX(-50%);
}

.avx-sticky-atc__price del {
	display: none;
}

/* -------------------------------------------------------------------------
 * Mixed-direction content.
 *
 * A bilingual store will have English product names sitting inside Arabic
 * pages and the other way round. `unicode-bidi: plaintext` makes each
 * paragraph take its direction from its own first strong character, so an
 * English sentence keeps its full stop at the end and an Arabic one keeps
 * its own — without the editor having to set dir on anything.
 * ---------------------------------------------------------------------- */

.avx-prose,
.avx-prose p,
.avx-prose li,
.avx-pdp__excerpt,
.avx-pdp__excerpt p,
.avx-card__title,
.avx-card__category,
.product_title,
.term-description,
.woocommerce-product-details__short-description,
.avx-accordion__body,
.avx-seo__body,
.avx-cat-tile__name,
.avx-collection-card__title,
.avx-collection-card__text,
.woocommerce-Reviews .description,
.cart_item .product-name,
.woocommerce-checkout-review-order-table .product-name,
.avx-search-suggestion__title,
.avx-hero__title,
.avx-hero__text,
.avx-hero__eyebrow,
.avx-hslider__title,
.avx-hslider__text,
.avx-hslider__eyebrow,
.avx-accordion__label,
.avx-section-header__title,
.avx-eyebrow,
.avx-campaign__body h2,
.avx-campaign__body p,
.avx-benefit__title,
.avx-benefit__text,
.avx-collection-card__label {
	unicode-bidi: plaintext;
	text-align: start;
}

/* A badge is a self-contained token, so its internal word order should follow
   its own text rather than the page. Without this, an untranslated English
   badge on an Arabic page renders "off 25%", because RTL is the paragraph
   direction and the English words are reordered as runs within it. With
   plaintext the badge takes its direction from its own first strong character:
   English stays "25% off", and a translated Arabic label reads right-to-left as
   it should. The <bdi> keeps the figure itself intact inside either. */
.avx-badge {
	unicode-bidi: plaintext;
}

.avx-badge bdi {
	unicode-bidi: isolate;
}

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

/* Arabic has no upper case; uppercase transforms and wide tracking make
   Arabic text harder to read, so they are switched off for the Arabic
   locale and the line height is opened up slightly. */
.avx-lang-ar {
	--avx-track-wide: 0;
	--avx-track-wider: 0;

	font-family: var(--wp--preset--font-family--arabic, sans-serif);
	line-height: 1.75;
}

.avx-lang-ar h1,
.avx-lang-ar h2,
.avx-lang-ar h3,
.avx-lang-ar h4,
.avx-lang-ar h5,
.avx-lang-ar h6,
.avx-lang-ar .avx-btn,
.avx-lang-ar .avx-nav__link,
.avx-lang-ar .avx-logo__text,
.avx-lang-ar .avx-badge,
.avx-lang-ar .avx-eyebrow,
.avx-lang-ar .avx-section-header__title,
.avx-lang-ar .avx-filter-group__legend,
.avx-lang-ar .avx-accordion__summary,
.avx-lang-ar .avx-checkout__section-title,
.avx-lang-ar .avx-funnel-head__title,
.avx-lang-ar .avx-thankyou__title,
.avx-lang-ar .product_title,
.avx-lang-ar .woocommerce-products-header__title,
.avx-lang-ar #place_order,
.avx-lang-ar .single_add_to_cart_button,
.avx-lang-ar .checkout-button {
	font-family: var(--wp--preset--font-family--arabic, sans-serif);
	text-transform: none;
	letter-spacing: 0;
	line-height: 1.35;
}

.avx-lang-ar .avx-hero__title,
.avx-lang-ar .avx-hslider__title,
.avx-lang-ar .avx-cat-tile__name {
	letter-spacing: 0;
	text-transform: none;
	line-height: 1.25;
}
