﻿/* =========================================================
   EQ Ninjas — Badge Display (PageShell: Header empty)
   Reveal stage + grid in ChildContent; CTAs in Footer
   ========================================================= */

/* -------- Editable knobs -------- */
:root {
    --bd-stage-vh: 35; /* % of viewport height reserved for stage */
    --bd-stage-min: 120px;
    --bd-stage-max: 240px;
    --bd-stage-pad: 0.5rem;
    --bd-earned-w-vw: 22; /* earned badge width clamp (middle in vw) */
    --bd-celebrate-w-vw: 40; /* celebrate image width clamp (middle in vw) */

    --bd-grow-scale: 1.25; /* grow amount within stage */
}

/* -------- Derived -------- */
:root {
    --bd-stage-h: clamp(var(--bd-stage-min), calc(var(--bd-stage-vh) * 1vh), var(--bd-stage-max));
    --bd-earned-max-h: calc((var(--bd-stage-h) - var(--bd-stage-pad)) / var(--bd-grow-scale));
}

/* -------- Reveal stage (in ChildContent) -------- */
.bd-reveal-stage {
    position: relative;
    min-height: var(--bd-stage-h);
    width: 100%;
    overflow: hidden;
}

    /* Absolutely positioned reveal visuals */
    .bd-reveal-stage .bd-earned,
    .bd-reveal-stage .bd-celebrate-image {
        position: absolute;
        inset: 0;
        display: flex;
        justify-content: center;
        align-items: center;
        pointer-events: none;
    }

        /* Containment rules */
        .bd-reveal-stage .bd-earned img {
            max-height: var(--bd-earned-max-h);
            width: auto;
            height: auto;
            object-fit: contain;
        }

        .bd-reveal-stage .bd-celebrate-image img {
            max-height: calc(var(--bd-stage-h) - var(--bd-stage-pad));
            width: auto;
            height: auto;
            object-fit: contain;
        }

/* -------- Earned badge animation -------- */
.bd-earned {
    opacity: 0;
    transform: scale(1);
    transform-origin: center center;
    transition: opacity 1s ease, transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

    .bd-earned.fade-in {
        opacity: 1;
    }

    .bd-earned.scale-up {
        transform: scale(var(--bd-grow-scale));
    }

    .bd-earned.scale-down {
        transform: scale(1);
    }

    .bd-earned.fade-out {
        opacity: 0;
        transition: opacity 0.6s ease;
    }

    /* Width clamp (height capped by rules above) */
    .bd-earned img {
        width: clamp(96px, calc(var(--bd-earned-w-vw) * 1vw), 140px);
        height: auto;
        object-fit: contain;
    }

/* -------- Celebrate image -------- */
.bd-celebrate-image {
    opacity: 0;
    transition: opacity 1.6s ease;
}

    .bd-celebrate-image.fade-in {
        opacity: 1;
    }

    .bd-celebrate-image img {
        width: clamp(140px, calc(var(--bd-celebrate-w-vw) * 1vw), 220px);
        height: auto;
        object-fit: contain;
    }

/* -------- Grid -------- */
.bd-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.4rem;
    width: 100%;
    max-width: 420px;
    justify-items: center;
    align-items: center;
    margin: 0 auto 0.25rem auto;
}

.bd-slot,
.bd-reveal-container {
    width: 90px;
    height: 90px;
    position: relative;
}

    .bd-slot img,
    .bd-reveal-container img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

/* Fill-up animation for revealed grid badge */
.bd-fill {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    clip-path: inset(100% 0% 0% 0%);
    animation: bd-fill-up 1.2s ease-out forwards;
    z-index: 2;
}

@keyframes bd-fill-up {
    0% {
        clip-path: inset(100% 0% 0% 0%);
        opacity: 0;
    }

    100% {
        clip-path: inset(0% 0% 0% 0%);
        opacity: 1;
    }
}

/* -------- Footer (message & buttons) -------- */
.bd-message {
    text-align: center;
    max-width: 92%;
    font-size: clamp(1rem, 2.8vw, 1.1rem);
    margin: 0 auto;
    animation: bd-fadeInText 0.8s ease;
}

@keyframes bd-fadeInText {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bd-get-button,
.bd-finish-button {
    padding: 0.75rem 1.5rem;
    font-size: clamp(1.05rem, 3.6vw, 1.25rem);
    font-weight: 600;
    color: #fff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: filter 0.2s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    touch-action: manipulation;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.bd-get-button {
    background-color: #007bff;
}

    .bd-get-button:hover {
        filter: brightness(0.92);
    }

.bd-finish-button {
    margin-top: 1rem;
    background-color: #28a745;
    border-radius: 10px;
}

    .bd-finish-button:hover {
        filter: brightness(0.92);
    }

/* -------- Small devices -------- */
@media (max-width: 360px) {
    :root {
        --bd-stage-vh: 28;
        --bd-stage-min: 110px;
        --bd-stage-max: 200px;
        /* Optional: --bd-grow-scale: 1.2; */
    }

    .bd-slot,
    .bd-reveal-container {
        width: 68px;
        height: 68px;
    }

    .bd-grid {
        gap: 0.35rem;
    }
}

/* -------- Reduced motion -------- */
@media (prefers-reduced-motion: reduce) {
    .bd-earned,
    .bd-celebrate-image,
    .bd-message,
    .bd-fill {
        animation: none !important;
        transition: none !important;
    }
}
