/* ============================================================================
 * ASHTAR KATKOOT - ADVENTURE 7, PHASE 4: FIND RABBIT (activity styles)
 *
 * A clean selection screen: three equally sized picture cards, no words, no counters.
 *
 *   .a7-find        the activity surface, inert until the instruction has finished
 *   .a7-find-row    the three cards
 *   .a7-fcard       one choice - the WHOLE card is the touch target
 *   .a7-find-hint   the help line, only when Learning v2 reports help is due
 *
 * Cards are DIV-free on purpose where it matters: they 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 .a7-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, #eaf6ff 0%, #fff8ec 100%);
}
#app .a7-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 .a7-find.is-closing {
  opacity: 0;
  transition: opacity .32s ease;
  pointer-events: none;
}

/* The cards: three across, equal size, comfortable spacing. */
#app .a7-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 .a7-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(20, 70, 40, .22), 0 8px 18px rgba(10, 40, 20, .18);
  cursor: pointer;
  /* TALLER THAN WIDE, deliberately. Three equal cards across a 390px screen cannot be
     wider than about 123px, so a square card left 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 .a7-fcard::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 22px;
  box-shadow: inset 0 0 0 3px rgba(120, 175, 205, .28);
  pointer-events: none;
}
/* The whole card is the target; the chip only holds the picture. */
#app .a7-fcard-chip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9%;
}
#app .a7-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 .a7-fcard:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(20, 70, 40, .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 .a7-fcard.is-wrong { animation: a7-find-no 400ms ease; }
@keyframes a7-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 - Rabbit is highlighted and celebrates; the other two settle back quietly so
   the answer is unmistakable. */
#app .a7-fcard.is-correct {
  background: #fff6d8;
  box-shadow: 0 5px 0 rgba(20, 70, 40, .22), 0 0 0 5px rgba(120, 210, 140, .95),
              0 10px 22px rgba(10, 40, 20, .22);
}
#app .a7-fcard.is-celebrate { animation: a7-find-win 620ms cubic-bezier(.3, 1.4, .5, 1) both; }
@keyframes a7-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 .a7-find.is-solved .a7-fcard { cursor: default; pointer-events: none; }
#app .a7-find.is-solved .a7-fcard.is-revealed { opacity: .72; }
#app .a7-find.is-solved .a7-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 .a7-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(10, 40, 20, .20);
  color: #14432c;
  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 .a7-find.is-help .a7-find-hint {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
/* Once the child has answered, the hint has done its job. Leaving "which one is
   Rabbit?" on screen while the correct card is already highlighted is noise, and it
   reads as though the question were still open. */
#app .a7-find.is-solved .a7-find-hint {
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
}

/* A short screen: keep the cards clear of the hint line. */
/* 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 .a7-find.is-retrying .a7-fcard { pointer-events: none; }
#app .a7-find.is-retrying .a7-fcard:not(.is-wrong) { opacity: .55; }

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

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