/* Scratch-off card — styles for the vanilla Scratcher component
 * (js/scratcher.js), adapted from the scratcher-package overlay CSS.
 * NY Lottery build: the card runs full-bleed (override in styles.css) and the
 * reveal layer hosts the trivia screen. Tokens come from styles.css. */

/* ------------------------------------------------------------------ */
/* Card + reveal layer (beneath the scratch surface).                  */
/* ------------------------------------------------------------------ */
.scratcher-card {
  position: relative;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  overflow: hidden;
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-hard);
  background: var(--ny-blue-dk);
  /* The whole card (border, background, contents) starts invisible and fades
   * in as one unit once it has painted at its final size — see scratcher.js.
   * Sizing happens while invisible, so there is no slide and no sizing flash. */
  opacity: 0;
  transition: opacity 0.35s ease;
}

.scratcher-card.is-ready {
  opacity: 1;
}

/* Stage wraps the reveal + scratch overlay. No entrance animation of its own —
 * the parent card fades the whole unit in together. */
.scratcher-stage {
  position: absolute;
  inset: 0;
  z-index: 5;
}

.scratcher-reveal {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: var(--holly-dk);
}

/* ------------------------------------------------------------------ */
/* Scratch overlay (canvas surface the player rubs away).              */
/* ------------------------------------------------------------------ */
.av8s-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* No radius here — the parent .scratcher-card has overflow:hidden + a 3px
     border, so it clips children to its INNER radius (16 - 3 = 13px). Declaring
     16px on the overlay/canvas made the corner curves disagree with that clip
     and left a sliver. Let the card own all corner rounding. */
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.av8s-overlay--hidden {
  opacity: 0;
  /* Let the revealed trivia receive taps the moment the fade starts. */
  pointer-events: none;
}

/* Canvas dimensions are set from paint() (with !important) — this rule
 * intentionally does NOT set width/height to avoid any aspect mismatch. */
.av8s-scratch-canvas {
  position: absolute;
  top: 0;
  left: 0;
  cursor: crosshair;
}

.av8s-particle-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

.av8s-shimmer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.av8s-shimmer-sweep {
  position: absolute;
  inset: 0;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    135deg,
    transparent 0%,
    transparent 30%,
    rgba(255, 255, 255, 0.25) 50%,
    transparent 70%,
    transparent 100%
  );
  animation: av8s-shimmer 1.5s ease-in-out forwards;
}

@keyframes av8s-shimmer {
  0% {
    transform: translateX(-100%) translateY(-100%);
    opacity: 1;
  }
  80% {
    transform: translateX(80%) translateY(80%);
    opacity: 1;
  }
  100% {
    transform: translateX(100%) translateY(100%);
    opacity: 0;
  }
}

.av8s-reveal-btn {
  /* Accessibility / boardroom-mouse fallback: fades in after 5s. */
  position: absolute;
  bottom: 24px;
  z-index: 10;
  padding: 8px 24px;
  border: none;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #ffffff;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  /* Without this the button is invisible but still tabbable, so keyboard focus
   * lands on nothing the player can see. */
  visibility: hidden;
  transition: opacity 0.5s ease, transform 0.5s ease, background 0.3s ease,
    visibility 0s linear 0.5s;
}

.av8s-reveal-btn:hover {
  background: rgba(255, 255, 255, 0.34);
}

.av8s-reveal-btn--visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  visibility: visible;
  transition: opacity 0.5s ease, transform 0.5s ease, background 0.3s ease,
    visibility 0s;
}

/* ------------------------------------------------------------------ */
/* "Swipe to reveal" hint — animated finger + label over the surface.  */
/* Sits above the canvas; pointer-events:none so scratches pass through.*/
/* ------------------------------------------------------------------ */
.scratch-hint {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  transition: opacity 0.3s ease;

  /* ---- the gesture's safe zone -------------------------------------------
   * The hand travels 200x90px and is itself 52x65, so the ink it can ever
   * cover is exactly 252x155. That box is RESERVED: the animation owns it and
   * host content must not be placed inside it. Anything a host adds goes in
   * .scratch-hint-slot--top / --bottom, which are sized off these same
   * variables and therefore stop where the zone starts.
   *
   * Retuning: change --scratch-zone-top to move the gesture up or down. Only
   * change the width/height if you also change the travel in HINT_KEYS or the
   * hand's width in .scratch-hint-finger — they describe the same rectangle,
   * and the trail canvas is sized from them. */
  /* Path box: 200x90 of travel plus the 52x65 hand. */
  --scratch-zone-w: 252px;
  --scratch-zone-h: 155px;
  --scratch-zone-top: 45%;
  /* The tail scatters sideways off the path (TRAIL_SPREAD in scratcher.js), so
   * the reserved box is the path box plus that margin on every side — the trail
   * canvas is the zone, and anything drawn outside it is clipped. */
  --scratch-zone-pad: 15px;
}

.scratch-hint-zone {
  position: absolute;
  /* Grown by the pad in all four directions, and pulled back by the same
     amount, so the PATH still starts exactly at --scratch-zone-top. */
  top: calc(var(--scratch-zone-top) - var(--scratch-zone-pad));
  left: 50%;
  transform: translateX(-50%);
  width: calc(var(--scratch-zone-w) + 2 * var(--scratch-zone-pad));
  height: calc(var(--scratch-zone-h) + 2 * var(--scratch-zone-pad));
}

/* Host slots: full width, clamped to the bands outside the zone. Laid out as
   centred flex boxes so dropping in an <img> or a line of text just works.
   pointer-events stay off — the whole hint is click-through to the canvas. */
.scratch-hint-slot {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  overflow: hidden;
}
/* Clamped to the PADDED zone, not the path box — the scatter margin is part of
   what the animation owns, so host content stops outside it too. */
.scratch-hint-slot--top {
  top: 0;
  height: calc(var(--scratch-zone-top) - var(--scratch-zone-pad));
}
.scratch-hint-slot--bottom {
  top: calc(var(--scratch-zone-top) + var(--scratch-zone-h) + var(--scratch-zone-pad));
  bottom: 0;
}

.scratch-hint--hidden {
  opacity: 0;
}

/* Finger traces the scratching gesture: three diagonal passes stepping down,
   so it reads as a zig-zag rather than one long sideways drag. It sits at the
   zone's origin — the zone is what positions the gesture on the card, so this
   needs no offsets of its own. Position is left/top, never transform: the
   animation owns transform. */
.scratch-hint-finger {
  position: absolute;
  /* Inset by the scatter pad so the PATH origin, not the padded box, is what
     --scratch-zone-top positions. scratcher.js reads these back via offsetLeft
     / offsetTop, so the trail follows automatically. */
  top: var(--scratch-zone-pad);
  left: var(--scratch-zone-pad);
  width: 52px;
  filter: drop-shadow(2px 3px 3px rgba(0, 0, 0, 0.4));
  /* The swipe animation lives in scratcher.js (HINT_KEYS) — the trail reads the
   * same table, which is the only way the two stay in step across engines.
   * Declaring it here as well would double-animate the hand. */
}

.scratch-hint-finger img {
  display: block;
  width: 100%;
  height: auto;
}

/* Motion trail: a particle canvas spanning the whole hint box. scratcher.js
   samples the fingertip's own animated position into it, so nothing here has
   to know where the path runs — the old one needed a hand-computed left offset
   (50% - 106.62px) kept in sync with both the hand size and the travel
   distance, and it silently misaligned whenever either moved. */
.scratch-hint-trail {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* "SWIPE TO REVEAL!" arched on an SVG textPath (see scratcher.js). */
.scratch-hint-text {
  order: 0;                 /* top of the card */
  width: 96%;
  max-width: 283px;
  filter: drop-shadow(2px 3px 2px rgba(0, 0, 0, 0.45));
}

.scratch-hint-text svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.scratch-hint-text text {
  font-family: var(--font-head);
  font-size: 30px;
  letter-spacing: 0.5px;
  fill: #ffffff;
}



@media (prefers-reduced-motion: reduce) {
  .av8s-shimmer-sweep {
    animation: none;
    display: none;
  }
  .av8s-overlay,
  .av8s-reveal-btn {
    transition: none;
  }
  .scratcher-card {
    transition: none;
  }
  /* Keep the hint visible but static — no swipe, no trail. */
  .scratch-hint-finger {
    animation: none;
    transform: none;
  }
  .scratch-hint-trail {
    display: none;
  }
}
