/* ============================================================
   PRELOADER OVERLAY
   ============================================================ */
#preloader {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2em;
    background-color: #dbf5db;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#preloader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.preloader-brand {
    font-family: 'Bricolage Grotesque', 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #dbf5db;
    opacity: 0.5;
}

/* ============================================================
   SPINNER — keyframes
   ============================================================ */
@keyframes ball {
    from {
        transform: rotate(0deg) translateY(-6.5em);
    }

    50% {
        transform: rotate(180deg) translateY(-6em);
    }

    to {
        transform: rotate(360deg) translateY(-6.5em);
    }
}

@keyframes ballInnerShadow {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(-360deg);
    }
}

@keyframes ballOuterShadow {
    from {
        transform: rotate(20deg);
    }

    to {
        transform: rotate(-340deg);
    }
}

@keyframes ballTexture {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(50%);
    }
}

@keyframes trackCover {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ============================================================
   SPINNER — structure
   ============================================================ */
.pl,
.pl__ball,
.pl__ball-inner-shadow,
.pl__ball-side-shadows,
.pl__ball-texture,
.pl__inner-ring,
.pl__outer-ring,
.pl__track-cover {
    border-radius: 50%;
}

.pl {
    position: relative;
    width: 12em;
    height: 12em;
    font-size: clamp(10px, 4vw, 16px);
}

.pl__ball,
.pl__ball-inner-shadow,
.pl__ball-outer-shadow,
.pl__ball-side-shadows,
.pl__ball-texture,
.pl__ball-texture::before,
.pl__inner-ring,
.pl__outer-ring,
.pl__track-cover {
    position: absolute;
}

.pl__ball,
.pl__ball-inner-shadow,
.pl__ball-outer-shadow,
.pl__ball-texture::before,
.pl__track-cover {
    animation: ball 3s linear infinite;
}

/* Ball sphere */
.pl__ball {
    top: calc(50% - 1.25em);
    left: calc(50% - 1.25em);
    transform: rotate(0) translateY(-6.5em);
    width: 2.5em;
    height: 2.5em;
}

/* Inner shadow for depth */
.pl__ball-inner-shadow {
    animation-name: ballInnerShadow;
    box-shadow:
        0 0.1em 0.2em hsla(0, 0%, 0%, 0.3),
        0 0 0.2em hsla(0, 0%, 0%, 0.1) inset,
        0 -1em 0.5em hsla(0, 0%, 0%, 0.15) inset;
    width: 100%;
    height: 100%;
}

/* Outer ground shadow */
.pl__ball-outer-shadow {
    animation-name: ballOuterShadow;
    background-image: linear-gradient(hsla(0, 0%, 0%, 0.15),
            hsla(0, 0%, 0%, 0));
    border-radius: 0 0 50% 50% / 0 0 100% 100%;
    filter: blur(2px);
    top: 50%;
    left: 0;
    width: 100%;
    height: 250%;
    transform: rotate(20deg);
    transform-origin: 50% 0;
    z-index: -2;
}

/* Side depth shadows */
.pl__ball-side-shadows {
    background-color: hsla(0, 0%, 0%, 0.1);
    filter: blur(2px);
    width: 100%;
    height: 100%;
    transform: scale(0.75, 1.1);
    z-index: -1;
}

/* Texture wrapper (overflow clip) */
.pl__ball-texture {
    overflow: hidden;
    width: 100%;
    height: 100%;
    transform: translate3d(0, 0, 0);
}

/* Texture surface — CSS gradient replaces snow.jpg */
.pl__ball-texture::before {
    animation-name: ballTexture;
    animation-duration: 0.5s;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
    /* Soft swirling highlight to simulate surface sheen */
    background: linear-gradient(120deg,
            hsla(145, 40%, 92%, 0.9) 0%,
            hsla(145, 30%, 85%, 0.7) 25%,
            hsla(145, 50%, 95%, 1) 50%,
            hsla(145, 30%, 85%, 0.7) 75%,
            hsla(145, 40%, 92%, 0.9) 100%);
    background-size: 50% 100%;
    content: "";
    display: block;
    filter: brightness(1.05);
    top: 0;
    right: 0;
    width: 200%;
    height: 100%;
}

/* Inner ring — glass rim highlight */
.pl__inner-ring {
    box-shadow:
        0 -0.25em 0.5em hsla(0, 0%, 100%, 0.4),
        0 0.5em 0.75em hsla(0, 0%, 100%, 0.4) inset,
        0 0.5em 0.375em hsla(0, 0%, 0%, 0.15),
        0 -0.5em 0.75em hsla(0, 0%, 0%, 0.15) inset;
    top: 2.375em;
    left: 2.375em;
    width: calc(100% - 4.75em);
    height: calc(100% - 4.75em);
}

/* Outer ring — glass rim highlight */
.pl__outer-ring {
    box-shadow:
        0 -0.45em 0.375em hsla(0, 0%, 0%, 0.15),
        0 0.5em 0.75em hsla(0, 0%, 0%, 0.15) inset,
        0 0.25em 0.5em hsla(0, 0%, 100%, 0.4),
        0 -0.5em 0.75em hsla(0, 0%, 100%, 0.4) inset;
    top: 0.75em;
    left: 0.75em;
    width: calc(100% - 1.5em);
    height: calc(100% - 1.5em);
}

/* Spinning track cover — uses brand green */
.pl__track-cover {
    animation-name: trackCover;
    background-image: conic-gradient(hsla(145, 60%, 93%, 1) 210deg,
            hsla(145, 60%, 93%, 0) 270deg);
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}