/* ChargeBattery: a Skanimal's whole-life Charge as one battery of cells (Components/Brand/ChargeBattery.razor).
   2 red Baby cells | 3 yellow Young Adult cells | 3 green Adult cells, then stars for an Adult. */

.cb {
    --cb-baby: var(--sc-danger, #ff6b6b);
    --cb-young: var(--sc-gold, #ffc83d);
    --cb-adult: var(--sc-success, #3ddc84);
    --cb-shell: var(--sc-line-strong, rgba(160, 200, 255, 0.18));
    --cb-empty: rgba(160, 200, 255, 0.08);
    --cb-height: 18px;
    --cb-gap: 2px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    vertical-align: middle;
    line-height: 1;
}

.cb-full {
    width: 100%;
}

.cb-body {
    display: flex;
    align-items: stretch;
    flex: 1 1 auto;
    min-width: 0;
    gap: var(--cb-gap);
    height: var(--cb-height);
    padding: 2px;
    border: 1.5px solid var(--cb-shell);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.25);
}

.cb-nub {
    flex: 0 0 auto;
    width: 3px;
    height: calc(var(--cb-height) * 0.45);
    margin-left: -6px;
    border-radius: 0 2px 2px 0;
    background: var(--cb-shell);
}

.cb-section {
    display: flex;
    gap: var(--cb-gap);
    min-width: 0;
}

/* Each section's width follows its cell count, so every cell is the same size */
.cb-section.is-baby { flex: 2 1 0; --cb-color: var(--cb-baby); }
.cb-section.is-young { flex: 3 1 0; --cb-color: var(--cb-young); }
.cb-section.is-adult { flex: 3 1 0; --cb-color: var(--cb-adult); }

.cb-cell {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    border-radius: 2px;
    background: var(--cb-empty);
}

.cb-fill {
    position: absolute;
    inset: 0 auto 0 0;
    background: var(--cb-color);
    transition: width 0.35s ease-out;
}

.cb-section.is-current .cb-cell.is-full .cb-fill,
.cb-section.is-current .cb-cell.is-half .cb-fill {
    box-shadow: 0 0 6px var(--cb-color);
}

/* Stages it has grown past stay full but step back a little */
.cb-section.is-past .cb-fill {
    opacity: 0.6;
}

/* A notch between stages: a gap in the shell with a tick */
.cb-notch {
    position: relative;
    flex: 0 0 auto;
    width: 3px;
    margin: -4px 1px;
    border-radius: 2px;
    background: var(--cb-shell);
}

.cb-notch.is-reached {
    background: var(--sc-text-muted, #9db1d8);
}

/* The next form waits at the notch ahead: a small chevron above it */
.cb-full .cb-notch.is-next::after {
    content: "";
    position: absolute;
    left: 50%;
    top: -5px;
    width: 5px;
    height: 5px;
    border-top: 1.5px solid var(--sc-text-muted, #9db1d8);
    border-right: 1.5px solid var(--sc-text-muted, #9db1d8);
    transform: translateX(-50%) rotate(-45deg);
    opacity: 0.8;
}

.cb-notch.is-crossed {
    animation: cb-notch-pulse 0.9s ease-out 0.4s 2;
}

@keyframes cb-notch-pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7); background: #fff; }
    100% { box-shadow: 0 0 0 7px rgba(255, 255, 255, 0); }
}

/* Stars after the battery */
.cb-stars {
    display: inline-flex;
    flex: 0 0 auto;
    gap: 1px;
    font-size: calc(var(--cb-height) * 0.85);
}

.cb-star.is-on {
    color: var(--sc-gold, #ffc83d);
    text-shadow: 0 0 6px rgba(255, 200, 61, 0.55);
}

.cb-star.is-off {
    color: rgba(160, 200, 255, 0.18);
}

.cb-star.is-new {
    animation: cb-star-pop 0.6s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}

.cb-star.is-lost {
    color: var(--sc-text-faint, #62779f);
    animation: cb-star-crack 0.7s ease-in both;
}

@keyframes cb-star-pop {
    0% { transform: scale(0) rotate(-40deg); opacity: 0; }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

@keyframes cb-star-crack {
    0% { transform: scale(1); opacity: 1; color: var(--sc-gold, #ffc83d); }
    40% { transform: scale(1.25) rotate(8deg); }
    100% { transform: scale(0.8) rotate(-12deg) translateY(3px); opacity: 0.35; }
}

/* Compact: for roster tiles. Only the current stage's cells stand out; the rest are thin ghosts. */
.cb-compact {
    --cb-height: 10px;
    --cb-gap: 1px;
    width: 100%;
    gap: 4px;
}

.cb-compact .cb-body {
    padding: 1px;
    border-width: 1px;
    border-radius: 4px;
    align-items: center;
}

.cb-compact .cb-section:not(.is-current) {
    align-self: center;
    height: 3px;
    opacity: 0.45;
}

.cb-compact .cb-section:not(.is-current) .cb-cell {
    height: 3px;
}

.cb-compact .cb-section:not(.is-current) {
    flex-grow: 1;
}

.cb-compact .cb-section.is-current {
    flex-grow: 4;
    align-self: stretch;
}

.cb-compact .cb-notch {
    width: 2px;
    margin: -2px 0;
}

.cb-compact .cb-nub {
    width: 2px;
    margin-left: -4px;
}

.cb-compact .cb-stars {
    font-size: 10px;
}

@media (prefers-reduced-motion: reduce) {
    .cb-fill { transition: none; }
    .cb-notch.is-crossed, .cb-star.is-new, .cb-star.is-lost { animation: none; }
}

/* Where it sits */
.mm-roster-charge {
    padding: 2px 4px 0;
}

.gym-roster-charge {
    padding: 0 4px;
}

.gym-confirm-charge {
    min-width: 140px;
    --cb-height: 12px;
}
