/* CricStack Intro Animation Styles */

/* Main Animation Container */
#cricstack-intro {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background-color: #000000; /* CHANGED: Pure Black */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

#cricstack-intro.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* Ambient Background Glow */
.intro-ambient-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 600px;
    background: rgba(220, 38, 38, 0.15); /* CHANGED: Dark Red Glow */
    border-radius: 50%;
    filter: blur(120px);
    animation: pulse 2s ease-in-out infinite;
}

/* SVG Container */
.intro-svg-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    aspect-ratio: 4/3;
}

.intro-svg-container svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* Progress Section */
.intro-progress-section {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
}

.intro-progress-number {
    padding: 0 24px 8px;
    display: flex;
    align-items: flex-end;
}

.intro-progress-value {
    font-size: 2.5rem;
    font-weight: 900;
    color: #ff8c00;
    font-family: 'Courier New', monospace;
    line-height: 1;
    letter-spacing: -0.05em;
}

.intro-progress-percent {
    font-size: 0.875rem;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 4px;
    margin-left: 4px;
}

.intro-progress-bar-container {
    width: 100%;
    height: 4px;
    background-color: #1e293b;
}

.intro-progress-bar-fill {
    height: 100%;
    background: linear-gradient(to right, #f59e0b, #d97706);
    box-shadow: 0 0 10px #ff8c00;
    transition: width 20ms linear;
}

/* Animation Keyframes */

/* Ball Movement */
@keyframes ballMove {
    0% {
        transform: translate(-50px, 250px);
    }

    100% {
        transform: translate(200px, 135px);
    }
}

/* Path Drawing */
@keyframes drawPath {
    to {
        stroke-dashoffset: 0;
    }
}

/* Stump Animations */
@keyframes stumpFlyLeft {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: translate(-40px, -20px) rotate(-60deg);
        opacity: 0;
    }
}

@keyframes stumpCartwheel {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: translate(10px, -30px) rotate(360deg);
        opacity: 0;
    }
}

@keyframes stumpFlyRight {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: translate(50px, -10px) rotate(45deg);
        opacity: 0;
    }
}

/* Bail Animations */
@keyframes bailFlyLeft {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: translate(-30px, -60px) rotate(-180deg);
        opacity: 0;
    }
}

@keyframes bailFlyRight {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: translate(30px, -60px) rotate(180deg);
        opacity: 0;
    }
}

/* Flash Effect */
@keyframes flash {
    from {
        r: 10;
        opacity: 0.8;
    }

    to {
        r: 150;
        opacity: 0;
    }
}

/* Logo Fade In */
@keyframes logoFadeIn {
    from {
        transform: translateY(10px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Energy Drop */
@keyframes energyDrop {
    0% {
        stroke-dashoffset: 120;
        opacity: 1;
    }

    50% {
        stroke-dashoffset: 0;
        opacity: 1;
    }

    100% {
        stroke-dashoffset: -120;
        opacity: 0;
    }
}

/* Line Expansion */
@keyframes expandLine {
    0% {
        stroke-dashoffset: 140;
        opacity: 0;
    }

    100% {
        stroke-dashoffset: 0;
        opacity: 1;
    }
}

/* Pulse Travel */
@keyframes pulseTravel {
    0% {
        transform: translateX(0);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        transform: translateX(140px);
        opacity: 0;
    }
}

/* Pulse Animation */
@keyframes pulse {

    0%,
    100% {
        opacity: 0.2;
    }

    50% {
        opacity: 0.3;
    }
}

/* SVG Element Animations */
.intro-stump-left {
    transform-origin: bottom;
    animation: stumpFlyLeft 1.0s cubic-bezier(0.1, 0.8, 0.2, 1) 0.9s forwards;
}

.intro-stump-center {
    transform-origin: bottom;
    animation: stumpCartwheel 1.0s cubic-bezier(0.1, 0.8, 0.2, 1) 0.9s forwards;
}

.intro-stump-right {
    transform-origin: bottom;
    animation: stumpFlyRight 1.0s cubic-bezier(0.1, 0.8, 0.2, 1) 0.9s forwards;
}

.intro-bail-left {
    animation: bailFlyLeft 1.0s cubic-bezier(0.1, 0.8, 0.2, 1) 0.9s forwards;
}

.intro-bail-right {
    animation: bailFlyRight 1.0s cubic-bezier(0.1, 0.8, 0.2, 1) 0.9s forwards;
}

.intro-ball-path {
    animation: drawPath 0.9s ease-in 0s forwards;
    stroke-dasharray: 450;
    stroke-dashoffset: 450;
}

.intro-ball {
    animation: ballMove 0.9s ease-in 0s forwards;
}

.intro-flash {
    opacity: 0;
    animation: flash 0.3s ease-out 0.9s forwards;
}

.intro-logo-group {
    animation: logoFadeIn 0.8s ease-out 1.1s forwards;
    opacity: 0;
}

.intro-energy-line {
    animation: energyDrop 0.3s ease-in 1.0s forwards;
    stroke-dasharray: 120;
    stroke-dashoffset: 120;
    opacity: 0.8;
}

.intro-expand-line {
    animation: expandLine 0.4s ease-out 1.2s forwards;
    stroke-dasharray: 140;
    stroke-dashoffset: 140;
}

.intro-pulse-dot {
    opacity: 0;
    animation: pulseTravel 1.2s linear 1.5s infinite;
}

/* Responsive Design */
@media (max-width: 768px) {
    .intro-svg-container {
        max-width: 90%;
    }

    .intro-progress-value {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .intro-ambient-glow {
        width: 400px;
        height: 400px;
    }

    .intro-progress-value {
        font-size: 1.75rem;
    }
}


/* ========================================
   PAGE CONTENT VISIBILITY CONTROL (FINAL FIX)
   ======================================== */

/* 1. INITIAL STATE: Hide everything except the intro */
body.loading-animation {
    overflow: hidden !important;
    background-color: #000000;
    height: 100vh !important;
}

/* 
   Hide content by removing it from flow with absolute positioning.
   z-index: -1 ensures it doesn't overlap the intro.
*/
body.loading-animation > *:not(#cricstack-intro):not(script):not(style):not(link) {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    z-index: -1 !important;
}

/* 2. ANIMATION COMPLETE: Restore layout */
body.animation-complete {
    height: auto !important;
    overflow-y: auto !important;
}

body.animation-complete > *:not(#cricstack-intro) {
    /* 
       FIX: Removed destructive overrides (visibility, z-index, pointer-events).
       By simply NOT stating them, the browser reverts elements to their 
       original CSS defined in your other files.
       
       We only keep the fade-in animation.