/*
 * The Carbles splash screen, shared by every host (Carbles.Web's index.html and Carbles.Mobile's
 * index.html link this same file), so the first thing a player sees is identical on the web and
 * in the app - the same rule specification.md §13.2 applies to the game UI itself.
 *
 * It paints before Blazor has booted, so it is plain CSS against a fixed brand palette rather
 * than the skin tokens in skins.css: the skin is a per-identity preference that isn't known yet,
 * and the splash is a brand moment, not a themed surface.
 */

.splash {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: clamp(1.5rem, 6vh, 3rem) 1.5rem;
    padding-top: calc(clamp(1.5rem, 6vh, 3rem) + env(safe-area-inset-top));
    padding-bottom: calc(clamp(1.5rem, 6vh, 3rem) + env(safe-area-inset-bottom));
    background: radial-gradient(ellipse at 50% 34%, #17334f 0%, #0d1b2a 55%, #060d15 100%);
    color: #eaf1f8;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    text-align: center;
}

.splash__mark {
    width: clamp(5.5rem, 22vh, 9rem);
    height: auto;
}

/* Wide tracking and a light weight to match the mark's thin ring; the A is the one letter that
   carries the accent, as in the logo lockup. */
.splash__word {
    margin: 1.25rem 0 0;
    font-size: clamp(1.75rem, 8vw, 3.25rem);
    font-weight: 300;
    letter-spacing: 0.32em;
    /* The tracking is applied to the right of every glyph, including the last - this pulls the
       word back so it stays optically centred under the mark. */
    text-indent: 0.32em;
    line-height: 1.1;
}

.splash__word-accent {
    color: #5b9bd5;
}

.splash__rule {
    width: min(20rem, 70vw);
    height: 1px;
    margin: 0.9rem 0 0;
    border: 0;
    background: linear-gradient(90deg, transparent, rgba(145, 190, 230, 0.55), transparent);
}

.splash__tagline {
    margin: 0.8rem 0 0;
    color: #8fb6d8;
    font-size: clamp(0.7rem, 2.6vw, 0.9rem);
    letter-spacing: 0.28em;
    text-indent: 0.28em;
    text-transform: uppercase;
}

/* The four player marbles resting on the board, drawn from the same gradients as the mark. */
.splash__table {
    position: relative;
    width: min(26rem, 82vw);
    aspect-ratio: 2 / 1;
    margin-top: clamp(1.5rem, 5vh, 3rem);
    border-radius: 50%;
    background:
        radial-gradient(closest-side, rgba(4, 9, 15, 0.85) 0 20%, rgba(5, 11, 18, 0) 23%),
        repeating-radial-gradient(closest-side, rgba(168, 205, 235, 0.09) 0 1px, rgba(168, 205, 235, 0) 1px 13%);
}

.splash__marble {
    position: absolute;
    width: 13%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: inset -0.18em -0.22em 0.4em rgba(0, 0, 0, 0.45), 0 0.35em 0.5em rgba(0, 0, 0, 0.5);
}

.splash__marble::after {
    content: "";
    position: absolute;
    top: 16%;
    left: 20%;
    width: 30%;
    height: 22%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.75);
}

.splash__marble--red {
    top: 42%;
    left: 16%;
    background: radial-gradient(circle at 34% 30%, #f2686c, #c62f34 60%, #8d1f24);
}

.splash__marble--yellow {
    top: 20%;
    left: 62%;
    width: 10%;
    background: radial-gradient(circle at 34% 30%, #ffd166, #e9a327 60%, #a86f11);
}

.splash__marble--green {
    top: 58%;
    left: 84%;
    width: 11%;
    background: radial-gradient(circle at 34% 30%, #7ed07a, #35a13c 60%, #1f6b28);
}

.splash__marble--white {
    top: 86%;
    left: 42%;
    width: 19%;
    background: radial-gradient(circle at 34% 30%, #ffffff, #dae6f1 55%, #9db5cd);
}

/* --- Loading ------------------------------------------------------------------------------ */

.splash__progress {
    width: min(22rem, 74vw);
    height: 0.4rem;
    margin-top: clamp(1.25rem, 4vh, 2.25rem);
    overflow: hidden;
    border-radius: 999px;
    background-color: rgba(146, 186, 220, 0.22);
}

.splash__bar {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #5b9bd5, #8cc0ea);
}

/* Carbles.Web: Blazor WASM publishes its own boot progress into these custom properties, so the
   bar is a real measure of the download rather than decoration. */
.splash--determinate .splash__bar {
    width: var(--blazor-load-percentage, 0%);
    transition: width 0.15s ease-out;
}

.splash--determinate .splash__status::after {
    content: var(--blazor-load-percentage-text, "Loading");
}

/* Carbles.Mobile: a hybrid WebView has nothing to download, so its bar just has to show the app
   is alive for the moment before the first render. */
.splash--indeterminate .splash__bar {
    width: 40%;
    animation: splash-sweep 1.1s ease-in-out infinite;
}

.splash--indeterminate .splash__status::after {
    content: "Loading";
}

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

    100% {
        transform: translateX(250%);
    }
}

.splash__status {
    margin: 0.7rem 0 0;
    min-height: 1em;
    color: #8fb6d8;
    font-size: 0.8rem;
    letter-spacing: 0.22em;
    text-indent: 0.22em;
    text-transform: uppercase;
}

/* The build the app is running, sat quietly at the foot of the splash. It is out of the flow -
   the splash centres its column, and the version is not part of that composition - and it is
   here to be read when someone is asked which build they are on rather than on the way into a
   game, so it is the dimmest thing on the screen. */
.splash__version {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(1rem + env(safe-area-inset-bottom));
    margin: 0;
    color: #5f83a6;
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-indent: 0.14em;
}

@media (prefers-reduced-motion: reduce) {
    .splash--indeterminate .splash__bar {
        width: 100%;
        animation: none;
    }

    .splash--determinate .splash__bar {
        transition: none;
    }
}

/* On a short landscape phone the board and the loading row are the first things to go: the mark
   and the wordmark alone still read as the splash. */
@media (max-height: 520px) {
    .splash__table {
        display: none;
    }
}
