/* MonkHero — animated homepage hero.
 * Layout + sprite base styles only. All per-frame motion (transform/opacity) is
 * written imperatively by the rAF loop in src/hero-components/MonkHero.tsx. */

.monk-hero {
  --monk-hero-h: 420px;
  --monk-hero-bg: var(--neutral);
  --monk-hero-bg-hover: #3ba4e2;
  position: relative;
  /* Contain the sprites' depth z-indexes to this hero so they can't paint over
   * page-level UI (modals, dropdowns, etc.). */
  isolation: isolate;
  width: 100%;
  height: var(--monk-hero-h);
  margin: 0 auto;
  max-width: 1200px;
  /* NB: clipping lives on .monk-hero__stage, not here, so the transformed
   * countdown can overflow the hero box without being cropped. */
  background-color: var(--monk-hero-bg);
  transition: background-color 0.4s ease;
  background-image: url('../assets/hero/monk/background.webp');
  background-repeat: no-repeat;
  background-position: calc(50% + 20px) bottom;
  background-size: 500px auto;
  display: block;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.monk-hero:hover {
  --monk-hero-bg: var(--monk-hero-bg-hover);
}

/* Countdown overlay — sits above the crowd; non-interactive so hover/clicks pass
 * through to the crowd sim and the wrapping link. */
.monk-hero__countdown {
  position: absolute;
  top: 2.25rem;
  left: 50%;
  transform: translateX(calc(-50% - 32px)) rotate(-11deg) skewX(-12deg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
  text-align: center;
}

.monk-hero__cd-row {
  display: flex;
  gap: 0.4rem;
  transition: gap 0.4s ease;
  /* fake perspective: tilt the row so the left units recede (smaller) and the
   * right units come forward (bigger). Self-contained via the perspective()
   * function (not the perspective property) so it doesn't clip against the
   * skewed/rotated parent. Flip the rotateY sign to reverse the direction. */
  transform: perspective(370px) rotateY(-24deg);
}

.monk-hero:hover .monk-hero__cd-row {
  gap: 1rem;
}

.monk-hero__cd-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 3rem;
  padding: 0.4rem 0.5rem;
  background-color: var(--monk-hero-bg);
  transition: background-color 0.4s ease;
  border: 2px solid #000;
  border-radius: 0.6rem;
  backdrop-filter: blur(3px);
}

.monk-hero__cd-num {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--neutral-darkest);
  font-variant-numeric: tabular-nums;
}

.monk-hero__cd-label {
  margin-top: 0.2rem;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--neutral-darkest);
}

.monk-hero__cd-live {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--neutral-darkest);
}

.monk-hero__stage {
  position: absolute;
  inset: 0;
  /* crop the walking sprites to the hero's (rounded) box */
  overflow: hidden;
  border-radius: inherit;
  /* let vertical page scroll through on touch while we still get pointermove */
  touch-action: pan-y;
}

.monk-hero__sprite {
  position: absolute;
  top: 0;
  left: 0;
  /* sized in px by the loop; hidden until first placed */
  opacity: 0;
  visibility: hidden;
  will-change: transform, opacity;
  transform-origin: 50% 100%;
  pointer-events: none; /* hit-testing is handled on the stage, not per sprite */
  user-select: none;
  -webkit-user-drag: none;
}

/* Margin + rounded corners only once the stage stops being full-bleed. */
@media (min-width: 1200px) {
  .monk-hero {
    margin-top: 1rem;
    margin-bottom: 1rem;
    border-radius: 1rem;
  }
}

/* Respect reduced-motion: MonkHero renders a single static frame and never
 * animates, so nothing extra is needed here, but keep transitions off. */
@media (prefers-reduced-motion: reduce) {
  .monk-hero__sprite {
    transition: none !important;
  }
}
