/* Loading experience: splash, top progress bar, slow-connection pill, inline spinner, page fade-in. */

/* ---------- splash (cold start only): feels like a native app launch ---------- */
#splash{position:fixed;inset:0;z-index:100;display:grid;place-items:center;background:var(--paper);overflow:hidden;transition:background .5s ease,opacity .35s ease .35s,visibility 0s .8s}
.sp-aurora{position:absolute;inset:-15%;background:radial-gradient(38% 30% at 20% 16%,rgba(242,104,27,.34),transparent 70%),radial-gradient(36% 28% at 84% 80%,rgba(15,138,76,.26),transparent 70%);animation:auroradrift 6s ease-in-out infinite alternate}
@keyframes auroradrift{to{transform:translate3d(3%,2%,0) scale(1.08)}}
.sp-in{position:relative;display:grid;justify-items:center;gap:26px;padding:24px;text-align:center}
.sp-icon{position:relative;width:176px;height:176px;display:grid;place-items:center}
.sp-icon::before{content:"";position:absolute;inset:18px;border-radius:50%;background:radial-gradient(circle,rgba(242,104,27,.16),transparent 68%);animation:breathe4 2.4s ease-in-out infinite}
@keyframes breathe4{50%{transform:scale(1.14)}}
.sp-ring{position:absolute;inset:0;width:100%;height:100%;transform:rotate(-90deg);opacity:0;animation:ringin .6s .1s ease-out forwards}
.sp-ring circle{fill:none;stroke-width:3;stroke-linecap:round}
.sp-ring .trk{stroke:var(--rule)}
.sp-ring .prg{stroke:url(#spg);stroke-dasharray:100;stroke-dashoffset:100;transition:stroke-dashoffset .55s cubic-bezier(.3,.7,.2,1)}
@keyframes ringin{from{opacity:0;transform:rotate(-90deg) scale(.9)}to{opacity:1;transform:rotate(-90deg)}}
.sp-tile{position:relative;width:132px;height:132px;display:grid;place-items:center;animation:tilein .8s cubic-bezier(.2,.9,.25,1) both;transition:transform .7s cubic-bezier(.65,0,.25,1);will-change:transform}
@keyframes tilein{0%{opacity:0;transform:scale(.6)}100%{opacity:1;transform:none}}
.sp-lotus{width:104px;height:111px;object-fit:contain;clip-path:inset(100% 0 0 0);animation:reveal 1.05s .45s cubic-bezier(.45,.05,.2,1) forwards;filter:drop-shadow(0 8px 14px rgba(0,0,0,.14))}
@keyframes reveal{to{clip-path:inset(0 0 0 0)}}
.sp-shine{position:absolute;left:14px;top:10px;width:104px;height:111px;-webkit-mask:url(/img/bjp-lotus.png) center/contain no-repeat;mask:url(/img/bjp-lotus.png) center/contain no-repeat;background:linear-gradient(105deg,transparent 35%,rgba(255,255,255,.9) 50%,transparent 65%);background-size:250% 100%;background-position:150% 0;animation:shine2 1s 1.35s ease-out forwards}
@keyframes shine2{to{background-position:-50% 0}}
.sp-t b{display:block;font-family:var(--serif);font-size:25px;letter-spacing:-.01em;animation:fadeup .7s .8s both}
.sp-t span{display:block;color:var(--ink-2);font-size:14.5px;margin-top:3px;animation:fadeup .7s .95s both}
@keyframes fadeup{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}
.sp-status{min-height:20px;font-size:13px;font-weight:700;letter-spacing:.02em;color:var(--ink-3);animation:fadeup .6s 1.1s both}
.sp-status.swap{animation:swap .35s ease both}
@keyframes swap{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
/* live progress bar with percentage */
.sp-prog{display:flex;align-items:center;gap:12px;width:min(270px,72vw);animation:fadeup .6s 1.2s both}
.sp-track{position:relative;flex:1;height:8px;border-radius:9px;background:var(--rule);overflow:visible}
.sp-track i{position:absolute;left:0;top:0;height:100%;width:0;border-radius:9px;background:linear-gradient(90deg,var(--saffron),#FFB347,var(--green),#FFB347,var(--saffron));background-size:300% 100%;animation:flow 1.6s linear infinite;}
.sp-track i::after{content:"";position:absolute;right:-5px;top:50%;width:14px;height:14px;margin-top:-7px;border-radius:50%;background:#fff;box-shadow:0 1px 4px rgba(120,50,0,.35),0 0 0 3px rgba(242,104,27,.3)}
@keyframes flow{to{background-position:-300% 0}}
@keyframes headpulse{50%{transform:scale(1.25)}}
.sp-prog b{min-width:46px;text-align:right;font-family:var(--serif);font-size:18px;font-weight:700;font-variant-numeric:tabular-nums;color:var(--ink)}
/* live sparks drifting up behind the icon */
.sp-sparks{position:absolute;left:50%;top:50%;width:0;height:0;pointer-events:none}
.sp-sparks i{position:absolute;width:6px;height:6px;border-radius:50%;background:var(--saffron);opacity:0;animation:rise2 3.2s ease-in infinite}
.sp-sparks i:nth-child(odd){background:var(--green)}
.sp-sparks i:nth-child(1){left:-70px;animation-delay:.2s}.sp-sparks i:nth-child(2){left:-40px;animation-delay:.9s;width:4px;height:4px}
.sp-sparks i:nth-child(3){left:-12px;animation-delay:1.5s}.sp-sparks i:nth-child(4){left:20px;animation-delay:.5s;width:4px;height:4px}
.sp-sparks i:nth-child(5){left:48px;animation-delay:1.9s}.sp-sparks i:nth-child(6){left:72px;animation-delay:1.1s;width:5px;height:5px}
.sp-sparks i:nth-child(7){left:0;animation-delay:2.4s;width:4px;height:4px}
@keyframes rise2{0%{opacity:0;transform:translateY(34px) scale(.6)}25%{opacity:.85}100%{opacity:0;transform:translateY(-130px) scale(1.2)}}
#splash.leaving .sp-prog,#splash.leaving .sp-sparks{opacity:0;transition:opacity .3s ease}
/* hand-off: text and ring melt away while the icon flies into the header */
#splash.leaving{background:transparent;opacity:0;pointer-events:none}
#splash.leaving .sp-t,#splash.leaving .sp-status,#splash.leaving .sp-ring,#splash.leaving .sp-aurora{opacity:0;transition:opacity .3s ease}

#splash.gone{display:none}
#splash.slow .sp-ring .prg{animation:pulse3 1.2s ease-in-out infinite}
@keyframes pulse3{50%{opacity:.45}}

/* ---------- top progress bar (any request) ---------- */
#topbar{position:fixed;left:0;right:0;top:0;height:3px;z-index:90;pointer-events:none;opacity:0;transition:opacity .25s}
#topbar.on{opacity:1}
#topbar i{position:absolute;left:0;top:0;height:100%;width:40%;border-radius:3px;background:linear-gradient(90deg,var(--saffron),#FFB27A,var(--green));animation:run 1.15s cubic-bezier(.4,0,.2,1) infinite}
@keyframes run{0%{left:-40%}100%{left:100%}}
#slow{position:fixed;left:50%;bottom:calc(100px + env(safe-area-inset-bottom));z-index:90;transform:translate(-50%,20px);opacity:0;pointer-events:none;display:flex;align-items:center;gap:10px;padding:10px 18px;border-radius:999px;background:var(--glass-strong);border:1px solid var(--glass-edge);box-shadow:var(--glass-shadow);-webkit-backdrop-filter:var(--glass-blur);backdrop-filter:var(--glass-blur);font-size:13.5px;font-weight:700;transition:opacity .3s,transform .3s}
#slow.on{opacity:1;transform:translate(-50%,0)}

/* ---------- inline spinner ---------- */
.spin{display:inline-block;width:18px;height:18px;border-radius:50%;border:2.5px solid currentColor;border-right-color:transparent;animation:rot .75s linear infinite;vertical-align:-3px;flex:none}
@keyframes rot{to{transform:rotate(360deg)}}
.btn .spin{margin-right:2px}

/* searching state: three soft dots + lotus pulse */
.searching{display:grid;justify-items:center;gap:14px;padding:46px 0 30px;color:var(--ink-2);font-weight:700;font-size:15px}
.searching img{width:44px;height:47px;object-fit:contain;animation:breathe2 1.4s ease-in-out infinite}
@keyframes breathe2{50%{transform:scale(1.14);opacity:.75}}
.dots{display:inline-flex;gap:5px}
.dots i{width:7px;height:7px;border-radius:50%;background:var(--saffron);animation:dot 1.1s ease-in-out infinite}
.dots i:nth-child(2){animation-delay:.15s}.dots i:nth-child(3){animation-delay:.3s}
@keyframes dot{0%,80%,100%{transform:translateY(0);opacity:.4}40%{transform:translateY(-6px);opacity:1}}

/* page fade-in */
main{animation:pagein .35s cubic-bezier(.2,.9,.25,1) both}
@keyframes pagein{from{opacity:0;transform:translateY(8px)}}

@media(prefers-reduced-motion:reduce){
  html:not([data-motion=full]) .sp-ring{opacity:1}
  html:not([data-motion=full]) .sp-aurora,html:not([data-motion=full]) .sp-shine,html:not([data-motion=full]) .sp-sparks{display:none}.sp-lotus{clip-path:none;animation:none}.sp-tile,.sp-t b,.sp-t span,.sp-status{animation:none}
}

#slow .spin{color:var(--saffron)}
