/* Tarjem — language switcher + bidi helpers.
   Colors, size and corner come from the settings through the --tj-* variables. */
.tarjem-switcher {
	--tj-bg: #fff;
	--tj-text: currentColor;
	--tj-active-bg: rgba(127, 127, 127, .16);
	--tj-active-text: currentColor;
	--tj-border: transparent;
	--tj-radius: 999px;
	--tj-size: 14px;
	--tj-x: 20px;
	--tj-y: 20px;
	display: inline-flex;
	align-items: center;
	gap: 2px;
	font-size: var(--tj-size);
	line-height: 1.4;
}
.tarjem-switcher__item {
	display: inline-block;
	padding: .36em .86em;
	border-radius: calc(var(--tj-radius) - 2px);
	text-decoration: none !important;
	color: var(--tj-text) !important;
	opacity: .75;
	transition: opacity .15s, background-color .15s;
	white-space: nowrap;
}
.tarjem-switcher__item:hover,
.tarjem-switcher__item:focus-visible { opacity: 1; }
.tarjem-switcher__item.is-active {
	opacity: 1;
	font-weight: 600;
	background: var(--tj-active-bg);
	color: var(--tj-active-text) !important;
}
.tarjem-switcher--toggle .tarjem-switcher__item { opacity: 1; }

/* Dropdown */
.tarjem-switcher__dd { position: relative; }
.tarjem-switcher__dd > summary {
	list-style: none;
	cursor: pointer;
	padding: .36em .86em;
	border-radius: calc(var(--tj-radius) - 2px);
	font-weight: 600;
	color: var(--tj-text);
}
.tarjem-switcher__dd > summary::-webkit-details-marker { display: none; }
.tarjem-switcher__dd > summary::after { content: " ▾"; font-size: .8em; opacity: .6; }
.tarjem-switcher__menu {
	position: absolute;
	inset-inline-start: 0;
	top: calc(100% + 6px);
	display: flex;
	flex-direction: column;
	min-width: 120px;
	padding: 4px;
	background: var(--tj-bg);
	border: 1px solid var(--tj-border);
	border-radius: min(var(--tj-radius), 14px);
	box-shadow: 0 8px 30px rgba(0, 0, 0, .15);
	z-index: 10;
}
.tarjem-switcher__menu .tarjem-switcher__item { border-radius: min(var(--tj-radius), 10px); }

/* Floating pill */
.tarjem-floating {
	position: fixed;
	z-index: 99990;
	padding: 4px;
	background: var(--tj-bg);
	border: 1px solid var(--tj-border);
	border-radius: var(--tj-radius);
}
.tarjem-floating.has-shadow { box-shadow: 0 6px 24px rgba(0, 0, 0, .14); }

/* Physical corners: same side in both languages. */
.tarjem-floating--bottom-right { bottom: var(--tj-y); right: var(--tj-x); }
.tarjem-floating--bottom-left  { bottom: var(--tj-y); left: var(--tj-x); }
.tarjem-floating--top-right    { top: var(--tj-y); right: var(--tj-x); }
.tarjem-floating--top-left     { top: var(--tj-y); left: var(--tj-x); }
/* Logical corners: follow the page direction (end = right in English, left in Arabic). */
.tarjem-floating--bottom-end   { inset-block-end: var(--tj-y); inset-inline-end: var(--tj-x); }
.tarjem-floating--bottom-start { inset-block-end: var(--tj-y); inset-inline-start: var(--tj-x); }

/* The dropdown opens away from the screen edge it sits on. */
.tarjem-floating[class*="--bottom"] .tarjem-switcher__menu { top: auto; bottom: calc(100% + 6px); }
.tarjem-floating--bottom-right .tarjem-switcher__menu,
.tarjem-floating--top-right .tarjem-switcher__menu { inset-inline-start: auto; left: auto; right: 0; }
.tarjem-floating--bottom-left .tarjem-switcher__menu,
.tarjem-floating--top-left .tarjem-switcher__menu { inset-inline-start: auto; right: auto; left: 0; }
.tarjem-floating--bottom-end .tarjem-switcher__menu { inset-inline-start: auto; inset-inline-end: 0; }

/* Admin bar pushes top corners down when shown. */
body.admin-bar .tarjem-floating--top-right,
body.admin-bar .tarjem-floating--top-left { top: calc(var(--tj-y) + 32px); }
@media (max-width: 782px) {
	body.admin-bar .tarjem-floating--top-right,
	body.admin-bar .tarjem-floating--top-left { top: calc(var(--tj-y) + 46px); }
}
@media (max-width: 767px) {
	.tarjem-floating.hide-mobile { display: none; }
}

/* Bidi helpers: these values are always left-to-right, even on Arabic pages. */
html[dir="rtl"] input[type="email"],
html[dir="rtl"] input[type="url"],
html[dir="rtl"] input[type="tel"],
html[dir="rtl"] input[type="password"] {
	direction: ltr;
	text-align: right;
}
html[dir="rtl"] input[type="email"]::placeholder,
html[dir="rtl"] input[type="tel"]::placeholder { direction: rtl; }
.tarjem-ltr { direction: ltr; unicode-bidi: isolate; }
.tarjem-rtl-text { direction: rtl; unicode-bidi: isolate; }
