/* ============================================================
   مِسبار — التمارين · fx.css
   Motion layer (fx.js) + orbit achievements (orbit.js).
   Transform/opacity only. Uses the #ex --ex-* tokens (dark default, html.light overrides).
   prefers-reduced-motion → no orbiting, no particles: calm fades only.
   ============================================================ */

/* ---------- particle layer ---------- */
#ex .fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 260; overflow: hidden; }
#ex .fx-p { position: fixed; display: block; will-change: transform, opacity; transform: translate(-50%, -50%); }
#ex .fx-star { width: 16px; height: 16px; filter: drop-shadow(0 0 6px currentColor); }
#ex .fx-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; }
#ex .fx-p.is-ok { color: var(--ex-ok); } #ex .fx-p.is-vio { color: var(--ex-vio); }
#ex .fx-p.is-bolt { color: var(--ex-bolt); } #ex .fx-p.is-vio2 { color: var(--ex-vio2); }
#ex .fx-ring { border-radius: 50%; border: 3px solid var(--ex-ok); box-shadow: 0 0 24px var(--ex-ok), inset 0 0 18px var(--ex-okbg); opacity: 0; }
#ex .fx-spark { width: 10px; height: 10px; border-radius: 50%; background: radial-gradient(circle, #FFF8D6 0 30%, var(--ex-bolt) 60%, transparent 72%); box-shadow: 0 0 12px var(--ex-bolt); opacity: 0; }
#ex .fx-xptag { padding: 4px 10px; border-radius: 999px; background: var(--ex-bolt); color: #1A1300; font-weight: 900; font-size: 14px; white-space: nowrap; box-shadow: 0 8px 22px rgba(0,0,0,.25); opacity: 0; }
#ex .fx-flash { border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.95) 0, rgba(196,181,253,.7) 30%, rgba(167,139,250,0) 70%); opacity: 0; }

/* ---------- sound toggle ---------- */
#ex .fx-sound { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--ex-line2); background: var(--ex-s2); color: var(--ex-ink); font: inherit; font-size: 13px; font-weight: 800; cursor: pointer; transition: background .15s, color .15s; }
#ex .fx-sound:hover { background: var(--ex-s3); }
#ex .fx-sound.is-muted { color: var(--ex-mut); }
#ex .fx-sound:focus-visible { outline: 2px solid var(--ex-vio); outline-offset: 2px; }
#ex .ex-dock .fx-sound { width: 40px; height: 40px; padding: 0; justify-content: center; border-radius: 12px; }
#ex .ex-dock .fx-sound-l { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#ex .ex-section-h .fx-sound { margin-inline-start: auto; }

/* ---------- sheet entrance accents ---------- */
@media (prefers-reduced-motion: no-preference) {
  #ex .ex-sheet.is-ok.is-on .ex-sheet-ic { animation: fx-ic-pop .55s cubic-bezier(.2,1.4,.4,1) both; }
  #ex .ex-sheet.is-close.is-on .ex-sheet-ic { animation: fx-ic-nod .5s ease-out both; }
}
@keyframes fx-ic-pop { 0% { transform: scale(.3) rotate(-30deg); } 60% { transform: scale(1.18) rotate(6deg); } 100% { transform: none; } }
@keyframes fx-ic-nod { 0%,100% { transform: none; } 30% { transform: rotate(-10deg); } 60% { transform: rotate(6deg); } }

/* ============================================================
   ORBIT ACHIEVEMENTS
   ============================================================ */
#ex .orb {
  --orb-sky1: #120C2A; --orb-sky2: #07060F; --orb-star: rgba(237,233,254,.9); --orb-path: rgba(167,139,250,.16); --orb-lit: rgba(196,181,253,.55);
  --orb-ghost: rgba(196,181,253,.42); --orb-cap: #F4F4F6; --orb-capm: #B9B4CC;
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 22px; align-items: center;
}
html.light #ex .orb {
  --orb-sky1: #EDE4FF; --orb-sky2: #F8F5FF; --orb-star: rgba(91,33,182,.55); --orb-path: rgba(109,40,217,.16); --orb-lit: rgba(109,40,217,.5);
  --orb-ghost: rgba(91,33,182,.5); --orb-cap: #18181B; --orb-capm: #52525B;
}
#ex .orb-stage { position: relative; aspect-ratio: 1 / 1; width: 100%; max-width: 460px; justify-self: center; border-radius: 28px; overflow: hidden; isolation: isolate;
  background: radial-gradient(70% 70% at 50% 46%, var(--orb-sky1) 0%, var(--orb-sky2) 100%); border: 1px solid var(--ex-line2); --mx: 0; --my: 0; }
#ex .orb-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible;
  transform: translate(calc(var(--mx) * -10px), calc(var(--my) * -10px)); transition: transform .5s cubic-bezier(.2,.8,.2,1); }

/* starfield: three depths, parallax on pointer + slow drift */
#ex .orb-sky { position: absolute; inset: -12%; z-index: -1; }
#ex .orb-stars { position: absolute; inset: 0; background-repeat: repeat; transition: transform .6s cubic-bezier(.2,.8,.2,1); }
#ex .orb-stars.s1 { background-image: radial-gradient(1px 1px at 20% 30%, var(--orb-star) 98%, transparent), radial-gradient(1px 1px at 70% 80%, var(--orb-star) 98%, transparent), radial-gradient(1px 1px at 85% 15%, var(--orb-star) 98%, transparent), radial-gradient(1px 1px at 40% 65%, var(--orb-star) 98%, transparent); background-size: 90px 90px; opacity: .55; transform: translate(calc(var(--mx) * 6px), calc(var(--my) * 6px)); }
#ex .orb-stars.s2 { background-image: radial-gradient(1.4px 1.4px at 10% 60%, var(--orb-star) 98%, transparent), radial-gradient(1.4px 1.4px at 60% 25%, var(--orb-star) 98%, transparent), radial-gradient(1.2px 1.2px at 90% 75%, var(--orb-star) 98%, transparent); background-size: 150px 150px; opacity: .75; transform: translate(calc(var(--mx) * 16px), calc(var(--my) * 16px)); }
#ex .orb-stars.s3 { background-image: radial-gradient(2px 2px at 30% 40%, var(--orb-star) 98%, transparent), radial-gradient(1.8px 1.8px at 80% 55%, var(--orb-star) 98%, transparent); background-size: 230px 230px; opacity: .9; transform: translate(calc(var(--mx) * 30px), calc(var(--my) * 30px)); }

/* orbits */
#ex .orb-path { fill: none; stroke: var(--orb-path); stroke-width: 1; stroke-dasharray: 2 5; }
#ex .orb-path.is-lit { stroke: var(--orb-lit); stroke-width: 1.4; stroke-dasharray: none; }
#ex .orb-shock { fill: none; stroke: #EDE9FE; stroke-width: 3; opacity: 0; transform-origin: 200px 200px; }

/* core (the Misbaar planet) */
#ex .orb-cring { fill: none; stroke: #C4B5FD; stroke-width: 3.2; stroke-linecap: round; }
#ex .orb-cring.is-thin { stroke-width: 1.4; opacity: .7; }
html.light #ex .orb-cring { stroke: #7C3AED; }
#ex .orb-coreglow { transform-origin: 0 0; }
#ex .orb-probe { filter: drop-shadow(0 0 4px #C4B5FD); }

/* planets */
#ex .orb-p { transform-origin: 200px 200px; transform: rotate(calc(var(--a) * 1deg)); }
#ex .orb-pin { transform-origin: var(--px) 200px; transform: rotate(calc(var(--a) * -1deg)); }
#ex .orb-ghost { fill: none; stroke: var(--orb-ghost); stroke-width: 1.3; stroke-dasharray: 3 3; }
#ex .orb-ghost-ring { fill: none; stroke: var(--orb-ghost); stroke-width: 1; stroke-dasharray: 2 3; opacity: .7; }
#ex .orb-pring { fill: none; stroke-width: 2.2; opacity: .95; }
#ex .orb-pring.is-thin { stroke-width: 1.1; opacity: .7; }
#ex .orb-band { fill: none; stroke: rgba(255,255,255,.35); stroke-width: 1.6; }
#ex .orb-body { filter: drop-shadow(0 0 6px rgba(167,139,250,.35)); }
#ex .orb-hot { fill: none; stroke: #EDE9FE; stroke-width: 1.5; opacity: 0; transition: opacity .2s; }
html.light #ex .orb-hot { stroke: #6D28D9; }
#ex .orb-p.is-hot .orb-hot { opacity: .9; }
#ex .orb-p.is-off.is-hot .orb-ghost { stroke: var(--ex-vio); stroke-dasharray: none; }
#ex .orb-settle, #ex .orb-hot, #ex .orb-core { transform-origin: 0 0; }
#ex .orb-moon { transform-origin: 0 0; transform: rotate(var(--ma)); }

/* comet */
#ex .orb-comet-path { fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 90 900; stroke-dashoffset: 90; opacity: 0; }

/* caption */
#ex .orb-cap { position: absolute; inset-inline: 0; bottom: 0; padding: 26px 16px 14px; display: grid; gap: 2px; text-align: center; background: linear-gradient(transparent, color-mix(in srgb, var(--orb-sky2) 92%, transparent)); }
#ex .orb-cap b { color: var(--orb-cap); font-size: 17px; font-weight: 900; line-height: 1.4; }
#ex .orb-cap span { color: var(--orb-capm); font-size: 12.5px; line-height: 1.6; }

/* legend + tooltips */
#ex .orb-side { display: grid; gap: 12px; align-content: start; min-width: 0; }
#ex .orb-h { font-size: 16px; font-weight: 900; line-height: 1.4; }
#ex .orb-count { color: var(--ex-mut); font-size: 13.5px; }
#ex .orb-count b { color: var(--ex-ink); font-size: 20px; font-weight: 900; margin-inline-end: 2px; }
#ex .orb-empty { color: var(--ex-mut); font-size: 14px; line-height: 1.8; }
#ex .orb-legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
#ex .orb-chip { position: relative; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 12px; border-radius: 14px; background: var(--ex-s); border: 1px solid var(--ex-line); cursor: default; outline: none; transition: border-color .15s, background .15s; }
#ex .orb-chip.is-off { background: transparent; border-style: dashed; }
#ex .orb-chip.is-hot, #ex .orb-chip:focus-visible { border-color: var(--ex-vio); background: var(--ex-t); }
#ex .orb-chip:focus-visible { box-shadow: 0 0 0 2px var(--ex-vio); }
#ex .orb-chip.is-new { border-color: var(--ex-vio); }
#ex .orb-sw { flex: none; width: 24px; height: 24px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--c1), var(--c2)); box-shadow: 0 0 10px color-mix(in srgb, var(--c1) 55%, transparent); }
#ex .orb-chip.is-off .orb-sw { background: transparent; box-shadow: none; border: 1.5px dashed var(--ex-faint); }
#ex .orb-chip-tx { display: grid; min-width: 0; }
#ex .orb-chip-tx b { font-size: 13.5px; font-weight: 800; line-height: 1.45; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ex .orb-chip.is-off .orb-chip-tx b { color: var(--ex-mut); }
#ex .orb-chip-tx small { font-size: 11.5px; color: var(--ex-mut); line-height: 1.5; }
#ex .orb-chip.is-new .orb-chip-tx small { color: var(--ex-vio); font-weight: 800; }
#ex .orb-tip { position: absolute; z-index: 20; bottom: calc(100% + 8px); inset-inline-start: 0; width: max-content; max-width: 260px; display: grid; gap: 4px; padding: 10px 12px; border-radius: 12px; background: var(--ex-ink); color: var(--ex-bg); font-size: 13px; line-height: 1.7; box-shadow: var(--ex-sh2); opacity: 0; visibility: hidden; transform: translateY(4px); transition: opacity .15s, transform .15s, visibility 0s .15s; pointer-events: none; }
#ex .orb-tip b { font-size: 13.5px; font-weight: 900; }
#ex .orb-tip em { font-style: normal; font-weight: 800; }
#ex .orb-chip.is-hot .orb-tip, #ex .orb-chip:hover .orb-tip, #ex .orb-chip:focus-visible .orb-tip { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }

/* compact (completion screen) */
#ex .orb.is-compact .orb-stage { max-width: 400px; }

/* level-up banner */
#ex .orb-levelup { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: 16px; background: linear-gradient(90deg, var(--ex-t2), var(--ex-t)); border: 1px solid var(--ex-vio); }
#ex .orb-levelup b { display: block; color: var(--ex-ink); font-size: 16px; font-weight: 900; line-height: 1.45; }
#ex .orb-levelup span { color: var(--ex-mut); font-size: 13.5px; }
#ex .orb-levelup .ex-ic { color: var(--ex-vio); flex: none; }

/* ---------- motion (only when allowed) ---------- */
@media (prefers-reduced-motion: no-preference) {
  #ex .orb-p.is-got { animation: orb-spin var(--dur) linear infinite; }
  #ex .orb-p.is-got .orb-pin { animation: orb-unspin var(--dur) linear infinite; }
  #ex .orb-moon { animation: orb-moon var(--md) linear infinite; }
  #ex .orb-comet-path { animation: orb-comet 11s cubic-bezier(.4,0,.3,1) 2.2s infinite; }
  #ex .orb-sky { animation: orb-drift 60s linear infinite alternate; }
  #ex .orb-coreglow { animation: orb-breathe 5s ease-in-out infinite; }

  /* entry: rings draw, core pops, planets settle into orbit one after another */
  #ex .orb.is-enter .orb-path { stroke-dashoffset: 1200; }
  #ex .orb.is-enter .orb-path.is-lit { stroke-dasharray: 1200; }
  #ex .orb.is-enter.is-go .orb-path.is-lit { animation: orb-draw 1.4s cubic-bezier(.2,.8,.2,1) calc(var(--k) * 140ms) both; }
  #ex .orb.is-enter .orb-core { opacity: 0; }
  #ex .orb.is-enter.is-go .orb-core { animation: orb-core-in .9s cubic-bezier(.2,1.3,.4,1) both; }
  #ex .orb.is-enter .orb-p.is-got .orb-settle { opacity: 0; }
  #ex .orb.is-enter.is-go .orb-p.is-got .orb-settle { animation: orb-settle 1.2s cubic-bezier(.2,.9,.25,1) calc(400ms + var(--i) * 110ms) both; }
  #ex .orb.is-enter.is-go .orb-p.is-new .orb-settle { animation: orb-settle-new 1.8s cubic-bezier(.2,.9,.25,1) 900ms both; }
  #ex .orb.is-enter.is-go .orb-p.is-new .orb-hot { animation: orb-halo 1.6s ease-out 2.4s 3 both; }
  #ex .orb.is-enter .orb-stars { opacity: 0; }
  #ex .orb.is-enter.is-go .orb-stars { animation: orb-fade 1.2s ease-out both; }
  #ex .orb.is-enter.is-go .orb-stars.s2 { animation-delay: .15s; } #ex .orb.is-enter.is-go .orb-stars.s3 { animation-delay: .3s; }
  #ex .orb.is-enter.is-go .orb-comet-path { animation: orb-comet 2.4s cubic-bezier(.4,0,.3,1) .2s both, orb-comet 11s cubic-bezier(.4,0,.3,1) 6s infinite; }

  /* level-up: the new orbit ring expands out of the core with a shockwave */
  #ex .orb.is-levelup.is-go .orb-path.is-new { animation: orb-ring-new 1.6s cubic-bezier(.2,.9,.25,1) 1.1s both; transform-origin: 200px 200px; stroke: #EDE9FE; }
  #ex .orb.is-levelup.is-go .orb-shock { animation: orb-shock 1.5s ease-out 1.5s both; }
  #ex .orb-levelup { animation: orb-lv-in .8s cubic-bezier(.2,1.3,.4,1) both; }
  #ex .orb-chip.is-new { animation: orb-chip-new 1.2s cubic-bezier(.2,.9,.25,1) 1.2s both; }
}
@media (prefers-reduced-motion: reduce) {
  #ex .orb.is-enter.is-go { animation: orb-fade .5s ease-out both; }
}
@keyframes orb-spin { from { transform: rotate(calc(var(--a) * 1deg)); } to { transform: rotate(calc(var(--a) * 1deg + 360deg)); } }
@keyframes orb-unspin { from { transform: rotate(calc(var(--a) * -1deg)); } to { transform: rotate(calc(var(--a) * -1deg - 360deg)); } }
@keyframes orb-moon { from { transform: rotate(var(--ma)); } to { transform: rotate(calc(var(--ma) + 360deg)); } }
@keyframes orb-comet { 0% { stroke-dashoffset: 90; opacity: 0; } 10% { opacity: 1; } 70% { opacity: 1; } 100% { stroke-dashoffset: -620; opacity: 0; } }
@keyframes orb-drift { from { transform: translate(0, 0); } to { transform: translate(-3%, 2%); } }
@keyframes orb-breathe { 0%,100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.12); opacity: 1; } }
@keyframes orb-draw { from { stroke-dashoffset: 1200; } to { stroke-dashoffset: 0; } }
@keyframes orb-core-in { from { opacity: 0; transform: scale(.2); } to { opacity: 1; transform: none; } }
@keyframes orb-settle { 0% { opacity: 0; transform: translate(70px, -30px) scale(.2); } 60% { opacity: 1; } 100% { opacity: 1; transform: none; } }
@keyframes orb-settle-new { 0% { opacity: 0; transform: translate(150px, -120px) scale(2.4); } 45% { opacity: 1; transform: translate(10px, -6px) scale(1.25); } 100% { opacity: 1; transform: none; } }
@keyframes orb-halo { 0% { opacity: .95; transform: scale(.8); } 100% { opacity: 0; transform: scale(2.2); } }
@keyframes orb-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes orb-ring-new { 0% { transform: scale(0); opacity: 0; stroke-width: 6; } 30% { opacity: 1; } 100% { transform: none; opacity: 1; stroke-width: 1.4; } }
@keyframes orb-shock { 0% { transform: scale(.4); opacity: .95; } 100% { transform: scale(1.35); opacity: 0; } }
@keyframes orb-lv-in { from { opacity: 0; transform: translateY(10px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes orb-chip-new { 0% { box-shadow: 0 0 0 0 var(--ex-vio); } 60% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: none; } }

@media (max-width: 860px) {
  #ex .orb { grid-template-columns: minmax(0, 1fr); }
  #ex .orb-stage { max-width: 420px; }
}
@media (max-width: 420px) {
  #ex .orb-legend { grid-template-columns: minmax(0, 1fr); }
  #ex .orb-tip { max-width: min(260px, calc(100vw - 48px)); }
}
