/* Scope splash theme vars and background ONLY while the splash container exists */
body.splash-page:has(.mud-wasm-cont) {
    /* Main theme color - change this one value to update entire color scheme */
    --primary-color: #1E88E5;
    --primary-light: color-mix(in srgb, var(--primary-color) 80%, white 20%);
    --primary-medium: var(--primary-color);
    --primary-dark: color-mix(in srgb, var(--primary-color) 70%, black 30%);
    --primary-darker: color-mix(in srgb, var(--primary-color) 50%, black 50%);
    /* Auto-generated rgba versions for transparency */
    --primary-rgba-light: color-mix(in srgb, var(--primary-color) 8%, transparent 92%);
    --primary-rgba-border: color-mix(in srgb, var(--primary-color) 20%, transparent 80%);
    --primary-rgba-glow-light: color-mix(in srgb, var(--primary-color) 30%, transparent 70%);
    --primary-rgba-glow-strong: color-mix(in srgb, var(--primary-color) 60%, transparent 40%);
    /* Primary color background ONLY during splash */
    background-color: var(--primary-medium);
    background-image: radial-gradient(circle at 30% 70%, var(--primary-dark) 0%, var(--primary-darker) 100%);
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: cover;
    min-height: 100vh;
    overflow: hidden;
}

/* Reset body for normal site pages */
body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* App container - no background so it inherits from body */
#app {
    min-height: 100vh;
}


@keyframes abstractFlow {
    0% {
        transform: translateX(-100%) translateY(50%) rotate(0deg) scale(0.8);
        border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
        opacity: 0;
    }

    25% {
        transform: translateX(25%) translateY(-20%) rotate(90deg) scale(1.2);
        border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
        opacity: 0.6;
    }

    50% {
        transform: translateX(50%) translateY(30%) rotate(180deg) scale(0.9);
        border-radius: 50% 50% 50% 50% / 60% 40% 60% 40%;
        opacity: 0.8;
    }

    75% {
        transform: translateX(75%) translateY(-10%) rotate(270deg) scale(1.1);
        border-radius: 40% 70% 60% 30% / 40% 50% 60% 50%;
        opacity: 0.4;
    }

    100% {
        transform: translateX(200%) translateY(60%) rotate(360deg) scale(0.7);
        border-radius: 70% 30% 40% 60% / 30% 70% 40% 60%;
        opacity: 0;
    }
}

@keyframes organicPulse {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        border-radius: 50% 60% 70% 40% / 60% 50% 40% 70%;
    }

    33% {
        transform: scale(1.3) rotate(120deg);
        border-radius: 70% 40% 50% 60% / 40% 70% 60% 50%;
    }

    66% {
        transform: scale(0.8) rotate(240deg);
        border-radius: 40% 70% 60% 50% / 70% 40% 50% 60%;
    }
}

@keyframes morphingWave {
    0% {
        clip-path: polygon(0% 50%, 20% 80%, 40% 30%, 60% 70%, 80% 20%, 100% 60%, 100% 100%, 0% 100%);
        transform: translateX(-50%) rotate(0deg);
    }

    25% {
        clip-path: polygon(0% 30%, 20% 60%, 40% 80%, 60% 20%, 80% 70%, 100% 40%, 100% 100%, 0% 100%);
        transform: translateX(0%) rotate(90deg);
    }

    50% {
        clip-path: polygon(0% 70%, 20% 40%, 40% 60%, 60% 80%, 80% 30%, 100% 50%, 100% 100%, 0% 100%);
        transform: translateX(50%) rotate(180deg);
    }

    75% {
        clip-path: polygon(0% 40%, 20% 70%, 40% 20%, 60% 60%, 80% 80%, 100% 30%, 100% 100%, 0% 100%);
        transform: translateX(100%) rotate(270deg);
    }

    100% {
        clip-path: polygon(0% 50%, 20% 80%, 40% 30%, 60% 70%, 80% 20%, 100% 60%, 100% 100%, 0% 100%);
        transform: translateX(150%) rotate(360deg);
    }
}

@keyframes gentleFloat {
    0%, 100% {
        transform: translateY(0px) scale(1) rotate(0deg);
    }

    33% {
        transform: translateY(-5px) scale(1.008) rotate(0.5deg);
    }

    66% {
        transform: translateY(-12px) scale(1.015) rotate(-0.5deg);
    }
}

@keyframes subtleGlow {
    0%, 100% {
        filter: drop-shadow(0 0 20px var(--primary-rgba-glow-light)) drop-shadow(0 0 40px var(--primary-rgba-glow-light));
    }

    50% {
        filter: drop-shadow(0 0 30px var(--primary-rgba-glow-strong)) drop-shadow(0 0 60px var(--primary-rgba-glow-strong));
    }
}


/* Abstract Background Animation */
.mud-wasm {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background: radial-gradient(ellipse at 40% 30%, color-mix(in srgb, var(--primary-color) 35%, transparent) 0%, color-mix(in srgb, var(--primary-color) 55%, transparent) 30%, color-mix(in srgb, var(--primary-color) 25%, transparent) 60%, transparent 100%);
    animation: abstractFlow 15s cubic-bezier(0.4, 0.0, 0.2, 1) infinite;
    will-change: transform, opacity, filter, border-radius;
    filter: blur(3px);
    border-radius: 50% 60% 70% 40% / 60% 50% 40% 70%;
}

    /* Soft spotlight centered on the screen to simulate light over the logo */
    .mud-wasm:first-of-type::after {
        content: "";
        position: absolute;
        inset: 0;
        pointer-events: none;
        /* A gentle white-to-transparent radial gradient to brighten the mid area */
        background: radial-gradient( circle at 50% 50%, color-mix(in srgb, white 18%, transparent) 0%, color-mix(in srgb, white 10%, transparent) 30%, transparent 60% );
        opacity: 0.18; /* keep subtle to avoid overpowering multiple layers */
        filter: blur(6px);
    }

/* Abstract floating shapes */
.abstract-shape {
    position: fixed;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle at 30% 70%, color-mix(in srgb, var(--primary-color) 40%, transparent) 0%, transparent 70%);
    border-radius: 50% 60% 40% 70% / 40% 50% 60% 70%;
    animation: organicPulse 12s ease-in-out infinite;
    will-change: transform, border-radius;
    filter: blur(2px);
}

/* Morphing wave elements */
.wave-shape {
    position: fixed;
    width: 100vw;
    height: 40vh;
    background: linear-gradient(45deg, color-mix(in srgb, var(--primary-color) 20%, transparent) 0%, color-mix(in srgb, var(--primary-color) 40%, transparent) 50%, transparent 100%);
    animation: morphingWave 18s linear infinite;
    will-change: transform, clip-path;
    filter: blur(4px);
}

.mud-wasm-cont {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    padding: 2rem;
    min-width: max-content;
    max-width: 95vw;
    max-height: 95vh;
    width: auto;
    height: auto;
    backdrop-filter: blur(10px);
    background: var(--primary-rgba-light);
    border-radius: 20px;
    border: 1px solid var(--primary-rgba-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    isolation: isolate;
}

    /* Soft radial glow behind the logo to draw focus */
    .mud-wasm-cont::before {
        content: "";
        position: absolute;
        inset: -15% -18%;
        background: radial-gradient(70% 70% at 50% 40%, color-mix(in srgb, var(--primary-color) 45%, transparent 55%) 0%, color-mix(in srgb, var(--primary-color) 25%, transparent 75%) 40%, transparent 80%);
        filter: blur(40px);
        z-index: -1;
        pointer-events: none;
    }

/* Logo Animation */
.splash-logo {
    width: clamp(160px, 35vmin, 450px);
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0;
    animation: gentleFloat 6s cubic-bezier(0.4, 0.0, 0.2, 1) infinite, subtleGlow 4s ease-in-out infinite;
    transition: all 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
    flex-shrink: 0;
    will-change: transform, filter;
    backface-visibility: hidden;
    transform: translateZ(0);
    position: relative;
    z-index: 2;
}

    .splash-logo:hover {
        transform: scale(1.05);
    }

/* Mobile-specific logo enhancements */
@media (max-width: 768px) {
    .splash-logo {
        width: clamp(180px, 45vmin, 350px);
        animation: gentleFloat 5s cubic-bezier(0.4, 0.0, 0.2, 1) infinite, subtleGlow 3.5s ease-in-out infinite, mobileBounce 8s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
        filter: drop-shadow(0 4px 20px var(--primary-rgba-glow-light)) drop-shadow(0 8px 40px var(--primary-rgba-glow-strong));
    }

        .splash-logo:active {
            transform: scale(0.95);
            animation-play-state: paused;
        }

    /* Enhanced container for mobile */
    .mud-wasm-cont {
        padding: 1.5rem;
        border-radius: 25px;
        backdrop-filter: blur(15px);
        background: linear-gradient(135deg, color-mix(in srgb, var(--primary-color) 12%, transparent 88%) 0%, color-mix(in srgb, var(--primary-color) 8%, transparent 92%) 100%);
        border: 2px solid var(--primary-rgba-border);
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), 0 4px 16px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    }

        /* Enhanced glow effect for mobile */
        .mud-wasm-cont::before {
            inset: -20% -25%;
            background: radial-gradient(80% 80% at 50% 40%, color-mix(in srgb, var(--primary-color) 60%, transparent 40%) 0%, color-mix(in srgb, var(--primary-color) 35%, transparent 65%) 35%, color-mix(in srgb, var(--primary-color) 15%, transparent 85%) 70%, transparent 100%);
            filter: blur(50px);
            animation: mobileGlow 6s ease-in-out infinite;
        }
}

/* Additional mobile bounce animation */
@keyframes mobileBounce {
    0%, 100% {
        transform: translateY(0px) scale(1) rotate(0deg);
    }

    10% {
        transform: translateY(-3px) scale(1.02) rotate(0.3deg);
    }

    20% {
        transform: translateY(-8px) scale(1.05) rotate(-0.3deg);
    }

    30% {
        transform: translateY(-5px) scale(1.03) rotate(0.2deg);
    }

    40% {
        transform: translateY(-10px) scale(1.08) rotate(-0.2deg);
    }

    50% {
        transform: translateY(-6px) scale(1.04) rotate(0.1deg);
    }

    60% {
        transform: translateY(-3px) scale(1.02) rotate(-0.1deg);
    }

    80% {
        transform: translateY(-1px) scale(1.01) rotate(0deg);
    }
}

/* Mobile glow animation */
@keyframes mobileGlow {
    0%, 100% {
        opacity: 0.8;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

/* Subtle shimmer for loader bar, only if the element exists */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.loader-bar {
    position: relative;
    overflow: hidden;
}

    .loader-bar::after {
        content: "";
        position: absolute;
        inset: 0;
        background: linear-gradient(90deg, transparent 0%, color-mix(in srgb, var(--primary-color) 25%, transparent 75%) 45%, color-mix(in srgb, var(--primary-color) 45%, transparent 55%) 50%, color-mix(in srgb, var(--primary-color) 25%, transparent 75%) 55%, transparent 100%);
        background-size: 200% 100%;
        animation: shimmer 2.4s linear infinite;
        pointer-events: none;
    }

/* Accessibility: respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .mud-wasm,
    .splash-logo,
    .loader-bar::after {
        animation: none !important;
    }

    .mud-wasm {
        opacity: 0.25;
        filter: blur(1px);
    }

    .splash-logo {
        transform: none !important;
    }
}
