/* ============================================================================
 * ASHTAR KATKOOT - ADVENTURE 8, ACTIVITY 3: FIND CAMEL (activity styles)
 *
 * This is the `a8-` prefix of Adventure 7's proven recognition stylesheet. The mechanic is
 * reused, so the geometry and the comments are deliberately IDENTICAL.
 *
 *   .a8-find        the activity surface, inert until the instruction has finished
 *   .a8-find-row    the three cards
 *   .a8-fcard       one choice - the WHOLE card is the touch target
 *   .a8-find-hint   the help line, only when Learning v2 reports help is due
 *
 * Cards are real <button>s so Android gives correct touch and keyboard behaviour, and
 * every inherited style is reset explicitly - `style.css` styles the bare `button`
 * element, and a rule only overrides what it actually declares.
 * ========================================================================== */

#app .a8-find {
  position: absolute;
  inset: 0;
  z-index: 6;
  overflow: hidden;
  overscroll-behavior: contain;
  touch-action: manipulation;
  /* Locked until the instruction cue has genuinely finished. First of two guards; the
     second is `unlocked` in the activity code. */
  pointer-events: none;
  /* A calm, low-contrast ground. The picture is the subject, so the background must not
     compete with it. */
  background: linear-gradient(180deg, #f6ecd8 0%, #fff8ec 100%);
}
#app .a8-find.is-open { pointer-events: auto; }

/* THE HAND-OVER. This surface is opaque and sits ABOVE the story layer, so it must fade
   and be removed before the ending illustration can be seen at all. */
#app .a8-find.is-closing {
  opacity: 0;
  transition: opacity .32s ease;
  pointer-events: none;
}

/* The cards: three across, equal size, comfortable spacing. */
#app .a8-find-row {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 94%;
  max-width: 460px;
  display: grid;
  /* THE DOCUMENT IS RTL (`<html lang="ar" dir="rtl">`). A grid row would lay these out
     right-to-left. That is harmless for the cards themselves, but the shuffle is recorded
     left-to-right, so pinning the direction keeps the recorded order and the rendered order
     the same thing. */
  direction: ltr;
  grid-template-columns: repeat(3, 1fr);
  gap: 3.2vmin;
}

#app .a8-fcard {
  position: relative;
  /* A square card. The button's own padding is inherited from `style.css` and MUST be
     zeroed or the picture shrinks off-centre. */
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  margin: 0;
  background: #ffffff;
  border-radius: 22px;
  box-shadow: 0 5px 0 rgba(90, 56, 16, .22), 0 8px 18px rgba(60, 40, 10, .18);
  cursor: pointer;
  /* TALLER THAN WIDE, deliberately. Three equal cards across a 390px screen cannot be wider
     than about 123px, and a square card would leave the animals only ~95px tall on an 844px
     screen - about a ninth of the height, which is small for a child who has to RECOGNISE
     the picture rather than read it. A 4:5 card keeps all three across and makes each
     animal roughly 60% taller. */
  aspect-ratio: 4 / 5;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform .18s ease, box-shadow .18s ease;
}
/* A soft inner ring so the white card reads as a card even on a pale background. */
#app .a8-fcard::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 22px;
  box-shadow: inset 0 0 0 3px rgba(205, 165, 95, .28);
  pointer-events: none;
}
/* The whole card is the target; the chip only holds the picture. */
#app .a8-fcard-chip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9%;
}
#app .a8-fcard-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* No drop-shadow: the artwork already carries its own, and adding one here made the
     animals look pasted onto the card rather than printed on it. */
}

/* Pressed - immediate acknowledgement, and nothing that moves the card's position. */
#app .a8-fcard:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(90, 56, 16, .22); }

/* WRONG - 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 .a8-fcard.is-wrong { animation: a8-find-no 400ms ease; }
@keyframes a8-find-no {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px) rotate(-1.5deg); }
  55% { transform: translateX(6px) rotate(1.5deg); }
  80% { transform: translateX(-3px); }
}

/* CORRECT - Camel is highlighted and celebrates; the other two settle back quietly so the
   answer is unmistakable. */
#app .a8-fcard.is-correct {
  background: #fff6d8;
  box-shadow: 0 5px 0 rgba(90, 56, 16, .22), 0 0 0 5px rgba(230, 180, 90, .95),
              0 10px 22px rgba(60, 40, 10, .22);
}
#app .a8-fcard.is-celebrate { animation: a8-find-win 620ms cubic-bezier(.3, 1.4, .5, 1) both; }
@keyframes a8-find-win {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.12) rotate(-2deg); }
  65%  { transform: scale(.97) rotate(1deg); }
  100% { transform: scale(1); }
}
/* The two that were not chosen stay perfectly usable-looking but are no longer
   interactive - the question is over. */
#app .a8-find.is-solved .a8-fcard { cursor: default; pointer-events: none; }
#app .a8-find.is-solved .a8-fcard.is-revealed { opacity: .72; }
#app .a8-find.is-solved .a8-fcard.is-correct { opacity: 1; }

/* THE HELP LINE - hidden until Learning v2 reports that help is due (two wrong attempts).
   It points the child; it never answers for them. */
#app .a8-find-hint {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 11vh);
  transform: translateX(-50%) translateY(8px);
  opacity: 0;
  padding: 9px 20px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 4px 14px rgba(60, 40, 10, .20);
  color: #3a2b12;
  font-size: 4.6vmin;
  font-weight: 800;
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity .26s ease, transform .26s ease;
}
#app .a8-find.is-help .a8-find-hint {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
/* Once the child has answered, the hint has done its job. Leaving "which one is Camel?" on
   screen while the correct card is already highlighted is noise, and it reads as though the
   question were still open. */
#app .a8-find.is-solved .a8-find-hint {
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
}

/* WHILE THE RETRY CLIP IS SPEAKING - a light hold, so the cards visibly wait for the audio
   instead of accepting taps. The JS refuses them too, but a child should be able to SEE
   that they are waiting rather than tap and wonder why nothing happens. */
#app .a8-find.is-retrying .a8-fcard { pointer-events: none; }
#app .a8-find.is-retrying .a8-fcard:not(.is-wrong) { opacity: .55; }

@media (max-height: 700px) {
  #app .a8-find-row { gap: 2.4vmin; width: 96%; }
  #app .a8-find-hint { bottom: calc(env(safe-area-inset-bottom, 0px) + 6vh); }
}

@media (prefers-reduced-motion: reduce) {
  #app .a8-fcard.is-wrong,
  #app .a8-fcard.is-celebrate { animation-duration: 1ms; }
}