/* Badge tab drawers (BadgeDrawer.razor) and what goes in them */

.badge-drawers {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
}

.badge-drawer {
    --drawer-accent: var(--sc-primary);
    border: 1px solid var(--sc-line);
    border-radius: var(--sc-radius-lg);
    background: var(--sc-surface);
    overflow: hidden;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.badge-drawer.is-open {
    border-color: color-mix(in srgb, var(--drawer-accent) 45%, transparent);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--drawer-accent) 15%, transparent), var(--sc-shadow);
}

.badge-drawer-head {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    border: 0;
    background: none;
    color: var(--sc-text);
    text-align: left;
    cursor: pointer;
}

.badge-drawer-icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: color-mix(in srgb, var(--drawer-accent) 18%, transparent);
    color: var(--drawer-accent);
    font-size: 19px;
    transition: transform 0.35s var(--sc-ease-spring);
}

.badge-drawer.is-open .badge-drawer-icon {
    transform: rotate(-8deg) scale(1.08);
}

.badge-drawer-title {
    font-family: var(--sc-font-display);
    font-size: 17px;
    font-weight: 700;
    white-space: nowrap;
}

.badge-drawer-summary {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
}

.badge-drawer-chevron {
    flex: none;
    color: var(--sc-text-faint);
    transition: transform 0.3s var(--sc-ease-out);
}

.badge-drawer.is-open .badge-drawer-chevron {
    transform: rotate(180deg);
    color: var(--drawer-accent);
}

/* Height animates by growing the row from 0fr to 1fr */
.badge-drawer-body {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.35s var(--sc-ease-out);
}

.badge-drawer.is-open .badge-drawer-body {
    grid-template-rows: 1fr;
}

.badge-drawer-inner {
    min-height: 0;
    overflow: hidden;
    padding: 0 14px;
    opacity: 0;
    transition: opacity 0.25s ease, padding 0.35s var(--sc-ease-out);
}

.badge-drawer.is-open .badge-drawer-inner {
    padding: 2px 14px 14px;
    opacity: 1;
}

.badge-pill {
    padding: 3px 9px;
    border-radius: var(--sc-radius-pill);
    background: var(--sc-surface-3);
    color: var(--sc-text-muted);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.badge-pill.is-good { background: var(--sc-success-soft); color: var(--sc-success); }
.badge-pill.is-bad { background: var(--sc-danger-soft); color: var(--sc-danger); }
.badge-pill.is-rare { background: rgba(192, 139, 255, 0.18); color: #d6b8ff; }

.badge-mini-ring {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: conic-gradient(var(--drawer-accent) calc(var(--p) * 1%), var(--sc-surface-3) 0);
    mask: radial-gradient(circle, transparent 5px, #000 6px);
}

/* Battle record: a win-rate ring beside the tiles */

.badge-record {
    display: flex;
    align-items: center;
    gap: 14px;
}

.badge-ring {
    --p: 0;
    display: grid;
    flex: none;
    place-items: center;
    align-content: center;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background:
        radial-gradient(circle, var(--sc-surface) 58%, transparent 59%),
        conic-gradient(var(--sc-success) calc(var(--p) * 1%), var(--sc-danger-soft) 0);
    font-family: var(--sc-font-display);
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
}

.badge-ring small {
    color: var(--sc-text-faint);
    font-family: var(--sc-font-body);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-record .stat-grid {
    flex: 1;
}

.stat-grid.is-compact {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.badge-xp {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: var(--sc-radius);
    background: var(--sc-purple-soft);
    color: var(--sc-text-muted);
    font-size: 13px;
}

.badge-xp ion-icon {
    color: var(--sc-purple);
    font-size: 18px;
}

.badge-xp .count-up {
    color: var(--sc-text);
    font-family: var(--sc-font-display);
    font-size: 20px;
    font-weight: 700;
}

/* Unlocks: progress per kind */

.badge-progress {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 6px 10px;
    padding: 8px 0;
}

.badge-progress + .badge-progress {
    border-top: 1px solid var(--sc-line);
}

.badge-progress ion-icon {
    color: var(--sc-gold);
    font-size: 18px;
}

.badge-progress-label {
    font-weight: 600;
}

.badge-progress-count {
    color: var(--sc-text-muted);
    font-size: 13px;
    font-weight: 600;
}

.badge-progress-track {
    grid-column: 1 / -1;
    height: 8px;
    border-radius: 4px;
    background: var(--sc-surface-3);
    overflow: hidden;
}

.badge-progress-fill {
    width: 0;
    height: 100%;
    border-radius: 4px;
    background: var(--sc-gradient-gold);
    transition: width 0.9s var(--sc-ease-out) 0.15s;
}

.badge-drawer.is-open .badge-progress-fill {
    width: var(--w);
}

/* Numbers that count up from zero whenever their drawer opens */

@property --n {
    syntax: "<integer>";
    inherits: false;
    initial-value: 0;
}

.count-up {
    --n: var(--to);
    counter-reset: n var(--n);
}

.count-up::before {
    content: counter(n);
}

.badge-drawer.is-open .count-up {
    animation: count-up 0.9s var(--sc-ease-out) both;
}

@keyframes count-up {
    from { --n: 0; }
    to { --n: var(--to); }
}

@media (prefers-reduced-motion: reduce) {
    .badge-drawer.is-open .count-up { animation: none; }
    .badge-drawer-body, .badge-drawer-inner, .badge-progress-fill { transition: none; }
}

@media (max-width: 380px) {
    .badge-record {
        flex-direction: column;
    }

    .badge-record .stat-grid {
        width: 100%;
    }

    .badge-drawer-title {
        font-size: 15px;
    }
}
