/**
 * Fight coach — eval bar + cinematic move-quality bursts.
 */

/* ── Eval bar (right edge of board deck) ── */
.chess-eval-bar {
  position: absolute;
  right: -14px;
  top: 12%;
  bottom: 12%;
  width: 12px;
  z-index: 45;
  pointer-events: none;
  display: none;
}
.chess-eval-bar.is-on,
.chess-eval-bar:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
body.eval-bar-on .chess-eval-bar {
  display: flex;
}
.chess-eval-bar__track {
  flex: 1 1 auto;
  width: 10px;
  border-radius: 6px;
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}
.chess-eval-bar__fill {
  width: 100%;
  height: 50%;
  background: linear-gradient(180deg, #f5f5f0 0%, #e8e4d4 100%);
  transition: height 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.chess-eval-bar__lab {
  font: 600 0.55rem/1 "Courier New", monospace;
  color: #9fdfb0;
  text-shadow: 0 1px 2px #000;
  min-width: 2rem;
  text-align: center;
}

/* Toggle button in controls */
#chess-eval-toggle.is-on,
#chess-coach-toggle.is-on {
  border-color: rgba(0, 255, 136, 0.55) !important;
  color: #3dffa0 !important;
  box-shadow: 0 0 10px rgba(0, 255, 136, 0.2);
}

/* Live multiplayer: force-hide evaluation bar (no engine edge UI) */
body.is-live-mode .chess-eval-bar,
body.is-live-mode #chess-eval-bar,
body.is-live-mode.eval-bar-on .chess-eval-bar {
  display: none !important;
  visibility: hidden !important;
}
body.is-live-mode #chess-eval-toggle {
  display: none !important;
}
/* Hits toggle mutes soft bursts — blunder full-screen is separate & always local */
body.coach-toast-off .chess-coach-fx {
  display: none !important;
}

/* ── Full-screen BLUNDER alert (LOCAL ONLY — this browser) ── */
.chess-blunder-flash {
  position: fixed;
  inset: 0;
  z-index: 16000;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
  background: radial-gradient(
    ellipse 70% 55% at 50% 45%,
    rgba(120, 0, 0, 0.55) 0%,
    rgba(40, 0, 0, 0.35) 45%,
    transparent 72%
  );
}
.chess-blunder-flash.is-on {
  opacity: 1;
  visibility: visible;
  animation: blunder-screen-pulse 2.1s ease-out forwards;
}
.chess-blunder-flash__panel {
  text-align: center;
  padding: 1.1rem 1.6rem 1rem;
  border-radius: 12px;
  border: 2px solid rgba(255, 70, 70, 0.85);
  background: rgba(12, 0, 0, 0.88);
  box-shadow:
    0 0 40px rgba(255, 40, 40, 0.45),
    0 0 0 1px rgba(0, 0, 0, 0.6) inset;
  max-width: min(92vw, 360px);
  transform: scale(0.92);
}
.chess-blunder-flash.is-on .chess-blunder-flash__panel {
  animation: blunder-panel-pop 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.chess-blunder-flash__title {
  font: 900 clamp(1.6rem, 6vw, 2.4rem)/1 "Courier New", ui-monospace, monospace;
  letter-spacing: 0.22em;
  color: #ff4a4a;
  text-shadow:
    0 0 24px rgba(255, 50, 50, 0.9),
    0 2px 0 #400;
}
.chess-blunder-flash__sub {
  margin-top: 0.55rem;
  font: 700 0.78rem/1.35 "Courier New", monospace;
  letter-spacing: 0.06em;
  color: #ffc0c0;
}
.chess-blunder-flash__hint {
  margin-top: 0.45rem;
  font: 600 0.58rem/1 "Courier New", monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 180, 180, 0.55);
}
@keyframes blunder-screen-pulse {
  0% {
    opacity: 0;
  }
  8% {
    opacity: 1;
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}
@keyframes blunder-panel-pop {
  0% {
    transform: scale(0.7);
    opacity: 0;
  }
  35% {
    transform: scale(1.06);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Puzzle-mob HP bar (map tactic fights) */
.chess-mob-hp-bar {
  height: 8px;
  margin: 0.25rem 0 0.35rem;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 80, 80, 0.35);
  overflow: hidden;
  max-width: 220px;
}
.chess-mob-hp-bar__fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff3b3b, #ff8844);
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 0 8px rgba(255, 60, 40, 0.45);
}

/* ── Cinematic coach FX layer ── */
.chess-coach-fx {
  position: fixed;
  inset: 0;
  z-index: 14000;
  pointer-events: none;
  overflow: hidden;
}

.chess-coach-burst {
  position: fixed;
  transform: translate(-50%, -50%) scale(0.55);
  opacity: 0;
  will-change: transform, opacity;
}
.chess-coach-burst.is-on {
  animation: coach-burst-rise 1.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.chess-coach-burst__label {
  display: block;
  font: 800 0.95rem/1.1 "Courier New", ui-monospace, monospace;
  letter-spacing: 0.14em;
  text-align: center;
  text-shadow:
    0 0 18px currentColor,
    0 2px 8px rgba(0, 0, 0, 0.85);
  white-space: nowrap;
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.6));
}
.chess-coach-burst__ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0.85;
  animation: coach-ring 1.1s ease-out forwards;
}
.chess-coach-burst__spark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 5px;
  margin: -2px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
  opacity: 0;
}
.chess-coach-burst.is-on .chess-coach-burst__spark.s1 {
  animation: coach-spark 0.9s ease-out 0.05s forwards;
  --dx: -28px;
  --dy: -36px;
}
.chess-coach-burst.is-on .chess-coach-burst__spark.s2 {
  animation: coach-spark 0.9s ease-out 0.08s forwards;
  --dx: 32px;
  --dy: -30px;
}
.chess-coach-burst.is-on .chess-coach-burst__spark.s3 {
  animation: coach-spark 0.95s ease-out 0.1s forwards;
  --dx: -22px;
  --dy: 26px;
}
.chess-coach-burst.is-on .chess-coach-burst__spark.s4 {
  animation: coach-spark 0.95s ease-out 0.12s forwards;
  --dx: 26px;
  --dy: 30px;
}

/* Palette by quality */
.chess-coach-burst.is-brilliant {
  color: #7cf7ff;
}
.chess-coach-burst.is-brilliant .chess-coach-burst__label {
  font-size: 1.05rem;
  letter-spacing: 0.18em;
}
.chess-coach-burst.is-great {
  color: #5ad4ff;
}
.chess-coach-burst.is-best {
  color: #3dffa0;
}
.chess-coach-burst.is-excellent {
  color: #7dffb0;
}
.chess-coach-burst.is-good {
  color: #b8e0c8;
}
.chess-coach-burst.is-inaccuracy {
  color: #f0d060;
}
.chess-coach-burst.is-mistake {
  color: #ff9a4a;
}
.chess-coach-burst.is-blunder {
  color: #ff5a5a;
}
.chess-coach-burst.is-blunder .chess-coach-burst__label {
  animation: coach-shake 0.45s ease;
}

@keyframes coach-burst-rise {
  0% {
    opacity: 0;
    transform: translate(-50%, -40%) scale(0.4);
  }
  12% {
    opacity: 1;
    transform: translate(-50%, -55%) scale(1.12);
  }
  55% {
    opacity: 1;
    transform: translate(-50%, -120%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -170%) scale(0.92);
  }
}
@keyframes coach-ring {
  0% {
    transform: scale(0.4);
    opacity: 0.9;
  }
  100% {
    transform: scale(3.2);
    opacity: 0;
  }
}
@keyframes coach-spark {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(0.2);
  }
}
@keyframes coach-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-3px);
  }
  75% {
    transform: translateX(3px);
  }
}

/* Board host positioning for eval bar */
#chess-flight-deck,
.arena-float-panel[data-float-id='board'] {
  position: relative;
}

@media (max-width: 720px) {
  .chess-eval-bar {
    right: 4px;
    width: 10px;
    top: 18%;
    bottom: 18%;
  }
  .chess-coach-burst__label {
    font-size: 0.78rem;
  }
}
