/* ============================================================
   مِسبار — التمارين · leaderboard.css — «ترتيب المدار» (2026-11-25)
   Route #/lb (lb.js), the landing widget, the hero link and the line on the lesson end screen.
   Uses only the #ex tokens (dark default, html.light redefines them). Planets reuse the orbit.js
   palettes — no gold / silver / bronze. RTL throughout; Arabic headings keep line-height ≥ 1.15.
   ============================================================ */

body.ex-lbpage .ex-wrap { max-width: 1280px; }
#ex .lb { gap: 22px; }
#ex .lb .ex-crumbs { margin-bottom: -10px; }

/* ---------- header ---------- */
.lb-head { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 22px; align-items: center; padding: 26px 30px; border-radius: 26px; background: var(--ex-hero); border: 1px solid var(--ex-line); overflow: hidden; }
.lb-head-mark { width: 96px; height: 96px; color: var(--ex-vio); flex: none; }
.lb-head-mark svg, .lb-cta-mark svg { display: block; width: 100%; height: 100%; }
.lb-head-tx { display: grid; gap: 8px; min-width: 0; }
.lb-head .ex-hero-p { max-width: 62ch; }

/* ---------- tabs + reset line ---------- */
.lb-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; }
.lb-tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 16px; background: var(--ex-s); border: 1px solid var(--ex-line); }
.lb-tabs [role="tab"] { min-height: 44px; padding: 0 20px; border-radius: 12px; border: 0; background: transparent; color: var(--ex-mut); font-weight: 800; font-size: 14.5px; cursor: pointer; transition: background .15s, color .15s; }
.lb-tabs [role="tab"]:hover { color: var(--ex-ink); background: var(--ex-s2); }
.lb-tabs [role="tab"][aria-selected="true"] { background: var(--ex-vio); color: var(--ex-on); }
.lb-reset { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 13.5px; color: var(--ex-mut); }
.lb-reset > svg { color: var(--ex-vio); }
.lb-reset b { color: var(--ex-ink); font-weight: 800; }
.lb-reset-d { color: var(--ex-faint); }

/* ---------- layout ---------- */
.lb-grid { display: grid; gap: 20px; }
.lb-main { display: grid; gap: 18px; align-content: start; min-width: 0; }
.lb-side { display: grid; gap: 16px; align-content: start; min-width: 0; }
@media (min-width: 720px) and (max-width: 1099px) { .lb-side { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; } }
@media (min-width: 1100px) {
  .lb-grid { grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
  .lb-side { position: sticky; top: 104px; }
}

/* ---------- small shared bits ---------- */
.lb-k { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 12.5px; font-weight: 800; color: var(--ex-vio); }
.lb-you { flex: none; display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 99px; background: var(--ex-vio); color: var(--ex-on); font-size: 11.5px; font-weight: 900; line-height: 1; }
.lb-hid { flex: none; display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 99px; background: var(--ex-s3); color: var(--ex-mut); font-size: 11.5px; font-weight: 800; white-space: nowrap; line-height: 1; }
.lb-up { flex: none; display: inline-flex; align-items: center; gap: 3px; height: 24px; padding: 0 9px; border-radius: 99px; background: var(--ex-okbg); color: var(--ex-ok); font-size: 12px; font-weight: 900; line-height: 1; vertical-align: middle; }
.lb-chip { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 99px; background: var(--ex-t); color: var(--ex-vio); font-size: 12px; font-weight: 800; }

/* ---------- planets (avatars) ---------- */
.lb-planet {
  --p1: #C4B5FD; --p2: #6D28D9;
  position: relative; z-index: 1; display: grid; place-items: center; flex: none; border-radius: 50%; color: #fff; font-weight: 900;
  background: radial-gradient(circle at 32% 28%, var(--p1) 0%, color-mix(in srgb, var(--p1) 35%, var(--p2)) 24%, var(--p2) 70%, color-mix(in srgb, var(--p2) 72%, #000) 100%);
  box-shadow: inset -6px -8px 14px rgba(0,0,0,.26), 0 6px 18px color-mix(in srgb, var(--p2) 32%, transparent);
}
/* palettes = orbit.js PLANETS (0 violet = the brand planet, 1 teal, 2 rose, 3 green, 4 blue, 5 indigo). Classes, not inline
   styles: theme.css recolours any inline style containing "C4B5FD" in light mode. Same in both themes (they are objects). */
.lb-planet.is-pal-0 { --p1: #C4B5FD; --p2: #6D28D9; }
.lb-planet.is-pal-1 { --p1: #A5F3FC; --p2: #0E7490; }
.lb-planet.is-pal-2 { --p1: #F9A8D4; --p2: #BE185D; }
.lb-planet.is-pal-3 { --p1: #A7F3D0; --p2: #047857; }
.lb-planet.is-pal-4 { --p1: #BFDBFE; --p2: #1D4ED8; }
.lb-planet.is-pal-5 { --p1: #DDD6FE; --p2: #4C1D95; }
.lb-planet-i { line-height: 1; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.lb-planet.is-sm { width: 36px; height: 36px; font-size: 14px; box-shadow: inset -3px -4px 8px rgba(0,0,0,.24); }
.lb-planet.is-lg { width: 70px; height: 70px; font-size: 23px; }
.lb-planet.is-xl { width: 96px; height: 96px; font-size: 31px; }
.lb-planet.is-anon { color: rgba(255,255,255,.92); }
.lb-planet.is-ghost { background: transparent; border: 2px dashed var(--ex-line2); box-shadow: none; }
/* the brand ring on the leader: full ring behind the planet (on the wrapper) + its front half over it */
.lb-pod-orb { position: relative; display: grid; place-items: center; }
.lb-pod-i.is-p1 .lb-pod-orb::before,
.lb-pod-i.is-p1 .lb-planet.is-xl::after {
  content: ""; position: absolute; left: -30%; right: -30%; top: 37%; height: 26%; border-radius: 50%;
  border: 2.5px solid color-mix(in srgb, var(--ex-vio2) 80%, transparent); transform: rotate(-24deg); pointer-events: none;
}
.lb-pod-i.is-p1 .lb-pod-orb::before { z-index: 0; opacity: .55; }
.lb-pod-i.is-p1 .lb-planet.is-xl::after { clip-path: inset(50% 0 0 0); }
.lb-pod-i.is-p1.is-ghost .lb-pod-orb::before, .lb-pod-i.is-p1.is-ghost .lb-planet.is-xl::after { border-style: dashed; border-color: var(--ex-line2); opacity: 1; }

/* ---------- guest conversion card + member card ---------- */
.lb-cta, .lb-me { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; align-items: center; padding: 22px 26px; }
.lb-cta { border-color: color-mix(in srgb, var(--ex-vio) 45%, var(--ex-line)); background: radial-gradient(90% 150% at 100% 0%, color-mix(in srgb, var(--ex-vio) 16%, transparent) 0%, transparent 62%), var(--ex-s); }
.lb-cta-mark { width: 84px; height: 84px; color: var(--ex-vio); }
.lb-cta-tx, .lb-me-tx { display: grid; gap: 4px; min-width: 0; }
.lb-cta-h { margin: 0; font-size: clamp(19px, 2.1vw, 23px); font-weight: 900; line-height: 1.55; }
.lb-cta-h b { color: var(--ex-vio); font-weight: 900; }
.lb-cta-p, .lb-me-p { margin: 0; font-size: 14.5px; line-height: 1.8; color: var(--ex-body); max-width: 64ch; }
.lb-cta-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin-top: 12px; }
.lb-cta-login { display: inline-flex; align-items: center; min-height: 44px; font-weight: 700; font-size: 14px; color: var(--ex-mut); text-decoration: underline; text-underline-offset: 4px; }
.lb-cta-login:hover { color: var(--ex-ink); }
.lb-me { border-color: color-mix(in srgb, var(--ex-vio) 35%, var(--ex-line)); }
.lb-me-orb { display: grid; place-items: center; }
.lb-me-h { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: clamp(22px, 2.6vw, 28px); font-weight: 900; line-height: 1.3; }
.lb-me.is-out .lb-me-h { font-size: clamp(18px, 2vw, 21px); line-height: 1.5; }
.lb-me-h small { font-size: 15px; font-weight: 700; color: var(--ex-mut); }
.lb-me-p { display: flex; flex-wrap: wrap; gap: 2px 0; }
.lb-me-p > span + span::before { content: "·"; margin: 0 10px; color: var(--ex-faint); }
.lb-me-p b, .lb-me-next b { color: var(--ex-ink); font-weight: 900; }
.lb-me-next { margin: 0; font-size: 14px; line-height: 1.7; color: var(--ex-vio); font-weight: 700; }

/* ---------- the board ---------- */
.lb-board { position: relative; display: grid; gap: 14px; padding: 18px 20px 20px; }
.lb-stage { position: relative; padding: 14px 0 2px; }
.lb-stage-orbits { position: absolute; inset: 0 0 auto; width: 100%; height: 74%; pointer-events: none; overflow: visible; }
.lb-stage-orbits ellipse { fill: none; stroke: var(--ex-line2); stroke-width: 1.3; stroke-dasharray: 2 7; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.lb-pod { position: relative; list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1fr); align-items: end; gap: 8px; }
.lb-pod-i { display: grid; justify-items: center; align-content: end; text-align: center; gap: 3px; min-width: 0; padding: 12px 8px 14px; border-radius: 20px; }
.lb-pod-i.is-p1 { order: 2; padding-bottom: 40px; }
.lb-pod-i.is-p2 { order: 1; }
.lb-pod-i.is-p3 { order: 3; }
.lb-pod-i.is-me { background: color-mix(in srgb, var(--ex-vio) 10%, transparent); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ex-vio) 55%, transparent); }
.lb-pod-rank { position: absolute; z-index: 2; left: 50%; bottom: -9px; transform: translateX(-50%); min-width: 26px; height: 26px; padding: 0 6px; border-radius: 99px; display: grid; place-items: center; background: var(--ex-s); border: 2px solid var(--ex-line2); color: var(--ex-ink); font-size: 13px; font-weight: 900; line-height: 1; }
.lb-pod-i.is-p1 .lb-pod-rank { border-color: var(--ex-vio); color: var(--ex-vio); }
.lb-pod-name { display: block; max-width: 100%; margin-top: 14px; font-size: 15.5px; font-weight: 800; line-height: 1.45; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-pod-tags { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.lb-pod-xp { font-size: 13px; font-weight: 700; color: var(--ex-mut); }
.lb-pod-xp b { font-size: 19px; font-weight: 900; color: var(--ex-ink); }
.lb-pod-i.is-p1 .lb-pod-xp b { font-size: 22px; }
.lb-pod-l { font-size: 12px; color: var(--ex-faint); font-weight: 600; }
.lb-pod-i.is-ghost .lb-pod-name { color: var(--ex-faint); font-weight: 700; font-size: 14px; }
.lb-pod-i.is-ghost .lb-pod-rank { color: var(--ex-faint); border-style: dashed; }
.lb-stage.is-empty .lb-pod-i { opacity: .9; }

.lb-empty { display: grid; gap: 4px; justify-items: center; text-align: center; margin: 2px 0 4px; padding: 0 12px; font-size: 17px; font-weight: 800; line-height: 1.55; color: var(--ex-ink); }
.lb-empty small { font-size: 13.5px; font-weight: 600; color: var(--ex-mut); }

.lb-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.lb-row, .lb-mebar { display: grid; grid-template-columns: 30px 36px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 9px 14px; border-radius: 14px; }
.lb-row { background: color-mix(in srgb, var(--ex-s2) 70%, transparent); }
.lb-row-rank { font-size: 15px; font-weight: 900; color: var(--ex-mut); text-align: center; font-variant-numeric: tabular-nums; }
.lb-row-who { display: grid; min-width: 0; line-height: 1.4; }
.lb-row-n { display: flex; align-items: center; gap: 8px; min-width: 0; }
.lb-row-name { font-size: 15px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lb-row-who small { font-size: 12px; color: var(--ex-faint); font-weight: 600; }
.lb-row-xp { font-size: 12.5px; font-weight: 700; color: var(--ex-mut); white-space: nowrap; }
.lb-row-xp b { font-size: 16px; font-weight: 900; color: var(--ex-ink); }
.lb-row.is-me { background: var(--ex-t); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ex-vio) 60%, transparent); }
.lb-row.is-me .lb-row-rank { color: var(--ex-vio); }

.lb-total { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 2px 0 0; font-size: 13px; color: var(--ex-faint); font-weight: 600; }

/* the floating «أنت» bar (sticky to the bottom of the viewport while the viewer's row is off-screen) */
.lb-mebar { position: sticky; bottom: 14px; z-index: 5; grid-template-columns: 30px 36px minmax(0, 1fr) auto auto; background: var(--ex-s); border: 1.5px solid color-mix(in srgb, var(--ex-vio) 65%, var(--ex-line)); box-shadow: var(--ex-sh2); transition: opacity .2s, transform .2s var(--ex-ease), visibility .2s; }
.lb-mebar .lb-row-rank { color: var(--ex-vio); }
.lb-mebar.is-off { opacity: 0; transform: translateY(10px); visibility: hidden; pointer-events: none; }
.lb-mebar-go { min-height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--ex-line2); background: transparent; color: var(--ex-ink); font-weight: 800; font-size: 13px; cursor: pointer; white-space: nowrap; }
.lb-mebar-go:hover { background: var(--ex-s2); }
/* below 1100px the site-wide back-to-top button (ux.css .to-top, bottom-left in RTL) would sit on the bar's XP: lift it while the bar shows */
@media (max-width: 1099px) { body.ex-lbpage:has(.lb-mebar:not(.is-off)) .to-top { bottom: 92px; } }

/* loading / error */
.lb-skel { display: grid; gap: 8px; }
.lb-skel-pod { display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 10px; align-items: end; margin-bottom: 8px; }
.lb-skel-pod .ex-skel { display: block; height: 150px; border-radius: 18px; }
.lb-skel-pod .ex-skel.is-1 { height: 186px; }
.lb-skel-row { display: block; height: 54px; border-radius: 14px; }
.lb-err { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 34px 16px 30px; }
.lb-err p { max-width: 44ch; }
.lb-err-ic { width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; background: var(--ex-t); color: var(--ex-vio); margin-bottom: 4px; }
.lb-err .ex-btn { margin-top: 6px; }

/* ---------- side column ---------- */
.lb-rules-l { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.lb-rules-l li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 10px; font-size: 13.5px; line-height: 1.75; color: var(--ex-body); }
.lb-rules-l svg { color: var(--ex-vio); margin-top: 4px; }
.lb-switchrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 8px 12px; border-radius: 14px; background: var(--ex-s2); cursor: pointer; }
.lb-switch-l { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 14.5px; }
.lb-switch-l svg { color: var(--ex-mut); }
.lb-switch { position: relative; flex: none; width: 52px; height: 30px; border-radius: 99px; border: 0; background: var(--ex-faint); cursor: pointer; transition: background .2s; }
.lb-switch i { position: absolute; top: 3px; inset-inline-start: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: inset-inline-start .2s var(--ex-ease); }
.lb-switch[aria-checked="true"] { background: var(--ex-vio); }
.lb-switch[aria-checked="true"] i { inset-inline-start: 25px; }
.lb-switch[disabled] { opacity: .6; cursor: progress; }
.lb-status { margin: 0; min-height: 1.2em; font-size: 13px; font-weight: 700; color: var(--ex-vio); }
.lb-status:empty { display: none; }

/* ---------- landing widget ---------- */
.lb-wid-b { display: grid; gap: 10px; }
.lb-skel-mini { display: block; height: 42px; border-radius: 12px; }
.lb-mini { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.lb-mini li { display: grid; grid-template-columns: 20px 32px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 12px; }
.lb-mini li.is-me { background: var(--ex-t); }
.lb-mini .lb-planet.is-sm { width: 32px; height: 32px; font-size: 13px; }
.lb-mini .lb-row-rank { font-size: 13.5px; }
.lb-mini-n { font-size: 14px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lb-mini-xp { font-size: 12px; font-weight: 700; color: var(--ex-mut); white-space: nowrap; }
.lb-mini-xp b { font-size: 14px; color: var(--ex-ink); font-weight: 900; }
.lb-wid-me { margin: 0; padding-top: 10px; border-top: 1px solid var(--ex-line); font-size: 13.5px; line-height: 1.7; color: var(--ex-body); }
.lb-wid-me b { color: var(--ex-ink); font-weight: 900; }
.lb-wid-me.is-out, .lb-wid-me.is-guest { color: var(--ex-mut); }
.lb-wid-me.is-guest b { color: var(--ex-vio); }
.lb-wid-empty { text-align: center; color: var(--ex-mut); }
.lb-wid-err { display: flex; align-items: center; gap: 8px; color: var(--ex-mut); }
.lb-wid-err svg { color: var(--ex-vio); flex: none; }
.lb-wid-cta { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 14px; border-radius: 12px; background: var(--ex-vio); color: var(--ex-on); font-weight: 800; font-size: 14px; }
.lb-wid-cta:hover { filter: brightness(1.06); }
.lb-wid-link { justify-self: start; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; font-weight: 800; font-size: 13.5px; color: var(--ex-vio); }
.lb-wid-link:hover span { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- landing hero link ---------- */
.ex-hero-lb { justify-self: start; display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-height: 44px; margin-top: 4px; padding: 6px 14px 6px 16px; border-radius: 999px; background: color-mix(in srgb, var(--ex-s) 78%, transparent); border: 1px solid color-mix(in srgb, var(--ex-vio) 45%, var(--ex-line)); font-weight: 800; font-size: 14.5px; transition: border-color .15s, transform .15s var(--ex-ease); }
.ex-hero-lb > svg { color: var(--ex-vio); }
.ex-hero-lb small { font-size: 12.5px; color: var(--ex-mut); font-weight: 700; }
.ex-hero-lb:hover { border-color: var(--ex-vio); transform: translateY(-1px); }

/* ---------- lesson / test end screen line ---------- */
#ex .ls-lb { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 8px; margin: 0 0 12px; padding: 8px 16px; border-radius: 99px; background: var(--ex-t); color: var(--ex-body); font-size: 14px; font-weight: 700; line-height: 1.6; }
#ex .ls-lb[hidden] { display: none; }
#ex .ls-lb > svg { color: var(--ex-vio); }
#ex .ls-lb b { color: var(--ex-ink); font-weight: 900; }
#ex .ls-lb a { color: var(--ex-vio); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
#ex .ls-lb .ls-lb-wait { color: var(--ex-mut); }

/* ---------- motion ---------- */
.lb-board.is-in .lb-pod-i { animation: lb-rise .55s var(--ex-ease) both; }
.lb-board.is-in .lb-pod-i.is-p1 { animation-delay: .06s; }
.lb-board.is-in .lb-pod-i.is-p3 { animation-delay: .12s; }
.lb-board.is-in .lb-row { animation: lb-fade .4s var(--ex-ease) both; animation-delay: .15s; }
@keyframes lb-rise { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes lb-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .lb-board.is-in .lb-pod-i, .lb-board.is-in .lb-row { animation: none; }
  .lb-mebar, .lb-switch, .lb-switch i, .ex-hero-lb { transition: none; }
}

/* ---------- phones ---------- */
@media (max-width: 680px) {
  #ex .lb { gap: 18px; }
  .lb-head { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 20px 18px; border-radius: 22px; }
  .lb-head-mark { position: absolute; inset-inline-end: -14px; top: -10px; width: 92px; height: 92px; opacity: .35; }
  .lb-bar { gap: 10px; }
  .lb-tabs { width: 100%; }
  .lb-tabs [role="tab"] { flex: 1; padding: 0 10px; }
  .lb-cta, .lb-me { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 18px; }
  .lb-cta-mark { display: none; }
  .lb-me { grid-template-columns: auto minmax(0, 1fr); align-items: start; }
  .lb-me .lb-planet.is-lg { width: 52px; height: 52px; font-size: 18px; }
  .lb-cta-btn { width: 100%; }
  .lb-board { padding: 14px 12px 16px; }
  .lb-pod { gap: 4px; }
  .lb-pod-i { padding: 10px 4px 12px; }
  .lb-pod-i.is-p1 { padding-bottom: 30px; }
  .lb-planet.is-xl { width: 74px; height: 74px; font-size: 25px; }
  .lb-planet.is-lg { width: 56px; height: 56px; font-size: 19px; }
  .lb-pod-name { font-size: 14px; }
  .lb-pod-xp b { font-size: 17px; }
  .lb-pod-i.is-p1 .lb-pod-xp b { font-size: 19px; }
  .lb-row, .lb-mebar { grid-template-columns: 24px 34px minmax(0, 1fr) auto; gap: 10px; padding: 9px 10px; }
  .lb-mebar { grid-template-columns: 24px 34px minmax(0, 1fr) auto; }
  .lb-mebar-go { display: none; }
  .lb-planet.is-sm { width: 34px; height: 34px; font-size: 13px; }
}
