/**
 * css/combat.css — habillage des modales de combat du plateau (PvM + PvP).
 *
 * Deux combattants face à face (notre monstre à gauche, l'adversaire à
 * droite), barres de vie, sorts, et animations : ruée à l'attaque, orbe de
 * sort, secousse + flash à l'impact, dégâts flottants.
 *
 * Chargé par plateau.php et pvm.php (la page pvp.php garde son propre
 * habillage).
 */

/* --- Cadre de l'arène ---------------------------------------------------- */
.combat-arena {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 6px;
    padding: 12px 10px;
    border-radius: 18px;
    background:
        radial-gradient(120% 90% at 50% 0%, rgba(110, 168, 255, 0.22), transparent 60%),
        linear-gradient(180deg, #223046 0%, #141c2b 70%, #0e1420 100%);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
    overflow: hidden;
    color: #eef3ff;
}

.combat-side {
    position: relative;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px 8px 10px;
    border-radius: 14px;
    transition: background 0.25s, box-shadow 0.25s;
}

/* Le camp dont c'est le tour est mis en avant. */
.combat-side.actif {
    background: radial-gradient(90% 70% at 50% 90%, rgba(110, 168, 255, 0.18), transparent 70%);
    box-shadow: inset 0 0 0 1px rgba(110, 168, 255, 0.35);
}

.combat-role {
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.55;
}

.combat-stage {
    min-width: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 170px;
    width: 100%;
}

.combat-sprite {
    min-width: 0;
    max-height: 170px;
    max-width: 100%;
    object-fit: contain;
    filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.45));
    transform-origin: 50% 100%;
}

/* Repli quand l'image du monstre n'existe pas. */
.combat-sprite.vide {
    visibility: hidden;
}

.combat-name {
    font-weight: 700;
    font-size: 14px;
    line-height: 1.1;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.combat-sort {
    font-size: 11px;
    opacity: 0.7;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Barre de vie -------------------------------------------------------- */
.combat-hp {
    width: 100%;
    height: 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}

.combat-hp > span {
    display: block;
    height: 100%;
    width: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #4ade80, #22a35c);
    transition: width 0.55s cubic-bezier(0.2, 0.7, 0.2, 1), background 0.3s;
}

.combat-hp > span.moyen {
    background: linear-gradient(90deg, #f7d154, #e0a21b);
}

.combat-hp > span.bas {
    background: linear-gradient(90deg, #ff7b7b, #c0392b);
}

.combat-hp-txt {
    font-size: 12px;
    opacity: 0.9;
}

.combat-hp-txt b {
    font-size: 14px;
    color: #ffd9d9;
}

/* --- « VS » -------------------------------------------------------------- */
.combat-vs {
    align-self: center;
    font-weight: 900;
    font-size: 20px;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.55);
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
    padding: 0 4px;
}

/* --- Animations de combat ------------------------------------------------ */
@keyframes combat-ruade-droite {
    0% { transform: translateX(0) scale(1); }
    30% { transform: translateX(46px) scale(1.06) rotate(4deg); }
    55% { transform: translateX(38px) scale(1.02) rotate(2deg); }
    100% { transform: translateX(0) scale(1); }
}
@keyframes combat-ruade-gauche {
    0% { transform: translateX(0) scale(1); }
    30% { transform: translateX(-46px) scale(1.06) rotate(-4deg); }
    55% { transform: translateX(-38px) scale(1.02) rotate(-2deg); }
    100% { transform: translateX(0) scale(1); }
}

/* Notre monstre est à gauche : il part vers la droite (et inversement). */
.combat-side--moi.attaque .combat-sprite {
    animation: combat-ruade-droite 0.5s ease-out;
}
.combat-side--adv.attaque .combat-sprite {
    animation: combat-ruade-gauche 0.5s ease-out;
}

@keyframes combat-secousse {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-7px); }
    32% { transform: translateX(6px); }
    50% { transform: translateX(-5px); }
    68% { transform: translateX(4px); }
    84% { transform: translateX(-2px); }
}
@keyframes combat-flash {
    0%, 100% { filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.45)); }
    25% { filter: brightness(2.1) saturate(1.6) drop-shadow(0 0 12px #ff6b6b); }
    60% { filter: brightness(1.35) drop-shadow(0 0 8px #ff6b6b); }
}

.combat-side.touche .combat-stage {
    animation: combat-secousse 0.5s ease-in-out;
}
.combat-side.touche .combat-sprite {
    animation: combat-flash 0.5s ease-in-out;
}
.combat-side.touche {
    background: radial-gradient(80% 60% at 50% 70%, rgba(255, 82, 82, 0.35), transparent 72%);
}

/* Dégâts flottants. */
.combat-degats {
    position: absolute;
    left: 50%;
    top: 32%;
    z-index: 3;
    font-weight: 900;
    font-size: 27px;
    line-height: 1;
    color: #ff5252;
    text-shadow: 0 2px 0 #3a0000, 0 0 14px rgba(255, 60, 60, 0.75);
    pointer-events: none;
    animation: combat-degats 1.05s ease-out forwards;
}
@keyframes combat-degats {
    0% { opacity: 0; transform: translate(-50%, 12px) scale(0.6); }
    18% { opacity: 1; transform: translate(-50%, -8px) scale(1.3); }
    55% { opacity: 1; transform: translate(-50%, -34px) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -60px) scale(1); }
}

/* Orbe de sort : traverse l'arène du lanceur vers la cible. */
.combat-fx {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}
.combat-orbe {
    position: absolute;
    top: 44%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ffffff 0%, #9ec5ff 40%, #2b5cff 78%);
    box-shadow: 0 0 16px #7fb0ff, 0 0 34px rgba(110, 168, 255, 0.65);
}
.combat-orbe.vers-adv {
    left: 25%;
    animation: combat-orbe-droite 0.42s cubic-bezier(0.45, 0, 0.85, 0.6) forwards;
}
.combat-orbe.vers-moi {
    left: 75%;
    animation: combat-orbe-gauche 0.42s cubic-bezier(0.45, 0, 0.85, 0.6) forwards;
}
@keyframes combat-orbe-droite {
    0% { left: 25%; opacity: 0.2; transform: scale(0.5); }
    25% { opacity: 1; transform: scale(1.15); }
    100% { left: 76%; opacity: 0.9; transform: scale(1.35); }
}
@keyframes combat-orbe-gauche {
    0% { left: 75%; opacity: 0.2; transform: scale(0.5); }
    25% { opacity: 1; transform: scale(1.15); }
    100% { left: 24%; opacity: 0.9; transform: scale(1.35); }
}

/* --- Journal + pied de modale ------------------------------------------- */
.combat-log {
    min-height: 20px;
    margin: 10px 4px 0;
    font-size: 13px;
    text-align: center;
    color: #33414f;
    font-weight: 600;
}

.combat-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.combat-tour {
    font-size: 13px;
    font-weight: 600;
    color: #0d6efd;
}

/* Le bouton « sort » devient une pastille avec le nom du sort. */
.combat-footer .BoutonLanceSort {
    width: auto;
    min-width: 132px;
    height: 46px;
    padding: 0 20px;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 700;
    border-width: 2px;
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.28);
    transition: transform 0.15s, box-shadow 0.15s;
}
.combat-footer .BoutonLanceSort:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(13, 110, 253, 0.38);
}
.combat-footer .BoutonLanceSort:not(:disabled):active {
    transform: translateY(1px) scale(0.98);
}

/* --- Écran de fin : défaite --------------------------------------------- */
/* Reprend l'habillage sombre de l'arène pour que la fin du combat reste dans
   le même univers que le plateau. */
.combat-result {
    background:
        radial-gradient(120% 90% at 50% 0%, rgba(255, 110, 110, 0.16), transparent 60%),
        linear-gradient(180deg, #223046 0%, #141c2b 70%, #0e1420 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    color: #eef3ff;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.combat-result [hidden] {
    display: none !important;
}

.combat-result .modal-header {
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.combat-result .modal-title.TitreModalCombat {
    color: #ffd9d9;
    font-weight: 700;
}

.combat-result .btn-close {
    filter: invert(1) grayscale(1) brightness(2);
    opacity: 0.7;
}
.combat-result .btn-close:hover {
    opacity: 1;
}

.combat-result-body {
    padding: 18px 22px 14px;
    text-align: center;
}

.combat-result-visual {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 118px;
    margin-bottom: 6px;
}

.combat-result-sprite {
    max-height: 132px;
    max-width: 100%;
    object-fit: contain;
    opacity: 0.9;
    filter: grayscale(1) brightness(0.7) drop-shadow(0 8px 10px rgba(0, 0, 0, 0.5));
}

.combat-result-emblem {
    width: 74px;
    height: 74px;
    color: rgba(255, 123, 123, 0.92);
    filter: drop-shadow(0 0 18px rgba(255, 80, 80, 0.35));
}
.combat-result-emblem svg {
    display: block;
    width: 100%;
    height: 100%;
}

.combat-result-ko-nom {
    margin: -2px 0 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(255, 217, 217, 0.75);
}

.combat-result-lead {
    margin: 0 0 6px;
    font-size: 17px;
    font-weight: 700;
    color: #ffe9e9;
}

.combat-result-text {
    max-width: 34ch;
    margin: 0 auto 14px;
    font-size: 13px;
    line-height: 1.45;
    color: rgba(238, 243, 255, 0.75);
}

.combat-result-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    max-width: 360px;
    margin: 0 auto;
}

.combat-result-stat {
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.combat-result-label {
    display: block;
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(238, 243, 255, 0.55);
}

.combat-result-value {
    display: block;
    margin-top: 2px;
    overflow: hidden;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.combat-result-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.combat-result-note {
    font-size: 11px;
    color: rgba(238, 243, 255, 0.55);
}

/* Même pastille que le bouton « Sort » de l'arène, lisible sur fond sombre. */
.combat-result-footer .BoutonLanceSort {
    width: auto;
    min-width: 120px;
    height: 44px;
    padding: 0 20px;
    border: 2px solid #0d6efd;
    border-radius: 999px;
    background: #fff;
    color: #0d6efd;
    font-size: 15px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.28);
    transition: transform 0.15s, box-shadow 0.15s;
}
.combat-result-footer .BoutonLanceSort:hover {
    background: #fff;
    color: #0b5ed7;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(13, 110, 253, 0.38);
}
.combat-result-footer .BoutonLanceSort:active {
    transform: translateY(1px) scale(0.98);
}

/* --- Petits écrans ------------------------------------------------------- */
@media (max-width: 520px) {
    .combat-stage { height: 120px; }
    .combat-sprite { max-height: 120px; }
    .combat-name { font-size: 12px; }
    .combat-degats { font-size: 22px; }
    .combat-vs { font-size: 15px; }
    .combat-footer .BoutonLanceSort { min-width: 110px; height: 42px; font-size: 14px; }

    .combat-result-details { grid-template-columns: 1fr; }
    .combat-result-footer {
        flex-direction: column-reverse;
        align-items: stretch;
        text-align: center;
    }
    .combat-result-footer .BoutonLanceSort { width: 100%; }
}
