/* REFERENCE
 * - ui/companion/fight-stage.js (builds this DOM)
 * - ui/companion/fight-conductor.js (toggles the state classes)
 * - ui/mote-animation/mote-anim-combat.css (the mote-body combat keyframes)
 *
 * Fight-stage chrome: fixed formation slots, identity tags (name + HP bar
 * with a lagging ghost chunk), target-lock ring, boss-hit camera shake.
 * The identity layer NEVER animates (raid-frame rule: readability comes
 * from a stable frame, motion belongs to the body only).
 */

.fight-stage { position: relative; }

.fight-actor {
  position: absolute;
  translate: -50% -50%;
  display: grid;
  justify-items: center;
  gap: 2px;
  z-index: calc(var(--z-sticky) - 1);
}
.fight-actor__body {
  position: relative;
  scale: var(--mote-scale, 1);
}
.fight-actor--boss { z-index: calc(var(--z-sticky) - 2); }

/* Boss evil kit (RUTTO): eye glints come back RED — glints are the only
   circles inside .mote-eye, so this retint is surgical. */
.mote-fight--boss .mote-eye circle { fill: #FF4B2E; }

/* Ember under-glow: the contrast device that keeps a black boss's
   silhouette alive against dusk scenes — it stands in its own fire. */
.fight-actor--boss .fight-actor__body::before {
  content: "";
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 1%;
  height: 20%;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 50%, rgba(255, 98, 54, 0.5), rgba(232, 68, 42, 0.24) 55%, transparent 72%);
  z-index: -1;
}

/* Identity tag — small, calm, constant */
.fight-actor__tag {
  display: grid;
  justify-items: center;
  gap: 2px;
  pointer-events: none;
}
.fight-actor__name {
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: 10px;
  font-weight: 700;
  color: rgba(247, 241, 226, 0.92);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  max-width: 86px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fight-actor__hp {
  position: relative;
  width: 52px;
  height: 5px;
  border-radius: 3px;
  background: rgba(12, 10, 14, 0.65);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4);
}
.fight-actor__hp-fill,
.fight-actor__hp-ghost {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  border-radius: 3px;
}
.fight-actor__hp-fill { background: linear-gradient(180deg, #a4cf7f, #6d9d51); transition: width 160ms ease-out; }
/* ghost chunk lags so a glance still shows what was just lost */
.fight-actor__hp-ghost { background: rgba(255, 246, 223, 0.55); transition: width 450ms ease-in; }
.fight-actor--boss .fight-actor__hp { width: 96px; height: 7px; }
.fight-actor--boss .fight-actor__hp-fill { background: linear-gradient(180deg, #c8506e, #8c2f3f); }
.fight-actor--boss .fight-actor__name { font-size: 12px; }

/* Target lock — the boss's next victim glows softly */
.mote-target-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
}
.mote-target-ring ellipse {
  fill: none;
  stroke: #dfb668;
  stroke-width: 2.5;
  stroke-dasharray: 6 5;
}
.fight-actor--targeted .mote-target-ring {
  opacity: 1;
  animation: fight-ring-pulse 1.1s ease-in-out infinite;
}
@keyframes fight-ring-pulse {
  0%, 100% { opacity: 0.45; transform: scale(0.97); }
  50% { opacity: 0.95; transform: scale(1.04); }
}

/* KO: the fall itself is TERÄS's anim-fight-ko on the rig node — the
   wrapper only dims the identity tag and zeroes the bar. */
.fight-actor--ko .fight-actor__tag { opacity: 0.45; }
.fight-actor--ko .fight-actor__hp-fill { width: 0 !important; }

/* Boss defeat: heavy topple + fade */
.fight-actor--defeated .fight-actor__body {
  transform-origin: 50% 92%;
  transform: rotate(-72deg);
  opacity: 0.25;
  transition: transform 1.4s cubic-bezier(0.55, 0, 0.85, 0.4), opacity 2s ease 0.6s;
}

/* Camera shake — boss hits only (asymmetric juice rule) */
.fight-stage--shake { animation: fight-shake 260ms ease-out 1; }
@keyframes fight-shake {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-4px, 2px); }
  45% { transform: translate(3px, -2px); }
  70% { transform: translate(-2px, 1px); }
  100% { transform: translate(0, 0); }
}

/* === V2: intent widget / toast / guard / tether / spotlight / freeze === */

/* Boss intent: icon + FILLING charge ring (StS grammar - a filling ring
   is rising threat; a draining bar reads as safety) */
.fight-intent {
  position: absolute;
  width: 44px; height: 44px;
  transform: translate(-50%, -50%) scale(0.6);
  opacity: 0;
  z-index: 95;
  pointer-events: none;
  transition: opacity 220ms ease, transform 260ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.fight-intent--show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.fight-intent__ring { position: absolute; inset: 0; transform: rotate(-90deg); }
.fight-intent__track { fill: rgba(20, 14, 24, 0.72); stroke: rgba(255, 255, 255, 0.18); stroke-width: 3.5; }
.fight-intent__fill { fill: none; stroke: #e8b04b; stroke-width: 3.5; stroke-linecap: round; }
.fight-intent--hot .fight-intent__fill { stroke: #ff5a36; }
.fight-intent--hot { animation: fight-intent-pulse 500ms ease-in-out infinite; }
.fight-intent--dire .fight-intent__fill { stroke: #ff4b2e; }
.fight-intent__icon {
  position: absolute; inset: 9px;
  color: #f5e9d6;
  stroke-width: 2;
  fill: none;
}
.fight-intent--dire .fight-intent__icon { color: #ff9b8a; }
@keyframes fight-intent-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50%      { transform: translate(-50%, -50%) scale(1.14); }
}

/* Ultimate telegraph darkens the whole arena; act-2 enrage warms it */
.pg-scene { transition: filter 500ms ease; }
.fight-stage--dire .pg-scene { filter: brightness(0.72) saturate(0.85); }
.fight-stage--enrage .pg-scene { filter: brightness(0.94) saturate(1.12) hue-rotate(-6deg); }
.fight-stage--enrage.fight-stage--dire .pg-scene { filter: brightness(0.68) saturate(0.9); }

/* Announcer toast - attribution is the product */
.fight-toast {
  position: absolute;
  top: 6%; left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: 3px 12px 4px;
  border-radius: 999px;
  background: rgba(24, 18, 26, 0.82);
  border: 1px solid rgba(232, 176, 75, 0.5);
  color: #f5e9d6;
  font: 700 12px/1.4 "Nunito", "Trebuchet MS", sans-serif;
  letter-spacing: 0.02em;
  opacity: 0;
  z-index: 96;
  pointer-events: none;
  transition: opacity 240ms ease, transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 86%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fight-toast--show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Guard aura: golden shell in front of the holder */
.fight-guard {
  position: absolute;
  left: 50%; top: 46%;
  width: 74%; height: 82%;
  transform: translate(-50%, -50%) scale(0);
  border-radius: 50%;
  border: 3px solid rgba(232, 176, 75, 0.85);
  box-shadow: 0 0 14px rgba(232, 176, 75, 0.45), inset 0 0 10px rgba(232, 176, 75, 0.25);
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}
.fight-actor--guard .fight-guard {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  transition: transform 260ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 180ms ease;
}
/* Blocked hit: spark burst + NO camera shake (absence of trauma IS the read) */
.fight-actor--blocked .fight-guard { animation: fight-block-burst 480ms ease-out 1; }
@keyframes fight-block-burst {
  0%   { box-shadow: 0 0 14px rgba(232, 176, 75, 0.45); transform: translate(-50%, -50%) scale(1); }
  30%  { box-shadow: 0 0 34px rgba(255, 233, 170, 0.95), inset 0 0 22px rgba(255, 233, 170, 0.5); transform: translate(-50%, -50%) scale(1.18); }
  100% { box-shadow: 0 0 10px rgba(232, 176, 75, 0.35); transform: translate(-50%, -50%) scale(1); }
}

/* Taunt tether: dashed aggro line boss -> holder */
.fight-tether { position: absolute; inset: 0; z-index: 4; opacity: 0; transition: opacity 300ms ease; pointer-events: none; }
.fight-tether--on { opacity: 1; }
.fight-tether svg { width: 100%; height: 100%; }
.fight-tether__line {
  stroke: rgba(255, 122, 80, 0.75);
  stroke-width: 0.8;
  stroke-dasharray: 2.5 2;
  animation: fight-tether-crawl 900ms linear infinite;
}
@keyframes fight-tether-crawl { to { stroke-dashoffset: -9; } }

/* Spotlight turns: the acting mote pops, the rest breathe low */
.fight-stage--spot .fight-actor--party:not(.fight-actor--spot) .fight-actor__body { opacity: 0.62; }
.fight-actor--party .fight-actor__body { transition: opacity 220ms ease; }
.fight-actor--spot .fight-actor__tag .fight-actor__name { color: #ffe9b0; }

/* Hit-stop: pause every animation on the stage for the freeze window */
.fight-stage--freeze, .fight-stage--freeze * { animation-play-state: paused !important; }

/* Map ambient hooks (arena art exposes fm-* classes) */
.fm-drift { animation: fm-drift 26s ease-in-out infinite alternate; }
.fm-twinkle { animation: fm-twinkle 3.2s ease-in-out infinite; }
.fm-glow { animation: fm-glow 5s ease-in-out infinite alternate; }
.fm-ember { animation: fm-ember 1.6s ease-in-out infinite alternate; }
@keyframes fm-drift { from { transform: translateX(0); } to { transform: translateX(9px); } }
@keyframes fm-twinkle { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.95; } }
@keyframes fm-glow { from { opacity: 0.55; } to { opacity: 0.95; } }
@keyframes fm-ember { from { opacity: 0.6; transform: scaleY(0.96); } to { opacity: 1; transform: scaleY(1.05); } }

@media (prefers-reduced-motion: reduce) {
  .fight-stage--shake,
  .fight-actor--targeted .mote-target-ring { animation: none !important; }
  .fight-actor--targeted .mote-target-ring { opacity: 0.8; }
  .fight-actor--defeated .fight-actor__body { transition: opacity 400ms ease; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .fight-intent--hot, .fight-tether__line, .fm-drift, .fm-twinkle, .fm-glow, .fm-ember,
  .fight-actor--blocked .fight-guard { animation: none !important; }
  .fight-stage--dire .pg-scene, .fight-stage--enrage .pg-scene { filter: none; }
}
