/*
 * Right-to-left overrides for the Hebrew (/he/) tree.
 *
 * Loaded only when the page is in an RTL tree (see sabreen_enqueue_rtl_assets in functions.php,
 * gated on sabreen_i18n_is_rtl()). No LTR tree ever downloads or parses this file.
 *
 * SCOPE — read before adding rules
 * Flexbox, grid and text alignment already mirror themselves from the dir="rtl" attribute the
 * i18n plugin puts on <html>. Only *physical* properties need overriding: margin/padding/border
 * -left/-right, left/right offsets, text-align:left|right, and translateX. Everything here is a
 * direct mirror of a physical property in style.css or sabreen-nav.css — if you add a rule,
 * confirm it is fixing a physical property and not something the browser already handled.
 *
 * The nav source uses !important throughout to win against Elementor, so these overrides must
 * match that weight or they lose to the very rules they are correcting.
 *
 * As with every other stylesheet here, this must be a real enqueued file: Airlift strips inline
 * <style>. Re-upload and purge after editing.
 *
 * @package Sabreen
 */

/* ---------------------------------------------------------------------------
 * 1. Document flow
 * ------------------------------------------------------------------------ */

[dir="rtl"] body {
	text-align: right;
}

/* Lists indent from the reading-start edge. */
[dir="rtl"] .site-content ul,
[dir="rtl"] .site-content ol {
	padding-right: 1.5em;
	padding-left: 0;
}

/* Quote rules and accent bars flip to the start edge. */
[dir="rtl"] .site-content blockquote {
	border-right: 4px solid rgb(242, 102, 34);
	border-left: none;
	padding-right: 18px;
	padding-left: 0;
}

/* Latin runs (part numbers, emails, URLs, model codes) stay LTR inside Hebrew text.
   The bidi algorithm handles inline ordering, but a whole element that is pure Latin —
   an address block, a code sample — needs to be told explicitly. */
[dir="rtl"] code,
[dir="rtl"] pre,
[dir="rtl"] samp,
[dir="rtl"] kbd,
[dir="rtl"] .ltr {
	direction: ltr;
	text-align: left;
	unicode-bidi: isolate;
}

/* Tables read right-to-left; the first column becomes the rightmost. */
[dir="rtl"] .site-content th,
[dir="rtl"] .site-content td {
	text-align: right;
}

/* ---------------------------------------------------------------------------
 * 2. Header and primary navigation
 * ------------------------------------------------------------------------ */

[dir="rtl"] .site-header__inner {
	text-align: right;
}

/* Desktop dropdowns open from the right edge of their parent. */
@media (min-width: 1025px) {
	[dir="rtl"] #primary-menu .children {
		left: auto !important;
		right: 0 !important;
	}

	/* Nested submenus fly out to the left in RTL, not the right. */
	[dir="rtl"] #primary-menu .children .children {
		left: auto !important;
		right: 100% !important;
	}

	/* The dropdown chevron is a rotated square built from two borders. Mirroring the
	   element horizontally is more reliable than re-deriving which borders to set. */
	[dir="rtl"] #primary-menu .menu-item-has-children > a::after {
		margin-left: 0;
		margin-right: 2px;
		transform: translateY(-2px) rotate(45deg) scaleX(-1);
	}
}

/* Mobile off-canvas panel enters from the left in RTL. */
@media (max-width: 1024px) {
	[dir="rtl"] #primary-menu.primary-nav {
		right: auto !important;
		left: 0 !important;
		transform: translateX(-100%);
	}

	[dir="rtl"] body.nav-open #primary-menu.primary-nav {
		transform: translateX(0) !important;
	}

	/* Panel close button and per-item submenu toggles move to the opposite corner. */
	[dir="rtl"] #primary-menu .primary-nav__close {
		right: auto !important;
		left: 16px !important;
	}

	[dir="rtl"] #primary-menu .submenu-toggle {
		right: auto !important;
		left: -6px !important;
	}

	/* Nested items indent from the right. */
	[dir="rtl"] #primary-menu .children {
		padding-left: 0 !important;
		padding-right: 16px !important;
	}

	/* Hamburger bars are drawn from a left origin. */
	[dir="rtl"] .site-header .nav-toggle .bars::after {
		left: auto;
		right: 0;
	}
}

/* ---------------------------------------------------------------------------
 * 3. Footer
 * ------------------------------------------------------------------------ */

[dir="rtl"] .site-footer,
[dir="rtl"] .site-footer ul {
	text-align: right;
	padding-right: 0;
}

/* ---------------------------------------------------------------------------
 * 4. Focus, forms
 * ------------------------------------------------------------------------ */

[dir="rtl"] input,
[dir="rtl"] textarea,
[dir="rtl"] select {
	text-align: right;
	direction: rtl;
}

/* Email, phone and URL inputs hold Latin data — keep them LTR so the caret and any
   placeholder read correctly. */
[dir="rtl"] input[type="email"],
[dir="rtl"] input[type="tel"],
[dir="rtl"] input[type="url"] {
	direction: ltr;
	text-align: left;
}
