/* ════════════════════════════════════════════════════════════
   Languages (js/i18n.js): the header language menu, type for
   non-Latin scripts, and right-to-left layout for Arabic.
   ════════════════════════════════════════════════════════════ */

/* ─── Language menu ────────────────────────────────────────── */
/* Header order: brand · navigation · language · (phone) Menu */
.sw-header-row > .sw-nav { order: 1; margin-inline-start: auto; }
.i18n-switch { position: relative; flex: none; order: 2; }
.sw-header-row > .sw-menu-toggle { order: 3; }
.i18n-toggle {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px;
  font: var(--sw-weight-strong, 650) 0.875rem var(--sw-sans); letter-spacing: 0.06em; color: var(--sw-ink);
  background: none; border: 1px solid var(--sw-rule); border-radius: 0; cursor: pointer;
  transition: border-color 150ms var(--sw-ease), color 150ms var(--sw-ease);
}
.i18n-toggle:hover, .i18n-toggle[aria-expanded="true"] { border-color: var(--sw-ink); }
.i18n-caret { width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-2px) rotate(45deg); transition: transform 150ms var(--sw-ease); }
.i18n-toggle[aria-expanded="true"] .i18n-caret { transform: translateY(1px) rotate(225deg); }

.i18n-menu {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 60; min-width: 220px;
  list-style: none; margin: 0; padding: 6px 0;
  background: var(--sw-white); border: 1px solid var(--sw-ink); box-shadow: 0 18px 40px rgba(17, 17, 17, 0.14);
  max-height: min(70vh, 520px); overflow-y: auto;
}
.i18n-menu[hidden] { display: none; }
body.home .i18n-menu a {
  display: grid; grid-template-columns: 36px 1fr; align-items: baseline; gap: 8px;
  padding: 10px 16px; font-size: 0.9375rem; color: var(--sw-ink); text-decoration: none;
}
.i18n-menu-code { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; color: #A5A5AC; font-family: var(--sw-sans); }
body.home .i18n-menu a:hover, body.home .i18n-menu a:focus-visible { background: var(--sw-paper); outline: none; }
body.home .i18n-menu a:hover .i18n-menu-code, body.home .i18n-menu a:focus-visible .i18n-menu-code { color: var(--sw-ink); }
body.home .i18n-menu a[aria-current] { font-weight: var(--sw-weight-strong, 650); box-shadow: inset 3px 0 0 var(--sw-red); }
body.home .i18n-menu a[aria-current] .i18n-menu-code { color: var(--sw-red); }

@media (max-width: 768px) {
  .sw-header-row { gap: 12px; }
  .i18n-switch { margin-inline-start: auto; }
  .i18n-menu { position: fixed; top: auto; inset-inline: 16px; margin-top: 8px; min-width: 0; }
}

/* ─── Type for other scripts ────────────────────────────────
   Archivo covers Latin (numbers, codes and names stay in it); other scripts
   fall back to each system's best font. Tight tracking and 0.9 line-heights
   suit Latin display type only, so they are relaxed for these scripts. */
html:lang(ar) body.home { --sw-sans: "Archivo", "Noto Sans Arabic", "Segoe UI", "Geeza Pro", Tahoma, sans-serif; }
html:lang(zh) body.home { --sw-sans: "Archivo", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif; }
html:lang(ja) body.home { --sw-sans: "Archivo", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", "Noto Sans JP", sans-serif; }
html:lang(ko) body.home { --sw-sans: "Archivo", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif; }
html:lang(hi) body.home { --sw-sans: "Archivo", "Noto Sans Devanagari", "Nirmala UI", "Kohinoor Devanagari", "Mangal", sans-serif; }

html:is(:lang(ar), :lang(zh), :lang(ja), :lang(ko), :lang(hi)) body.home * { letter-spacing: 0 !important; }
html:is(:lang(ar), :lang(zh), :lang(ja), :lang(ko), :lang(hi)) body.home :is(h1, h2, h3, .sw-hero-title, .sw-lookup-title, .sw-policy-title, .sw-portal-greeting, .sw-step-title, .sw-policy-h2, .sw-guide h3) { line-height: 1.25; }
html:is(:lang(ar), :lang(hi)) body.home { line-height: 1.7; }
html:is(:lang(ar), :lang(hi)) body.home :is(.m-word, .rm-word) { padding-bottom: 0.3em; margin-bottom: -0.3em; }
/* Break CJK lines anywhere rather than overflow */
html:is(:lang(zh), :lang(ja)) body.home { line-break: strict; word-break: normal; overflow-wrap: anywhere; }
/* Long words in German, Swahili and Turkish */
html:is(:lang(de), :lang(sw), :lang(tr)) body.home :is(h1, h2, h3) { hyphens: auto; overflow-wrap: break-word; }

/* ─── Right-to-left (Arabic) ────────────────────────────────
   Grid and flex mirror by themselves; these are the pieces set with
   physical left/right. Numbers, codes and progress bars keep reading
   left-to-right where that is what they mean. */
html[dir="rtl"] body.home .sw-kicker,
html[dir="rtl"] body.home :is(.sw-hero-lead, .sw-policy-lead) { padding-right: 0; padding-left: 12px; }
html[dir="rtl"] body.home .sw-figure + .sw-figure { border-left: none; border-right: 1px solid var(--sw-rule); padding-left: 0; padding-right: var(--sw-col-gap); }
html[dir="rtl"] body.home .sw-partners-list li { border-left: none; border-right: 1px solid var(--sw-rule); }
html[dir="rtl"] body.home .sw-partners-list li:first-child { padding-right: 0; padding-left: clamp(16px, 2vw, 28px); border-right: none; }
html[dir="rtl"] body.home .m-marquee .sw-partners-list li:first-child { padding-right: clamp(16px, 2vw, 28px); border-right: 1px solid var(--sw-rule); }
html[dir="rtl"] body.home .sw-index li:hover > :is(h3, p),
html[dir="rtl"] body.home .sw-register li:is(:hover, .is-active) .sw-register-city { transform: translateX(-8px); }
html[dir="rtl"] body.home .sw-nav a:not(.sw-btn)::after { transform-origin: left center; }
html[dir="rtl"] body.home .sw-nav a:not(.sw-btn):is(:hover, :focus-visible)::after { transform-origin: right center; }
html[dir="rtl"] body.home .sw-summary-item + .sw-summary-item { border-left: none; border-right: 1px solid var(--sw-rule); padding-left: var(--sw-col-gap); padding-right: var(--sw-col-gap); }
html[dir="rtl"] body.home :is(.sw-form-message, .sw-rail-alert, .sw-policy-body blockquote) { border-left: none; border-right: 3px solid var(--sw-red); }
html[dir="rtl"] body.home .sw-form-message.is-info { border-right-color: var(--sw-ink); }
html[dir="rtl"] body.home .sw-field-toggle { right: auto; left: 0; border-left: none; border-right: 1px solid var(--sw-rule); }
html[dir="rtl"] body.home .sw-field-row input { padding-right: 18px; padding-left: 88px; }
html[dir="rtl"] body.home :is(.sw-record .contents-table th, .sw-policy-body th) { text-align: right; }
html[dir="rtl"] body.home .sw-record .contents-table :is(th, td) { padding: 12px 0 12px 12px; }
html[dir="rtl"] body.home .sw-policy-body :is(th, td) { padding: 10px 0 10px 16px; }
html[dir="rtl"] body.home .sw-policy-text { padding-left: 0; padding-right: calc(clamp(56px, 6vw, 88px) + 8px); }
html[dir="rtl"] body.home .sw-policy-body :is(ul, ol) > li { padding: 10px 28px 10px 0; }
html[dir="rtl"] body.home .sw-policy-body ul > li::before { left: auto; right: 4px; }
html[dir="rtl"] body.home .sw-policy-body ol > li::before { left: auto; right: 0; }
html[dir="rtl"] body.home .i18n-menu a[aria-current] { box-shadow: inset -3px 0 0 var(--sw-red); }

/* Animated figures are built digit by digit: keep the digits in reading order */
html[dir="rtl"] body.home [data-m-number] { direction: ltr; unicode-bidi: isolate; }
html[dir="rtl"] body.home .sw-figure dd { text-align: right; }
/* Stored values (names, places, weights, dates) take the direction of their own text */
html[dir="rtl"] body.home :is(.info-item span, .sw-summary-item dd, .sw-history-meta, .sw-history-desc, .contents-table td, .sw-register-city, .sw-register-country) { unicode-bidi: plaintext; }

/* Codes, numbers and addresses read left-to-right inside Arabic text */
html[dir="rtl"] body.home :is(.vv-vault-number, .vv-code, .sr-number, #cfg-top-phone, #cfg-contact-phone, [id^="cfg-contact-email"], #cfg-top-email, input[type="email"], input[inputmode="numeric"], #trackingNumber, #vaultNumber, #loginVault, #setupVault, #privateKey) { direction: ltr; unicode-bidi: isolate; }
html[dir="rtl"] body.home :is(#trackingNumber, #vaultNumber, #loginVault, #setupVault, #privateKey, input[type="email"]) { text-align: right; }

/* Progress rail and route: stage 01 starts on the right, as Arabic reads */
html[dir="rtl"] body.home .sw-rail-fill { transform-origin: right center; }
html[dir="rtl"] .sr-line { transform-origin: right center; }
html[dir="rtl"] .sr-runner { transform: translateX(100%); }
html[dir="rtl"] .sr-marker, html[dir="rtl"] .sr-ping { right: auto; left: 0; transform: translate(-50%, -50%); }
html[dir="rtl"] .sr-stop { transform: translate(50%, 0); }

@media (max-width: 768px) {
  html[dir="rtl"] body.home .sw-figure:nth-child(3) { border-right: none; padding-right: 0; }
  html[dir="rtl"] body.home .sw-hero-lead { padding-right: 0; padding-left: 16px; }
  html[dir="rtl"] body.home .sw-summary-item:nth-child(3) { border-right: none; padding-right: 0; }
  html[dir="rtl"] body.home .sw-rail li { padding: 10px 14px 10px 0; border-left: none; border-right: 4px solid var(--sw-rule); }
  html[dir="rtl"] body.home .sw-rail-fill { left: auto; right: -4px; }
  html[dir="rtl"] body.home .sw-policy-text { padding-right: 0; }
  html[dir="rtl"] body.home .sw-nav { text-align: right; }
}
