/* ===========================================================================
   main-15 — ZIELWAHL
   Wenn ein Effekt erst fragt, WELCHE Figur ihn ausfuehrt (state.pendingPickAction,
   z. B. zwei Quartiermeister beim Positionswechsel), zeigt das Brett die
   Kandidaten ruhig und eindeutig: ein leuchtender Runenring im Faehigkeits-Blau
   unter der Figur, der Rest der Armee tritt leicht zurueck. Keine Pfeile, keine
   Ausrufezeichen. JS-Gegenstueck: appendPickCandidateMarker in render/square.js.
   =========================================================================== */

#board {
  --mp-ability: 77, 208, 196;
}

/* Kandidat: Runenring am Fuss der Figur. Liegt unter der Figur (chip z 1). */
#board .sq .pickCandidateMarker {
  position: absolute;
  inset: auto auto 10% 50%;
  width: 74%;
  height: 24%;
  z-index: 0;
  pointer-events: none;
  translate: -50% 0;
  border-radius: 50%;
  border: 1.5px solid rgba(var(--mp-ability), .85);
  background: radial-gradient(ellipse at center,
    rgba(var(--mp-ability), .34) 0%, rgba(var(--mp-ability), .12) 55%, transparent 72%);
  box-shadow:
    0 0 14px rgba(var(--mp-ability), .45),
    inset 0 0 10px rgba(var(--mp-ability), .35);
  animation:
    mpPickRingIn .38s cubic-bezier(.2, 1.4, .4, 1) both,
    mpPickRingBreath 2.6s ease-in-out infinite;
  /* --mp-t: bereits verstrichene Zeit (render/anim-clock.js), damit Hover-
     Re-Renders die Animation nicht neu starten. */
  animation-delay: var(--mp-t, 0ms), calc(.38s + var(--mp-t, 0ms));
  transition: border-color .2s ease, box-shadow .2s ease, width .2s ease;
}
/* Zweiter, feiner Ring, der langsam nach aussen ausklingt: "hier waehlen". */
#board .sq .pickCandidateMarker::after {
  content: "";
  position: absolute;
  inset: -1.5px;
  border-radius: inherit;
  border: 1px solid rgba(var(--mp-ability), .7);
  animation: mpPickRipple 2.6s ease-out infinite;
  animation-delay: calc(.38s + var(--mp-t, 0ms));
}

/* Die Kandidaten selbst: ruhiger blauer Schein statt goldenem Pulsrahmen. */
#board .sq.pickCandidate .chip {
  animation: none;
  box-shadow: none;
}
#board .sq.pickCandidate .chip .pieceAsset {
  filter:
    drop-shadow(0 5px 4px rgba(0, 0, 0, .68))
    drop-shadow(0 0 9px rgba(var(--mp-ability), .55));
}
#board .sq.pickCandidate { cursor: var(--mp-cur-pointer); }

/* Hover: Figur hebt sich, Ring wird klar und breiter. */
#board .sq.pickCandidate:hover .chip {
  translate: 0 -6%;
  scale: 1.06;
}
#board .sq.pickCandidate:hover .pickCandidateMarker {
  width: 84%;
  border-color: rgba(150, 240, 230, 1);
  box-shadow:
    0 0 22px rgba(var(--mp-ability), .75),
    inset 0 0 14px rgba(var(--mp-ability), .5);
}

/* Alle anderen Figuren treten zurueck, damit die Wahl sofort klar ist. */
#board .sq .chip .pieceAsset {
  transition: filter .28s ease;
}
#board:has(.sq.pickCandidate) .sq:not(.pickCandidate) .chip .pieceAsset {
  filter: drop-shadow(0 5px 4px rgba(0, 0, 0, .6)) brightness(.62) saturate(.65);
}
#board:has(.sq.pickCandidate) .sq:not(.pickCandidate) .auraGlow,
#board:has(.sq.pickCandidate) .sq:not(.pickCandidate) .statusBadge,
#board:has(.sq.actionTarget) .sq:not(.actionTarget):not(.actionActor) .auraGlow,
#board:has(.sq.actionTarget) .sq:not(.actionTarget):not(.actionActor) .statusBadge {
  opacity: .25;
}

/* Zweiter Schritt (Ziel waehlen): dieselbe Sprache. Figuren, die als Ziel in
   Frage kommen, bekommen den Ring statt eines Leuchtflecks auf dem Bauch;
   die gewaehlte Figur behaelt ihren Schein, alles andere tritt zurueck. */
#board .sq.actionSourceTarget:has(.chip)::after {
  inset: auto auto 10% 50%;
  width: 74%;
  height: 24%;
  z-index: 0;
  translate: -50% 0;
  border-radius: 50%;
  border: 1.5px solid rgba(var(--mp-ability), .75);
  background: radial-gradient(ellipse at center,
    rgba(var(--mp-ability), .26) 0%, rgba(var(--mp-ability), .08) 55%, transparent 72%);
  box-shadow: 0 0 12px rgba(var(--mp-ability), .4);
  animation:
    mpPickRingIn .38s cubic-bezier(.2, 1.4, .4, 1) both,
    mpPickRingBreath 2.6s ease-in-out infinite;
  /* --mp-t: bereits verstrichene Zeit (render/anim-clock.js), damit Hover-
     Re-Renders die Animation nicht neu starten. */
  animation-delay: var(--mp-t, 0ms), calc(.38s + var(--mp-t, 0ms));
  transition: border-color .2s ease, box-shadow .2s ease, width .2s ease;
}
#board .sq.actionSourceTarget:has(.chip):hover::after {
  width: 84%;
  border-color: rgba(150, 240, 230, 1);
  box-shadow: 0 0 22px rgba(var(--mp-ability), .75);
}
#board .sq.actionSourceTarget:has(.chip):hover .chip {
  translate: 0 -6%;
  scale: 1.06;
}
#board:has(.sq.actionTarget) .sq:not(.actionTarget):not(.actionActor) .chip .pieceAsset {
  filter: drop-shadow(0 5px 4px rgba(0, 0, 0, .6)) brightness(.62) saturate(.65);
}

/* Nach einem Effekt: statt des dicken, je Faehigkeit anders gefaerbten
   Kachelrahmens (main-03, oft Lila) steigt am Fuss jeder betroffenen Figur
   ein Runenring auf (board-effect-ring.js, FX-Ebene ueber dem Brett). Der
   hintere Bogen ist nur angedeutet, der vordere laeuft vor dem Sockel. */
#board .sq.abilityFlash { animation: none; }

#boardRingLayer { position: fixed; inset: 0; z-index: 59; pointer-events: none; }
.boardFx-effectRing {
  position: fixed;
  pointer-events: none;
  border-radius: 50%;
  border: 2px solid rgba(var(--fx-ring-rgb), .95);
  border-top-color: rgba(var(--fx-ring-rgb), .22);
  background: radial-gradient(ellipse at center,
    rgba(var(--fx-ring-rgb), .22) 0%, rgba(var(--fx-ring-rgb), .06) 55%, transparent 72%);
  box-shadow: 0 3px 14px -2px rgba(var(--fx-ring-rgb), .75);
  opacity: 0;
  animation: mpFlashRing 1s cubic-bezier(.2, .8, .3, 1) both;
}
.boardFx-effectRing::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  border: 1.5px solid rgba(var(--fx-ring-rgb), .8);
  border-top-color: transparent;
  animation: mpFlashRipple 1s ease-out .08s both;
}

@keyframes mpFlashRing {
  0%   { opacity: 0; transform: scale(.4); }
  25%  { opacity: 1; transform: scale(1.05); }
  45%  { transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}
@keyframes mpFlashRipple {
  0%   { opacity: .9; transform: scale(1); }
  100% { opacity: 0;  transform: scale(1.6, 2); }
}

/* Hover auf die Effektkarte: Kandidaten mit blauen statt goldenen Ecken. */
#board .sq.effectHover::after {
  --effect-corner-gold: rgba(var(--mp-ability), .85);
}

@keyframes mpPickRingIn {
  from { opacity: 0; transform: scale(.55); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes mpPickRingBreath {
  0%, 100% { opacity: .82; }
  50%      { opacity: 1; }
}
@keyframes mpPickRipple {
  0%   { opacity: .7; transform: scale(1); }
  70%  { opacity: 0;  transform: scale(1.32, 1.5); }
  100% { opacity: 0;  transform: scale(1.32, 1.5); }
}

/* Fremde Passiv-Aura (render/chip-status.js appendAuraGlow): ersetzt das kleine
   ▴/▾-Abzeichen oben links (main-03). Unter der Figur liegt ein feiner Ring
   flach auf dem Boden (Kreis, per scaleY in die Brett-Perspektive gekippt), ein
   Glanzlicht umrundet die Figur. Alle Glanzlichter laufen an der Wanduhr
   (data-anim-period) im Gleichtakt und starten beim Hover nicht neu.
   - verstaerkt (Kapitaen, Erzbischof, General): Haarlinie im Faehigkeits-Blau.
   - geschwaecht (Lich, Faenger): violetter Ring, das Glanzlicht kreist gegenlaeufig,
     die Figur wird fahl wie am Ende der Verfall-Animation (board-fx-decay.js).
   Liegt unter der Figur (z -1 im Chip): der hintere Bogen verschwindet hinter
   dem Sockel, der vordere laeuft davor über den Boden. */
#board .chip .auraGlow {
  position: absolute;
  left: 50%;
  bottom: 1%;
  width: 62%;
  aspect-ratio: 1;
  z-index: -1;
  pointer-events: none;
  translate: -50% 0;
  transform-origin: 50% 100%;
  transform: scaleY(.3);
  border-radius: 50%;
  transition: opacity .28s ease;
  --aura-glint: 110, 230, 220;
  --aura-glint-hi: 190, 255, 248;
}
#board .chip .auraGlow-debuff {
  --aura-glint: 165, 115, 195;
  --aura-glint-hi: 228, 200, 248;
}
#board .chip .auraGlow::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
}
#board .chip .auraGlow-buff::after {
  border: 2px solid rgba(var(--mp-ability), .42);
  background: radial-gradient(circle,
    rgba(var(--mp-ability), .18) 0%, rgba(var(--mp-ability), .06) 50%, transparent 68%);
  box-shadow: 0 0 9px rgba(var(--mp-ability), .22);
}
#board .chip .auraGlow-debuff::after {
  border: 2px solid rgba(160, 115, 185, .45);
  background: radial-gradient(circle,
    rgba(40, 14, 44, .55) 0%, rgba(40, 14, 44, .2) 50%, transparent 68%);
  box-shadow: 0 0 9px rgba(140, 90, 170, .2);
}
#board .chip .auraGlow::before {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: 1;
  border-radius: 50%;
  background: conic-gradient(from 0deg,
    transparent 0deg 230deg,
    rgba(var(--aura-glint), .5) 300deg,
    rgba(var(--aura-glint-hi), .95) 345deg,
    #fff 356deg,
    transparent 360deg);
  -webkit-mask: radial-gradient(farthest-side,
    transparent calc(100% - 5px), #000 calc(100% - 3.5px), #000 calc(100% - 1px), transparent 100%);
  mask: radial-gradient(farthest-side,
    transparent calc(100% - 5px), #000 calc(100% - 3.5px), #000 calc(100% - 1px), transparent 100%);
  animation: mpAuraOrbit 4.8s linear infinite;
  animation-delay: var(--mp-t, 0ms);
}
/* Gegenlaeufig: gespiegelt (Kopf des Glanzlichts vorn) und rueckwaerts gedreht. */
#board .chip .auraGlow-debuff::before {
  scale: -1 1;
  animation-direction: reverse;
}
#board .chip.auraTouched-debuff .pieceAsset {
  filter:
    drop-shadow(0 5px 4px rgba(0, 0, 0, .68))
    brightness(.8) saturate(.55);
}

@keyframes mpAuraOrbit {
  to { rotate: 360deg; }
}

@media (prefers-reduced-motion: reduce) {
  #board .chip .auraGlow::before,
  .boardFx-effectRing,
  .boardFx-effectRing::after,
  #board .sq .pickCandidateMarker,
  #board .sq .pickCandidateMarker::after { animation: none; }
}
