/* Feedback animado do treino (trainfx.js). Só transform/opacity; desligado com
   prefers-reduced-motion ou com "Efeitos e animações" off (classe html.tfx-on ausente). */

/* Seleção: o destaque vermelho "estala" ao marcar a casa. */
html.tfx-on .square.selected::after { animation: tfx-sel .2s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes tfx-sel { from { transform: scale(.55); opacity: 0; } }

/* Resultado: cada casa marcada surge em cascata. */
.square.tfx-mark { animation: tfx-mark-in .42s var(--tfx-d, 0ms) cubic-bezier(.2, .9, .3, 1.3) backwards; z-index: 1; }
@keyframes tfx-mark-in { from { transform: scale(.6); filter: brightness(1.8); } }
.square.tfx-wrong { animation: tfx-mark-in .3s var(--tfx-d, 0ms) ease-out backwards, tfx-shake .38s calc(var(--tfx-d, 0ms) + .3s) ease-in-out; }
@keyframes tfx-shake { 20% { transform: translateX(-7%); } 45% { transform: translateX(6%); } 70% { transform: translateX(-4%); } 90% { transform: translateX(2%); } }
.square.tfx-missed::before {
  content: ""; position: absolute; inset: 8%; border-radius: 50%; pointer-events: none; z-index: 3;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .85);
  animation: tfx-missed 1.1s calc(var(--tfx-d, 0ms) + .2s) ease-out 2 backwards;
}
@keyframes tfx-missed { from { transform: scale(1.5); opacity: 0; } 40% { opacity: 1; } to { transform: scale(1); opacity: 0; } }
.square.tfx-correct .piece, .square.tfx-answer .piece { animation: tfx-hop .5s calc(var(--tfx-d, 0ms) + .12s) cubic-bezier(.3, 1.6, .5, 1) backwards; }
@keyframes tfx-hop { 40% { transform: translateY(-14%) scale(1.08); } }

/* Caixa de resumo entra deslizando; a perfeita ganha brilho verde. */
.summary-box.tfx-in { animation: tfx-box .45s cubic-bezier(.2, .9, .3, 1.15) backwards; }
@keyframes tfx-box { from { transform: translateY(10px) scale(.97); opacity: 0; } }
.summary-box.perfect.tfx-in { animation: tfx-box .45s cubic-bezier(.2, .9, .3, 1.15) backwards, tfx-perfect 1.6s .3s ease-out; }
@keyframes tfx-perfect { 0% { box-shadow: inset 4px 0 0 var(--green), 0 0 0 0 rgba(129, 182, 76, .55); } 100% { box-shadow: inset 4px 0 0 var(--green), 0 0 0 18px rgba(129, 182, 76, 0); } }
.summary-box.perfect.tfx-in .summary-msg {
  background: linear-gradient(90deg, #fff, #d9f99d 40%, #81b64c 55%, #fff); background-size: 220% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: tfx-shine 1.6s .35s ease-out backwards;
}
@keyframes tfx-shine { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* XP no topo. */
.xp-progress-container.tfx-xp-glow { animation: tfx-xp-glow 1.2s .2s ease-out; }
@keyframes tfx-xp-glow { 30% { box-shadow: 0 0 0 2px rgba(129, 182, 76, .7), 0 0 14px rgba(129, 182, 76, .7); } }
.tfx-xp-float {
  position: fixed; translate: -50% 0; z-index: 2; pointer-events: none; white-space: nowrap;
  font: 800 .85rem/1 system-ui, sans-serif; color: #d9f99d; text-shadow: 0 0 8px rgba(129, 182, 76, .9), 0 1px 2px #000;
  animation: tfx-xp-float 1.6s cubic-bezier(.2, .8, .2, 1) forwards;
}
@keyframes tfx-xp-float { from { transform: translateY(8px) scale(.7); opacity: 0; } 18% { transform: translateY(0) scale(1.1); opacity: 1; } 70% { opacity: 1; } to { transform: translateY(18px); opacity: 0; } }
.level-pill.tfx-lvlup { animation: tfx-lvl .9s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes tfx-lvl { 30% { transform: scale(1.35); box-shadow: 0 0 18px rgba(253, 224, 71, .9); } }

@media (prefers-reduced-motion: reduce) {
  .square.tfx-mark, .square.tfx-mark .piece, .square.tfx-missed::before, .summary-box.tfx-in,
  .summary-box.tfx-in .summary-msg, .xp-progress-container, .tfx-xp-float, .level-pill { animation: none !important; }
}

/* No resultado a cor da marcação manda: o vermelho de "selecionada" não cobre o verde do acerto. */
.square[class*="mark-"].selected::after { display: none; }
.square.mark-correct.selected, .square.mark-wrong.selected { box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .55); }
