/* ==========================================================================
   Entry preloader (Views/Shared/_Preloader.cshtml + js/preloader.js).
   Hidden unless html.pl-active (set by the partial's inline script on the first page of a browser session),
   so without JavaScript it never covers the page. Logo animation from image/logo-loader-v2.html, with every
   class and keyframe prefixed pl- to stay clear of site.css.
   ========================================================================== */
.preloader { display: none; }

html.pl-active .preloader {
    position: fixed;
    inset: 0;
    z-index: 2000; /* above the navbar, sidebar, toasts and dialogs */
    display: grid;
    place-items: center;
    padding: 1.5rem;
    color: #ffffff;
    opacity: 1;
    transition: opacity 0.55s ease, visibility 0s linear 0s;
}

/* The backdrop is its own layer, so it can fade away while the logo is still flying (.is-flying) */
.preloader::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(600px 420px at 50% 42%, rgba(47, 139, 255, 0.20), transparent 65%),
        radial-gradient(900px 600px at 50% 120%, rgba(93, 230, 255, 0.08), transparent 60%),
        #03030f;
    transition: opacity 0.7s ease 0.15s;
}

/* ---- Fly-to-logo exit (preloader.js): the logo shrinks into the page's logo tile ---- */
.preloader.is-flying { pointer-events: none; }
.preloader.is-flying::before { opacity: 0; }

/* Name, bar and status leave first */
.pl-brand, .pl-bar, .pl-status { transition: opacity 0.3s ease, transform 0.3s ease; }

.preloader.is-flying .pl-brand,
.preloader.is-flying .pl-bar,
.preloader.is-flying .pl-status {
    opacity: 0;
    transform: translateY(8px);
}

/* The logo travels (transform set inline by the script); the ripples and sparkles fade on the way */
.pl-logo {
    transform-origin: 50% 50%;
    transition: transform 0.95s cubic-bezier(0.65, 0, 0.25, 1), filter 0.95s ease, opacity 0.35s ease;
}

.preloader.is-flying .pl-logo { filter: drop-shadow(0 0 4px rgba(47, 139, 255, 0.35)); }
.preloader.is-flying .pl-rip,
.preloader.is-flying .pl-sp { transition: opacity 0.4s ease; opacity: 0 !important; animation: none; }

/* Landed: the real logo tile fades in under it and the flying copy fades out (crossfade) */
.preloader.is-landed .pl-logo { opacity: 0; }

[data-preloader-target] { transition: opacity 0.35s ease; }
html.pl-active [data-preloader-target].pl-target-wait { opacity: 0; }

/* The page behind does not scroll while the preloader is up. Unlocked (html.pl-flying) just before the fly-to-logo
   exit measures the target, so the page's scrollbar is already back and the logo tile does not shift on landing. */
html.pl-active:not(.pl-flying),
html.pl-active:not(.pl-flying) body { overflow: hidden !important; }

/* Fade out: the logo grows slightly and fades, the overlay fades */
.preloader.is-done {
    opacity: 0 !important;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.55s ease, visibility 0s linear 0.55s;
}

    .preloader.is-done .pl-stage {
        transform: scale(1.06);
        opacity: 0;
    }

/* Light theme: the logo keeps its dark navy "app icon" look on a warm cream page */
html[data-theme="light"].pl-active .preloader { color: #3b2f25; }

html[data-theme="light"] .preloader::before {
    background:
        radial-gradient(600px 420px at 50% 42%, rgba(47, 139, 255, 0.16), transparent 65%),
        radial-gradient(900px 600px at 50% 120%, rgba(180, 83, 9, 0.08), transparent 60%),
        #f8f2e9;
}

.pl-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.45s ease;
    animation: pl-enter 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes pl-enter {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to { opacity: 1; transform: none; }
}

/* ---- Logo ---- */
.pl-logo {
    width: min(46vmin, 220px);
    height: auto;
    overflow: visible;
    filter: drop-shadow(0 0 14px rgba(47, 139, 255, 0.45));
}

html[data-theme="light"] .pl-logo { filter: drop-shadow(0 6px 18px rgba(47, 139, 255, 0.30)); }

.pl-breathe {
    transform-box: view-box;
    transform-origin: 50% 50%;
    animation: pl-breathe 2.4s ease-in-out infinite;
}

@keyframes pl-breathe { 50% { transform: scale(1.05); } }

.pl-ring {
    transform-box: view-box;
    transform-origin: 50% 50%;
    animation: pl-orbit 4.5s cubic-bezier(.45, .05, .55, .95) infinite;
}

@keyframes pl-orbit { to { transform: rotate(360deg); } }

.pl-cube {
    transform-box: fill-box;
    transform-origin: 50% 50%;
    animation: pl-pulse 1.8s ease-in-out infinite;
    animation-delay: var(--o);
}

@keyframes pl-pulse { 50% { transform: scale(1.09); } }

.pl-fa, .pl-fb, .pl-fc { animation: pl-cycle 3.6s ease-in-out infinite; }
.pl-fa { animation-delay: calc(var(--o) + 0s); }
.pl-fb { animation-delay: calc(var(--o) - 1.2s); }
.pl-fc { animation-delay: calc(var(--o) - 2.4s); }

@keyframes pl-cycle {
    0%, 22% { fill: #0a0f2e; }
    33%, 55% { fill: #0b22a8; }
    66%, 88% { fill: #5de6ff; }
    100% { fill: #0a0f2e; }
}

.pl-px {
    opacity: 0;
    transform-box: fill-box;
    transform-origin: 50% 50%;
    animation: pl-trail var(--t, 2s) ease-out infinite;
    animation-delay: var(--d);
}

@keyframes pl-trail {
    0% { opacity: 0; transform: translate(20px, 0) scale(.5); }
    25% { opacity: 1; }
    100% { opacity: 0; transform: translate(-34px, var(--y)) scale(.15); }
}

.pl-rip {
    fill: none;
    stroke: #2f8bff;
    stroke-width: 3;
    opacity: 0;
    transform-box: fill-box;
    transform-origin: 50% 50%;
    animation: pl-ripple 2.4s ease-out infinite;
}

.pl-rip-b { animation-delay: -1.2s; }

@keyframes pl-ripple {
    0% { opacity: .6; transform: scale(.6); }
    100% { opacity: 0; transform: scale(2.6); }
}

/* The T: white on the dark page, navy on the light one */
.pl-t {
    fill: #ffffff;
    transform-box: fill-box;
    transform-origin: 50% 50%;
    animation: pl-beat 1.8s ease-in-out infinite;
}

html[data-theme="light"] .pl-t { fill: #0a0f2e; }

@keyframes pl-beat { 50% { transform: scale(1.1); } }

.pl-sp {
    opacity: 0;
    animation: pl-twinkle 2.4s ease-in-out infinite;
    animation-delay: var(--d);
}

@keyframes pl-twinkle { 50% { opacity: .9; } }

/* ---- Brand, progress, status ---- */
.pl-brand {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin-top: 1.6rem;
}

.pl-name {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.pl-by {
    font-family: "Inter", system-ui, sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8fd3ff;
}

html[data-theme="light"] .pl-by { color: #2f6fa8; }

.pl-bar {
    position: relative;
    width: min(240px, 60vw);
    height: 4px;
    margin-top: 1.4rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.10);
    overflow: hidden;
}

html[data-theme="light"] .pl-bar { background: rgba(94, 64, 28, 0.12); }

.pl-bar-fill {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #2f8bff, #5de6ff);
    box-shadow: 0 0 12px rgba(93, 230, 255, 0.6);
    transform: scaleX(0.04);
    transform-origin: left center;
    transition: transform 0.25s ease-out;
}

/* moving shine on the bar */
.pl-bar-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
    transform: translateX(-100%);
    animation: pl-shine 1.3s ease-in-out infinite;
}

@keyframes pl-shine { to { transform: translateX(100%); } }

.pl-status {
    margin-top: 0.75rem;
    font-family: "Inter", system-ui, sans-serif;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.62);
}

html[data-theme="light"] .pl-status { color: #7a6a5a; }

/* ---- Phones ---- */
@media (max-width: 480px) {
    .pl-logo { width: min(56vmin, 190px); }
    .pl-name { font-size: 1.15rem; }
}

/* ---- Reduced motion: a still logo with a slow turn, no fades or shine ---- */
@media (prefers-reduced-motion: reduce) {
    .pl-stage { animation: none; transition: none; }
    .pl-breathe, .pl-cube, .pl-fa, .pl-fb, .pl-fc, .pl-px, .pl-rip, .pl-t, .pl-sp, .pl-bar-fill::after { animation: none; }
    .pl-ring { animation: pl-orbit 16s linear infinite; }
    .pl-fa { fill: #0a0f2e; }
    .pl-fb { fill: #0b22a8; }
    .pl-fc { fill: #5de6ff; }
    .pl-px { opacity: .7; }
    html.pl-active .preloader, .preloader.is-done { transition: none; }
}
