/* Clean, minimal preloader: a leather bouncing cricket ball nothing else. */
.preloader.cp-loader {
    --cp-loader-bg: #ffffff;
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: var(--cp-loader-bg);
    isolation: isolate;
    opacity: 1;
    transition: opacity 280ms ease;
}

.cp-loader,
.cp-loader *,
.cp-loader *::before,
.cp-loader *::after {
    box-sizing: border-box;
}

.preloader.cp-loader[hidden] {
    display: none !important;
}

.preloader.cp-loader.is-leaving {
    animation: none;
    opacity: 0;
    pointer-events: none;
}

/* Center stage container */
.cp-bouncing-ball-wrapper {
    position: relative;
    width: 120px;
    height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 20px;
}

/* The Leather Cricket Ball container */
.cp-leather-ball {
    width: 58px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-origin: 50% 90%;
    animation: cp-ball-bounce 0.74s cubic-bezier(0.28, 0, 0.62, 1) infinite;
    will-change: transform;
}

/* Canvas styling: rendered from the exact cursor ball engine */
.cp-loader-canvas {
    display: block;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    filter: drop-shadow(0 8px 16px rgba(112, 16, 28, 0.24));
}

/* Pitch contact shadow */
.cp-ball-shadow {
    width: 48px;
    height: 9px;
    background: radial-gradient(ellipse at center, rgba(37, 27, 32, 0.38) 0%, rgba(37, 27, 32, 0.12) 55%, transparent 75%);
    border-radius: 50%;
    margin-top: 4px;
    animation: cp-shadow-pulse 0.74s infinite;
    transform-origin: center center;
    will-change: transform, opacity;
}

.cp-loader-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* Authentic cricket ball bounce physics (gravity drop -> impact squash -> launch stretch -> peak hang) */
@keyframes cp-ball-bounce {
    0%, 100% {
        transform: translateY(-68px) scale(1, 1);
        animation-timing-function: cubic-bezier(0.35, 0, 0.65, 1);
    }
    45% {
        transform: translateY(0) scale(0.96, 1.04);
        animation-timing-function: ease-out;
    }
    50% {
        transform: translateY(3px) scale(1.18, 0.82); /* Squash on contact */
        animation-timing-function: ease-in;
    }
    56% {
        transform: translateY(-10px) scale(0.92, 1.08); /* Stretch on launch */
        animation-timing-function: cubic-bezier(0, 0, 0.28, 1);
    }
}

@keyframes cp-shadow-pulse {
    0%, 100% {
        transform: scale(0.42);
        opacity: 0.12;
        animation-timing-function: cubic-bezier(0.35, 0, 0.65, 1);
    }
    50% {
        transform: scale(1.18);
        opacity: 0.48;
        animation-timing-function: ease-in;
    }
}

@media (prefers-reduced-motion: reduce) {
    .preloader.cp-loader { animation: none; transition: none; }
    .cp-leather-ball { animation: none; transform: translateY(0); }
    .cp-ball-shadow { animation: none; transform: scale(1); opacity: 0.35; }
}
