/* ============ Login page: space scene + assembling logo ============ */
.lp-body {
  --brand: #5b2aa3;
  --brand-2: #3c1680;
  --orange: #f79e0e;
  --deep: #12052e;
  background: radial-gradient(ellipse at 70% 30%, #3a1478 0%, #1d0a45 45%, var(--deep) 100%);
  color: #fff;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------- space background ---------- */
.space { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.nebula { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .55; animation: nebula 22s ease-in-out infinite alternate; }
.n1 { width: 520px; height: 520px; background: #6d34c9; top: -120px; right: -80px; }
.n2 { width: 420px; height: 420px; background: #f79e0e; opacity: .16; bottom: -140px; left: 10%; animation-duration: 28s; }
.n3 { width: 380px; height: 380px; background: #2f3fd0; opacity: .3; top: 40%; left: -120px; animation-duration: 34s; }
@keyframes nebula { to { transform: translate(60px, 40px) scale(1.15); } }

.starfield { position: absolute; inset: -5%; animation: drift 140s linear infinite; }
.starfield i { position: absolute; width: var(--s); height: var(--s); border-radius: 50%; background: #fff;
  box-shadow: 0 0 6px rgba(255,255,255,.8); opacity: .2; animation: twinkle var(--t) ease-in-out var(--dl) infinite; }
.starfield i.o { background: #ffc35c; box-shadow: 0 0 8px #f79e0e; }
@keyframes twinkle { 50% { opacity: 1; transform: scale(1.3); } }
@keyframes drift { to { transform: translate3d(-4%, 3%, 0); } }

.shooting { position: absolute; top: 12%; left: 70%; width: 140px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, rgba(255,255,255,0), #fff 70%, #ffd38a);
  transform: rotate(-28deg); opacity: 0; animation: shoot 9s ease-in 3s infinite; }
.shooting.s2 { top: 30%; left: 30%; animation-delay: 7s; animation-duration: 13s; width: 100px; }
.shooting.s3 { top: 6%; left: 15%; animation-delay: 11s; animation-duration: 17s; }
@keyframes shoot {
  0% { opacity: 0; transform: rotate(-28deg) translateX(0); }
  2% { opacity: 1; }
  8% { opacity: 0; transform: rotate(-28deg) translateX(-420px); }
  100% { opacity: 0; transform: rotate(-28deg) translateX(-420px); }
}

/* ---------- layout ---------- */
.lp { position: relative; z-index: 1; min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  align-items: center; gap: 40px; max-width: 1240px; margin: 0 auto; padding: 40px 32px; }
.lp-brand { display: flex; flex-direction: column; align-items: center; text-align: center; }

/* ---------- logo stage ---------- */
.stage { position: relative; width: min(440px, 80vw); aspect-ratio: 800 / 657; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.halo { position: absolute; inset: 8% 14%; border-radius: 50%;
  background: radial-gradient(circle, rgba(247,158,14,.35), rgba(120,60,220,.35) 45%, transparent 70%);
  filter: blur(18px); opacity: 0; transform: scale(.6); transition: opacity .8s, transform 1.2s cubic-bezier(.16,1,.3,1); }
.emblem { position: absolute; inset: 0; z-index: 2; }
.emblem-img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0;
  animation: fallbackIn .8s ease 2.4s forwards; /* if JS never runs */
  filter: drop-shadow(0 18px 40px rgba(0,0,0,.45)); }
.stage.js .emblem-img { animation: none; }
.tiles { position: absolute; inset: 0; }
.tile { position: absolute; background-image: url(/img/emblem.webp); background-repeat: no-repeat; will-change: transform, opacity;
  opacity: 0; transform: translate(var(--tx), var(--ty)) rotate(var(--rot)) scale(.2);
  transition: transform 1.25s cubic-bezier(.16,1,.3,1) var(--d), opacity .6s ease var(--d); }
.stage.go .tile { opacity: 1; transform: none; }
.stage.assembled .tiles { opacity: 0; transition: opacity .35s; }
.stage.assembled .emblem-img { opacity: 1; animation: float 6s ease-in-out .4s infinite; }
.stage.assembled .halo { opacity: 1; transform: scale(1); animation: halo 4s ease-in-out 1s infinite; }
@keyframes fallbackIn { to { opacity: 1; } }
@keyframes float { 50% { transform: translateY(-10px); } }
@keyframes halo { 50% { opacity: .65; transform: scale(1.06); } }

/* flash ring when pieces lock in */
.stage::after { content: ''; position: absolute; inset: 4% 13%; border-radius: 50%; border: 2px solid rgba(255,255,255,.9);
  opacity: 0; pointer-events: none; }
.stage.assembled::after { animation: ripple 1.1s ease-out; }
@keyframes ripple { 0% { opacity: .9; transform: scale(.95); } 100% { opacity: 0; transform: scale(1.35); } }

/* light sweep masked to the emblem shape */
.shine { position: absolute; inset: 0; pointer-events: none; opacity: 0;
  -webkit-mask: url(/img/emblem.webp) center / contain no-repeat; mask: url(/img/emblem.webp) center / contain no-repeat;
  background: linear-gradient(115deg, transparent 35%, rgba(255,255,255,.55) 50%, transparent 65%) no-repeat;
  background-size: 250% 100%; background-position: 130% 0; }
.stage.assembled .shine { opacity: 1; animation: sweep 5.5s ease-in-out .5s infinite, float 6s ease-in-out .4s infinite; }
@keyframes sweep { 0% { background-position: 130% 0; } 35%, 100% { background-position: -30% 0; } }

/* sparkles on the logo's stars */
.spark { position: absolute; left: var(--x); top: var(--y); width: 26px; height: 26px; margin: -13px 0 0 -13px; opacity: 0; pointer-events: none;
  background: radial-gradient(circle, #fff 0 8%, transparent 9%),
              linear-gradient(0deg, transparent 46%, rgba(255,255,255,.95) 50%, transparent 54%),
              linear-gradient(90deg, transparent 46%, rgba(255,255,255,.95) 50%, transparent 54%);
  filter: drop-shadow(0 0 4px #ffd27a); }
.spark.sm { width: 18px; height: 18px; margin: -9px 0 0 -9px; }
.stage.assembled .spark { animation: spark 3.2s ease-in-out calc(var(--d) + .6s) infinite; }
@keyframes spark { 0%, 70%, 100% { opacity: 0; transform: scale(.2) rotate(0); } 82% { opacity: 1; transform: scale(1) rotate(45deg); } }

/* orbiting planet following the logo's orange ring */
.orbit { position: absolute; left: -2%; right: -2%; top: 39%; height: 20%; transform: rotate(15.6deg); z-index: 3; opacity: 0;
  pointer-events: none; transition: opacity .8s; }
.stage.assembled .orbit { opacity: 1; animation: zswap 8s linear infinite; }
.ox { position: absolute; top: 0; bottom: 0; width: 0; animation: ox 4s ease-in-out infinite alternate; }
.oy { position: absolute; left: 0; width: 0; height: 0; animation: oy 4s ease-in-out -2s infinite alternate; }
.planet { position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff3d6, #f79e0e 55%, #c2620a);
  box-shadow: 0 0 14px 4px rgba(247,158,14,.75), 0 0 34px 10px rgba(247,158,14,.3);
  animation: depth 8s linear infinite; }
@keyframes ox { from { left: 0; } to { left: 100%; } }
@keyframes oy { from { top: 0; } to { top: 100%; } }
@keyframes zswap { 0%, 49.9% { z-index: 3; } 50%, 100% { z-index: 1; } }
@keyframes depth { 0% { transform: scale(1); } 25% { transform: scale(1.3); } 50% { transform: scale(1); } 75% { transform: scale(.55); opacity: .6; } 100% { transform: scale(1); } }

/* ---------- names ---------- */
.names { width: min(460px, 86vw); margin-top: 22px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.names img { width: 100%; height: auto; display: block; filter: brightness(0) invert(1) drop-shadow(0 2px 10px rgba(120,60,220,.6)); }
.name-en, .name-ar { clip-path: inset(0 100% 0 0); animation: fallbackClip .01s 2.6s forwards; }
.name-ar { clip-path: inset(0 0 0 100%); }
.divider { display: flex; align-items: center; gap: 10px; width: 100%; }
.divider span { flex: 1; height: 2px; background: linear-gradient(90deg, transparent, rgba(255,255,255,.85)); transform: scaleX(0); transform-origin: left; animation: fallbackGrow .01s 2.6s forwards; }
.divider span:last-child { background: linear-gradient(270deg, transparent, rgba(255,255,255,.85)); transform-origin: right; }
.divider b { color: var(--orange); font-size: 18px; line-height: 1; text-shadow: 0 0 12px var(--orange); transform: scale(0); animation: fallbackGrow .01s 2.6s forwards; }
.tagline { margin-top: 18px; color: rgba(255,255,255,.75); font-size: .98rem; opacity: 0; animation: fallbackIn .01s 2.6s forwards; }
@keyframes fallbackClip { to { clip-path: inset(0); } }
@keyframes fallbackGrow { to { transform: none; } }

.stage.js ~ .names * , .stage.js ~ .tagline { animation: none; }
.lp-brand.reveal .name-en { animation: wipe .9s cubic-bezier(.65,0,.35,1) .15s forwards; }
.lp-brand.reveal .divider span { animation: grow .7s cubic-bezier(.65,0,.35,1) .55s forwards; }
.lp-brand.reveal .divider b { animation: pop .6s cubic-bezier(.34,1.56,.64,1) .95s forwards, spin 6s linear 1.6s infinite; }
.lp-brand.reveal .name-ar { animation: wipe .9s cubic-bezier(.65,0,.35,1) .85s forwards; }
.lp-brand.reveal .tagline { animation: rise .7s ease 1.5s forwards; }
@keyframes wipe { to { clip-path: inset(0 -2% 0 -2%); } }
@keyframes grow { to { transform: scaleX(1); } }
@keyframes pop { to { transform: scale(1); } }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- card ---------- */
.lp-form { display: flex; flex-direction: column; align-items: center; }
.lp-card { width: 100%; max-width: 430px; background: rgba(255,255,255,.97); color: #1b1235; border-radius: 24px; padding: 34px 32px 26px;
  box-shadow: 0 30px 80px rgba(8,2,30,.55), 0 0 0 1px rgba(255,255,255,.08); position: relative;
  animation: cardIn .9s cubic-bezier(.16,1,.3,1) .35s both; }
.lp-card::before { content: ''; position: absolute; inset: -1px; border-radius: 25px; padding: 1px; pointer-events: none;
  background: linear-gradient(140deg, rgba(247,158,14,.9), transparent 35%, transparent 65%, rgba(140,90,240,.9));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; }
@keyframes cardIn { from { opacity: 0; transform: translateY(30px) scale(.97); } to { opacity: 1; transform: none; } }
.lp-card-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.lp-card-head img { border-radius: 50%; box-shadow: 0 6px 16px rgba(91,42,163,.35); }
.lp-card-head h1 { font-size: 1.55rem; margin: 0; color: #2a1260; }
.lp-card-head p { margin: 0; color: #6b6488; font-size: .92rem; }
.lp-card .field > span { color: #3b2f5c; }
.ifield { position: relative; }
.ifield > svg { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: #9a8fbf; pointer-events: none; transition: color .2s; }
.lp-card .ifield input { padding: 12px 42px 12px 14px; border-radius: 12px; border: 1.5px solid #e3ddf2; background: #faf8ff; color: #1b1235; font-size: 1rem; }
.lp-card .ifield.pw-wrap input { padding-left: 74px; }
.lp-card .ifield input:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 4px rgba(91,42,163,.14); }
.ifield:focus-within > svg { color: var(--brand); }
.lp-card .pw-toggle { background: #f0ebfb; border-color: #e3ddf2; color: var(--brand); }
.lp-btn { margin-top: 4px; padding: 13px 18px; font-size: 1.02rem; border-radius: 12px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #6a34bd, var(--brand-2)); box-shadow: 0 10px 24px rgba(91,42,163,.4); transition: box-shadow .2s, transform .1s; }
.lp-btn::after { content: ''; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.35), transparent); transform: skewX(-20deg); transition: left .6s; }
.lp-btn:hover { box-shadow: 0 12px 30px rgba(91,42,163,.5), 0 0 0 3px rgba(247,158,14,.35); }
.lp-btn:hover::after { left: 120%; }
.lp-btn svg { transition: transform .2s; }
html[dir=rtl] .lp-btn svg { transform: rotate(180deg); }
html[dir=rtl] .lp-btn:hover svg { transform: rotate(180deg) translateX(4px); }
html[dir=ltr] .lp-btn:hover svg { transform: translateX(4px); }
.lp-hint { margin-top: 20px; padding: 12px 14px; border-radius: 12px; background: #f6f2ff; border: 1px dashed #d9cff2; font-size: .86rem; color: #5e5680; display: flex; flex-direction: column; gap: 2px; }
.lp-hint b { color: #3b2f5c; }
.lp-hint code { background: #fff; border-color: #e3ddf2; color: var(--brand); }
.lp-foot { margin-top: 18px; color: rgba(255,255,255,.55); font-size: .82rem; }
.lp-card .alert { margin-bottom: 16px; }
.shake { animation: shake .45s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }

@media (prefers-color-scheme: dark) {
  .lp-card { background: rgba(26,16,56,.92); color: #ece8fb; backdrop-filter: blur(12px); }
  .lp-card-head h1 { color: #fff; }
  .lp-card-head p, .lp-hint { color: #b8b0d8; }
  .lp-card .field > span, .lp-hint b { color: #ddd6f5; }
  .lp-card .ifield input { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.14); color: #fff; }
  .lp-card .ifield input:focus { background: rgba(255,255,255,.08); border-color: #a17ff0; }
  .lp-card .pw-toggle { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.14); color: #cbb8ff; }
  .lp-hint { background: rgba(255,255,255,.04); border-color: rgba(255,255,255,.14); }
  .lp-hint code { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.14); color: #cbb8ff; }
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .lp { grid-template-columns: minmax(0, 1fr); gap: 26px; padding: 28px 16px 24px; align-content: start; }
  .stage { width: min(280px, 70vw); }
  .names { width: min(320px, 82vw); margin-top: 14px; }
  .tagline { margin: 12px 0 0; font-size: .9rem; }
  .lp-card { padding: 26px 20px 20px; }
  .n1 { width: 320px; height: 320px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .lp-body *, .lp-body *::before, .lp-body *::after { animation: none !important; transition: none !important; }
  .emblem-img, .tagline { opacity: 1 !important; }
  .name-en, .name-ar { clip-path: none !important; }
  .divider span, .divider b { transform: none !important; }
  .tiles, .shooting { display: none; }
  .halo { opacity: 1; transform: none; }
}

/* language switch on the login page */
.lp-lang { position: fixed; top: 18px; inset-inline-end: 18px; z-index: 5; background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.28);
  color: #fff; backdrop-filter: blur(8px); animation: rise .6s ease .2s both; }
.lp-lang:hover { background: rgba(255,255,255,.2); border-color: #fff; color: #fff; }
@media (max-width: 640px) { .lp-lang span { display: inline; } .lp-lang { padding: 6px 12px; top: 12px; inset-inline-end: 12px; } }

/* LTR (English) */
html[dir=ltr] .ifield > svg { right: auto; left: 12px; }
html[dir=ltr] .lp-card .ifield input { padding: 12px 14px 12px 42px; }
html[dir=ltr] .lp-card .ifield.pw-wrap input { padding-left: 42px; padding-right: 74px; }
