/* Launch host stays independent from page/layout. Replace RocketLaunchVisual without changing timing. */
:root {
    --launch-ground: 12vh;
    --rocket-ground-offset: 2.45rem;
}

.site-launch-backdrop,
.site-launch-rocket,
.site-launch-ground,
.site-launch-ground-exhaust {
    position: fixed;
    pointer-events: none;
    display: none;
}

/* Safe default: no persisted/remounted launch DOM may overlay a normal page. */
html[data-site-launch="play"] .site-launch-backdrop,
html[data-site-launch="play"] .site-launch-rocket,
html[data-site-launch="play"] .site-launch-ground,
html[data-site-launch="play"] .site-launch-ground-exhaust {
    display: block;
}

.site-launch-backdrop {
    z-index: 1;
    position: fixed;
    inset: 0;
    background: linear-gradient(160deg, #0a0a0d 0%, #15161a 100%);
}

.site-launch-rocket {
    z-index: 3;
    inset: 0;
    overflow: hidden;
}

.site-launch-ground {
    z-index: 4;
    right: 0;
    bottom: var(--launch-ground);
    left: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent 4%, #34353a 20%, #b5b5b8 50%, #34353a 80%, transparent 96%);
    box-shadow: 0 0 .8rem rgba(79, 195, 255, .16);
}

.site-launch-ground-exhaust {
    z-index: 3;
    bottom: calc(var(--launch-ground) + 2px);
    left: 50%;
    width: 22rem;
    height: 7.5rem;
    transform: translateX(-50%);
    overflow: visible;
}

.site-launch-ground-exhaust span {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: .65rem;
    height: .65rem;
    border-radius: 999px;
    background: #b5b5b8;
    box-shadow: 0 0 .65rem rgba(79, 195, 255, .45);
    opacity: 0;
}

/* Stationary launch phase: exhaust reaches the ground, then is redirected sideways. */
.site-launch-ground-exhaust span:nth-child(1) { --ground-hit-x: -1.1rem; --ground-x: -8.2rem; --ground-rise: -1.05rem; --ground-delay: .02s; }
.site-launch-ground-exhaust span:nth-child(2) { --ground-hit-x: -.65rem; --ground-x: -5.9rem; --ground-rise: -2.4rem; --ground-delay: .12s; }
.site-launch-ground-exhaust span:nth-child(3) { --ground-hit-x: -.2rem; --ground-x: -3.1rem; --ground-rise: -.55rem; --ground-delay: .2s; }
.site-launch-ground-exhaust span:nth-child(4) { --ground-hit-x: .2rem; --ground-x: 3.1rem; --ground-rise: -.55rem; --ground-delay: .16s; }
.site-launch-ground-exhaust span:nth-child(5) { --ground-hit-x: .65rem; --ground-x: 5.9rem; --ground-rise: -2.4rem; --ground-delay: .07s; }
.site-launch-ground-exhaust span:nth-child(6) { --ground-hit-x: 1.1rem; --ground-x: 8.2rem; --ground-rise: -1.05rem; --ground-delay: .25s; }

.site-launch-content {
    position: relative;
    z-index: 2;
}

.rocket-launch-visual {
    position: absolute;
    left: 50%;
    bottom: calc(var(--launch-ground) - var(--rocket-ground-offset));
    z-index: 3;
    width: clamp(5rem, 10vw, 8rem);
    transform: translateX(-50%);
}

.launch-thruster-glow {
    position: absolute;
    z-index: 0;
    top: 65%;
    left: 50%;
    width: 17rem;
    height: 15rem;
    transform: translateX(-50%);
    background: radial-gradient(ellipse at 50% 16%, rgba(79, 195, 255, .3), rgba(30, 61, 155, .12) 38%, transparent 72%);
    filter: blur(.3rem);
}

.launch-tether {
    position: absolute;
    z-index: 1;
    top: 82%;
    left: 50%;
    width: 1px;
    height: 125vh;
    transform: translateX(-50%);
    background: linear-gradient(to bottom, #f2f2f4 0%, #4fc3ff 16%, rgba(79, 195, 255, .28) 55%, transparent 100%);
    box-shadow: 0 0 .35rem rgba(79, 195, 255, .48);
    opacity: 0;
}

.launch-rocket {
    position: relative;
    z-index: 2;
    display: block;
    width: 100%;
    overflow: visible;
    filter: drop-shadow(0 0 0.8rem rgba(79, 195, 255, 0.32));
}

.rocket-body { fill: none; stroke: #f2f2f4; stroke-width: 2.4; }
.rocket-body-line { fill: none; stroke: #b5b5b8; stroke-width: 1.1; }
.rocket-fin { fill: none; stroke: #b5b5b8; stroke-width: 2; }
.rocket-window { fill: none; stroke: #4fc3ff; stroke-width: 2.2; }
.rocket-band { fill: none; stroke: #b5b5b8; stroke-width: 1.25; }
.rocket-nozzle { fill: none; stroke: #f2f2f4; stroke-width: 2; }

.launch-particles {
    position: absolute;
    left: 50%;
    width: 12rem;
    height: 12rem;
    transform: translateX(-50%);
    transform-origin: top center;
    z-index: 1;
}

.launch-particles-fire { top: 73%; }
.launch-particles-smoke { top: 83%; }

.launch-particles span {
    position: absolute;
    display: block;
    border-radius: 999px;
}

.launch-particles-smoke span {
    background: #b5b5b8;
    box-shadow: 0 0 1rem rgba(242, 242, 244, 0.16);
}

.launch-particles-smoke span:nth-child(1) { left: 46%; top: 0; width: 2.1rem; height: 2.1rem; --drift-x: -.7rem; --drift-y: 3.3rem; --delay: .02s; }
.launch-particles-smoke span:nth-child(2) { left: 26%; top: 2.1rem; width: 2.8rem; height: 2.8rem; --drift-x: -1.5rem; --drift-y: 4.6rem; --delay: .18s; }
.launch-particles-smoke span:nth-child(3) { right: 20%; top: 2.5rem; width: 2.5rem; height: 2.5rem; --drift-x: 1.25rem; --drift-y: 4rem; --delay: .31s; }
.launch-particles-smoke span:nth-child(4) { left: 42%; top: 4.4rem; width: 3.4rem; height: 3.4rem; --drift-x: .35rem; --drift-y: 5.3rem; --delay: .09s; }
.launch-particles-smoke span:nth-child(5) { left: 5%; top: 5rem; width: 2rem; height: 2rem; --drift-x: -1.9rem; --drift-y: 3.8rem; --delay: .43s; }
.launch-particles-smoke span:nth-child(6) { right: 6%; top: 5.8rem; width: 1.8rem; height: 1.8rem; --drift-x: 1.65rem; --drift-y: 3.6rem; --delay: .26s; }

.launch-particles-fire span {
    left: 50%;
    top: -1.3rem;
    width: 1.1rem;
    height: 5.4rem;
    transform: translateX(-50%);
    background: linear-gradient(#f2f2f4 0%, #4fc3ff 45%, rgba(30, 61, 155, 0) 100%);
    filter: blur(0.14rem);
    transform-origin: top;
}

.launch-particles-fire span:nth-child(1) { --drift-x: -.45rem; --drift-y: 4rem; --delay: .02s; }
.launch-particles-fire span:nth-child(2) { margin-left: -1.2rem; height: 4.2rem; --drift-x: -1.95rem; --drift-y: 3.1rem; --delay: .12s; }
.launch-particles-fire span:nth-child(3) { margin-left: 1.2rem; height: 4.5rem; --drift-x: 1.8rem; --drift-y: 3.4rem; --delay: .22s; }
.launch-particles-fire span:nth-child(4) { margin-left: .15rem; height: 6.2rem; --drift-x: .7rem; --drift-y: 4.9rem; --delay: .35s; }

html[data-site-launch="play"] .site-launch-content {
    animation: site-lift 1.25s cubic-bezier(.2, .82, .2, 1) 1.85s both;
    will-change: transform;
}

html[data-site-launch="play"] .rocket-launch-visual {
    animation: rocket-ascend 2.35s cubic-bezier(.55, 0, .85, .45) both;
    will-change: bottom;
}

html[data-site-launch="play"] .launch-rocket { animation: rocket-ignite .28s ease-in-out 0s 2 alternate; }
html[data-site-launch="play"] .launch-particles { animation: particles-ramp 2.6s cubic-bezier(.2, .82, .2, 1) both; }
html[data-site-launch="play"] .launch-particles-smoke span { animation: smoke-trail 1.05s ease-out var(--delay) infinite; }
html[data-site-launch="play"] .launch-particles-fire span { animation: fire-trail .48s ease-out var(--delay) infinite; }
html[data-site-launch="play"] .site-launch-ground-exhaust span { animation: ground-reverb 1.25s cubic-bezier(.16, .76, .28, 1) var(--ground-delay) both; }
html[data-site-launch="play"] .site-launch-backdrop { animation: launch-fade .28s ease 2.92s forwards; }
html[data-site-launch="play"] .launch-tether { animation: tether-visibility 2.35s ease-out both; }
html[data-site-launch="play"] .site-launch-ground { animation: ground-impact .9s ease-out both, ground-fade .25s ease 1.85s forwards; }
html[data-site-launch="play"] .site-launch-ground-exhaust { animation: ground-fade .25s ease 1.85s forwards; }

html[data-site-launch="skip"] .site-launch-backdrop,
html[data-site-launch="skip"] .site-launch-rocket,
html[data-site-launch="skip"] .site-launch-ground,
html[data-site-launch="skip"] .site-launch-ground-exhaust { display: none; }

@keyframes site-lift {
    from { transform: translateY(105vh); }
    100% { transform: translateY(0); }
}

@keyframes rocket-ascend {
    0%, 28% { bottom: calc(var(--launch-ground) - var(--rocket-ground-offset)); }
    100% { bottom: 135vh; }
}

@keyframes rocket-ignite {
    from { filter: drop-shadow(0 0 .45rem rgba(79, 195, 255, .24)); }
    to { filter: drop-shadow(0 0 1.4rem rgba(79, 195, 255, .7)); }
}

@keyframes launch-fade { to { opacity: 0; visibility: hidden; } }

@keyframes particles-ramp {
    /* Do not emit the moving trail until rocket has cleared the ground plane. */
    0%, 39% { opacity: 0; transform: translateX(-50%) scale(.04); }
    47% { opacity: 1; transform: translateX(-50%) scale(1); }
    100% { opacity: .92; transform: translateX(-50%) scale(1.08); }
}

@keyframes tether-visibility {
    0%, 24% { opacity: 0; }
    30%, 75% { opacity: .9; }
    100% { opacity: 0; }
}

@keyframes ground-reverb {
    0% { transform: translate(-50%, -4.35rem) scale(.25); opacity: 0; }
    16% { opacity: .9; }
    42% { transform: translate(calc(-50% + var(--ground-hit-x)), 0) scale(.95); opacity: .96; }
    70% { transform: translate(calc(-50% + var(--ground-x)), var(--ground-rise)) scale(.75); opacity: .72; }
    100% { transform: translate(calc(-50% + var(--ground-x)), calc(var(--ground-rise) - .35rem)) scale(.45); opacity: 0; }
}

@keyframes ground-impact {
    0% { opacity: .55; box-shadow: 0 0 .35rem rgba(79, 195, 255, .12); }
    48% { opacity: 1; box-shadow: 0 0 1.25rem rgba(79, 195, 255, .72); }
    100% { opacity: .82; box-shadow: 0 0 .8rem rgba(79, 195, 255, .2); }
}

@keyframes ground-fade { to { opacity: 0; visibility: hidden; } }

@keyframes smoke-trail {
    0% { transform: translate(0, 0) scale(.28); opacity: 0; }
    18% { opacity: .78; }
    100% { transform: translate(var(--drift-x), var(--drift-y)) scale(1.18); opacity: 0; }
}

@keyframes fire-trail {
    0% { transform: translateX(-50%) translate(0, 0) scaleY(.2); opacity: 0; }
    16% { opacity: 1; }
    100% { transform: translateX(-50%) translate(var(--drift-x), var(--drift-y)) scaleY(.92); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .site-launch-backdrop,
    .site-launch-rocket,
    .site-launch-ground,
    .site-launch-ground-exhaust { display: none; }
    .site-launch-content { animation: none !important; }
}

@media (max-width: 640px) {
    .rocket-launch-visual { bottom: 11vh; width: 5.75rem; }
    .launch-particles { transform: translateX(-50%) scale(.8); transform-origin: bottom; }
}
