/**
 * FYPMS Master Portal — Mobile PWA Splash Screen Stylesheet
 * Ultra-smooth, GPU-accelerated launch animation for mobile & standalone PWA.
 * Zero layout shift, zero CPU thrashing, safe-area aware.
 */

:root {
    --fyp-splash-bg-deep: #062337;
    --fyp-splash-bg-glow: #0d3859;
    --fyp-splash-blue-primary: #2563eb;
    --fyp-splash-blue-accent: #38bdf8;
    --fyp-splash-emerald: #10b981;
}

/* Master Splash Overlay */
#fyp-pwa-splash {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 99999999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 50% 32%, var(--fyp-splash-bg-glow) 0%, var(--fyp-splash-bg-deep) 65%, #031422 100%);
    color: #ffffff;
    font-family: 'Space Grotesk', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    padding: env(safe-area-inset-top, 20px) env(safe-area-inset-right, 16px) env(safe-area-inset-bottom, 24px) env(safe-area-inset-left, 16px);
    box-sizing: border-box;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    opacity: 1;
    transform: scale(1);
    filter: blur(0px);
    transition: opacity 0.38s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.38s cubic-bezier(0.16, 1, 0.3, 1),
                filter 0.38s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0.38s;
    visibility: visible;
}

/* Hidden state for instant suppression on re-visits */
#fyp-pwa-splash.is-hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Exit Transition */
#fyp-pwa-splash.fyp-splash-exit {
    opacity: 0 !important;
    transform: scale(1.035) !important;
    filter: blur(6px) !important;
    pointer-events: none !important;
}

/* Ambient Background Light Effects */
.fyp-splash-ambient {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

/* Luminous Radial Aura Pulse */
.fyp-splash-glow {
    position: absolute;
    top: 32%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: clamp(280px, 75vw, 420px);
    height: clamp(280px, 75vw, 420px);
    background: radial-gradient(circle, rgba(56, 189, 248, 0.22) 0%, rgba(37, 99, 235, 0.14) 45%, rgba(6, 35, 55, 0) 70%);
    border-radius: 50%;
    filter: blur(32px);
    animation: fypGlowPulse 3.4s ease-in-out infinite alternate;
    will-change: transform, opacity;
}

/* Micro Concentric Light Waves */
.fyp-splash-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 1px solid rgba(56, 189, 248, 0.16);
    pointer-events: none;
}

.fyp-splash-ring-1 {
    width: clamp(140px, 36vw, 170px);
    height: clamp(140px, 36vw, 170px);
    animation: fypRingPulse 2.8s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}

.fyp-splash-ring-2 {
    width: clamp(180px, 46vw, 220px);
    height: clamp(180px, 46vw, 220px);
    animation: fypRingPulse 2.8s cubic-bezier(0.2, 0.8, 0.2, 1) infinite 0.7s;
}

/* Floating Ambient Particles / Shimmer */
.fyp-splash-particles {
    position: absolute;
    inset: 0;
    background-image: 
        radial-gradient(1.5px 1.5px at 20% 30%, rgba(255, 255, 255, 0.45), transparent),
        radial-gradient(1.5px 1.5px at 80% 25%, rgba(56, 189, 248, 0.5), transparent),
        radial-gradient(2px 2px at 40% 70%, rgba(147, 197, 253, 0.35), transparent),
        radial-gradient(1.5px 1.5px at 70% 65%, rgba(255, 255, 255, 0.3), transparent);
    opacity: 0.65;
    animation: fypParticleDrift 6s ease-in-out infinite alternate;
}

/* Main Content Container */
.fyp-splash-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    max-width: 90vw;
    width: 360px;
    margin: 0 auto;
}

/* Logo Frame - Safe Zone Protected & Untrimmed */
.fyp-splash-logo-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 22px;
}

.fyp-splash-logo-card {
    position: relative;
    width: clamp(96px, 24vw, 116px);
    height: clamp(96px, 24vw, 116px);
    border-radius: 28px;
    background: radial-gradient(circle at 30% 25%, rgba(20, 68, 105, 0.75) 0%, rgba(6, 35, 55, 0.88) 100%);
    border: 1px solid rgba(147, 197, 253, 0.28);
    box-shadow: 
        0 14px 34px -4px rgba(0, 0, 0, 0.45),
        0 0 24px rgba(56, 189, 248, 0.22),
        inset 0 1px 1px rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 10px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fypLogoEntrance 0.75s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    will-change: transform, opacity;
}

/* The Logo Image - Pristine Aspect Ratio & Breathing Margin */
.fyp-splash-logo-img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    aspect-ratio: 1 / 1;
    display: block;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.32));
    /* Prevents any image clipping on vendor Android skins */
    border-radius: 4px;
}

/* Typography Hierarchy */
.fyp-splash-brand-title {
    font-size: clamp(1.08rem, 4.4vw, 1.28rem);
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin: 0 0 4px 0;
    background: linear-gradient(135deg, #ffffff 30%, #93c5fd 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.25;
}

.fyp-splash-brand-sub {
    font-size: clamp(0.78rem, 3.2vw, 0.86rem);
    font-weight: 500;
    color: rgba(224, 242, 254, 0.82);
    letter-spacing: 0.05em;
    margin: 0 0 14px 0;
}

/* Security / Status Pill */
.fyp-splash-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: rgba(15, 42, 68, 0.65);
    border: 1px solid rgba(56, 189, 248, 0.24);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: #e0f2fe;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    margin-bottom: 24px;
}

.fyp-splash-pill-dot {
    width: 6.5px;
    height: 6.5px;
    border-radius: 50%;
    background: var(--fyp-splash-emerald);
    box-shadow: 0 0 8px var(--fyp-splash-emerald);
    animation: fypSignalPulse 1.8s ease-in-out infinite;
}

/* Futuristic Neon Progress Track */
.fyp-splash-progress-track {
    width: clamp(140px, 44vw, 180px);
    height: 3.5px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 99px;
    overflow: hidden;
    position: relative;
    margin-bottom: 12px;
}

.fyp-splash-progress-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #2563eb 0%, #38bdf8 50%, #818cf8 100%);
    border-radius: 99px;
    transform-origin: left center;
    animation: fypProgressFill 1.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    position: relative;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
}

.fyp-splash-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.75), transparent);
    animation: fypShimmerSweep 1.1s ease-in-out infinite;
}

/* Subtle Loading Caption */
.fyp-splash-status {
    font-size: 0.72rem;
    font-weight: 500;
    color: rgba(186, 230, 253, 0.68);
    letter-spacing: 0.04em;
    min-height: 16px;
    transition: opacity 0.2s ease;
}

/* Footer Tagline */
.fyp-splash-footer {
    position: absolute;
    bottom: calc(env(safe-area-inset-bottom, 16px) + 14px);
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    pointer-events: none;
}

/* ── Keyframe Animations ─────────────────────────────────────────────── */

@keyframes fypGlowPulse {
    0% {
        transform: translate(-50%, -50%) scale(0.92);
        opacity: 0.45;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.08);
        opacity: 0.8;
    }
}

@keyframes fypRingPulse {
    0% {
        transform: translate(-50%, -50%) scale(0.85);
        opacity: 0;
    }
    40% {
        opacity: 0.65;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.35);
        opacity: 0;
    }
}

@keyframes fypLogoEntrance {
    0% {
        opacity: 0;
        transform: translateY(12px) scale(0.92);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes fypParticleDrift {
    0% {
        transform: translateY(0) scale(1);
    }
    100% {
        transform: translateY(-8px) scale(1.04);
    }
}

@keyframes fypProgressFill {
    0% {
        transform: scaleX(0.08);
    }
    45% {
        transform: scaleX(0.68);
    }
    100% {
        transform: scaleX(1);
    }
}

@keyframes fypShimmerSweep {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

@keyframes fypSignalPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.4;
        transform: scale(0.85);
    }
}

/* Accessibility: Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    #fyp-pwa-splash,
    .fyp-splash-glow,
    .fyp-splash-ring,
    .fyp-splash-logo-card,
    .fyp-splash-progress-bar,
    .fyp-splash-progress-bar::after,
    .fyp-splash-pill-dot {
        animation: none !important;
        transition: opacity 0.15s linear !important;
    }
    .fyp-splash-progress-bar {
        transform: scaleX(1) !important;
    }
}
