/* Stats Bar CSS - Horizontal stats bar at the top */

.stats-bar {
    display: flex;
    justify-content: center;
    align-items: stretch;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 15px;
    border-bottom: 2px solid var(--ui-teal);
    flex-shrink: 0;
    gap: 8px;
    flex-wrap: wrap;
}

.stat-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5px 12px;
    min-width: 70px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    flex: 0 1 auto;
    max-width: 200px;
}

.stat-block-label {
    color: var(--ui-teal);
    font-size: 0.65em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
    font-weight: bold;
}

.stat-block-value {
    color: var(--ui-gold);
    font-size: 0.9em;
    font-weight: bold;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-align: center;
    /* Fixed-width digits so equal-length numbers keep the same pixel width and
       don't shove neighbouring stat blocks onto a new row as values change. */
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

.stat-block-sub {
    color: var(--p-aaaaaa);
    font-size: 0.7em;
    margin-top: 2px;
}

/* Dantian block specific styling */
.stat-block.dantian-block {
    flex-direction: row;
    gap: 8px;
    padding: 5px 10px;
    overflow: hidden;
}

.stat-block.dantian-block .dantian-orb {
    width: 40px;
    height: 40px;
    /* Never let the flex row compress the orb: with huge energy values (e251+) the long
       number in .dantian-info would otherwise squeeze the 40px orb into an ellipse. */
    flex-shrink: 0;
}

/* Broken/shattered dantian for Fist Cultivator */
.stat-block.dantian-block .dantian-orb.state-broken {
    background: radial-gradient(circle, var(--p-1a1a1a) 30%, var(--p-0a0a0a) 70%, var(--p-000000) 100%);
    border: 2px solid var(--p-333333);
    border-radius: 50%;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.8), 0 0 5px rgba(50, 50, 50, 0.3);
    animation: none;
}

.stat-block.dantian-block .dantian-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

/* Combat stats block specific styling */
.stat-block.combat-stats-block {
    /* Reserve a stable, wider footprint: the three combat numbers (DMG/DEF/PWR)
       grow the most, so give the block room and a fixed basis so it stops
       resizing (and reflowing the whole bar) every time a value changes width. */
    min-width: 300px;
    max-width: 380px;
    flex: 1 1 320px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.stat-block.combat-stats-block:hover {
    border-color: rgba(78, 205, 196, 0.5);
}

.stat-block.combat-stats-block .combat-stats-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.72em;
    margin-top: 2px;
    white-space: nowrap;
    width: 100%;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

/* HP bar inside combat stats block */
.combat-hp-bar-container {
    position: relative;
    width: 100%;
    height: 14px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    margin-top: 4px;
    overflow: hidden;
}

.combat-hp-bar-fill {
    height: 100%;
    width: 100%;
    background: var(--ui-red);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.combat-hp-bar-text {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6em;
    color: var(--p-ffffff);
    font-weight: bold;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
}

/* Elemental damage colors */
.dmg-fire { color: var(--ui-red); }
.dmg-water { color: var(--ui-blue); }
.dmg-wood { color: var(--p-27ae60); }
.dmg-metal { color: var(--p-95a5a6); }
.dmg-earth { color: var(--p-d4a574); }

/* Elemental resistance colors */
.resist-fire { color: var(--ui-red); }
.resist-water { color: var(--ui-blue); }
.resist-wood { color: var(--p-27ae60); }
.resist-metal { color: var(--p-95a5a6); }
.resist-earth { color: var(--p-d4a574); }

/* QI Progress within stats bar */
.stat-block .qi-progress-container {
    width: 100%;
    max-width: 100px;
    height: 6px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 3px;
    margin-top: 4px;
    overflow: hidden;
    border: 1px solid var(--ui-teal);
}

.stat-block .qi-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--ui-teal) 0%, var(--ui-teal-2) 100%);
    transition: width 0.3s;
    border-radius: 2px;
}

/* Tiny progress bar for Body Realm display */
.progress-bar-tiny {
    width: 100%;
    max-width: 100px;
    height: 4px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 2px;
    overflow: hidden;
    border: 1px solid var(--p-d97706);
}

.progress-bar-fill-tiny {
    height: 100%;
    transition: width 0.3s;
    border-radius: 1px;
}

/* Spacer to push right section elements */
.stats-spacer {
    flex: 1;
    min-width: 20px;
}

/* Rebirth quick-access button */
.stat-block.rebirth-quick-btn {
    cursor: pointer;
    border: 1px solid rgba(231, 76, 60, 0.3);
    transition: all 0.2s;
}
.stat-block.rebirth-quick-btn:hover {
    border-color: var(--ui-red);
    background: rgba(231, 76, 60, 0.15);
}

/* Hidden stat blocks */
.stat-block.hidden {
    display: none !important;
}

/* ─── Mobile Portrait ─── */
@media (max-width: 768px), (max-height: 500px) and (pointer: coarse) {
    .stats-bar {
        padding: 4px 8px;
        gap: 4px;
    }

    .stat-block {
        padding: 3px 6px;
        min-width: 55px;
    }

    .stat-block-value {
        font-size: 0.75em;
    }

    .stat-block.combat-stats-block {
        min-width: 180px;
        max-width: none;
        width: 100%;
    }

    .stats-spacer {
        display: none;
    }
}
