/* "Being watched" overlay shown to the DEFENDER while an opponent peeks at
 * (Spy) or discards from (Sabotage) their hand. main.js
 * (updateSpyWatchOverlay) appends the overlay INSIDE the defender's visible
 * hand-container, so CSS positioning (absolute inset:0) keeps it aligned
 * through the board's responsive transforms.
 *
 * Treatment: a hooded enemy leans in over your hand (swaying, eyes aglow),
 * your cards tilt back to "present" themselves to him, and an aged-parchment
 * plaque names what's happening. Spy = cool blue; Sabotage = blood red. */

.hand-container {
  position: relative; /* anchor for .spy-watch-overlay */
}

.spy-watch-overlay {
  position: absolute;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.spy-watch-overlay.active {
  opacity: 1;
}

/* Torchlit shadow falling across the hand. */
.spy-watch-veil {
  position: absolute;
  inset: -8px;
  border-radius: 14px;
  background: radial-gradient(
    130% 100% at 50% 25%,
    transparent 45%,
    rgba(0, 0, 0, 0.34) 100%
  );
  animation: spyWatchFlicker 3.2s ease-in-out infinite;
}
.spy-watch-overlay.sabotage .spy-watch-veil {
  background: radial-gradient(
    130% 100% at 50% 25%,
    transparent 42%,
    rgba(70, 0, 0, 0.4) 100%
  );
}

/* The hooded enemy leaning in over your hand — sits IN FRONT of the cards. */
.spy-watch-peer {
  position: absolute;
  left: 50%;
  top: -24px; /* drapes down over the top of the cards */
  transform: translateX(-50%);
  z-index: 5; /* above the parchment plaque and the cards */
  opacity: 0;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.6));
  animation: spyWatchPeerIn 0.5s ease 0.05s forwards;
}
.spy-watch-figure {
  display: block;
  font-size: 4.2rem;
  transform-origin: bottom center;
  animation: spyWatchSway 3.2s ease-in-out infinite;
}
.spy-watch-overlay.spy .spy-watch-figure {
  color: #15263a;
  text-shadow:
    0 0 16px rgba(90, 160, 215, 0.9),
    0 0 5px rgba(170, 210, 245, 0.95);
}
.spy-watch-overlay.sabotage .spy-watch-figure {
  color: #280b0b;
  text-shadow:
    0 0 16px rgba(215, 60, 60, 0.95),
    0 0 5px rgba(245, 150, 150, 0.95);
}

/* Aged-parchment plaque, held front-and-center so the enemy's head/eyes
 * rise just above it. */
.spy-watch-banner {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px 7px 9px;
  white-space: nowrap;
  border-radius: 6px;
  font-family: "Cinzel", serif;
  color: #3a2a16;
  background: linear-gradient(180deg, #efe3c2 0%, #e3d2a6 55%, #d4be8e 100%);
  border: 1px solid #6b4f2a;
  box-shadow:
    0 3px 0 rgba(0, 0, 0, 0.22),
    0 8px 18px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 0 18px rgba(120, 86, 40, 0.25);
  animation: spyWatchBannerIn 0.35s ease;
}

/* Wax-seal style emblem. */
.spy-watch-emblem {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #f3e9cf;
  box-shadow:
    inset 0 -2px 4px rgba(0, 0, 0, 0.4),
    0 1px 2px rgba(0, 0, 0, 0.4);
}
.spy-watch-overlay.spy .spy-watch-emblem {
  background: radial-gradient(circle at 35% 30%, #4a6b86, #2c4760);
  border: 1px solid #1c2f42;
}
.spy-watch-overlay.sabotage .spy-watch-emblem {
  background: radial-gradient(circle at 35% 30%, #a83232, #7a1414);
  border: 1px solid #4f0d0d;
}
.spy-watch-icon {
  font-size: 1rem;
  animation: spyWatchEmblemPulse 1.6s ease-in-out infinite;
}

.spy-watch-label {
  display: flex;
  flex-direction: column;
  line-height: 1.12;
}
.spy-watch-title {
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.spy-watch-overlay.spy .spy-watch-title {
  color: #2c4760;
}
.spy-watch-overlay.sabotage .spy-watch-title {
  color: #7a1414;
}
.spy-watch-sub {
  font-size: 0.76rem;
  font-family: "Oswald", sans-serif;
  color: #4a3a22;
}

/* Cards tilt back to "present" themselves to the looming enemy, and dim. */
.cwl-being-spied #game .hands .hand,
.cwl-being-sabotaged #game .hands .hand {
  transform: perspective(900px) rotateX(8deg);
  transform-origin: bottom center;
  transition: transform 0.45s ease;
}
.cwl-being-spied .hands .card-container,
.cwl-being-sabotaged .hands .card-container {
  filter: brightness(0.8) saturate(0.9);
  transition: filter 0.3s ease;
}

@keyframes spyWatchPeerIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-22px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes spyWatchSway {
  0%,
  100% {
    transform: rotate(-3.5deg) translateY(0);
  }
  50% {
    transform: rotate(3.5deg) translateY(-3px);
  }
}

@keyframes spyWatchFlicker {
  0%,
  100% {
    opacity: 0.85;
  }
  45% {
    opacity: 1;
  }
  60% {
    opacity: 0.78;
  }
}

@keyframes spyWatchEmblemPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.14);
  }
}

@keyframes spyWatchBannerIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spy-watch-veil,
  .spy-watch-figure,
  .spy-watch-peer,
  .spy-watch-icon,
  .spy-watch-banner {
    animation: none;
  }
  .spy-watch-peer {
    opacity: 1;
  }
}
