/* ── Languages: switcher, fonts, right-to-left ────────────────────────────── */

/* While a non-English dictionary loads (one small cached file), hold the page
   for a moment rather than flashing English. i18n.js lifts this after 1.5 s
   at most, whatever happens. */
html.i18n-pending body {
  opacity: 0;
}

body {
  transition: opacity 0.18s ease;
}

/* Arabic and Japanese need their own type; the Latin fonts have no glyphs for
   them. Code and the version/hash lines keep the monospace face. */
html[lang="ar"] body,
html[lang="ar"] h1,
html[lang="ar"] h2,
html[lang="ar"] h3,
html[lang="ar"] .btn,
html[lang="ar"] .pill,
html[lang="ar"] .section-title,
html[lang="ar"] .layer-toggle,
html[lang="ar"] .reel-title,
html[lang="ar"] .shot-card strong,
html[lang="ar"] .nav-link {
  font-family: "Noto Kufi Arabic", "Manrope", sans-serif;
}

html[lang="ja"] body,
html[lang="ja"] h1,
html[lang="ja"] h2,
html[lang="ja"] h3,
html[lang="ja"] .btn,
html[lang="ja"] .pill,
html[lang="ja"] .section-title,
html[lang="ja"] .layer-toggle,
html[lang="ja"] .reel-title,
html[lang="ja"] .shot-card strong,
html[lang="ja"] .nav-link {
  font-family: "Noto Sans JP", "Manrope", sans-serif;
}

/* letter-spaced capitals are a Latin idiom; they break Arabic joining and
   look odd in Japanese */
html[lang="ar"] .pill,
html[lang="ja"] .pill,
html[lang="ar"] .compare-tag,
html[lang="ja"] .compare-tag,
html[lang="ar"] .layer-plane figcaption,
html[lang="ja"] .layer-plane figcaption {
  letter-spacing: 0;
  text-transform: none;
}

html[lang="ar"] .hero h1,
html[lang="ja"] .hero h1 {
  line-height: 1.3;
}

/* ── Right-to-left fixes the logical layout doesn't cover ─ */
[dir="rtl"] .faq summary {
  text-align: right;
}

[dir="rtl"] .callout-cta .arrow,
[dir="rtl"] .win-dialog .arrow {
  display: inline-block;
  transform: scaleX(-1);
}

[dir="rtl"] .list,
[dir="rtl"] .install-steps,
[dir="rtl"] .guide-steps {
  padding-right: 1.2rem;
  padding-left: 0;
}

[dir="rtl"] .onion-legend li,
[dir="rtl"] .layer-toggle {
  text-align: right;
}

/* code, keys, hashes and the version line read left to right in every language */
code,
.mono,
.code-line,
.license-key,
#expectedHash {
  direction: ltr;
  unicode-bidi: isolate;
}

/* ── The language switcher ─ */
.lang-switch {
  position: relative;
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: 38px;
  padding: 0 0.7rem;
  border-radius: 10px;
  border: 1px solid rgba(88, 166, 255, 0.35);
  background: rgba(88, 166, 255, 0.08);
  color: var(--text);
  font: 700 0.78rem "JetBrains Mono", monospace;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.lang-btn:hover,
.lang-switch.open .lang-btn {
  border-color: rgba(0, 255, 208, 0.6);
}

.lang-globe {
  width: 16px;
  height: 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges' fill='%2300ffd0'%3E%3Cpath d='M2 0h4v1H2zM1 1h1v1H1zM6 1h1v1H6zM0 2h1v4H0zM7 2h1v4H7zM1 6h1v1H1zM6 6h1v1H6zM2 7h4v1H2zM3 1h1v6H3zM4 1h1v6H4zM1 3h6v1H1zM1 4h6v1H1z'/%3E%3C/svg%3E") center / contain no-repeat;
  image-rendering: pixelated;
}

.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  min-width: 160px;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  border-radius: 12px;
  border: 1px solid rgba(88, 166, 255, 0.3);
  background: rgba(13, 17, 23, 0.97);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  display: none;
  z-index: 60;
}

.lang-switch.open .lang-menu {
  display: block;
}

.lang-menu button {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: 600 0.95rem "Manrope", sans-serif;
  text-align: start;
  cursor: pointer;
}

.lang-menu button[lang="ar"] {
  font-family: "Noto Kufi Arabic", sans-serif;
}

.lang-menu button[lang="ja"] {
  font-family: "Noto Sans JP", sans-serif;
}

.lang-menu button:hover,
.lang-menu button[aria-selected="true"] {
  background: rgba(88, 166, 255, 0.12);
  color: #9dfbe9;
}

/* ── The notice on legal pages in other languages ─ */
.legal-lang-note {
  display: none;
  margin: 0 0 1.4rem;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(0, 255, 208, 0.35);
  background: rgba(0, 255, 208, 0.06);
  color: var(--text);
}

html:not([lang="en"]) .legal-lang-note {
  display: block;
}

@media (max-width: 760px) {
  .lang-menu {
    inset-inline-end: auto;
    inset-inline-start: 0;
  }
}
