/* ============================================================================
 * ASHTAR KATKOOT - ADVENTURE 9, ACTIVITY 1: CHOOSE THE SAFE PATH (activity styles)
 *
 * The scene artwork already contains the two signposts. This stylesheet draws a tappable
 * TARGET over each painted arrow - a soft ring, not a button - so the child presses
 * something that is really in the picture. There are no invented buttons or icons.
 *
 *   .a9r-path     the activity surface, inert until the instruction has finished
 *   .a9r-path-bg  the artwork, object-fit:cover
 *   .a9r-sign     one tappable sign, positioned over a painted arrow
 *
 * The positions are set per-instance from JS (measured against the artwork, not by eye) and
 * land here as inline `left`/`top`/`width`/`height`.
 * ========================================================================== */

#app .a9r-path {
  position: absolute;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  overscroll-behavior: contain;
  touch-action: manipulation;
  /* Nothing is tappable until the engine opens the activity after the instruction. This is
     the FIRST of two independent guards; `unlocked` in the activity is the second. */
  pointer-events: none;
}
#app .a9r-path.is-open { pointer-events: auto; }
/* The hand-off to the next story picture: fade out, then the activity removes itself and
   calls `activityDone()`. Nothing interactive survives this. */
#app .a9r-path.is-closing {
  opacity: 0;
  transition: opacity .32s ease;
  pointer-events: none;
}

/* ------------------------------------------------------------------------ *
 * THE ARTWORK
 * ------------------------------------------------------------------------ */
#app .a9r-path-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}
#app .a9r-path-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
}

/* ------------------------------------------------------------------------ *
 * A TAPPABLE SIGN
 *
 * The button IS the touch target and is deliberately larger than the painted arrow it sits
 * on: the visible ring is drawn at 78% of the button, and that margin is the finger
 * tolerance. It is generous because these are preschool fingers.
 *
 * THE GLOBAL BUTTON MUST BE FULLY NEUTRALISED. `style.css` declares a bare
 * `button{border-radius:18px; box-shadow:0 6px 0 #bc6716; padding:14px 30px;
 * background:linear-gradient(...)}`. A rule only overrides what it actually DECLARES, so
 * `box-shadow` and `border-radius` are reset explicitly - otherwise every sign would wear a
 * solid brown bar that read as a brush stroke on the painting.
 * ------------------------------------------------------------------------ */
#app .a9r-sign {
  position: absolute;
  z-index: 3;
  transform: translate(-50%, -50%);
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  border-radius: 50%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  /* A gentle invitation marking this as the pressable kind of sign. It never stops moving
     long enough to read as decoration. */
  animation: a9r-sign-bob 3.4s ease-in-out infinite;
}
#app .a9r-sign::before {
  content: "";
  position: absolute;
  inset: 11%;
  border-radius: 50%;
  /* A soft ring: bright enough to find, transparent enough not to sit on the art as a
     sticker. */
  background: radial-gradient(circle,
    rgba(255, 255, 255, .10) 0%,
    rgba(255, 255, 255, .04) 55%,
    rgba(255, 255, 255, 0) 72%);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .78),
              0 0 14px 4px rgba(255, 248, 210, .55);
  transition: opacity .2s ease, transform .2s ease;
}
#app .a9r-sign::after {
  content: "";
  position: absolute;
  inset: 30%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 250, 220, .42) 0%, rgba(255, 240, 170, 0) 70%);
  pointer-events: none;
}

@keyframes a9r-sign-bob {
  0%, 100% { transform: translate(-50%, -50%) translateY(0) scale(1); }
  50%      { transform: translate(-50%, -50%) translateY(-4px) scale(1.06); }
}

/* Pressed - immediate acknowledgement, and nothing that moves the target. */
#app .a9r-sign:active::before { transform: scale(.92); }

/* WHILE THE RETRY CLIP IS SPEAKING - the question is held. The JS refuses the taps too, but a
   child should be able to SEE that they are waiting rather than tap and wonder why nothing
   happens. */
#app .a9r-path.is-retrying .a9r-sign { pointer-events: none; }
#app .a9r-path.is-retrying .a9r-sign:not(.is-wrong) { opacity: .55; }

/* WRONG - the cave. A short rock, deliberately small and brief: this is not a test the child
   can fail, and a big reaction would tell them they did something serious. */
#app .a9r-sign.is-wrong { animation: a9r-no 400ms ease; }
@keyframes a9r-no {
  0%, 100% { transform: translate(-50%, -50%) translateX(0) rotate(0deg); }
  20% { transform: translate(-50%, -50%) translateX(-7px) rotate(-2deg); }
  55% { transform: translate(-50%, -50%) translateX(7px) rotate(2deg); }
  80% { transform: translate(-50%, -50%) translateX(-3px) rotate(0deg); }
}

/* CORRECT - the house. It brightens and settles; the other sign dims so the choice is
   unmistakable. */
#app .a9r-sign.is-correct::before {
  box-shadow: 0 0 0 5px #a8e6b8,
              0 0 20px 6px rgba(140, 230, 170, .85);
  animation: none;
}
#app .a9r-sign.is-correct { animation: none; }
#app .a9r-sign.is-dimmed { animation: none; opacity: .45; }
#app .a9r-sign.is-dimmed::before { opacity: .4; }

/* Once answered, no sign takes a tap any more - including the correct one. */
#app .a9r-path.is-solved .a9r-sign { pointer-events: none; animation: none; }

@media (prefers-reduced-motion: reduce) {
  #app .a9r-sign { animation: none; }
  #app .a9r-sign.is-wrong { animation-duration: 1ms; }
}