/* Aasiya v36: the globe button and its language list. Colours come from the shared design tokens, so every
   theme restyles it (see also the .lang-btn lines next to .account-btn in themes.css). Logical properties
   only, so it works in right-to-left. */
.lang-btn {
  position: relative;
  display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0;
  min-width: 0; height: 34px; padding-block: 0; padding-inline: 10px;
  color: var(--text-dim); font-size: .74rem; font-weight: 600; letter-spacing: .04em; line-height: 1;
  border: 1px solid var(--line); border-radius: var(--r-pill);
  transition: color .2s, border-color .2s;
}
.lang-btn:hover, .lang-btn[aria-expanded="true"] { color: var(--accent, var(--gold-bright)); border-color: var(--accent, var(--gold-dim)); }
.lang-btn:focus-visible, .lang-opt:focus-visible { outline: 2px solid var(--accent, var(--gold)); outline-offset: 2px; }
.lang-btn svg { flex-shrink: 0; }
/* a 44px touch target around the compact pill */
.lang-btn::after { content: ""; position: absolute; inset-block: -5px; inset-inline: -4px; }
html[data-theme="v1"] .lang-btn, html[data-theme="v2"] .lang-btn,
html[data-theme="v3"] .lang-btn, html[data-theme="v4"] .lang-btn { background: var(--surface); }

/* floating copy on the compass page, where the top bar is hidden (opposite the back button) */
.lang-btn-float { display: none; }
body:has(#view-qibla.view.active) .lang-btn-float { display: inline-flex; }
.lang-btn-float {
  position: fixed; z-index: 120;
  top: calc(14px + env(safe-area-inset-top)); right: 14px;   /* physical: the compass back button is physically at the left in both directions */
  height: 40px; padding-inline: 12px;
  background: var(--surface-2); border-color: var(--gold-dim); color: var(--gold);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
}
.lang-btn-float::after { inset-block: -2px; }
/* on a phone the compass title line is full width: sit on the back button's row instead, at the opposite edge */
@media (max-width: 600px) { .lang-btn-float { top: calc(66px + env(safe-area-inset-top)); } }

/* inside the setup wizard (first screen) */
.ob-lang-row { display: flex; justify-content: flex-end; margin-block-end: 4px; }
.ob-lang-row .lang-btn { height: 36px; }
.ob-lang-row .lang-btn::after { inset-inline: 0; }   /* the hit area must not widen the scrolling setup body */

/* the list (one shared popover, positioned in JS) */
.lang-pop {
  position: fixed; z-index: 500; display: flex; flex-direction: column;
  width: min(260px, calc(100vw - 16px));
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .38);
  overflow: hidden;
}
.lang-pop[hidden] { display: none; }
.lang-pop-h { padding: 10px 14px 8px; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); border-block-end: 1px solid var(--line); }
.lang-pop-list { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding-block: 4px; }
.lang-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; min-height: 44px; padding-block: 8px; padding-inline: 14px;
  text-align: start; font-size: .98rem; color: var(--text);
  background: transparent; border-radius: 0;
}
.lang-opt:hover, .lang-opt:focus-visible { background: var(--surface-2); }
.lang-opt-mark { visibility: hidden; color: var(--accent, var(--gold)); font-weight: 700; }
.lang-opt.on { font-weight: 600; }
.lang-opt.on .lang-opt-mark { visibility: visible; }

/* small phones: keep the top bar on one line next to the logo, title and sign-in button */
@media (max-width: 360px) {
  .lang-btn:not(.lang-btn-float) { gap: 3px; padding-inline: 7px; }
  .lang-btn:not(.lang-btn-float) svg { width: 16px; height: 16px; }
}

/* v36 polish: at 320 the page title was cut to "SIGN..." once the globe joined the bar. Tighter bar, smaller
   title tracking, a smaller back button and sign-in pill: the globe stays. */
@media (max-width: 360px) {
  .topbar { padding-inline: 10px; gap: 4px; }
  .topbar .nav-back { width: 34px; height: 34px; margin-inline-end: 0; }
  .topbar .nav-title { font-size: .74rem; letter-spacing: .05em; }
  .topbar .account-btn { padding: 6px 9px; gap: 4px; font-size: .74rem; }
  .topbar .account-btn svg { width: 18px; height: 18px; }
}

/* ---- v36 fixes: top bar that fits 320 to 430 px in English, Urdu and Arabic ----
   The globe and the Sign in pill are real touch targets (44px tall, text 14px or more). On a phone the page
   title moves to its own centred row under the bar and may wrap to two lines, so it is never cut to "MOS...".
   Logical properties only: the bar mirrors cleanly in right-to-left. */
.topbar .lang-btn:not(.lang-btn-float) { height: 44px; font-size: .875rem; padding-inline: 12px; }
.topbar .lang-btn::after { inset-block: 0; }
.topbar .account-btn { min-height: 44px; font-size: .875rem; padding-block: 0; padding-inline: 13px; }
.topbar .account-btn span { font-size: .875rem; }
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; row-gap: 2px; }
  .topbar .brand { flex: 1 1 0; min-width: 0; margin-inline-end: auto; }
  .topbar .brand-logo { flex-shrink: 0; }
  .topbar .brand-sub { margin-right: 0; margin-inline-end: 6px; }
  .topbar .nav-title {
    order: 9; flex: 1 0 100%; min-width: 0;
    white-space: normal; overflow: visible; text-overflow: clip;
    font-size: .9rem; line-height: 1.3; letter-spacing: .08em;
    padding-block: 2px 4px; text-wrap: balance;
  }
  .topbar .nav-title:empty { display: none; }
}
/* narrow bars: keep the logo, globe and Sign in on one row (the back arrow is 40px, the pill a little tighter) */
@media (max-width: 360px) {
  .topbar { padding-inline: 10px; gap: 4px; }
  .topbar .nav-back { width: 40px; height: 40px; margin-inline-end: 6px; }   /* v37.1 J: clear of the logo in both directions */
  .topbar .brand-logo { height: 26px; object-fit: contain; object-position: center; }   /* squeezed, the logo shrinks instead of stretching */
  .topbar .lang-btn:not(.lang-btn-float) { gap: 3px; padding-inline: 8px; }
  .topbar .account-btn { padding-inline: 9px; gap: 4px; max-width: none; }
  .topbar .account-btn svg { width: 18px; height: 18px; }
}
/* on the compass page the top bar is hidden: the globe sits in its own row above the dial, clear of the round buttons */
.lang-btn-float { height: 44px; font-size: .875rem; top: calc(10px + env(safe-area-inset-top)); }
@media (max-width: 600px) { .lang-btn-float { top: calc(10px + env(safe-area-inset-top)); } }
