/* ============================================
   DUAL EMPIRES - Animations de présentation du combat (Alpha 0.1.3, chantier C6)
   ============================================
   js/animations-combat.js. Couche au-dessus du plateau, sous les fenêtres de
   décision ; ne capte jamais un clic. Couleurs de la charte provisoire. */

.animations-combat {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  overflow: hidden;
}

.animation-bandeau {
  position: absolute;
  left: 50%;
  top: 47%;
  transform: translate(-50%, -50%);
  padding: 10px 46px;
  border-top: 2px solid #c9a24b;
  border-bottom: 2px solid #c9a24b;
  background: linear-gradient(90deg, rgba(14, 16, 24, 0), rgba(14, 16, 24, 0.92) 18%, rgba(14, 16, 24, 0.92) 82%, rgba(14, 16, 24, 0));
  color: #f3ead6;
  font-family: "Cinzel", Georgia, serif;
  font-size: clamp(1.1rem, 2.6vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  white-space: nowrap;
  text-shadow: 0 0 12px rgba(59, 111, 216, 0.85);
  animation: animation-bandeau 1.6s ease-out forwards;
}

.animation-bandeau--adversaire {
  color: #ffd6c8;
  text-shadow: 0 0 12px rgba(200, 60, 40, 0.8);
}

.animation-bandeau--phase {
  top: 50%;
  padding: 6px 32px;
  font-size: clamp(0.9rem, 1.7vw, 1.3rem);
  animation-duration: 1.2s;
}

@keyframes animation-bandeau {
  0% { opacity: 0; transform: translate(-50%, -50%) scaleX(0.6); }
  15% { opacity: 1; transform: translate(-50%, -50%) scaleX(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scaleX(1.03); }
}

.animation-flottant {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: "Cinzel", Georgia, serif;
  font-size: 1.5rem;
  font-weight: 800;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
  animation: animation-flottant 1.4s ease-out forwards;
}

.animation-flottant--degat,
.animation-flottant--forteresse {
  color: #ff6b5a;
}

.animation-flottant--forteresse {
  font-size: 1.9rem;
}

.animation-flottant--soin,
.animation-flottant--gain {
  color: #7fe0a0;
}

.animation-flottant--depense {
  color: #e8c87a;
  font-size: 1.1rem;
}

@keyframes animation-flottant {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.8); }
  15% { opacity: 1; transform: translate(-50%, -60%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(1); }
}

.animation-secousse {
  animation: animation-secousse 0.45s ease-in-out;
}

@keyframes animation-secousse {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-4px, 1px); }
  40% { transform: translate(4px, -1px); }
  60% { transform: translate(-3px, 0); }
  80% { transform: translate(2px, 1px); }
}

/* Effets réduits : apparitions en fondu, sans déplacement ni secousse. */
.animation-bandeau.reduit,
.animation-flottant.reduit {
  animation-name: animation-fondu;
}

@keyframes animation-fondu {
  0% { opacity: 0; }
  20%, 75% { opacity: 1; }
  100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .animation-secousse {
    animation: none;
  }
}

/* ----- A11 / A12 : apparition d'une carte posée ----- */
.animation-apparition {
  animation: animation-apparition 0.9s ease-out;
}

@keyframes animation-apparition {
  0% { box-shadow: 0 0 0 0 rgba(59, 111, 216, 0.95); filter: brightness(1.8); }
  100% { box-shadow: 0 0 0 18px rgba(59, 111, 216, 0); filter: brightness(1); }
}

/* ----- A23 : éclat de destruction ----- */
.animation-eclat {
  position: absolute;
  border-radius: 6px;
  background: radial-gradient(circle, rgba(255, 210, 160, 0.85), rgba(200, 80, 40, 0.4) 45%, transparent 70%);
  animation: animation-eclat 0.9s ease-out forwards;
}

@keyframes animation-eclat {
  0% { opacity: 1; transform: scale(0.9); }
  100% { opacity: 0; transform: scale(1.35); }
}

/* ----- A24 : bonus et malus ----- */
.animation-flottant--bonus {
  color: #7fe0a0;
  font-size: 1.05rem;
}

.animation-flottant--malus {
  color: #ff8a7a;
  font-size: 1.05rem;
}

/* ----- A30 : attente du tour adverse ----- */
.animation-attente {
  position: absolute;
  transform: translateX(-50%);
  padding: 3px 12px;
  border: 1px solid rgba(201, 162, 75, 0.55);
  border-radius: 999px;
  background: rgba(11, 13, 20, 0.8);
  color: #f3ead6;
  font-size: 0.85rem;
}

.animation-attente span {
  animation: animation-points 1.2s infinite;
}

.animation-attente span:nth-child(2) { animation-delay: 0.2s; }
.animation-attente span:nth-child(3) { animation-delay: 0.4s; }

@keyframes animation-points {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

/* ----- A01 : arrivée sur le plateau ----- */
.animation-arrivee {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(59, 111, 216, 0.35), #05070c 70%);
  animation: animation-arrivee 1.3s ease-out forwards;
}

@keyframes animation-arrivee {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* Finalisation du peaufinage : arrivée par le portail (js/transition-combat.js). La page s'ouvre sur le noir de la
   traversée (classe posée par l'en-tête de la page) ; il se lève quand le voile A01 est en place, et ce voile part alors
   d'un bleu nuit opaque : le terrain apparaît progressivement, sans éclair de page blanche ni plateau déjà visible. */
html.arrivee-portail::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: #05070c;
  pointer-events: none;
}

html.arrivee-portail.arrivee-portail--levee::before {
  opacity: 0;
  transition: opacity 0.3s ease;
}

html.arrivee-portail .animation-arrivee {
  background: radial-gradient(circle at center, #0f1c3d 0%, #05070c 62%);
}

/* ----- A32 : onde de fin de combat ----- */
.animation-onde-fin {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 40px;
  height: 40px;
  border: 4px solid rgba(232, 200, 122, 0.9);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: animation-onde 1.4s ease-out forwards;
}

@keyframes animation-onde {
  0% { opacity: 1; width: 40px; height: 40px; }
  100% { opacity: 0; width: 160vmax; height: 160vmax; }
}

.animation-eclat.reduit,
.animation-onde-fin.reduit {
  animation-name: animation-fondu;
}

@media (prefers-reduced-motion: reduce) {
  .animation-attente span {
    animation: none;
  }
}

/* ----- A28 : invocation spéciale (ondes d'énergie bleues) ----- */
.animation-invocation {
  animation: animation-invocation 1.3s ease-out;
}

@keyframes animation-invocation {
  0% { box-shadow: 0 0 0 0 rgba(90, 160, 255, 1), 0 0 0 0 rgba(90, 160, 255, 0.6); filter: brightness(2.2) saturate(1.4); }
  50% { box-shadow: 0 0 0 14px rgba(90, 160, 255, 0.45), 0 0 0 28px rgba(90, 160, 255, 0.2); }
  100% { box-shadow: 0 0 0 30px rgba(90, 160, 255, 0), 0 0 0 46px rgba(90, 160, 255, 0); filter: brightness(1) saturate(1); }
}

/* ----- A13 : évolution (Héros au Stade 2, Bâtiment d'Évolution construit) ----- */
.animation-evolution {
  animation: animation-evolution 1.5s ease-out;
}

@keyframes animation-evolution {
  0% { filter: brightness(1); box-shadow: 0 0 0 0 rgba(232, 200, 122, 0.9); }
  35% { filter: brightness(2.4) sepia(0.6); box-shadow: 0 0 26px 10px rgba(232, 200, 122, 0.8); }
  100% { filter: brightness(1); box-shadow: 0 0 0 0 rgba(232, 200, 122, 0); }
}

.animation-bandeau--evolution {
  top: 50%;
  padding: 6px 32px;
  color: #e8c87a;
  font-size: clamp(0.9rem, 1.7vw, 1.3rem);
}

@media (prefers-reduced-motion: reduce) {
  .animation-invocation,
  .animation-evolution,
  .animation-apparition {
    animation: none;
  }
}

/* ----- Directive V1.7 : animations complétées ----- */
/* A14 / A15 / A27 / A16 : présentation agrandie de la carte jouée ou révélée (au-dessus du centre, sous le bandeau). */
.animation-presentation {
  position: absolute;
  left: 50%;
  top: 30%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 34px 12px;
  border: 2px solid #c9a24b;
  border-radius: 10px;
  background: radial-gradient(ellipse at center, rgba(28, 24, 40, 0.95), rgba(14, 16, 24, 0.9));
  box-shadow: 0 0 28px rgba(201, 162, 75, 0.45);
  color: #f3ead6;
  transform: translate(-50%, -50%);
  animation: animation-presentation 1.7s ease-out forwards;
}

.animation-presentation__etiquette {
  font-size: clamp(0.7rem, 1.1vw, 0.85rem);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.85;
}

.animation-presentation__nom {
  font-family: "Cinzel", Georgia, serif;
  font-size: clamp(1.15rem, 2.4vw, 1.9rem);
  font-weight: 700;
  white-space: nowrap;
}

.animation-presentation--sort { box-shadow: 0 0 30px rgba(120, 170, 255, 0.6); }
.animation-presentation--tactique { box-shadow: 0 0 30px rgba(232, 200, 122, 0.7); }
.animation-presentation--skill { box-shadow: 0 0 30px rgba(170, 120, 255, 0.6); }
.animation-presentation--annule { border-color: #8a8a8a; color: #c9c9c9; box-shadow: 0 0 20px rgba(200, 60, 40, 0.5); }
.animation-presentation--annule .animation-presentation__nom { text-decoration: line-through; }

@keyframes animation-presentation {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  14% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
  24% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(1); }
}

/* A17 : élan de l'attaquant vers le camp adverse (vers le haut pour le joueur, vers le bas pour l'adversaire). */
.animation-elan-joueur { animation: animation-elan-joueur 0.5s ease-out; }
.animation-elan-adversaire { animation: animation-elan-adversaire 0.5s ease-out; }

@keyframes animation-elan-joueur {
  0%, 100% { transform: translateY(0); }
  35% { transform: translateY(-14px) scale(1.04); }
}

@keyframes animation-elan-adversaire {
  0%, 100% { transform: translateY(0); }
  35% { transform: translateY(14px) scale(1.04); }
}

/* A19 : attaque bloquée (aucun dégât). */
.animation-flottant--bloque {
  color: #b9d4ff;
  font-size: 1.15rem;
}

/* A21 : fissures persistantes de la barre de Forteresse (PV perdus). */
.barre-joueur[data-fissures],
.barre-adversaire[data-fissures] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 60' preserveAspectRatio='none'%3E%3Cg fill='none' stroke='rgba(0,0,0,0.55)' stroke-width='1.6'%3E%3Cpath d='M18 0 L30 14 L24 26 L40 40 L34 60'/%3E%3Cpath d='M372 0 L360 18 L368 30 L352 46'/%3E%3C/g%3E%3Cg fill='none' stroke='rgba(255,220,170,0.18)' stroke-width='0.8'%3E%3Cpath d='M19 1 L31 15 L25 27 L41 41'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.barre-joueur[data-fissures="2"],
.barre-adversaire[data-fissures="2"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 60' preserveAspectRatio='none'%3E%3Cg fill='none' stroke='rgba(0,0,0,0.6)' stroke-width='1.8'%3E%3Cpath d='M18 0 L30 14 L24 26 L40 40 L34 60'/%3E%3Cpath d='M372 0 L360 18 L368 30 L352 46'/%3E%3Cpath d='M150 60 L162 44 L156 32 L176 18 L170 0'/%3E%3Cpath d='M256 0 L248 20 L262 34 L254 60'/%3E%3Cpath d='M162 44 L180 50'/%3E%3C/g%3E%3Cg fill='none' stroke='rgba(255,220,170,0.2)' stroke-width='0.8'%3E%3Cpath d='M151 59 L163 43 L157 31 L177 17'/%3E%3C/g%3E%3C/svg%3E");
}

/* A04 : distribution de la main de départ, carte par carte. */
.animation-distribution {
  animation: animation-distribution 0.45s ease-out both;
}

@keyframes animation-distribution {
  0% { opacity: 0; transform: translateY(26px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* A25 : couleurs dédiées des états spéciaux (badges des cartes posées, repérés par leur intitulé). */
.etat-badge[title^="Paralysie"] { box-shadow: 0 0 6px 2px rgba(250, 214, 60, 0.75); }
.etat-badge[title^="Gel"] { box-shadow: 0 0 6px 2px rgba(110, 210, 255, 0.8); }
.etat-badge[title^="Brûlure"] { box-shadow: 0 0 6px 2px rgba(255, 120, 40, 0.8); }
.etat-badge[title^="Venin"] { box-shadow: 0 0 6px 2px rgba(110, 220, 90, 0.8); }
.etat-badge[title^="Ne peut pas attaquer"] { opacity: 0.8; }

/* Effets réduits : présentation en fondu, sans élan ni distribution. */
.animation-presentation.reduit {
  animation-name: animation-fondu;
}

@media (prefers-reduced-motion: reduce) {
  .animation-elan-joueur,
  .animation-elan-adversaire,
  .animation-distribution {
    animation: none;
  }
}

/* ===== Bloc 6 (directive V1.9-N) ===== */
/* A27 : bandeau bref de sa fenêtre de réaction, en haut de l'écran : jamais sur les boutons de réaction. */
.animation-bandeau--reaction {
  top: 12%;
  padding: 6px 30px;
  font-size: clamp(0.9rem, 1.6vw, 1.25rem);
  color: #ffe9a8;
  text-shadow: 0 0 12px rgba(232, 200, 122, 0.85);
}
/* ----- Finalisation du peaufinage : fissures progressives du terrain (js/fissures-terrain.js) -----
   Un calque par camp, sous les cartes. Solo : dans le calque décoratif de l'arène (.arene-energie, z-index -1), entre
   les deux murs du tapis, du fond du camp jusqu'à la ligne de front (--fissures-front, mesurée). Duel PvP : dans la
   section du camp. Le tracé du camp du joueur est retourné (ses fissures montent depuis le bas). Cinq paliers
   (data-niveau), chacun en fondu d'opacité ; aux deux derniers, les premières fissures s'élargissent. */
.fissures-terrain {
  position: absolute;
  left: var(--tv-mur-g, 0px);
  right: var(--tv-mur-d, 0px);
  pointer-events: none;
}

.fissures-terrain--adversaire {
  top: 0;
  height: var(--fissures-front, 50%);
}

.fissures-terrain--joueur {
  top: var(--fissures-front, 50%);
  bottom: 0;
  transform: scaleY(-1);
}

.fissures-terrain svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.fissures-terrain path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.fissures-creux {
  stroke: rgba(2, 3, 8, 0.9);
  stroke-width: 2.6px;
}

.fissures-arete {
  stroke: rgba(190, 215, 255, 0.26);
  stroke-width: 1.2px;
  transform: translate(1.8px, 1.8px);
}

.fissures-palier {
  opacity: 0;
  transition: opacity 0.8s ease;
}

.fissures-terrain[data-niveau="1"] .fissures-palier--1,
.fissures-terrain[data-niveau="2"] :is(.fissures-palier--1, .fissures-palier--2),
.fissures-terrain[data-niveau="3"] :is(.fissures-palier--1, .fissures-palier--2, .fissures-palier--3),
.fissures-terrain[data-niveau="4"] :is(.fissures-palier--1, .fissures-palier--2, .fissures-palier--3, .fissures-palier--4),
.fissures-terrain[data-niveau="5"] .fissures-palier {
  opacity: 1;
}

.fissures-terrain:is([data-niveau="3"], [data-niveau="4"], [data-niveau="5"]) .fissures-palier--1 .fissures-creux {
  stroke-width: 3.4px;
}

.fissures-terrain:is([data-niveau="4"], [data-niveau="5"]) :is(.fissures-palier--1, .fissures-palier--2) .fissures-creux {
  stroke-width: 4.2px;
}

.fissures-terrain[data-niveau="5"] .fissures-palier--3 .fissures-creux {
  stroke-width: 3.4px;
}

/* Dernier palier (3 PV ou moins) : lueur de braise légère au bord des fissures les plus anciennes */
.fissures-terrain[data-niveau="5"] :is(.fissures-palier--1, .fissures-palier--2) .fissures-arete {
  stroke: rgba(255, 140, 80, 0.5);
  stroke-width: 1.6px;
}

/* Duel PvP : le calque couvre la section du camp, sous ses rangées */
.fissures-terrain--duel {
  inset: 0;
  height: auto;
  z-index: -1;
  border-radius: inherit;
  overflow: hidden;
}

/* La section du camp devient le repère du calque ; z-index -1 dans ce repère = au-dessus du fond du camp, sous tout
   son contenu (rangées, informations, indicateur d'attente), sans rien repositionner. */
main#duel > .duel-camp {
  position: relative;
  isolation: isolate;
}

@media (prefers-reduced-motion: reduce) {
  .fissures-palier {
    transition: none;
  }
}

html.effets-reduits .fissures-palier {
  transition: none;
}

/* A21 en PvP : mêmes fissures persistantes, sur les informations de Forteresse de chaque camp du duel. */
.duel-infos[data-fissures] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 60' preserveAspectRatio='none'%3E%3Cg fill='none' stroke='rgba(0,0,0,0.55)' stroke-width='1.6'%3E%3Cpath d='M18 0 L30 14 L24 26 L40 40 L34 60'/%3E%3Cpath d='M372 0 L360 18 L368 30 L352 46'/%3E%3C/g%3E%3Cg fill='none' stroke='rgba(255,220,170,0.18)' stroke-width='0.8'%3E%3Cpath d='M19 1 L31 15 L25 27 L41 41'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.duel-infos[data-fissures="2"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 60' preserveAspectRatio='none'%3E%3Cg fill='none' stroke='rgba(0,0,0,0.6)' stroke-width='1.8'%3E%3Cpath d='M18 0 L30 14 L24 26 L40 40 L34 60'/%3E%3Cpath d='M372 0 L360 18 L368 30 L352 46'/%3E%3Cpath d='M150 60 L162 44 L156 32 L176 18 L170 0'/%3E%3Cpath d='M256 0 L248 20 L262 34 L254 60'/%3E%3Cpath d='M162 44 L180 50'/%3E%3C/g%3E%3Cg fill='none' stroke='rgba(255,220,170,0.2)' stroke-width='0.8'%3E%3Cpath d='M151 59 L163 43 L157 31 L177 17'/%3E%3C/g%3E%3C/svg%3E");
}
/* Option « Réduire les animations » (js/effets-reduits.js, classe sur <html>) : mêmes réductions que la préférence système. */
html.effets-reduits .animation-secousse,
html.effets-reduits .animation-invocation,
html.effets-reduits .animation-evolution,
html.effets-reduits .animation-apparition,
html.effets-reduits .animation-elan-joueur,
html.effets-reduits .animation-elan-adversaire,
html.effets-reduits .animation-distribution {
  animation: none;
}
html.effets-reduits .animation-attente span {
  animation: none;
  opacity: 1;
}

/* =====================================================================
   Directive V1.9-T — finition du Bloc 6 (catalogue du cahier § 9.1, effets « validés dans leur principe »).
   Présentation seule : aucun élément ne capte de clic ; tout mouvement est neutralisé par « Réduire les animations »
   (html.effets-reduits) et par la préférence système.
   ===================================================================== */

/* ----- A01 : portail tournant, aspiration, noir, apparition progressive du terrain (1,3 s, durée inchangée) ----- */
.animation-arrivee::before,
.animation-arrivee::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46vmin;
  height: 46vmin;
  margin: -23vmin 0 0 -23vmin;
  border-radius: 50%;
}
.animation-arrivee::before {
  background: conic-gradient(from 0deg, rgba(120, 170, 255, 0), rgba(120, 170, 255, 0.85), rgba(232, 200, 122, 0.6), rgba(120, 170, 255, 0) 70%);
  -webkit-mask: radial-gradient(circle, transparent 46%, #000 48%, #000 66%, transparent 68%);
  mask: radial-gradient(circle, transparent 46%, #000 48%, #000 66%, transparent 68%);
  animation: animation-portail 1.1s cubic-bezier(0.5, 0, 0.75, 0.2) forwards;
}
.animation-arrivee::after {
  background: radial-gradient(circle, rgba(170, 200, 255, 0.9), rgba(59, 111, 216, 0.35) 40%, transparent 65%);
  animation: animation-aspiration 1.1s ease-in forwards;
}
@keyframes animation-portail {
  0% { transform: rotate(0deg) scale(1.15); opacity: 0; }
  20% { opacity: 1; }
  80% { transform: rotate(540deg) scale(0.25); opacity: 1; }
  100% { transform: rotate(620deg) scale(0); opacity: 0; }
}
@keyframes animation-aspiration {
  0% { transform: scale(1.4); opacity: 0.2; }
  75% { transform: scale(0.1); opacity: 1; }
  100% { transform: scale(0); opacity: 0; }
}

/* ----- A07 / A11 / A12 / A23 : cartes en déplacement (clones de présentation, animations Web) ----- */
.animation-vol {
  position: fixed;
  margin: 0;
  pointer-events: none;
  z-index: 2;
  transform-origin: center;
  will-change: transform, opacity;
}
.animation-vol--defausse {
  border-radius: 6px;
  background: linear-gradient(160deg, rgba(40, 46, 66, 0.95), rgba(14, 16, 24, 0.95));
  border: 1px solid rgba(201, 162, 75, 0.8);
  box-shadow: 0 0 12px rgba(255, 120, 60, 0.6);
}
/* A14 : carte du Sort agrandie au centre, avant son effet (le nom présenté dessous est conservé). */
.animation-carte-agrandie {
  position: absolute;
  left: 50%;
  top: 45%;
  width: min(170px, 28vw);
  transform: translate(-50%, -50%);
  pointer-events: none;
  filter: drop-shadow(0 0 22px rgba(120, 170, 255, 0.65));
  animation: animation-carte-agrandie 1.5s ease-out forwards;
}
.animation-carte-agrandie > * { width: 100% !important; max-width: none !important; margin: 0 !important; }
@keyframes animation-carte-agrandie {
  0% { transform: translate(-50%, -50%) scale(0.35); opacity: 0; }
  18% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; }
  70% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.92); opacity: 0; }
}
.animation-carte-agrandie.reduit { animation: animation-fondu 1.2s ease-out forwards; }

/* ----- A10 : ciblage — assombrissement discret de ce qui n'est pas une cible légale ----- */
/* Bloc 7 : « :has » ancré sur l'arène (qui contient les quatre zones) et non sur body : même effet, mais une modification
   hors de l'arène (panneau d'inspection, main, journal) ne relance plus le calcul des styles de toute la page
   (aperçu d'une carte mesuré à 3,2 ms avec body:has, 2,1 ms sans : test-plateau-169 C5, seuil 3 ms). */
.arene:has(.emplacement.cible-attaque) #troupes-adversaire .emplacement:not(.cible-attaque),
.arene:has(.emplacement.cible-attaque) #batiments-adversaire .emplacement:not(.cible-attaque),
.arene:has(.emplacement.cible-pose) #troupes-joueur .emplacement:not(.cible-pose),
.arene:has(.emplacement.cible-pose) #batiments-joueur .emplacement:not(.cible-pose),
main#duel:has(.duel-emplacement.cible) .duel-emplacement:not(.cible):not(.attaquant):not(.selectionne) {
  filter: brightness(0.62) saturate(0.8);
  transition: filter 0.2s ease;
}

/* ----- A17 : ligne d'attaque (attaquant → cible) et impacts ----- */
.animation-ligne-attaque {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.animation-ligne-attaque line {
  stroke: rgba(255, 196, 92, 0.95);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 14 10;
  filter: drop-shadow(0 0 6px rgba(255, 140, 40, 0.9));
  animation: animation-ligne-attaque 0.8s ease-out forwards;
}
.animation-ligne-attaque--adversaire line { stroke: rgba(255, 110, 110, 0.95); filter: drop-shadow(0 0 6px rgba(220, 40, 40, 0.9)); }
@keyframes animation-ligne-attaque {
  0% { stroke-dashoffset: 120; opacity: 0; }
  20% { opacity: 1; }
  75% { opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}
.animation-impact { animation: animation-impact 0.38s ease-out; }
@keyframes animation-impact {
  0% { filter: brightness(1); transform: scale(1); }
  35% { filter: brightness(1.9) saturate(1.4); transform: scale(0.96); }
  100% { filter: brightness(1); transform: scale(1); }
}

/* ----- A19 : protections distinctes (états publics réels : boucliers, armures ; « Bloqué » sans perte de PV) ----- */
.animation-flottant--bouclier { color: #ffe9a8; text-shadow: 0 0 10px rgba(255, 220, 120, 0.95), 0 2px 3px #000; }
.animation-flottant--armure { color: #a8d8ff; text-shadow: 0 0 10px rgba(90, 170, 255, 0.95), 0 2px 3px #000; }
.animation-protection {
  position: fixed;
  border-radius: 10px;
  pointer-events: none;
  animation: animation-protection 0.9s ease-out forwards;
}
.animation-protection--bouclier { box-shadow: inset 0 0 0 3px rgba(255, 220, 120, 0.95), 0 0 26px rgba(255, 210, 100, 0.85); }
.animation-protection--armure { box-shadow: inset 0 0 0 3px rgba(110, 180, 255, 0.95), 0 0 22px rgba(80, 150, 255, 0.8); }
.animation-protection--bloque { box-shadow: inset 0 0 0 3px rgba(220, 220, 230, 0.9), 0 0 18px rgba(200, 200, 220, 0.7); }
@keyframes animation-protection {
  0% { opacity: 0; transform: scale(1.12); }
  25% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.02); }
}
.animation-protection.reduit { animation: animation-fondu 0.9s ease-out forwards; }

/* ----- A25 : Accélération cyan, Paralysie violette, ZZZ (Troupe qui ne peut pas encore attaquer) ----- */
.etat-badge[title^="Paralysie"],
.duel-etat-icone[title^="⏸ Paralysie"] { box-shadow: 0 0 7px 2px rgba(170, 90, 255, 0.85); }
.animation-acceleration { animation: animation-acceleration 1.1s ease-out; }
@keyframes animation-acceleration {
  0% { box-shadow: 0 0 0 0 rgba(60, 230, 255, 0); }
  30% { box-shadow: 0 0 22px 6px rgba(60, 230, 255, 0.9); }
  100% { box-shadow: 0 0 0 0 rgba(60, 230, 255, 0); }
}
.animation-paralysie { animation: animation-paralysie 1.1s ease-out; }
@keyframes animation-paralysie {
  0% { box-shadow: 0 0 0 0 rgba(170, 90, 255, 0); }
  30% { box-shadow: 0 0 22px 6px rgba(170, 90, 255, 0.9); }
  100% { box-shadow: 0 0 0 0 rgba(170, 90, 255, 0); }
}
.etat-badge[title^="Ne peut pas attaquer"],
.duel-etat-icone[title^="⛔"] { display: inline-block; animation: animation-zzz 2.4s ease-in-out infinite; }
@keyframes animation-zzz {
  0%, 100% { transform: translateY(0); opacity: 0.8; }
  50% { transform: translateY(-3px); opacity: 1; }
}

/* ----- A32 : dernier coup ralenti, forte onde de choc, fracture du terrain ----- */
.animation-fracture {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.animation-fracture path {
  fill: none;
  stroke: rgba(255, 236, 190, 0.95);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 1600;
  stroke-dashoffset: 1600;
  filter: drop-shadow(0 0 8px rgba(255, 150, 60, 0.95));
  animation: animation-fracture 1.6s ease-out 0.45s forwards;
}
@keyframes animation-fracture {
  0% { stroke-dashoffset: 1600; opacity: 1; }
  55% { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}
.animation-dernier-coup { animation: animation-dernier-coup 1.1s cubic-bezier(0.2, 0.8, 0.3, 1); }
@keyframes animation-dernier-coup {
  0% { transform: scale(1); filter: brightness(1); }
  40% { transform: scale(1.06); filter: brightness(1.8); }
  100% { transform: scale(1); filter: brightness(1); }
}
.animation-onde-fin--forte { animation-duration: 1.6s; }

/* ----- A09 (PvP) : carte de la main soulevée au survol, halo de sélection (aperçu : inspection existante) ----- */
.duel-main .duel-carte { transition: transform 0.15s ease, box-shadow 0.15s ease; }
.duel-main .duel-carte:hover,
.duel-main .duel-carte:focus-visible {
  transform: translateY(-8px) scale(1.04);
  box-shadow: 0 0 0 2px rgba(232, 200, 122, 0.85), 0 10px 22px rgba(0, 0, 0, 0.5), 0 0 18px rgba(59, 111, 216, 0.55);
  z-index: 2;
}

/* ----- A35 (PvP) : ambiance légère du terrain (poussières bleues, brume) ----- */
main#duel { position: relative; isolation: isolate; } /* le décor reste sous le plateau */
main#duel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(2px 2px at 12% 28%, rgba(140, 190, 255, 0.55), transparent 60%),
    radial-gradient(2px 2px at 38% 72%, rgba(140, 190, 255, 0.45), transparent 60%),
    radial-gradient(1.5px 1.5px at 64% 36%, rgba(180, 210, 255, 0.5), transparent 60%),
    radial-gradient(2px 2px at 86% 64%, rgba(140, 190, 255, 0.45), transparent 60%),
    radial-gradient(60% 40% at 50% 52%, rgba(59, 111, 216, 0.08), transparent 70%);
  animation: animation-ambiance-duel 18s ease-in-out infinite alternate;
}
@keyframes animation-ambiance-duel {
  0% { transform: translateY(0); opacity: 0.65; }
  100% { transform: translateY(-14px); opacity: 1; }
}

/* ----- Effets réduits : aucun mouvement (V1.9-T) ----- */
html.effets-reduits .animation-arrivee::before,
html.effets-reduits .animation-arrivee::after,
html.effets-reduits .animation-ligne-attaque,
html.effets-reduits .animation-fracture,
html.effets-reduits .animation-vol { display: none; }
html.effets-reduits .animation-impact,
html.effets-reduits .animation-acceleration,
html.effets-reduits .animation-paralysie,
html.effets-reduits .animation-dernier-coup,
html.effets-reduits .etat-badge,
html.effets-reduits .duel-etat-icone,
html.effets-reduits main#duel::before { animation: none !important; }
html.effets-reduits .duel-main .duel-carte:hover { transform: none; }
@media (prefers-reduced-motion: reduce) {
  .animation-arrivee::before, .animation-arrivee::after, .animation-ligne-attaque, .animation-fracture, .animation-vol { display: none; }
  .animation-impact, .animation-acceleration, .animation-paralysie, .animation-dernier-coup, main#duel::before,
  .etat-badge[title^="Ne peut pas attaquer"], .duel-etat-icone[title^="⛔"] { animation: none !important; }
  .duel-main .duel-carte:hover { transform: none; }
}

/* V1.9-T : empilement sans superposition — carte agrandie en haut, nom présenté dessous, bandeau de tour au centre. */
.animation-presentation--avec-carte { top: 76%; }
.animation-presentation--sous-bandeau { top: 64%; }
.animation-presentation--avec-carte.animation-presentation--sous-bandeau { top: 80%; }

/* =====================================================================
   Directive « Finalisation PvP, audio, animations » (§ 10 et § 11) — js/effets-combat.js, Solo et duel entre amis.
   Présentation seule : aucun élément ne capte de clic. Carte détruite : elle a déjà quitté le terrain (état réel) ; son
   image reste le temps de lire l'impact (éclat, fissures lumineuses), se désintègre de bas en haut en particules, puis
   son essence rejoint la défausse. Effet original (dégradés, masque et particules CSS). Petite surface (une carte),
   moins de deux secondes : seul le masque de la désintégration est repeint ; tout le reste est transform et opacity.
   ===================================================================== */
@property --destruction-p {
  syntax: "<percentage>";
  inherits: false;
  initial-value: 0%;
}

.animation-destruction {
  position: fixed;
  z-index: 3;
  pointer-events: none;
  --destruction-teinte: 150, 195, 255;
}

.animation-destruction__carte {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 6px;
  animation: destruction-impact 0.42s ease-out both;
}

.animation-destruction__carte > * {
  width: 100%;
  height: 100%;
}

/* Éclat de l'impact */
.animation-destruction__eclat {
  position: absolute;
  inset: -14%;
  border-radius: 12px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95) 0%, rgba(var(--destruction-teinte), 0.6) 38%, transparent 70%);
  opacity: 0;
  animation: destruction-eclat 0.46s ease-out both;
}

/* Fissures lumineuses : quelques traits fins de lumière qui zèbrent la carte, et un voile sombre (carte hors de combat) */
.animation-destruction__fissures {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  opacity: 0;
  background:
    linear-gradient(118deg, transparent 46.6%, rgba(255, 255, 255, 0.95) 47.4%, rgba(var(--destruction-teinte), 0.9) 48.2%, transparent 49.2%),
    linear-gradient(64deg, transparent 29.6%, rgba(255, 255, 255, 0.9) 30.3%, rgba(var(--destruction-teinte), 0.85) 31%, transparent 31.9%),
    linear-gradient(156deg, transparent 63.4%, rgba(255, 255, 255, 0.85) 64%, rgba(var(--destruction-teinte), 0.8) 64.6%, transparent 65.4%),
    linear-gradient(22deg, transparent 71.6%, rgba(255, 255, 255, 0.8) 72.1%, rgba(var(--destruction-teinte), 0.75) 72.7%, transparent 73.4%),
    rgba(5, 7, 12, 0.32);
  animation: destruction-fissures 0.5s ease-out 0.14s both;
}

/* Désintégration : la carte s'efface de bas en haut (masque), suivie d'un liseré de lumière */
.animation-destruction--dissolution .animation-destruction__carte,
.animation-destruction--dissolution .animation-destruction__fissures {
  -webkit-mask-image: linear-gradient(to top, transparent calc(var(--destruction-p) - 22%), #000 var(--destruction-p));
  mask-image: linear-gradient(to top, transparent calc(var(--destruction-p) - 22%), #000 var(--destruction-p));
  opacity: 1;
  animation: destruction-dissolution 0.82s cubic-bezier(0.4, 0, 0.7, 1) forwards;
}

.animation-destruction--dissolution::after {
  content: "";
  position: absolute;
  left: -8%;
  right: -8%;
  bottom: 0;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.95) 0%, rgba(var(--destruction-teinte), 0.85) 34%, transparent 72%);
  animation: destruction-lisere 0.82s cubic-bezier(0.4, 0, 0.7, 1) forwards;
}

.animation-destruction__particule {
  position: absolute;
  width: var(--t, 4px);
  height: var(--t, 4px);
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, rgba(var(--destruction-teinte), 0.9) 45%, transparent 72%);
  opacity: 0;
  animation: destruction-particule 0.72s ease-out both;
}

.animation-destruction__essence {
  position: fixed;
  z-index: 3;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, rgba(var(--destruction-teinte, 150, 195, 255), 0.9) 40%, transparent 72%);
  pointer-events: none;
}

/* Machine modeste : pas de masque animé, simple effacement */
.animation-destruction--simple .animation-destruction__carte,
.animation-destruction--simple .animation-destruction__fissures {
  -webkit-mask-image: none;
  mask-image: none;
  animation: destruction-simple 0.6s ease-in forwards;
}

.animation-destruction--simple::after {
  display: none;
}

/* « Réduire les animations » : fondu bref, rien d'autre */
.animation-destruction--reduit,
html.effets-reduits .animation-destruction {
  animation: destruction-fondu 0.4s ease-out forwards;
}

.animation-destruction--reduit > *,
html.effets-reduits .animation-destruction > * {
  animation: none;
}

.animation-destruction--reduit .animation-destruction__eclat,
.animation-destruction--reduit .animation-destruction__fissures {
  display: none;
}

@keyframes destruction-impact {
  0% { transform: translate(0, 0) scale(1); }
  18% { transform: translate(-4px, 2px) scale(1.05); }
  36% { transform: translate(4px, -2px) scale(1.03); }
  54% { transform: translate(-3px, -1px) scale(1.01); }
  72% { transform: translate(2px, 1px) scale(1); }
  100% { transform: translate(0, 0) scale(1); }
}

@keyframes destruction-eclat {
  0% { opacity: 0; transform: scale(0.6); }
  22% { opacity: 0.95; }
  100% { opacity: 0; transform: scale(1.15); }
}

@keyframes destruction-fissures {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes destruction-dissolution {
  from { --destruction-p: 0%; }
  to { --destruction-p: 124%; }
}

@keyframes destruction-lisere {
  0% { transform: translateY(0); opacity: 0; }
  12% { opacity: 1; }
  88% { opacity: 1; }
  100% { transform: translateY(calc(-1 * var(--destruction-h, 150px))); opacity: 0; }
}

@keyframes destruction-particule {
  0% { opacity: 0; transform: translate(0, 0) scale(0.6); }
  16% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx, 0), var(--dy, -40px)) scale(1.25); }
}

@keyframes destruction-simple {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(0.9); }
}

@keyframes destruction-fondu {
  from { opacity: 0.85; }
  to { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .animation-destruction,
  .animation-destruction > * {
    animation-duration: 0.3s;
  }

  .animation-destruction__particule,
  .animation-destruction::after {
    display: none;
  }
}

/* Défausse qui reçoit l'essence d'une carte : bref éclat du cadre */
.animation-defausse-recue {
  animation: defausse-recue 0.55s ease-out;
}

@keyframes defausse-recue {
  0% { box-shadow: 0 0 0 0 rgba(150, 195, 255, 0); }
  35% { box-shadow: 0 0 18px 4px rgba(150, 195, 255, 0.75); }
  100% { box-shadow: 0 0 0 0 rgba(150, 195, 255, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .animation-defausse-recue {
    animation: none;
  }
}

/* § 10 : la ligne de ciblage reste visible jusqu'après l'impact (durée posée par js/animations-combat.js) */
.animation-ligne-attaque line {
  animation-duration: var(--ligne-duree, 0.8s);
}

/* =====================================================================
   Directive « Finalisation PvP, audio, animations » (§ 12) : fissures plus naturelles (js/fissures-terrain.js).
   Mêmes cinq paliers, même tracé principal. Chaque fissure reçoit en plus une ombre large et douce, fondue dans la pierre
   du tapis (fusion « multiply » : le grain du sol reste visible à travers, la fissure semble creusée dans le décor), et de
   courts éclats de pierre en travers. Plus la Forteresse est entamée, plus l'ombre s'élargit et s'assombrit : les fissures
   se lisent nettement à faible quantité de PV. Contenu fixe (aucune animation continue) ; toujours sous les cartes.
   ===================================================================== */
.fissures-ombre {
  stroke: rgba(8, 10, 22, 0.42);
  stroke-width: 7px;
  mix-blend-mode: multiply;
}

.fissures-eclats {
  stroke: rgba(3, 4, 10, 0.78);
  stroke-width: 1.3px;
}

.fissures-terrain:is([data-niveau="3"], [data-niveau="4"], [data-niveau="5"]) .fissures-palier--1 .fissures-ombre {
  stroke-width: 10px;
}

.fissures-terrain:is([data-niveau="4"], [data-niveau="5"]) :is(.fissures-palier--1, .fissures-palier--2) .fissures-ombre {
  stroke: rgba(6, 7, 16, 0.55);
  stroke-width: 13px;
}

.fissures-terrain[data-niveau="5"] .fissures-ombre {
  stroke: rgba(4, 5, 12, 0.6);
}

.fissures-terrain[data-niveau="5"] :is(.fissures-palier--1, .fissures-palier--2, .fissures-palier--3) .fissures-eclats {
  stroke-width: 1.8px;
}

/* Un palier qui apparaît : la fissure s'ouvre (fondu un peu plus long, le creux arrive après son ombre) */
.fissures-palier .fissures-creux,
.fissures-palier .fissures-eclats {
  transition: stroke-width 0.6s ease;
}

/* =====================================================================
   Directive « Finalisation PvP, audio, animations » (§ 13) : vie discrète du terrain (plateau.html, calque .arene-energie,
   sous les cartes). Complète les flux des murs, les éclats et les sursauts déjà en place, sans les modifier.
   - nœuds : les deux foyers d'énergie aux extrémités de la ligne de front respirent, puis lancent de temps en temps une
     onde ;
   - scintillements : bref éclat en croix sur les pointes dorées du tapis, à de longs intervalles décalés ;
   - poussières : quelques grains lumineux montent lentement le long des murs, entre les pierres.
   Douze éléments, transform et opacity seulement, cycles de 9 à 23 s : aucun mouvement continu de grande surface, aucune
   brume, rien au-dessus des cartes, rien de cliquable. « Réduire les animations » : tout est masqué.
   ===================================================================== */
.vie-noeud {
  top: calc(var(--fissures-front, 50%) - min(4.2vw, 46px));
  width: min(8.4vw, 92px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(165, 243, 252, 0.34) 0%, rgba(56, 189, 248, 0.16) 42%, transparent 70%);
  opacity: 0.35;
  animation: vie-noeud 9s ease-in-out infinite;
}

.vie-noeud--gauche {
  left: calc(var(--tv-mur-g) - min(4.2vw, 46px));
}

.vie-noeud--droite {
  right: calc(var(--tv-mur-d) - min(4.2vw, 46px));
  animation-delay: -4.5s;
}

.vie-scintille {
  width: clamp(10px, 1.1vw, 18px);
  aspect-ratio: 1;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.95) 0 7%, rgba(232, 200, 122, 0.6) 16%, transparent 58%),
    linear-gradient(90deg, transparent 45%, rgba(255, 236, 190, 0.7) 50%, transparent 55%),
    linear-gradient(0deg, transparent 45%, rgba(255, 236, 190, 0.7) 50%, transparent 55%);
  opacity: 0;
  animation: vie-scintille 13s ease-in-out infinite;
}

.vie-scintille--1 { left: calc(50% + var(--tapis-decalage-x, 0px) - 0.6vw); top: 15%; animation-delay: -2s; }
.vie-scintille--2 { left: calc(50% + var(--tapis-decalage-x, 0px) - 0.6vw); top: 82%; animation-duration: 17s; animation-delay: -9s; }
.vie-scintille--3 { left: calc(var(--tv-mur-g) + var(--tv-sol) * 0.215); top: 31%; animation-duration: 19s; animation-delay: -13s; }
.vie-scintille--4 { right: calc(var(--tv-mur-d) + var(--tv-sol) * 0.215); top: 66%; animation-duration: 23s; animation-delay: -5s; }

.vie-poussiere {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95), rgba(125, 211, 252, 0.7) 45%, transparent 72%);
  opacity: 0;
  animation: vie-poussiere 16s linear infinite;
}

.vie-poussiere--1 { left: calc(var(--tv-mur-g) + 2.2%); top: 78%; }
.vie-poussiere--2 { left: calc(var(--tv-mur-g) + 4.6%); top: 38%; animation-duration: 21s; animation-delay: -8s; }
.vie-poussiere--3 { left: calc(var(--tv-mur-g) + 1.1%); top: 58%; animation-duration: 18s; animation-delay: -12s; }
.vie-poussiere--4 { right: calc(var(--tv-mur-d) + 2.4%); top: 72%; animation-duration: 19s; animation-delay: -4s; }
.vie-poussiere--5 { right: calc(var(--tv-mur-d) + 4.2%); top: 30%; animation-duration: 22s; animation-delay: -15s; }
.vie-poussiere--6 { right: calc(var(--tv-mur-d) + 1.3%); top: 52%; animation-duration: 17s; animation-delay: -10s; }

@keyframes vie-noeud {
  0%, 100% { opacity: 0.3; transform: scale(0.92); }
  42% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(1.12); }
  64% { opacity: 0.2; transform: scale(1.7); }
  66% { opacity: 0.3; transform: scale(0.92); }
}

@keyframes vie-scintille {
  0%, 84%, 100% { opacity: 0; transform: scale(0.4) rotate(0deg); }
  90% { opacity: 0.9; transform: scale(1) rotate(25deg); }
  95% { opacity: 0.25; transform: scale(0.7) rotate(40deg); }
}

@keyframes vie-poussiere {
  0% { opacity: 0; transform: translate(0, 0); }
  12% { opacity: 0.7; }
  78% { opacity: 0.45; }
  100% { opacity: 0; transform: translate(10px, -11vh); }
}

@media (prefers-reduced-motion: reduce) {
  .vie-noeud,
  .vie-scintille,
  .vie-poussiere {
    display: none;
  }
}

html.effets-reduits :is(.vie-noeud, .vie-scintille, .vie-poussiere) {
  display: none;
}
