/* ==========================================================================
   SPACE Home / Loading Screen
   Uses the official SPACE emblem asset supplied by the team.
   ========================================================================== */

:root {
    --space-navy: #1b1d52;
    --space-blue: #1f4298;
    --space-light-blue: #4a64ae;
    --space-grey: #606874;
}

.home-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    overflow: hidden;
    padding: clamp(18px, 4vw, 48px);
    background:
        radial-gradient(circle at 50% 34%, rgba(74, 100, 174, 0.12), transparent 34%),
        linear-gradient(145deg, #ffffff 0%, #f7f8fc 55%, #eef1f8 100%);
    opacity: 1;
    visibility: visible;
    transition:
        opacity 360ms ease,
        transform 420ms cubic-bezier(0.22, 1, 0.36, 1),
        visibility 420ms;
}

.home-screen.leaving {
    opacity: 0;
    transform: scale(1.025);
    pointer-events: none;
}

.home-screen.hidden {
    display: none !important;
}

.home-background-grid {
    position: absolute;
    inset: -10%;
    pointer-events: none;
    opacity: 0.38;
    background-image:
        linear-gradient(rgba(27, 29, 82, 0.055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(27, 29, 82, 0.055) 1px, transparent 1px);
    background-size: 46px 46px;
    mask-image: radial-gradient(circle at center, black 18%, transparent 72%);
    transform: perspective(900px) rotateX(58deg) translateY(27%);
    transform-origin: center bottom;
}

.home-card {
    position: relative;
    z-index: 2;
    width: min(720px, 96vw);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: clamp(26px, 5vw, 54px) clamp(24px, 5vw, 64px);
    border: 1px solid rgba(27, 29, 82, 0.11);
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.84);
    box-shadow:
        0 34px 80px rgba(27, 29, 82, 0.14),
        0 8px 26px rgba(31, 66, 152, 0.08);
    backdrop-filter: blur(15px);
}

/* --------------------------------------------------------------------------
   3D spinning emblem
   The logo is constructed as a stack of the official emblem image along the
   Z axis, then the entire stack is rotated in CSS 3D space.
   -------------------------------------------------------------------------- */

.home-logo-scene {
    width: clamp(180px, 32vw, 290px);
    aspect-ratio: 1;
    perspective: 1100px;
    perspective-origin: 50% 44%;
    margin-bottom: clamp(10px, 2vw, 18px);
    filter: drop-shadow(0 18px 24px rgba(27, 29, 82, 0.18));
}

.home-logo-spinner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    animation: space-logo-spin 7.2s linear infinite;
    will-change: transform;
}

.home-logo-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    pointer-events: none;
    transform: translateZ(var(--logo-z));
    transform-origin: center;
}

.home-logo-depth {
    filter:
        brightness(var(--layer-brightness, 0.66))
        saturate(1.06);
    opacity: 0.92;
}

.home-logo-face {
    filter: saturate(1.03) contrast(1.02);
}

@keyframes space-logo-spin {
    0% {
        transform: rotateX(-7deg) rotateY(0deg);
    }

    25% {
        transform: rotateX(5deg) rotateY(90deg);
    }

    50% {
        transform: rotateX(-4deg) rotateY(180deg);
    }

    75% {
        transform: rotateX(6deg) rotateY(270deg);
    }

    100% {
        transform: rotateX(-7deg) rotateY(360deg);
    }
}

/* --------------------------------------------------------------------------
   Stationary 3D SPACE wordmark
   -------------------------------------------------------------------------- */

.home-wordmark-wrap {
    perspective: 900px;
    margin-top: 2px;
}

.home-wordmark {
    position: relative;
    color: #000;
    font-family: Inter, "Arial Black", Arial, sans-serif;
    font-size: clamp(4rem, 11vw, 7.2rem);
    font-weight: 950;
    letter-spacing: 0.015em;
    line-height: 0.9;
    transform: rotateX(5deg);
    transform-style: preserve-3d;
    text-shadow:
        1px 1px 0 #1b1d52,
        2px 2px 0 #1b1d52,
        3px 3px 0 #1b1d52,
        4px 4px 0 #1f4298,
        5px 5px 0 #1f4298,
        6px 6px 0 #1f4298,
        7px 7px 0 rgba(27, 29, 82, 0.88),
        11px 16px 24px rgba(27, 29, 82, 0.20);
}

.home-tagline {
    margin-top: clamp(18px, 3vw, 26px);
    color: var(--space-grey);
    font-size: clamp(0.82rem, 2.4vw, 1.1rem);
    font-weight: 650;
    letter-spacing: 0.07em;
    text-align: center;
    text-transform: uppercase;
}

.home-runtime-row {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 22px;
    margin-top: clamp(22px, 4vw, 34px);
    color: #6d7482;
    font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 0.78rem;
}

.home-runtime-dot {
    width: 9px;
    height: 9px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #a9afba;
    box-shadow: 0 0 0 4px rgba(96, 104, 116, 0.10);
    animation: space-runtime-pulse 1.25s ease-in-out infinite;
}

.home-runtime-dot.ready {
    background: #28a86b;
    box-shadow: 0 0 0 4px rgba(40, 168, 107, 0.13);
    animation: none;
}

@keyframes space-runtime-pulse {
    0%, 100% { opacity: 0.45; transform: scale(0.86); }
    50% { opacity: 1; transform: scale(1); }
}

.home-enter-button {
    min-width: min(340px, 84vw);
    margin-top: 18px;
    padding: 14px 28px;
    border: 1px solid rgba(27, 29, 82, 0.16);
    border-radius: 12px;
    background: #dde1e9;
    color: #8a909b;
    font-size: 0.95rem;
    font-weight: 850;
    letter-spacing: 0.035em;
    cursor: not-allowed;
    box-shadow: none;
    transform: translateY(0);
    transition:
        background 160ms ease,
        border-color 160ms ease,
        color 160ms ease,
        transform 160ms ease,
        box-shadow 160ms ease;
}

.home-enter-button.ready {
    border-color: var(--space-navy);
    background: linear-gradient(135deg, var(--space-navy), var(--space-blue));
    color: #fff;
    cursor: pointer;
    box-shadow:
        0 12px 28px rgba(31, 66, 152, 0.24),
        inset 0 1px 0 rgba(255, 255, 255, 0.13);
}

.home-enter-button.ready:hover {
    transform: translateY(-2px);
    box-shadow:
        0 16px 34px rgba(31, 66, 152, 0.30),
        inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.home-enter-button.ready:active {
    transform: translateY(0);
}

.home-loading-note {
    max-width: 520px;
    margin: 12px 0 0;
    color: #9096a1;
    font-size: 0.72rem;
    line-height: 1.5;
    text-align: center;
}

/* Sidebar debug-menu button retained from the previous web-debug work. */
.developer-panel {
    margin-top: 2px;
}

.debug-menu-button {
    width: 100%;
    border: 1px solid #37506f;
    background: #162337;
    color: #d9e8fa;
    font-weight: 700;
}

.debug-menu-button:hover {
    background: #1d304a;
    border-color: #4d7099;
}

.debug-menu-button::before {
    content: ">_ ";
    font-family: Consolas, "Cascadia Mono", monospace;
}

/* The editor is already running behind the home screen. */
.app-shell.editor-entering {
    filter: blur(1px);
}

@media (max-width: 620px) {
    .home-card {
        border-radius: 22px;
        padding: 28px 18px 30px;
    }

    .home-logo-scene {
        width: min(220px, 62vw);
    }

    .home-wordmark {
        font-size: clamp(3.5rem, 19vw, 5.6rem);
    }

    .home-tagline {
        letter-spacing: 0.045em;
    }
}

@media (prefers-reduced-motion: reduce) {
    .home-logo-spinner {
        animation-duration: 18s;
    }

    .home-screen,
    .home-enter-button,
    .home-runtime-dot {
        transition-duration: 0.01ms;
    }
}
