/* Daily and weekly challenges (ChallengesDrawer.razor), the "challenge complete" toast and the topbar level ring */

.badge-pill.is-claim {
    background: var(--sc-gradient-gold);
    color: #2a1a00;
    animation: chal-pill-pulse 1.8s ease-in-out infinite;
}

.chal-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin: 12px 2px 8px;
}

.chal-section-head:first-child {
    margin-top: 4px;
}

.chal-section-head span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--sc-text);
    font-family: var(--sc-font-display);
    font-size: 15px;
    font-weight: 700;
}

.chal-section-head small {
    color: var(--sc-text-faint);
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.chal-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chal-card {
    --tone: var(--sc-purple);
    --tone-soft: var(--sc-purple-soft);
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--sc-line);
    border-radius: var(--sc-radius);
    background: var(--sc-surface-2);
    transition: border-color 0.25s ease, transform 0.25s var(--sc-ease-spring), opacity 0.3s ease;
}

.chal-card.is-coins { --tone: var(--sc-gold); --tone-soft: var(--sc-gold-soft); }
.chal-card.is-gem { --tone: #6cc8ff; --tone-soft: rgba(108, 200, 255, 0.15); }
.chal-card.is-gem.is-rare { --tone: #c08bff; --tone-soft: rgba(192, 139, 255, 0.18); }
.chal-card.is-bundle { --tone: var(--sc-primary); --tone-soft: var(--sc-primary-soft); }

.chal-list.is-weekly .chal-card {
    padding: 14px;
    border-color: color-mix(in srgb, var(--tone) 35%, transparent);
    background:
        radial-gradient(ellipse 80% 120% at 0% 0%, var(--tone-soft), transparent 70%),
        var(--sc-surface-2);
}

.chal-card.is-ready {
    border-color: var(--tone);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--tone) 30%, transparent), 0 6px 22px color-mix(in srgb, var(--tone) 25%, transparent);
    animation: chal-ready 0.5s var(--sc-ease-spring) both;
}

.chal-card.is-claimed {
    opacity: 0.6;
}

.chal-card.is-just-claimed {
    opacity: 1;
    animation: chal-claimed 0.6s var(--sc-ease-spring) both;
}

.chal-icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--tone-soft);
    color: var(--tone);
    font-size: 20px;
}

.chal-card.is-claimed .chal-icon {
    background: var(--sc-success-soft);
    color: var(--sc-success);
}

.chal-body {
    display: grid;
    flex: 1;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 5px 8px;
    min-width: 0;
}

.chal-title {
    grid-column: 1 / -1;
    overflow: hidden;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.25;
    text-overflow: ellipsis;
}

.chal-card.is-claimed .chal-title {
    text-decoration: line-through;
    text-decoration-color: color-mix(in srgb, var(--sc-text) 40%, transparent);
}

.chal-track {
    height: 7px;
    overflow: hidden;
    border-radius: var(--sc-radius-pill);
    background: rgba(255, 255, 255, 0.08);
}

.chal-fill {
    width: var(--w);
    height: 100%;
    border-radius: inherit;
    background: var(--tone);
    box-shadow: 0 0 8px color-mix(in srgb, var(--tone) 60%, transparent);
    transition: width 0.6s var(--sc-ease-out);
    animation: chal-fill 0.8s var(--sc-ease-out) both;
}

.chal-count {
    color: var(--sc-text-muted);
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.chal-side {
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.chal-reward,
.chal-reward > span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--tone);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.chal-reward .sc-coins {
    font-size: 12px;
}

.chal-claim {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border: 0;
    border-radius: var(--sc-radius-pill);
    background: var(--tone);
    color: #10142a;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    animation: chal-claim-bob 1.6s ease-in-out infinite;
}

.chal-claim:disabled {
    opacity: 0.6;
    animation: none;
}

.chal-claim.is-blocked {
    background: var(--sc-surface-3);
    color: var(--sc-text-muted);
    font-size: 11px;
    animation: none;
}

.chal-claimed {
    max-width: 110px;
    overflow: hidden;
    color: var(--sc-success);
    font-size: 11px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chal-burst {
    position: absolute;
    top: 50%;
    right: 40px;
    pointer-events: none;
}

.chal-burst i {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--tone);
    box-shadow: 0 0 8px var(--tone);
    opacity: 0;
    animation: chal-burst 0.8s var(--sc-ease-out) both;
}

.chal-all-done {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    padding: 10px 12px;
    border-radius: var(--sc-radius);
    background: var(--sc-success-soft);
    color: var(--sc-success);
    animation: chal-ready 0.5s var(--sc-ease-spring) both;
}

.chal-all-done ion-icon {
    flex: none;
    font-size: 26px;
}

.chal-all-done div {
    display: grid;
}

.chal-all-done small {
    color: var(--sc-text-muted);
}

.chal-message {
    margin: 10px 2px 0;
    color: var(--sc-warning);
    font-size: 13px;
}

/* "Challenge complete!": slides down under the topbar and takes you to the Badge tab */
.challenge-toast {
    --tone: var(--sc-purple);
    position: fixed;
    top: calc(var(--sc-topbar-height) + var(--sc-safe-top) + 8px);
    left: 50%;
    z-index: 1500;
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(380px, calc(100vw - 24px));
    padding: 10px 12px;
    border: 1px solid color-mix(in srgb, var(--tone) 55%, transparent);
    border-radius: var(--sc-radius);
    background: color-mix(in srgb, var(--sc-bg-elevated) 92%, var(--tone));
    box-shadow: 0 0 24px color-mix(in srgb, var(--tone) 35%, transparent), var(--sc-shadow-lg);
    color: var(--sc-text);
    text-align: left;
    cursor: pointer;
    transform: translateX(-50%);
    animation: chal-toast 4.5s var(--sc-ease-out) both;
}

.challenge-toast.is-coins { --tone: var(--sc-gold); }
.challenge-toast.is-gem { --tone: #6cc8ff; }
.challenge-toast.is-bundle { --tone: var(--sc-primary); }

.challenge-toast-icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--tone);
    color: #10142a;
    font-size: 20px;
    animation: chal-toast-icon 0.6s var(--sc-ease-spring) 0.2s both;
}

.challenge-toast-text {
    display: grid;
    flex: 1;
    min-width: 0;
}

.challenge-toast-text small {
    color: var(--tone);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.challenge-toast-text b {
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.challenge-toast-cta {
    flex: none;
    padding: 5px 12px;
    border-radius: var(--sc-radius-pill);
    background: var(--tone);
    color: #10142a;
    font-size: 12px;
    font-weight: 800;
}

/* Trainer level in the topbar: a ring that fills towards the next level */
.app-level {
    display: grid;
    flex: none;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: conic-gradient(var(--sc-purple) calc(var(--p) * 1%), var(--sc-surface-3) 0);
    cursor: pointer;
}

.app-level span {
    display: grid;
    place-items: center;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: var(--sc-bg-elevated);
    color: var(--sc-text);
    font-family: var(--sc-font-display);
    font-size: 13px;
    font-weight: 700;
}

.app-level.is-levelup {
    animation: chal-level-flash 1.2s ease-in-out infinite;
}

@keyframes chal-pill-pulse { 50% { box-shadow: 0 0 12px rgba(255, 200, 61, 0.7); } }
@keyframes chal-ready { from { transform: scale(0.96); } }
@keyframes chal-claimed { 40% { transform: scale(1.04); } }
@keyframes chal-fill { from { width: 0; } }
@keyframes chal-claim-bob { 50% { transform: translateY(-2px); box-shadow: 0 4px 14px color-mix(in srgb, var(--tone) 55%, transparent); } }

@keyframes chal-burst {
    0% { opacity: 1; transform: rotate(var(--a)) translateX(0); }
    100% { opacity: 0; transform: rotate(var(--a)) translateX(46px) scale(0.3); }
}

@keyframes chal-toast {
    0% { opacity: 0; transform: translate(-50%, -24px) scale(0.95); }
    8%, 88% { opacity: 1; transform: translate(-50%, 0) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -12px); }
}

@keyframes chal-toast-icon { from { transform: scale(0) rotate(-40deg); } }

@keyframes chal-level-flash {
    50% { box-shadow: 0 0 0 4px rgba(157, 123, 255, 0.35), 0 0 18px rgba(157, 123, 255, 0.8); transform: scale(1.12); }
}

@media (prefers-reduced-motion: reduce) {
    .chal-card, .chal-claim, .chal-fill, .badge-pill.is-claim, .app-level, .challenge-toast-icon {
        animation: none !important;
    }
    .challenge-toast {
        animation: none;
    }
}
