/* css/combat.css - Combat overlay styles */

.combat-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 6500;
    justify-content: center;
    align-items: center;
    font-family: 'Segoe UI', Arial, sans-serif;
}

.combat-overlay.combat-enter {
    animation: combatFadeIn 0.5s ease-out;
}

@keyframes combatFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.combat-arena {
    position: relative;
    width: 90%;
    max-width: 600px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border: 2px solid #e94560;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 0 40px rgba(233, 69, 96, 0.3), inset 0 0 20px rgba(0, 0, 0, 0.5);
}

/* Header with HP bars */
.combat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
}

.combat-combatant {
    flex: 1;
    text-align: center;
}

.combat-name {
    display: block;
    font-size: 14px;
    font-weight: bold;
    color: #fff;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.combat-vs {
    font-size: 20px;
    font-weight: bold;
    color: #e94560;
    text-shadow: 0 0 10px #e94560;
    padding: 0 8px;
}

.combat-hp-bar-container {
    width: 100%;
    height: 16px;
    background: #333;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #555;
}

.combat-hp-bar {
    height: 100%;
    border-radius: 8px;
    transition: width 0.5s ease-out, background 0.3s;
}

.combat-hp-player {
    background: #4CAF50;
}

.combat-hp-enemy {
    background: #F44336;
}

.combat-hp-text {
    display: block;
    font-size: 12px;
    color: #aaa;
    margin-top: 4px;
}

/* Phase text */
.combat-phase-text {
    display: none;
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    color: #e94560;
    text-shadow: 0 0 20px #e94560;
    padding: 8px;
}

.combat-phase-animate {
    animation: phaseFlash 2s ease-out;
}

@keyframes phaseFlash {
    0% { transform: scale(1.5); opacity: 1; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 0; }
}

/* Combat log */
.combat-log {
    min-height: 80px;
    max-height: 120px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 12px;
    border: 1px solid #333;
}

.combat-log-entry {
    font-size: 13px;
    color: #ccc;
    padding: 2px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.combat-log-entry:last-child {
    color: #fff;
    font-weight: bold;
    border-bottom: none;
}

/* Info row */
.combat-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 13px;
    color: #aaa;
}

.combat-potions {
    color: #4CAF50;
}

/* Action buttons */
.combat-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.combat-btn {
    flex: 1;
    min-width: 80px;
    padding: 12px 8px;
    border: 2px solid;
    border-radius: 8px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
}

.combat-btn:hover:not(.disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.combat-btn:active:not(.disabled) {
    transform: translateY(0);
}

.combat-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.combat-btn-attack {
    border-color: #F44336;
    color: #F44336;
}
.combat-btn-attack:hover:not(.disabled) {
    background: rgba(244, 67, 54, 0.2);
}

.combat-btn-defend {
    border-color: #2196F3;
    color: #2196F3;
}
.combat-btn-defend:hover:not(.disabled) {
    background: rgba(33, 150, 243, 0.2);
}

.combat-btn-heal {
    border-color: #4CAF50;
    color: #4CAF50;
}
.combat-btn-heal:hover:not(.disabled) {
    background: rgba(76, 175, 80, 0.2);
}

.combat-btn-special {
    border-color: #FFD700;
    color: #FFD700;
}
.combat-btn-special:hover:not(.disabled) {
    background: rgba(255, 215, 0, 0.2);
}

.combat-btn-flee {
    border-color: #888;
    color: #888;
}
.combat-btn-flee:hover:not(.disabled) {
    background: rgba(136, 136, 136, 0.2);
}

/* Damage numbers */
.combat-damage-number {
    position: absolute;
    font-size: 28px;
    font-weight: bold;
    text-shadow: 0 0 8px currentColor, 2px 2px 4px rgba(0,0,0,0.8);
    pointer-events: none;
    animation: dmgFloat 1.2s ease-out forwards;
    z-index: 10;
}

.combat-crit {
    font-size: 36px;
    animation: critFloat 1.2s ease-out forwards;
}

@keyframes dmgFloat {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-60px) scale(0.8); opacity: 0; }
}

@keyframes critFloat {
    0% { transform: translateY(0) scale(1.5); opacity: 1; }
    30% { transform: translateY(-20px) scale(1.2); opacity: 1; }
    100% { transform: translateY(-80px) scale(0.7); opacity: 0; }
}

/* Status text */
.combat-status-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 32px;
    font-weight: bold;
    text-shadow: 0 0 15px currentColor;
    pointer-events: none;
    animation: statusPulse 1.5s ease-out forwards;
    z-index: 10;
}

@keyframes statusPulse {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    20% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    50% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* Result overlay */
.combat-result {
    display: none;
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 16px;
    z-index: 20;
}

.combat-victory {
    text-align: center;
}

.combat-defeat {
    text-align: center;
}

.combat-fled {
    text-align: center;
    font-size: 28px;
    color: #888;
}

/* Mobile */
@media (max-width: 768px) {
    .combat-arena {
        width: 95%;
        padding: 16px;
    }

    .combat-btn {
        min-width: 60px;
        padding: 10px 6px;
        font-size: 11px;
    }

    .combat-name {
        font-size: 12px;
    }

    .combat-log {
        max-height: 80px;
        min-height: 60px;
    }

    .combat-log-entry {
        font-size: 11px;
    }

    .combat-damage-number {
        font-size: 22px;
    }

    .combat-crit {
        font-size: 28px;
    }
}

/* HP Bar Shake on damage */
@keyframes hpShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-3px); }
    40% { transform: translateX(3px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
}

.hp-bar-shake {
    animation: hpShake 0.3s ease-out;
}

/* ── Victory result animations ── */

/* Pulsing gold border on result container when victory */
.combat-result-victory {
    animation: victoryBorderPulse 1.5s ease-in-out infinite;
}

@keyframes victoryBorderPulse {
    0%, 100% {
        box-shadow: inset 0 0 20px rgba(255, 215, 0, 0.1);
        border-color: transparent;
    }
    50% {
        box-shadow: inset 0 0 30px rgba(255, 215, 0, 0.3), 0 0 15px rgba(255, 215, 0, 0.2);
        border-color: #FFD700;
    }
}

/* Victory title bounce-in */
.combat-victory-title {
    font-size: 48px;
    font-weight: bold;
    color: #FFD700;
    text-shadow: 0 0 20px #FFD700, 0 0 40px #FFA500;
    animation: victoryBounce 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    transform: scale(0);
    margin-bottom: 8px;
}

@keyframes victoryBounce {
    0% { transform: scale(0); opacity: 0; }
    70% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* Enemy name fade-in with delay */
.combat-victory-enemy {
    font-size: 16px;
    color: #ccc;
    opacity: 0;
    animation: fadeInUp 0.4s ease-out 0.3s forwards;
    margin-bottom: 12px;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Coin counter */
.combat-coin-counter {
    font-size: 22px;
    font-weight: bold;
    color: #FFD700;
    margin-bottom: 4px;
    opacity: 0;
    animation: fadeInUp 0.3s ease-out 0.6s forwards, coinCountGlow 1s ease-in-out 0.6s infinite;
}

.combat-coin-counter-done {
    animation: coinCountGlow 0.6s ease-in-out 1 !important;
    opacity: 1 !important;
}

@keyframes coinCountGlow {
    0%, 100% { text-shadow: 0 0 5px rgba(255, 215, 0, 0.3); }
    50% { text-shadow: 0 0 15px rgba(255, 215, 0, 0.8), 0 0 25px rgba(255, 165, 0, 0.4); }
}

/* XP reward with green glow */
.combat-xp-reward {
    font-size: 18px;
    font-weight: bold;
    color: #4CAF50;
    text-shadow: 0 0 10px rgba(76, 175, 80, 0.6), 0 0 20px rgba(76, 175, 80, 0.3);
    opacity: 0;
    animation: fadeInUp 0.3s ease-out 0.8s forwards;
}

/* Confetti particles */
.combat-confetti {
    position: absolute;
    width: 8px;
    height: 8px;
    top: -10px;
    border-radius: 2px;
    pointer-events: none;
    animation: confettiFall 2.5s ease-in forwards;
    z-index: 25;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    80% {
        opacity: 1;
    }
    100% {
        transform: translateY(400px) rotate(720deg);
        opacity: 0;
    }
}

/* White screen flash */
.combat-victory-flash {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #fff;
    border-radius: 16px;
    pointer-events: none;
    z-index: 30;
    animation: victoryFlash 0.3s ease-out forwards;
}

@keyframes victoryFlash {
    0% { opacity: 0; }
    30% { opacity: 0.8; }
    100% { opacity: 0; }
}

/* ── Defeat result animations ── */

.combat-result-defeat {
    background: rgba(40, 0, 0, 0.8);
}

.combat-defeat-title {
    font-size: 36px;
    font-weight: bold;
    color: #F44336;
    text-shadow: 0 0 20px #F44336, 0 0 40px rgba(244, 67, 54, 0.5);
    margin-bottom: 8px;
}

.combat-defeat-detail {
    font-size: 16px;
    color: #ccc;
}

.combat-arena-shake {
    animation: defeatShake 0.6s ease-out;
}

@keyframes defeatShake {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-8px); }
    20% { transform: translateX(8px); }
    30% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    50% { transform: translateX(-4px); }
    60% { transform: translateX(4px); }
    70% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
}

/* Mobile adjustments for victory */
@media (max-width: 768px) {
    .combat-victory-title {
        font-size: 36px;
    }

    .combat-coin-counter {
        font-size: 18px;
    }

    .combat-xp-reward {
        font-size: 15px;
    }
}
