/* ============================================================
   Site Preloader — Learnisium Hub
   Orbit + progress-ring intro, curtain-lift exit
   ============================================================ */

/* Always reserve the scrollbar's space so hiding it (preloader, lightbox, mobile menu)
   doesn't make the whole page jump sideways when it comes back */
html { scrollbar-gutter: stable; }

html.preloader-lock,
html.preloader-lock body { overflow: hidden !important; }

html.sp-skip #sitePreloader { display: none !important; }

#sitePreloader {
    --sp-ink: #0f172a;
    --sp-teal: #0d9488;
    --sp-teal-d: #0f766e;
    --sp-mint: #5eead4;
    --sp-ease: cubic-bezier(0.76, 0, 0.24, 1);
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: radial-gradient(120% 90% at 50% 40%, #ffffff 0%, #f0fdfa 45%, #dff5f1 100%);
    border-radius: 0 0 0 0;
    will-change: transform, border-radius;
}

/* ---------- Background ---------- */
.sp-bg { position: absolute; inset: 0; pointer-events: none; }

.sp-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.55;
}
.sp-glow.g1 { width: 48vmax; height: 48vmax; top: -18vmax; right: -14vmax; background: radial-gradient(circle, rgba(45, 212, 191, 0.55), transparent 70%); animation: spDriftA 9s ease-in-out infinite alternate; }
.sp-glow.g2 { width: 38vmax; height: 38vmax; bottom: -16vmax; left: -12vmax; background: radial-gradient(circle, rgba(251, 207, 232, 0.8), transparent 70%); animation: spDriftB 11s ease-in-out infinite alternate; }
.sp-glow.g3 { width: 26vmax; height: 26vmax; top: 40%; left: 55%; background: radial-gradient(circle, rgba(253, 230, 138, 0.55), transparent 70%); animation: spDriftA 13s ease-in-out infinite alternate-reverse; }
@keyframes spDriftA { to { transform: translate(-6vmax, 5vmax) scale(1.15); } }
@keyframes spDriftB { to { transform: translate(7vmax, -5vmax) scale(1.2); } }

.sp-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(15, 118, 110, 0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 118, 110, 0.07) 1px, transparent 1px);
    background-size: 44px 44px;
    -webkit-mask-image: radial-gradient(circle at 50% 45%, #000 0%, transparent 60%);
    mask-image: radial-gradient(circle at 50% 45%, #000 0%, transparent 60%);
    animation: spGridIn 1.2s ease-out both;
}
@keyframes spGridIn { from { opacity: 0; transform: scale(1.08); } }

#sitePreloader .sp-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.sp-inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 16px;
    transition: transform 0.55s var(--sp-ease), opacity 0.45s ease, filter 0.45s ease;
}

/* ---------- Stage: ring + orbit + core ---------- */
.sp-stage {
    position: relative;
    width: 220px;
    height: 220px;
    animation: spStageIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes spStageIn { from { opacity: 0; transform: scale(0.7) rotate(-20deg); } }

.sp-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.sp-ring circle { fill: none; }
.sp-ring-track { stroke: rgba(13, 148, 136, 0.12); stroke-width: 6; }
.sp-ring-dash { stroke: rgba(13, 148, 136, 0.25); stroke-width: 1.5; stroke-dasharray: 2 9; transform-origin: 110px 110px; animation: spSpin 14s linear infinite; }
.sp-ring-fill {
    stroke: url(#spRingGrad);
    stroke-width: 6;
    stroke-linecap: round;
    filter: drop-shadow(0 0 6px rgba(13, 148, 136, 0.45));
}
@keyframes spSpin { to { transform: rotate(360deg); } }

/* Orbiting subject planets (counter-rotated so icons stay upright) */
.sp-orbit {
    position: absolute;
    inset: 0;
    animation: spSpin 9s linear infinite;
}
.sp-planet {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    transform: rotate(var(--a)) translateY(-110px) rotate(calc(-1 * var(--a)));
}
.sp-planet.p1 { --a: 0deg; }
.sp-planet.p2 { --a: 90deg; }
.sp-planet.p3 { --a: 180deg; }
.sp-planet.p4 { --a: 270deg; }
.sp-planet i {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid rgba(13, 148, 136, 0.18);
    box-shadow: 0 8px 18px -8px rgba(15, 23, 42, 0.3);
    color: var(--sp-teal-d);
    animation: spSpin 9s linear infinite reverse, spPlanetIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.sp-planet.p1 i { animation-delay: 0s, 0.35s; }
.sp-planet.p2 i { animation-delay: 0s, 0.45s; }
.sp-planet.p3 i { animation-delay: 0s, 0.55s; }
.sp-planet.p4 i { animation-delay: 0s, 0.65s; }
.sp-planet.p2 i { color: #b45309; }
.sp-planet.p3 i { color: #be185d; }
.sp-planet svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@keyframes spPlanetIn { from { opacity: 0; scale: 0.3; } }

/* Core emblem */
.sp-core {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 84px;
    height: 84px;
    margin: -42px 0 0 -42px;
}
.sp-emblem {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    border-radius: 26px;
    background: linear-gradient(145deg, #14b8a6 0%, var(--sp-teal) 45%, var(--sp-teal-d) 100%);
    box-shadow: 0 18px 40px -12px rgba(13, 148, 136, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.25);
    animation: spCoreIn 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both, spBreathe 2.8s ease-in-out 1s infinite;
}
@keyframes spCoreIn { from { opacity: 0; transform: scale(0.4) rotate(-45deg); } }
@keyframes spBreathe { 50% { transform: scale(1.05); } }
.sp-emblem svg { width: 42px; height: 42px; fill: none; stroke: #ffffff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sp-cap { stroke-dasharray: 60; stroke-dashoffset: 60; animation: spDraw 0.9s ease-out 0.45s forwards; }
.sp-cap-b { animation-delay: 0.75s; }
.sp-cap-c { animation-delay: 1s; }
@keyframes spDraw { to { stroke-dashoffset: 0; } }

.sp-ripple {
    position: absolute;
    inset: 0;
    border-radius: 26px;
    border: 2px solid rgba(13, 148, 136, 0.45);
    animation: spRipple 2.4s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}
.sp-ripple.r2 { animation-delay: 1.2s; }
@keyframes spRipple { from { transform: scale(1); opacity: 0.8; } to { transform: scale(1.9); opacity: 0; border-radius: 50%; } }

/* ---------- Brand name ---------- */
.sp-name {
    margin: 30px 0 0;
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: clamp(1.7rem, 4vw, 2.2rem);
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: var(--sp-ink);
}
.sp-name span {
    display: inline-block;
    opacity: 0;
    transform: translateY(0.6em);
    filter: blur(6px);
    animation: spLetter 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: calc(0.35s + var(--i, 0) * 0.035s);
}
.sp-name .sp-sp { width: 0.28em; }
@keyframes spLetter { to { opacity: 1; transform: none; filter: blur(0); } }

.sp-tag {
    margin: 8px 0 0;
    font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: #64748b;
    animation: spFadeUp 0.6s ease-out 0.9s both;
}
@keyframes spFadeUp { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Status ---------- */
.sp-status {
    margin-top: 22px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px 8px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(13, 148, 136, 0.15);
    box-shadow: 0 8px 22px -12px rgba(15, 23, 42, 0.25);
    backdrop-filter: blur(8px);
    animation: spFadeUp 0.6s ease-out 1s both;
}
.sp-pct {
    min-width: 58px;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--sp-ink);
    color: #ffffff;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.sp-cycle { position: relative; display: block; width: 170px; height: 20px; overflow: hidden; text-align: left; }
.sp-cycle span {
    position: absolute;
    inset: 0;
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 20px;
    color: #475569;
    white-space: nowrap;
    opacity: 0;
    animation: spCycle 3.6s ease-in-out infinite;
}
.sp-cycle span:nth-child(2) { animation-delay: 1.2s; }
.sp-cycle span:nth-child(3) { animation-delay: 2.4s; }
@keyframes spCycle {
    0% { opacity: 0; transform: translateY(100%); }
    8%, 30% { opacity: 1; transform: none; }
    38%, 100% { opacity: 0; transform: translateY(-100%); }
}

/* ---------- Exit: content zooms forward, curtain lifts with a curved edge ---------- */
#sitePreloader.sp-exit .sp-inner {
    transform: scale(1.35);
    opacity: 0;
    filter: blur(8px);
}
#sitePreloader.sp-exit .sp-bg { opacity: 0; transition: opacity 0.5s ease; }
#sitePreloader.sp-exit {
    pointer-events: none;
    animation: spCurtain 0.9s var(--sp-ease) 0.25s forwards;
}
@keyframes spCurtain {
    0% { transform: translateY(0); border-radius: 0 0 0 0 / 0 0 0 0; }
    100% { transform: translateY(-105%); border-radius: 0 0 50% 50% / 0 0 14vh 14vh; }
}

/* ---------- Responsive ---------- */
@media (max-width: 480px), (max-height: 600px) {
    .sp-stage { width: 180px; height: 180px; }
    .sp-planet { width: 34px; height: 34px; margin: -17px 0 0 -17px; transform: rotate(var(--a)) translateY(-90px) rotate(calc(-1 * var(--a))); }
    .sp-planet i { border-radius: 10px; }
    .sp-planet svg { width: 15px; height: 15px; }
    .sp-core { width: 70px; height: 70px; margin: -35px 0 0 -35px; }
    .sp-emblem, .sp-ripple { border-radius: 22px; }
    .sp-emblem svg { width: 34px; height: 34px; }
    .sp-name { margin-top: 24px; }
}

/* ---------- Reduced motion: a simple, quick fade ---------- */
@media (prefers-reduced-motion: reduce) {
    #sitePreloader *,
    #sitePreloader *::before,
    #sitePreloader *::after {
        animation: none !important;
        transition: none !important;
    }
    .sp-name span, .sp-cap { opacity: 1 !important; transform: none !important; filter: none !important; stroke-dashoffset: 0 !important; }
    .sp-cycle span:first-child { opacity: 1 !important; }
    #sitePreloader.sp-exit { animation: none !important; opacity: 0; transition: opacity 0.3s ease !important; }
}
