/* Meridian splash — cinematic hero, theme-aware
   Light: soil parchment + chlorophyll
   Dark: orbit night + mint */

:root {
    --splash-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --splash-snap: cubic-bezier(0.2, 0, 0, 1);
    --earth-px: 0;
    --earth-py: 0;
    --earth-scroll: 0;
}

/* Only the splash host — never style #app (breaks map height chain). */
.app-splash-host {
    --earth-px: 0;
    --earth-py: 0;
    --splash-canvas: var(--md-canvas, #f1ebe1);
    --splash-ink: var(--md-ink, #18211c);
    --splash-body: var(--md-body, #3a453f);
    --splash-muted: var(--md-muted, #66706a);
    --splash-accent: var(--md-blue, #1f7a5f);
    --splash-mint: var(--md-mint, #3da88a);
    --splash-mint-soft: var(--md-mint-soft, #8fd4b8);
    position: fixed;
    inset: 0;
    z-index: var(--md-z-splash);
    display: grid;
    place-items: center;
    padding: clamp(1.5rem, 5vw, 3rem);
    overflow: hidden;
    background: var(--splash-canvas);
    color: var(--splash-body);
}

html.md-theme-dark .app-splash-host {
    --splash-canvas: var(--md-orbit, #0b0d0e);
    --splash-ink: var(--md-ink, #f2eee6);
    --splash-body: var(--md-body, #d2d0c6);
    --splash-muted: var(--md-muted, #87928a);
    --splash-accent: var(--md-mint, #3faf92);
    --splash-mint: var(--md-mint, #3faf92);
    --splash-mint-soft: var(--md-mint-soft, #9fdcc4);
}

.app-splash-host .earth-scene--splash {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 1;
    filter: none;
    background: #0a192f;
    -webkit-mask-image: none;
    mask-image: none;
    will-change: transform;
}

.app-splash-host .earth-scene--splash .earth-canvas,
.app-splash-host .earth-scene--splash .earth-starfield {
    pointer-events: none;
}

html.md-theme-dark .app-splash-host .earth-scene--splash {
    opacity: 1;
    filter: none;
    background: #0a192f;
}

/* Parchment wash over space — brand stays readable, globe stays in the starfield */
.app-splash-veil {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background:
        linear-gradient(90deg, var(--splash-canvas) 0%, color-mix(in srgb, var(--splash-canvas) 82%, transparent) 24%, transparent 48%);
}

.app-splash-host--boot .app-splash-veil {
    background:
        linear-gradient(90deg, var(--splash-canvas) 0%, color-mix(in srgb, var(--splash-canvas) 86%, transparent) 22%, transparent 46%);
}

.app-splash-host--boot .earth-scene--splash {
    background: #0a192f;
}

.app-splash-host--session {
    background:
        radial-gradient(ellipse 50% 42% at 78% 16%, color-mix(in srgb, var(--splash-mint) 14%, transparent), transparent 58%),
        radial-gradient(ellipse 38% 30% at 14% 84%, color-mix(in srgb, var(--md-tone-weather, #2f7a90) 10%, transparent), transparent 55%),
        var(--splash-canvas);
}

.app-splash-ambience {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    translate: calc(var(--earth-px) * 5px) calc(var(--earth-py) * 4px);
    will-change: translate;
}

.app-splash-ambience__glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(48px);
    opacity: 0.45;
    animation: splash-glow-drift 12s ease-in-out infinite;
}

html.md-theme-dark .app-splash-ambience__glow {
    opacity: 0.55;
}

.app-splash-ambience__glow--a {
    top: 12%;
    right: 8%;
    width: min(48vw, 28rem);
    height: min(38vw, 22rem);
    background: radial-gradient(circle, color-mix(in srgb, var(--splash-mint) 36%, transparent), transparent 68%);
}

.app-splash-ambience__glow--b {
    bottom: 8%;
    left: 6%;
    width: min(42vw, 24rem);
    height: min(34vw, 18rem);
    background: radial-gradient(circle, color-mix(in srgb, var(--md-tone-weather, #2f7a90) 24%, transparent), transparent 70%);
    animation-delay: -4s;
    animation-duration: 15s;
}

.app-splash-ambience__stars {
    position: absolute;
    inset: 0;
    opacity: 0.28;
    background-image:
        radial-gradient(1.5px 1.5px at 18% 22%, color-mix(in srgb, var(--splash-accent) 35%, transparent), transparent),
        radial-gradient(1px 1px at 72% 28%, color-mix(in srgb, var(--splash-mint) 40%, transparent), transparent),
        radial-gradient(1.5px 1.5px at 42% 74%, color-mix(in srgb, var(--splash-ink) 18%, transparent), transparent),
        radial-gradient(1px 1px at 86% 64%, color-mix(in srgb, var(--md-tone-weather, #2f7a90) 30%, transparent), transparent),
        radial-gradient(1px 1px at 28% 48%, color-mix(in srgb, var(--splash-accent) 22%, transparent), transparent);
    animation: splash-stars-breathe 7s ease-in-out infinite;
}

html.md-theme-dark .app-splash-ambience__stars {
    opacity: 0.55;
    background-image:
        radial-gradient(1.5px 1.5px at 18% 22%, color-mix(in srgb, #ffffff 55%, transparent), transparent),
        radial-gradient(1px 1px at 72% 28%, color-mix(in srgb, var(--splash-mint-soft) 55%, transparent), transparent),
        radial-gradient(1.5px 1.5px at 42% 74%, color-mix(in srgb, #ffffff 35%, transparent), transparent),
        radial-gradient(1px 1px at 86% 64%, color-mix(in srgb, #7ec8ff 40%, transparent), transparent),
        radial-gradient(1px 1px at 28% 48%, color-mix(in srgb, #ffffff 40%, transparent), transparent);
}

/* Hero stage */
.app-splash-stage {
    position: relative;
    z-index: 2;
    width: min(100%, 28rem);
    /* Counter-parallax vs globe */
    translate: calc(var(--earth-px) * -10px) calc(var(--earth-py) * -7px);
    animation: splash-stage-in 0.85s var(--splash-ease) both;
    will-change: transform, opacity, translate;
}

.app-splash-stage--session {
    translate: none;
    width: min(100%, 24rem);
}

.app-splash-host--boot .app-splash-stage {
    justify-self: start;
    margin-left: clamp(0rem, 3vw, 4rem);
}

.app-splash-hero {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    text-align: left;
}

.app-splash-stage--session .app-splash-hero {
    align-items: center;
    text-align: center;
}

.app-splash-hero__mark {
    position: relative;
    display: grid;
    place-items: center;
    width: 4.25rem;
    height: 4.25rem;
    margin-bottom: 1.6rem;
    animation: splash-rise 0.7s var(--splash-ease) 0.05s both;
}

.app-splash-hero__orbit {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px solid color-mix(in srgb, var(--splash-accent) 32%, transparent);
    animation: splash-orbit-spin 14s linear infinite;
}

.app-splash-hero__orbit--slow {
    inset: -10%;
    border-color: color-mix(in srgb, var(--splash-mint) 28%, transparent);
    border-style: dashed;
    animation-duration: 28s;
    animation-direction: reverse;
}

.app-splash-hero__orbit::before,
.app-splash-hero__orbit--slow::before {
    content: "";
    position: absolute;
    top: -3px;
    left: 50%;
    width: 6px;
    height: 6px;
    margin-left: -3px;
    border-radius: 50%;
    background: var(--splash-accent);
    box-shadow: 0 0 12px color-mix(in srgb, var(--splash-mint) 55%, transparent);
}

.app-splash-hero__orbit--slow::before {
    background: var(--splash-mint);
    width: 4px;
    height: 4px;
    margin-left: -2px;
    top: -2px;
}

.app-splash-hero__logo {
    position: relative;
    z-index: 1;
    width: 2.35rem;
    height: 2.35rem;
    display: block;
    filter: drop-shadow(0 8px 18px color-mix(in srgb, var(--splash-mint) 28%, transparent));
}

.app-splash-hero__logo--dark {
    display: none;
}

html.md-theme-dark .app-splash-hero__logo--light {
    display: none !important;
}

html.md-theme-dark .app-splash-hero__logo--dark {
    display: block !important;
}

.app-splash-hero__eyebrow {
    margin: 0 0 0.55rem;
    color: color-mix(in srgb, var(--splash-accent) 72%, var(--splash-muted));
    font-family: var(--md-font, "Onest", system-ui, sans-serif);
    font-size: 0.95rem;
    font-style: italic;
    font-weight: 400;
    letter-spacing: -0.01em;
    animation: splash-rise 0.7s var(--splash-ease) 0.12s both;
}

.app-splash-hero__brand {
    margin: 0;
    color: var(--splash-ink);
    font-family: var(--md-font-display, "Literata", Georgia, serif);
    font-size: clamp(2.75rem, 7vw, 4rem);
    font-weight: 500;
    line-height: 0.98;
    letter-spacing: -0.055em;
    text-wrap: balance;
    animation: splash-rise 0.8s var(--splash-ease) 0.18s both;
}

.app-splash-hero__lede {
    margin: 0.85rem 0 0;
    max-width: 18rem;
    color: var(--splash-body);
    font-family: var(--md-font, "Onest", system-ui, sans-serif);
    font-size: 1.05rem;
    line-height: 1.45;
    animation: splash-rise 0.75s var(--splash-ease) 0.26s both;
}

.app-splash-stage--session .app-splash-hero__lede {
    text-align: center;
}

.app-splash-hero__progress {
    position: relative;
    width: min(100%, 14rem);
    height: 2px;
    margin-top: 1.75rem;
    animation: splash-rise 0.7s var(--splash-ease) 0.34s both;
}

.app-splash-stage--session .app-splash-hero__progress {
    width: min(100%, 11rem);
}

.app-splash-hero__rail {
    position: absolute;
    inset: 0;
    border-radius: var(--md-radius-pill);
    background: color-mix(in srgb, var(--splash-accent) 16%, var(--md-stone, #e8e0d2));
}

html.md-theme-dark .app-splash-hero__rail {
    background: color-mix(in srgb, var(--splash-mint) 18%, transparent);
}

.app-splash-hero__fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--blazor-load-percentage, 0%);
    border-radius: inherit;
    background: linear-gradient(90deg, var(--splash-accent), var(--splash-mint), var(--splash-mint-soft));
    box-shadow: 0 0 14px color-mix(in srgb, var(--splash-mint) 40%, transparent);
    transition: width var(--md-dur-base) var(--splash-ease);
}

.app-splash-hero__sweep {
    position: absolute;
    inset: 0 auto 0 0;
    width: 38%;
    border-radius: inherit;
    background: linear-gradient(90deg, transparent, var(--splash-accent), var(--splash-mint-soft), transparent);
    animation: splash-sweep 1.8s var(--splash-ease) infinite;
}

.app-splash-hero__pct {
    position: absolute;
    top: calc(100% + 0.65rem);
    left: 0;
    margin: 0;
    color: var(--splash-muted);
    font-family: var(--md-mono, ui-monospace, monospace);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
}

.app-splash-hero__pct.loading-progress-text::after {
    content: var(--blazor-load-percentage-text, "0%");
}

.app-splash-hero__progress--known {
    margin-bottom: 1.65rem;
}

.app-splash-hero__progress--soft {
    margin-bottom: 0;
}

.app-splash-hero__status {
    margin: 1.35rem 0 0;
    max-width: 22rem;
    color: var(--splash-muted);
    font-family: var(--md-font, "Onest", system-ui, sans-serif);
    font-size: 0.875rem;
    line-height: 1.4;
    animation: splash-rise 0.7s var(--splash-ease) 0.42s both;
}

.app-splash-stage--session .app-splash-hero__status {
    margin-top: 1.5rem;
}

.loading-progress-bar {
    display: block;
}

@keyframes splash-stage-in {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes splash-rise {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes splash-orbit-spin {
    to { transform: rotate(360deg); }
}

@keyframes splash-sweep {
    0% { transform: translateX(-120%); opacity: 0; }
    20% { opacity: 1; }
    100% { transform: translateX(320%); opacity: 0; }
}

@keyframes splash-glow-drift {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.4; }
    50% { transform: translate(-3%, 2%) scale(1.06); opacity: 0.65; }
}

@keyframes splash-stars-breathe {
    0%, 100% { opacity: 0.22; }
    50% { opacity: 0.4; }
}

html.md-theme-dark .app-splash-ambience__stars {
    animation-name: splash-stars-breathe-dark;
}

@keyframes splash-stars-breathe-dark {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.7; }
}

@media (max-width: 720px) {
    .app-splash-host--boot .app-splash-stage {
        justify-self: center;
        margin-left: 0;
        align-self: end;
        margin-bottom: 8vh;
    }

    .app-splash-hero,
    .app-splash-stage--session .app-splash-hero {
        align-items: center;
        text-align: center;
    }

    .app-splash-hero__progress {
        align-self: center;
    }

    .app-splash-hero__pct {
        left: 50%;
        transform: translateX(-50%);
    }

    .app-splash-host--boot .app-splash-veil {
        background:
            linear-gradient(180deg, color-mix(in srgb, var(--splash-canvas) 40%, transparent) 0%, transparent 35%, color-mix(in srgb, var(--splash-canvas) 78%, transparent) 88%),
            linear-gradient(90deg, var(--splash-canvas) 0%, transparent 55%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-splash-stage,
    .app-splash-hero__mark,
    .app-splash-hero__eyebrow,
    .app-splash-hero__brand,
    .app-splash-hero__lede,
    .app-splash-hero__progress,
    .app-splash-hero__status,
    .app-splash-hero__orbit,
    .app-splash-hero__sweep,
    .app-splash-ambience__glow,
    .app-splash-ambience__stars {
        animation: none !important;
    }

    .app-splash-stage,
    .app-splash-ambience,
    .app-splash-host .earth-scene--splash {
        translate: none !important;
        transform: none !important;
        opacity: 1;
        will-change: auto;
    }

    .app-splash-hero__fill {
        transition: none;
    }
}
