/*
 * Post-login boot splash — LoadingOverlay.razor.
 *
 * Maritime command-console aesthetic: a dark navy field, a radar scope
 * sweeping over concentric range rings, the "درع الساحل" wordmark, a status
 * line driven by LiveDataService.LoadPhase, and a thin progress bar.
 *
 * Theme-aware: every colour is a design token (tokens.css), so the splash
 * follows Dunkel / Karte / Alarm like the rest of the chrome. All motion is
 * CSS — no JS animation framework, no interop.
 */

.ms-loading {
    position: fixed;
    inset: 0;
    z-index: 2000; /* above the map, panels, and layer pills */
    display: flex;
    align-items: center;
    justify-content: center;
    /* Deep-sea radial wash, anchored a little above centre behind the scope. */
    background:
        radial-gradient(120% 90% at 50% 38%,
            color-mix(in srgb, var(--ms-accent) 7%, var(--ms-bg)) 0%,
            var(--ms-bg) 55%,
            #02060c 100%);
    color: var(--ms-text);
    /* Fade IN on mount so the splash itself does not pop. */
    animation: ms-loading-in 360ms ease-out both;
    transition: opacity 600ms ease, visibility 600ms ease;
}

/* Ready → fade the whole overlay out. The component drops the node from the
   DOM a beat later (FadeOutDuration) so it stops covering the map. */
.ms-loading.is-ready {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

@keyframes ms-loading-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.ms-loading-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 26px;
    padding: 32px;
    text-align: center;
}

/* ---- Radar scope ---- */
/* درع الساحل coastal-shield outline framing the radar scope (brand motif). */
.ms-loading-shield {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 156%;
    height: 156%;
    transform: translate(-50%, -50%);
    opacity: 0.5;
    filter: drop-shadow(0 0 6px color-mix(in srgb, var(--ms-accent) 45%, transparent));
    pointer-events: none;
    animation: ms-loading-shield-pulse 2.6s ease-in-out infinite;
}
@keyframes ms-loading-shield-pulse {
    0%, 100% { opacity: 0.35; }
    50%      { opacity: 0.7; }
}

.ms-loading-radar {
    position: relative;
    width: 168px;
    height: 168px;
    border-radius: 50%;
    /* Faint scope face so the rings read against the background wash. */
    background:
        radial-gradient(circle at 50% 50%,
            color-mix(in srgb, var(--ms-accent) 10%, transparent) 0%,
            transparent 70%);
    box-shadow:
        0 0 0 1px color-mix(in srgb, var(--ms-accent) 35%, transparent),
        0 0 40px color-mix(in srgb, var(--ms-accent) 18%, transparent);
}

/* Concentric range rings. */
.ms-loading-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 1px solid color-mix(in srgb, var(--ms-accent) 28%, transparent);
}
.ms-loading-ring.r1 { width: 33%;  height: 33%;  }
.ms-loading-ring.r2 { width: 66%;  height: 66%;  }
.ms-loading-ring.r3 { width: 100%; height: 100%; opacity: 0.7; }

/* Crosshair graticule. */
.ms-loading-crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    background: color-mix(in srgb, var(--ms-accent) 22%, transparent);
}
.ms-loading-crosshair.v { width: 1px; height: 100%; transform: translate(-50%, -50%); }
.ms-loading-crosshair.h { width: 100%; height: 1px; transform: translate(-50%, -50%); }

/* The sweeping beam — a conic wedge that rotates, trailing a fading wake.
   The bright leading edge sits at the start of the gradient. */
.ms-loading-sweep {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        color-mix(in srgb, var(--ms-accent) 55%, transparent) 0deg,
        color-mix(in srgb, var(--ms-accent) 12%, transparent) 28deg,
        transparent 70deg,
        transparent 360deg);
    animation: ms-loading-sweep 2.4s linear infinite;
}

@keyframes ms-loading-sweep {
    to { transform: rotate(360deg); }
}

/* Pulsing centre blip. */
.ms-loading-core {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--ms-accent);
    transform: translate(-50%, -50%);
    box-shadow: 0 0 12px var(--ms-accent);
    animation: ms-loading-core 2.4s ease-out infinite;
}

@keyframes ms-loading-core {
    0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ms-accent) 60%, transparent); }
    70%  { box-shadow: 0 0 0 16px color-mix(in srgb, var(--ms-accent) 0%, transparent); }
    100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ms-accent) 0%, transparent); }
}

/* ---- Branding ---- */
.ms-loading-brand {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ms-loading-wordmark {
    font-family: var(--ms-font-brand);
    font-size: 34px;
    font-weight: 700;
    color: var(--ms-text);
}
.ms-loading-subtitle {
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ms-text-mute);
}

/* ---- Status line ---- */
.ms-loading-status {
    font-family: var(--ms-font-mono);
    font-size: 13px;
    letter-spacing: 0.04em;
    color: var(--ms-text-dim);
    min-height: 1.2em; /* reserve the line so the bar doesn't jump on text change */
    animation: ms-loading-status-pulse 1.6s ease-in-out infinite;
}

@keyframes ms-loading-status-pulse {
    0%, 100% { opacity: 0.6; }
    50%      { opacity: 1; }
}

/* ---- Progress bar ---- */
.ms-loading-bar {
    width: 260px;
    max-width: 70vw;
    height: 3px;
    border-radius: 2px;
    background: color-mix(in srgb, var(--ms-text-mute) 28%, transparent);
    overflow: hidden;
}
.ms-loading-bar-fill {
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg,
        var(--ms-accent2), var(--ms-accent));
    box-shadow: 0 0 8px color-mix(in srgb, var(--ms-accent) 50%, transparent);
    /* Ease the bar toward each phase target rather than snapping. */
    transition: width 500ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Status pulse is decorative; honour reduced-motion by stilling the sweep,
   blip, and pulse. The progress bar width transition stays (it conveys
   meaning, not decoration). */
@media (prefers-reduced-motion: reduce) {
    .ms-loading-sweep,
    .ms-loading-core,
    .ms-loading-status,
    .ms-loading-shield {
        animation: none;
    }
}
