/* ==========================================================================
   ASHTAR KATKOOT — ADVENTURE 5: "THE BEE"
   --------------------------------------------------------------------------
   Mobile-first. Designed at 390 x 844, the target Android portrait viewport.
   Everything is scoped to `#app .a5-`, so nothing here can reach Adventures 1-4,
   the Book, the album, or any other world.

   THE LAYOUT PROBLEMS PHYSICAL-PHONE TESTING FOUND, AND WHAT CHANGED
   ==================================================================
   Phase 1 passed 60 automated checks and still looked wrong on a phone. Every
   change below exists because a person reported it:

     Teacher too small          -> .a5-teacher is now ~40vmin wide and stands
                                   BESIDE the board, overlapping its lower-left
                                   corner, so his pointer aims at the content
     Teacher too low            -> raised off the bottom edge by ~6vmin
     Board too small            -> 88vmin wide, filling the width
     Bee too small              -> 62% of the writing surface
     Cards too small            -> 44vmin (172 px), in a 2-up arrangement
     Empty space                -> three bands that consume the whole viewport
     Unreadable headings        -> every instruction sits on .a5-panel, a cream
                                   glass surface at 92% with a real shadow

   SIZING IS IN `vmin` THROUGHOUT. A fixed px board overflows a 360-wide phone and
   wastes a 430-wide one; `vmin` tracks the short edge, which is what actually
   decides the vertical room in portrait.

   MOTION BUDGET. Teacher Katkoot breathes by about 1%, the page turns once, the
   Bee pulses while its own name is sounding, the listen targets float gently, and
   cards react to being tapped. Nothing moves that does not mean something. No
   leaves, no sparkles, no particles, no confetti.
   ========================================================================== */

#app .a5-root {
  position: absolute;
  inset: 0;
  z-index: 30;
  overflow: hidden;
  overscroll-behavior: contain;
  padding: calc(env(safe-area-inset-top, 0px) + 4px)
           calc(env(safe-area-inset-right, 0px) + 4px)
           calc(env(safe-area-inset-bottom, 0px) + 4px)
           calc(env(safe-area-inset-left, 0px) + 4px);
  box-sizing: border-box;
  color: #14324a;
  font-family: inherit;
  /* Gives the intro page turn a real page's perspective to swing through. Declared on
     the root, once, rather than in a second `#app .a5-root` block further down - two
     rules for one selector is how a stylesheet starts to disagree with itself. */
  perspective: 1400px;
}
#app .a5-root[hidden] { display: none; }

/* ==================================================================== *
 * THE ON-SCREEN DIAGNOSTIC  (`?adv5=diag`)
 *
 * Lives OUTSIDE `#app .a5-` on purpose: it is instrumentation, not part of the game,
 * and it must be removable by deleting one block.
 *
 * The critical property is that it CANNOT STEAL A TAP. The panel is a thin strip at the
 * very top of the viewport; the answer cards occupy the middle and lower area, so the
 * panel never overlaps them. `pointer-events` is off everywhere except its two buttons,
 * so even if it did overlap, every tap would still pass straight through to the card
 * underneath. That is verified by a test which taps a card centre with the panel open.
 * ==================================================================== */
#a5diag {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  z-index: 99999;
  font: 11px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #eaf6ee;
  background: rgba(6, 22, 14, .92);
  border-bottom: 2px solid #2f8f52;
  pointer-events: none;          /* NEVER intercepts a tap */
  max-height: 34vh;
  overflow: hidden;
  direction: ltr;
  text-align: left;
}
/* SHORT BY DEFAULT. The panel is small enough to leave the answer area alone, so a
   diagnosis is never distorted by the thing diagnosing it. The `–` button expands it;
   the collapsed state still shows the build and the classification. */
#a5diag .a5d-body { max-height: 13vh; overflow: hidden; }
#a5diag:not(.is-min) .a5d-body { max-height: 34vh; overflow-y: auto; }
#a5diag.is-min { max-height: 26px; overflow: hidden; }
#a5diag.is-min .a5d-foot { display: none; }
#a5diag .a5d-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px;
  pointer-events: none;
}
#a5diag .a5d-bar b { color: #6ee7a0; letter-spacing: .06em; }
#a5diag .a5d-badge {
  font-style: normal;
  padding: 1px 7px;
  border-radius: 999px;
  background: #2f8f52;
  color: #fff;
  font-weight: 700;
}
#a5diag .a5d-min {
  margin-left: auto;
  pointer-events: auto;         /* one of only two interactive parts */
  background: #1d4b31;
  color: #cfe9d8;
  border: 1px solid #2f8f52;
  border-radius: 6px;
  min-width: 26px;
  height: 22px;
  font: inherit;
  padding: 0 6px;
}
#a5diag .a5d-body {
  padding: 0 8px 4px;
  max-height: 30vh;
  overflow: hidden;
  pointer-events: none;
}
#a5diag .a5d-r {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
#a5diag .a5d-r span { width: 34%; flex: none; color: #8fbf9f; }
#a5diag .a5d-r b {
  font-weight: 600;
  word-break: break-all;
  direction: ltr;
  unicode-bidi: plaintext;
}
#a5diag .a5d-foot { padding: 0 8px 6px; display: flex; gap: 6px; pointer-events: none; }
#a5diag .a5d-copy {
  pointer-events: auto;         /* the other interactive part */
  background: #2f8f52;
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 7px 14px;
  font: 700 13px/1 inherit;
  font-family: inherit;
  touch-action: manipulation;
}
#a5diag .a5d-ta {
  display: none;
  width: 100%;
  height: 22vh;
  margin-top: 4px;
  font: 10px/1.25 ui-monospace, Menlo, Consolas, monospace;
  pointer-events: auto;
  background: #06160e;
  color: #cfe9d8;
  border: 1px solid #2f8f52;
  border-radius: 6px;
  padding: 6px;
  -webkit-user-select: text;
  user-select: text;
}

/* ==================================================================== *
 * THE ANDROID DEAD-TAP FIX, part 2 of 2 (the JS half is `img.draggable=false`).
 *
 * On Android an <img> inside a <button> is a native drag handle, and a text glyph is a
 * selectable range. Either one, triggered by a child tapping and holding even briefly,
 * fires `dragstart` / starts a selection and CANCELS the `click` - while `pointerdown`
 * still runs. The card therefore lights up when pressed and then nothing happens, which
 * is precisely the Lesson 2 symptom on a phone and cannot be reproduced with a desktop
 * mouse or with a synthetic tap that never holds long enough to drag.
 *
 * These four declarations stop all of it, and they cost nothing anywhere else.
 * ==================================================================== */
#app .a5-card,
#app .a5-letter,
#app .a5-card-art,
#app .a5-card-img,
#app .a5-card-text {
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
/* Nothing inside an answer control may be a drag or selection source. */
#app .a5-card img,
#app .a5-card-art img,
#app .a5-card-text {
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  pointer-events: none;
  -webkit-user-drag: none;
}

/* ---------------------------------------------------------------- *
 * THE GARDEN. Full bleed, cover, never distorted.
 *
 * unit5-school-garden.jpg is 1080x720 (1.5) and the phone is 390x844 (0.462), so
 * `contain` would letterbox it into a 390x260 band. `cover` scales by height
 * (844/720 = 1.172) giving 1266px of width, so ~438px is cropped per side and the
 * path, gate and blossom trees stay in frame. One scale factor on both axes.
 * ---------------------------------------------------------------- */
#app .a5-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
#app .a5-bg-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Biased down so the horizon and the trees stay in frame under a tall phone. */
  object-position: center 46%;
  display: block;
}

/* ==================================================================== *
 * THE INTRO - A BOOK PAGE, AND A REAL PAGE TURN
 * ==================================================================== */

/* THE INTRO IS ONE FULL-SCREEN PICTURE. Not a poster on a blurred background.
 *
 * c5-adventure-intro.png is 1024x1536 = 2:3. The phone is 390x844 = 1:2.16.
 *
 * `contain` leaves ~130px of empty band above and below, which is what produced the
 * rejected 390x585 poster floating on a smear.
 * `cover` scales by height to 563px wide, and a viewport 390px wide can therefore show
 * only 710 of the 1024 source columns. Symmetric centring showed source 157..867, which
 * cut Katkoot down to a pointing hand - and Katkoot is the instructor.
 *
 * So the crop is CHOSEN, not centred, and every candidate was screenshotted and looked
 * at. Katkoot occupies source x 0..340, the Bee silhouette x 620..930, so no 710px
 * window can hold both: that is arithmetic, not taste. The window is therefore anchored
 * 78 source px in, which is the offset that keeps Katkoot whole and large, keeps the
 * book's title and both paragraphs readable, keeps the mystery Bee and both question
 * marks in shot, and pushes the artwork's own baked-in home button out of frame instead
 * of slicing it in half.
 *
 * `78 / 1536` of the height is the offset, so `5.08vh` keeps the SAME crop on any
 * screen: the artwork is always rendered at `height:100%` and never distorted. */
#app .a5-intro-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #24402d;
  /* ABOVE THE WHOLE STAGE.
     The intro page is a SIBLING of `.a5-stage` and comes FIRST in the DOM, so without
     this the stage paints over it: Lesson 1's board and Teacher were visible ON TOP of
     the intro picture, before the page had even turned.

     The overlap is deliberate and this is what resolves it. The page turn needs Lesson 1
     already FINISHED underneath it - that is what guarantees the turn can never expose a
     blank frame - so the wrap has to be opaque and uppermost until it swings away. */
  z-index: 8;
}
#app .a5-intro-page {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
#app .a5-intro-img {
  position: absolute;
  top: 0;
  left: 50%;
  /* Height-driven, never `object-fit`: the painting must keep its shape. At 844 tall
     this is 563px wide, of which the viewport shows the chosen 390px window. */
  height: 100%;
  width: auto;
  display: block;
  transform: translateX(calc(-50% + 5.08vh));
}
/* A viewport WIDER than 2:3 is the only case where a height-driven image would be
   too narrow to cover the width, so there the painting is width-driven and simply
   centred. `min-aspect-ratio`, not `max`: the target phone is 390/844 = 0.46, which is
   NARROWER than 2:3 and must take the height-driven full-bleed rule above. Writing
   `max` here silently put the whole portrait phone into the letterboxed fallback. */
@media (min-aspect-ratio: 2/3) {
  #app .a5-intro-img {
    left: 0;
    top: 50%;
    height: auto;
    width: 100%;
    transform: translateY(-50%);
  }
}

/* Perspective for the page turn below. Declared here, on the root that owns it,
   rather than in a second `#app .a5-root` block further down - two rules for one
   selector is how a stylesheet starts to disagree with itself. The perspective belongs
   to the root's own box, so it is merged into the root rule at the top of this file. */

/* THE PAGE TURN.
 *
 * The NEXT scene is already painted underneath - Lesson 1 is rendered before the
 * narration is even requested - so this is a leaf swinging off the top layer rather
 * than a transition into emptiness. It therefore CANNOT produce a blank, white, black
 * or loading frame: there is nothing behind it but a finished lesson.
 *
 * transform-origin on the spine at the left edge, one rotateY, 420 ms. A leaf, not a
 * 3D page-curl engine. The perspective that makes it read as a page is declared on
 * the root, above. */
#app .a5-root.is-turning .a5-intro-wrap {
  transform-origin: left center;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  animation: a5-page-turn 420ms cubic-bezier(.42, 0, .25, 1) forwards;
}
@keyframes a5-page-turn {
  0%   { transform: rotateY(0deg)   translateZ(0); filter: brightness(1); }
  55%  { filter: brightness(0.86); }
  100% { transform: rotateY(-104deg) translateZ(-40px); filter: brightness(0.6); }
}
@media (prefers-reduced-motion: reduce) {
  #app .a5-root.is-turning .a5-intro-wrap { animation: none; opacity: 0; }
}

/* ==================================================================== *
 * THE STAGE. Three bands that consume the whole viewport.
 * ==================================================================== */
#app .a5-stage {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* `flex-start`, NOT `space-between`: with one lesson panel in flow, spacing the
     children apart strands the board at the top and leaves a band of empty path. */
  justify-content: flex-start;
  min-height: 0;
}

/* ==================================================================== *
 * THE INSTRUCTION PANEL - THE FIX FOR UNREADABLE HEADINGS
 *
 * Phase 1 put dark Arabic text straight onto the garden, and on a real phone it was
 * unreadable against the flowers, the path and the tree. Every instruction now sits
 * on this surface: a light cream glass at 92% with a soft border and a real shadow.
 * It is a panel, not a banner - rounded, and never wider than the content needs.
 * ==================================================================== */
#app .a5-panel {
  flex: none;
  max-width: 94%;
  /* THE HEADING MUST NOT SIT ON THE ANSWER AREA.
   *
   * This panel carried only a TOP margin, so nothing separated it from what follows.
   * Measured at 390x844 on Final Challenge, the panel's bottom edge landed exactly on
   * the first answer frame's top edge - a 0px gap, reported as "almost touching". On the
   * word round it touched the Bee picture above the choices instead.
   *
   * A smaller top margin lifts the heading slightly and a real bottom margin opens a
   * readable band below it: 4.6vmin is ~18px at 390x844. Only the spacing changes - the
   * type, the colour, the glass background, the centring and the width rule above are
   * all untouched. */
  margin: 0.6vmin auto 4.6vmin;
  padding: 2.2vmin 4.4vmin;
  border-radius: 3.4vmin;
  background: linear-gradient(180deg, rgba(255, 253, 246, .95), rgba(250, 246, 234, .90));
  border: 0.7vmin solid rgba(255, 255, 255, .82);
  box-shadow: 0 1.4vmin 4vmin rgba(24, 54, 38, .30);
  text-align: center;
  direction: rtl;
  color: #123c2c;
  opacity: 0;
  transform: translateY(-1.2vmin);
  transition: opacity .2s ease-out, transform .2s ease-out;
}
#app .a5-panel.is-on { opacity: 1; transform: translateY(0); }

#app .a5-title {
  margin: 0;
  font-size: 6.6vmin;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0;
  color: #123c2c;
  text-shadow: none;
  direction: rtl;
}
#app .a5-caption {
  margin: 1.2vmin 0 0;
  font-size: 5.4vmin;
  line-height: 1.3;
  font-weight: 700;
  color: #17492f;
  direction: rtl;
}
#app .a5-caption:empty { display: none; }

/* A word shown as a CHOICE - large, centred, never black on artwork. */
#app .a5-word {
  font-size: 9.5vmin;
  line-height: 1;
  font-weight: 900;
  letter-spacing: .04em;
  color: #143c26;
  direction: ltr;
  unicode-bidi: isolate;
}
/* ON THE BOARD the word is chalk on green, so it is LIGHT.

   The first version used the same dark green here as everywhere else, and BEE came out
   dark-on-dark-green on a chalkboard: perfectly readable against the cream panels, and
   effectively invisible against the surface it is actually written on. The contrast rule
   is about the SURFACE behind the text, not the text itself. */
#app .a5-board-face .a5-word {
  color: #fdfbf2;
  text-shadow: 0 .5vmin 1.2vmin rgba(8, 38, 24, .6);
}

/* ==================================================================== *
 * TEACHER KATKOOT - A MAJOR ELEMENT, PRESENTING, NOT PERCHED
 *
 * He stands at the lower LEFT and overlaps the board's lower-left corner, so the
 * pointer in the supplied artwork aims up and to the right, into the Bee and the
 * word. Anchored by his own bottom edge, raised clear of the viewport bottom.
 *
 * Three real <img> nodes, one visible. The swap is a class, never a `src` change, so
 * a pose change can never wait on a 2 MB file - which is what "no loading gap" has to
 * mean when the art is that large.
 * ==================================================================== */
#app .a5-teacher {
  position: absolute;
  left: 0;
  bottom: 4vmin;
  /* 58vmin wide = 226px, which puts him at roughly 340px tall: about 40% of the
     viewport's height. Phase 1 shipped him at 29%, and that is exactly what "too
     small, too low" looked like on a real phone.

     He deliberately OVERLAPS the board's lower-left corner. He is presenting it, not
     standing beside it in a corner - and the raised pointer in the supplied artwork only
     reads as pointing at something when he is close enough to it. */
  width: 58vmin;
  max-width: 62%;
  pointer-events: none;   /* never intercepts a tap meant for an answer */
  z-index: 5;
}
#app .a5-teacher-img {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: auto;
  display: block;
  opacity: 0;
  /* THE WHOLE IDLE ANIMATION: a 1% breath. Long, small, calm. */
  transition: opacity .14s linear;
  transform-origin: 50% 100%;
  animation: a5-breathe 7.5s ease-in-out infinite;
}
#app .a5-teacher-img.is-front { opacity: 1; }
@keyframes a5-breathe {
  0%, 100% { transform: scale(1)    translateY(0); }
  50%      { transform: scale(1.01) translateY(-0.4vmin); }
}
@media (prefers-reduced-motion: reduce) {
  #app .a5-teacher-img { animation: none; transition: none; }
}

/* In an ANSWER lesson he steps aside into the corner: the cards need the middle, and
   he must never cover an answer. Same anchoring logic, smaller box. */
#app .a5-root.is-answering .a5-teacher {
  width: 26vmin;
  max-width: 30%;
  bottom: 1.5vmin;
  opacity: .97;
  z-index: 2;
}

/* ==================================================================== *
 * A LESSON PANEL
 * ==================================================================== */
#app .a5-lesson {
  position: relative;
  width: 100%;
  /* Takes the screen above the Teacher, so content is never stranded at the top. */
  flex: 1 1 0%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Content is centred in the space the Teacher leaves, NOT pinned to the top. The
     Teacher is a corner presence in an answer lesson, so top-aligning left roughly
     300px of empty garden under every question. Centring puts the instruction, the
     answer and the Teacher in one readable group. */
  justify-content: center;
  padding-top: 2vmin;
  padding-bottom: 0;
}
#app .a5-lesson[hidden] { display: none; }

/* ---------------------------------------------------------------- *
 * THE BOARD - THE PRIMARY LEARNING SURFACE
 *
 * 88vmin wide at 390x844 is 343px of a 390px screen. It is the biggest thing on
 * the screen, which is the point: this is where the child is being taught.
 * ---------------------------------------------------------------- */

/* ---------------------------------------------------------------- *
 * ANSWER LESSONS ARE CENTRED; THE TEACHING LESSON IS NOT.
 *
 * Lesson 1 has the Teacher at ~40% of the viewport overlapping the board, so the board
 * belongs in the top two thirds. Lessons 2, 3 and 6 make him a small corner guide, and a
 * top-aligned group left the cards crammed under the header with a wide dead band beneath
 * - which is the "tiny activity in the middle of a huge background" complaint wearing a
 * different hat.
 *
 * NOTE THE CLASS NAMES: the wrappers are `a5-lesson a5-l-<id>`, built from the lesson
 * ids. An earlier version of this rule said `a5-l2` .. `a5-l6`, which matched no element
 * at all, so it silently did nothing.
 * ---------------------------------------------------------------- */
#app .a5-l-find,
#app .a5-l-catch,
#app .a5-l-build,
#app .a5-l-letter,
#app .a5-l-challenge {
  justify-content: center;
  padding-top: 0;
  padding-bottom: 0;
}

#app .a5-board {
  position: relative;
  width: 88vmin;
  max-width: 98%;
  filter: drop-shadow(0 1.6vmin 3vmin rgba(20, 50, 30, .34));
}
#app .a5-board-img {
  display: block;
  width: 100%;
  height: auto;
}

/* The writing surface, measured off the 640x444 artwork so the content lands INSIDE
   the green rather than on the wooden frame. */
#app .a5-board-face {
  position: absolute;
  left: 9%;
  right: 9%;
  top: 8%;
  /* 26%, not 20%. The chalk rail and the eraser lie across the bottom of the artwork,
     and at 20% the word was landing ON them - half on the green, half on the frame. */
  bottom: 26%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6vmin;
}

/* THE BEE. 62% of the writing surface - large enough to BE the subject. */
#app .a5-bee-img {
  width: 62%;
  max-width: 26vmin;
  height: auto;
  object-fit: contain;
  display: block;
  transform-origin: 50% 60%;
}
/* One breath-sized pulse, only while its own pronunciation is sounding, so the child
   can see which picture the voice belongs to. Not a bounce. */
#app .a5-bee-img.is-speaking { animation: a5-bee-pulse .62s ease-in-out 1; }
@keyframes a5-bee-pulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.055); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  #app .a5-bee-img.is-speaking { animation: none; }
}

/* ==================================================================== *
 * ANSWER CARDS - BIG, AND THE WHOLE RECTANGLE IS THE BUTTON
 *
 * 44vmin = 172px at 390x844. Phase 1 shipped 105x125 and it read as "too small" on a
 * real phone; that is the specific number this replaces.
 *
 * THE TOUCH CONTRACT. The <button> IS the card and owns the pointer event for its
 * entire rectangle. The <img> and any label inside it are `pointer-events: none`, so
 * a tap on the picture, on the padding, on a corner, or on the gap between the
 * picture and the edge all resolve to the same card. There is no inner hit target to
 * miss and no decorative layer above the cards to steal the tap.
 * ==================================================================== */

/* Three choices, two up then one centred below: a balanced arrangement that makes
   each card far larger than a single row of three ever could. */
#app .a5-grid-3 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3vmin;
  width: 100%;
  max-width: 96%;
  flex: none;
  justify-items: center;
}
/* The third card spans the full width but must KEEP THE CARD'S OWN SIZE. `grid-column:
   1 / -1` alone lets `justify-items: center` shrink it to the width of its content, so
   it rendered narrower and shorter than the other two - a card the child can tell is
   different by its size alone. `justify-self: stretch` plus an explicit width holds the
   row's column width exactly. */
#app .a5-grid-3 > :nth-child(3) {
  grid-column: 1 / -1;
  justify-self: stretch;
  justify-items: center;
  width: 44vmin;
  max-width: 100%;
}

/* Four choices, two by two. */
#app .a5-grid-4 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3vmin;
  width: 100%;
  max-width: 92%;
  flex: none;
  justify-items: center;
}

/* `hidden` must actually hide. A card is a flex item, and `display:flex` from the rule
   below overrides the UA's `[hidden]{display:none}` - so a pool taken down between
   questions stayed fully on screen, still showing its previous "correct" ring. */
#app .a5-card[hidden] { display: none !important; }

#app .a5-card {
  width: 44vmin;
  max-width: 100%;
  height: 44vmin;
  min-width: 96px;
  min-height: 96px;
  padding: 1.6vmin;
  border: 0;
  border-radius: 4.4vmin;
  background: linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(250, 247, 238, .93));
  box-shadow: 0 1.2vmin 0 rgba(18, 60, 44, .20), 0 2vmin 4vmin rgba(20, 50, 34, .18);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;          /* no 300 ms double-tap delay */
  transition: transform .13s ease-out, box-shadow .13s ease-out, opacity .2s ease-out;
}
/* THE IMMEDIATE ACKNOWLEDGEMENT.
 *
 * Added on POINTERDOWN, synchronously, before anything is scored and long before any
 * audio is requested - so the child sees the press in the same frame they touched, and
 * never has to wonder whether the tap landed. Audio follows the acknowledgement; it
 * never owns it. */
#app .a5-card.is-pressed {
  transform: scale(.94);
  box-shadow: 0 0 0 1.2vmin rgba(255, 255, 255, .9), 0 0 0 2.4vmin #2f8f52, 0 2vmin 4vmin rgba(20, 50, 34, .18);
}

#app .a5-card-art {
  display: block;
  width: 100%;
  height: 100%;
  /* The picture is decoration. It must never intercept the tap that belongs to the
     button around it. */
  pointer-events: none;
}
#app .a5-card-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}
/* A WORD CARD. The English word is the whole content of the card, so it is centred on
   both axes, given the full box, and laid out left-to-right even inside this RTL page -
   a centred flex item is otherwise offset by the page direction, which is what left the
   Final Challenge words sitting ~40px off centre.

   The opaque plate matters as much as the centring: the cards were translucent, so the
   garden showed through the words and the showy background competed with the answer.
   A word the child must read deserves a plain surface. */
#app .a5-card-text {
  pointer-events: none;
  font-size: 7.4vmin;
  line-height: 1.12;
  font-weight: 900;
  color: #143c26;
  direction: ltr;
  unicode-bidi: isolate;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 0 2vmin;
  box-sizing: border-box;
  /* A long word must shrink to fit its card rather than spill past the edge. */
  overflow-wrap: anywhere;
  word-break: break-word;
  font-variant-ligatures: none;
  letter-spacing: .02em;
}
/* The card itself must not let its own direction shift the content box. */
/* A card showing a WORD gets an opaque reading plate; a card showing a PICTURE keeps
   its light translucent frame, because the artwork is the content there. */
#app .a5-card.is-word {
  direction: ltr;
  background: linear-gradient(180deg, #fffefb, #fdfaf2);
  box-shadow: 0 0 0 .5vmin rgba(255, 255, 255, .9),
              0 1.2vmin 0 rgba(18, 60, 44, .18), 0 2vmin 4vmin rgba(20, 50, 34, .16);
}
/* Set by `paintChoices` whenever a label is shown, so the two modes cannot drift apart
   and no word card is ever left translucent. */
#app .a5-card.is-word .a5-card-text { opacity: 1; }

/* ---------------------------------------------------------------- *
 * FINAL CHALLENGE - THE FOUR ENGLISH WORD CHOICES
 *
 * A word frame is a word, not a picture. At the picture-card size of 44vmin - measured
 * 172x172 at 390x844, and 352x352 on a desktop viewport - a four-letter word in a large
 * font sat in a large empty box and the four of them dominated the screen.
 *
 * These four are smaller. 24vmin is 93x93 at 390x844, a little over half of 172, and it
 * still clears a 44x44 touch target three times over, so no separate transparent hit
 * area is needed and nothing has to be overlaid to catch a tap.
 *
 * THE SCOPE IS DELIBERATE AND TRIPLE: `.a5-final` + `[data-pool='g-final']` + `.is-word`.
 * A word frame only exists when `paintChoices` was given a label, and only the Final
 * Challenge word round builds these four. No image-answer card in Lesson 2 or in any
 * other lesson matches this selector, so none of them can be affected by it.
 *
 * The English type is NOT scaled down with the frame. It keeps `7.4vmin` from the rule
 * above, so the words stay as readable as they were - only the box around them shrinks.
 * ---------------------------------------------------------------- */
#app .a5-final [data-pool='g-final'] .a5-card.is-word {
  /* THE FRAME AND THE TYPE SCALE AS ONE, AND THAT IS THE POINT.
   *
   * Measured at 390x844 in this exact font at weight 900: BEE 54px, FISH 68px, LION 74px,
   * FROG 81px. FROG is the widest word these four choices can be, so any frame smaller
   * than ~87px of text space breaks it as "FRO" / "G" - which is legal CSS
   * (`overflow-wrap: anywhere`) and therefore invisible to a naive overflow check, and
   * which is exactly what appeared in the first screenshot of this fix.
   *
   * So the font is derived from the frame instead of being a second, independent value
   * that can disagree with it: at 0.30 the word occupies at most ~30% of the frame's
   * width, leaving generous room on one line. `16vh` caps the frame on a short desktop
   * window - at 1280x800 an uncapped 24vmin was 192px and the lower pair ran off the
   * bottom of the screen. Because both values come from one variable, the fit holds at
   * every viewport instead of only the one it was tuned on.
   *
   * On the target phone this leaves the English at 28.1px - within 3% of the 28.9px it
   * was, and a far larger share of its frame than before. The type is NOT scaled down
   * with the frame the way a proportional shrink would do it. */
  --a5w: min(24vmin, 16vh);
  width: var(--a5w);
  height: var(--a5w);
  min-width: 56px;
  min-height: 56px;
  padding: 0.6vmin;
  border-radius: 3.2vmin;
  font-size: calc(var(--a5w) * 0.30);
}
/* The word is centred in the frame by the shared rule. `nowrap` is the guarantee: a
   choice may shrink the frame or the font, but it may never break a word in half.
   The size is restated here, not left to inherit: the shared `.a5-card-text` rule sets
   its own `font-size: 7.4vmin`, and a font size on the parent button would lose to it -
   which is exactly how the desktop round kept a 59px word inside a 128px frame. */
#app .a5-final [data-pool='g-final'] .a5-card.is-word .a5-card-text {
  padding: 0 0.2vmin;
  white-space: nowrap;
  line-height: 1.06;
  font-size: calc(var(--a5w) * 0.30);
}

/* THE BEE ABOVE THE FOUR WORDS - DECOUPLED FROM THE GRID'S WIDTH.
 *
 * `.a5-bee-side` carries `max-width: 40%`, measured against `.a5-final`. When the four
 * word frames were 44vmin they defined that container at 326px and the Bee rendered at
 * its full 30vmin; shrinking the frames narrowed the container to 183px and silently
 * shrank the Bee to 80px with them. The Bee must not depend on how wide the choices
 * happen to be, so inside the Final Challenge its width is driven by the viewport alone.
 * The picture is unchanged in shape and position - only its size is no longer a side
 * effect of the answer grid. */
#app .a5-final > .a5-bee-side {
  width: min(26vmin, 18vh);
  max-width: none;
  height: auto;
}

/* CORRECT. A calm confirmation ring. Praise is already carrying the audio. */
#app .a5-card.is-right {
  box-shadow: 0 0 0 1.2vmin rgba(255, 255, 255, .9), 0 0 0 2.6vmin #35a356,
              0 2vmin 4vmin rgba(20, 50, 34, .18);
  transform: scale(1.03);
}
/* WRONG. A short shake on the card the child chose, then it clears. The card is NOT
   emptied, hidden or replaced - the same choices are still there to try again. */
#app .a5-card.is-wrong {
  animation: a5-shake .3s ease-in-out 1;
  box-shadow: 0 0 0 1.2vmin rgba(255, 255, 255, .9), 0 0 0 2.6vmin #d8743a,
              0 2vmin 4vmin rgba(20, 50, 34, .18);
}
@keyframes a5-shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-1.4vmin); }
  75%      { transform: translateX(1.4vmin); }
}
@media (prefers-reduced-motion: reduce) {
  #app .a5-card.is-wrong { animation: none; }
}

/* ==================================================================== *
 * HELP MODE
 *
 * After the second genuine wrong answer, on any scored question. It TEACHES rather
 * than answers: the correct card pulses gently, the distractors step back a little,
 * and every card stays visible AND tappable. The child still makes the final tap.
 *
 * The pulse is a slow, low-amplitude ring. A steady glow would read as "this one is
 * lit up" rather than "look here".
 * ==================================================================== */
#app .a5-card.is-hint { animation: a5-hint 1.9s ease-in-out infinite; }
@keyframes a5-hint {
  0%, 100% { box-shadow: 0 0 0 0 rgba(53, 163, 86, 0),    0 1.2vmin 0 rgba(18, 60, 44, .20); }
  50%      { box-shadow: 0 0 0 1.6vmin rgba(53, 163, 86, .62), 0 1.2vmin 0 rgba(18, 60, 44, .20); }
}
@media (prefers-reduced-motion: reduce) {
  #app .a5-card.is-hint { animation: none; box-shadow: 0 0 0 1.6vmin rgba(53, 163, 86, .62); }
}
/* Reduced emphasis, NOT removed. This is "look more carefully", never "one option". */
#app .a5-card.is-dim { opacity: .55; }

/* ==================================================================== *
 * LISTEN & CATCH - GENTLE FLOATING TARGETS
 *
 * The BUTTON is still. The PICTURE inside it drifts, by a few pixels, on a long slow
 * cycle. That is deliberate: if the whole card moved, the hit rectangle would move
 * with it and a target could slip out from under a child's finger. Animating the
 * artwork alone makes the motion impossible to miss and impossible to mis-tap.
 * ==================================================================== */
#app .a5-card.is-floating .a5-card-art {
  animation: a5-float 4.2s ease-in-out infinite alternate;
}
#app .a5-card.is-floating.is-alt .a5-card-art { animation-duration: 5.1s; animation-delay: -1.6s; }
@keyframes a5-float {
  0%   { transform: translateY(-1.4vmin) rotate(-1.4deg); }
  100% { transform: translateY(1.4vmin)  rotate(1.4deg); }
}
@media (prefers-reduced-motion: reduce) {
  #app .a5-card.is-floating .a5-card-art { animation: none; }
}
/* In help mode the drift STOPS, so a highlighted target is not also moving. */
#app .a5-card.is-hint .a5-card-art,
#app .a5-card.is-pressed .a5-card-art { animation-play-state: paused; }

/* ==================================================================== *
 * LETTERS - BUILD BEE and MISSING LETTER
 *
 * Reliable, large, and tappable over their whole box. NO drag mechanic: a drag that
 * can be fumbled by a five-year-old is worse than a tap, and reliability was chosen
 * over flourish deliberately.
 * ==================================================================== */
#app .a5-slots {
  display: flex;
  gap: 2.6vmin;
  justify-content: center;
  align-items: center;
  flex: none;
  margin-top: 1.6vmin;
  /* LTR, ALWAYS. The page inherits RTL for Arabic, and a flex row under RTL lays its
     items out RIGHT TO LEFT - so a completed B-E-E rendered as E-E-B, i.e. the child
     built the word and then read it backwards. The slots and the tray are English, so
     they must pin their own direction; the Arabic around them stays RTL. */
  direction: ltr;
}
#app .a5-slot {
  width: 17vmin;
  height: 19vmin;
  min-width: 54px;
  min-height: 60px;
  border-radius: 3vmin;
  background: linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(244, 240, 230, .92));
  border: 0.9vmin dashed rgba(30, 96, 62, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12vmin;
  line-height: 1;
  font-weight: 900;
  color: #143c26;
  direction: ltr;
  unicode-bidi: isolate;
  box-shadow: 0 1vmin 3vmin rgba(20, 50, 34, .14);
}
#app .a5-slot.is-filled {
  border-style: solid;
  border-color: rgba(255, 255, 255, .9);
  background: linear-gradient(180deg, #ffffff, #f3f8f2);
}
/* The slot the child is being asked for next, in help mode. */
#app .a5-slot.is-hint { animation: a5-slot-hint 1.7s ease-in-out infinite; }
@keyframes a5-slot-hint {
  0%, 100% { border-color: rgba(30, 96, 62, .45); }
  50%      { border-color: rgba(53, 163, 86, .95); }
}
@media (prefers-reduced-motion: reduce) {
  #app .a5-slot.is-hint { animation: none; border-color: rgba(53, 163, 86, .95); }
}

#app .a5-letters {
  display: flex;
  gap: 2.6vmin;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  flex: none;
  margin-top: 3vmin;
  direction: ltr;   /* English letters, for the same reason as the slots */
}
#app .a5-letters.is-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3vmin;
  width: 100%;
  max-width: 84%;
  justify-items: center;
}
/* 25vmin = 97px at 390 wide. The tiles measured 82px at 21vmin, which is a small
   target for a four-year-old's primary control in three of the six lessons. */
#app .a5-letter {
  width: 25vmin;
  height: 25vmin;
  min-width: 88px;
  min-height: 88px;
  border: 0;
  border-radius: 3.6vmin;
  background: linear-gradient(180deg, #ffffff, #f2f7f0);
  box-shadow: 0 1.2vmin 0 rgba(18, 60, 44, .20), 0 1.6vmin 3vmin rgba(20, 50, 34, .16);
  font-family: inherit;
  font-size: 13vmin;
  line-height: 1;
  font-weight: 900;
  color: #143c26;
  direction: ltr;
  unicode-bidi: isolate;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform .13s ease-out, box-shadow .13s ease-out, opacity .2s ease-out;
}
#app .a5-letter.is-pressed {
  transform: scale(.93);
  box-shadow: 0 0 0 1vmin rgba(255, 255, 255, .9), 0 0 0 2.2vmin #2f8f52;
}
#app .a5-letter.is-right { box-shadow: 0 0 0 1vmin rgba(255, 255, 255, .9), 0 0 0 2.4vmin #35a356; }
#app .a5-letter.is-wrong { animation: a5-shake .3s ease-in-out 1; }
#app .a5-letter.is-hint { animation: a5-letter-hint 1.8s ease-in-out infinite; }
@keyframes a5-letter-hint {
  0%, 100% { box-shadow: 0 1.2vmin 0 rgba(18, 60, 44, .20), 0 0 0 0 rgba(53, 163, 86, 0); }
  50%      { box-shadow: 0 1.2vmin 0 rgba(18, 60, 44, .20), 0 0 0 1.4vmin rgba(53, 163, 86, .65); }
}
@media (prefers-reduced-motion: reduce) {
  #app .a5-letter.is-hint { animation: none; box-shadow: 0 0 0 1.4vmin rgba(53, 163, 86, .65); }
}
#app .a5-letter.is-dim { opacity: .55; }
/* A letter already used is gone from the tray, not greyed in place. */
#app .a5-letter.is-used { opacity: 0; pointer-events: none; }

/* The word being built, big, one line, never wrapped. */
#app .a5-build-word {
  font-size: 14vmin;
  line-height: 1;
  font-weight: 900;
  color: #143c26;
  direction: ltr;
  unicode-bidi: isolate;
  white-space: nowrap;
}
#app .a5-bee-side {
  width: 30vmin;
  max-width: 40%;
  height: auto;
  object-fit: contain;
  pointer-events: none;
}
#app .a5-word-row {
  display: flex;
  align-items: center;
  gap: 4vmin;
  justify-content: center;
  flex: none;
}

/* ==================================================================== *
 * THE RESULT
 * ==================================================================== */

/* Not a screen that covers the celebration: a panel that sits BELOW the Teacher, so
   he is never hidden while he is congratulating the child. */
#app .a5-result {
  position: relative;
  z-index: 6;
  width: 100%;
  max-width: 92%;
  /* VERTICALLY CENTRED. The stage column is top-aligned - correctly, for every lesson -
     so the result inherited that and sat across the top with a tall dead band under it.
     `auto` margins centre it in whatever space is left, which leaves the celebrating
     Teacher clear at the bottom instead of covering him. */
  margin: auto auto;
  margin-top: auto;
  padding: 3vmin 4vmin;
  border-radius: 4vmin;
  background: linear-gradient(180deg, rgba(255, 253, 246, .96), rgba(250, 246, 234, .93));
  border: 0.8vmin solid rgba(255, 255, 255, .85);
  box-shadow: 0 1.6vmin 4.4vmin rgba(24, 54, 38, .30);
  text-align: center;
  direction: rtl;
  opacity: 0;
  transform: translateY(1.6vmin);
  transition: opacity .22s ease-out, transform .22s ease-out;
}
#app .a5-result.is-on { opacity: 1; transform: translateY(0); }

#app .a5-stars {
  display: flex;
  justify-content: center;
  gap: 2vmin;
  margin-bottom: 1.4vmin;
}
/* The project's own existing star artwork - the 500x500 star in the KG1 unit 5
   curriculum folder - reused as it is. No new artwork. `object-fit: contain` so it is
   never cropped, and no opacity-dimming on the unearned ones: a translucent star over
   the cream panel looks like a printing fault, so the unearned state is simply smaller
   and flat. */
#app .a5-star {
  width: 11vmin;
  height: 11vmin;
  min-width: 30px;
  min-height: 30px;
  object-fit: contain;
  display: block;
  filter: grayscale(1) opacity(.22);
  transform: scale(.74);
  transition: filter .25s ease-out, transform .25s ease-out;
}
#app .a5-star.is-on { filter: none; transform: scale(1); }
#app .a5-result-msg {
  margin: 0;
  font-size: 6.2vmin;
  line-height: 1.3;
  font-weight: 800;
  color: #123c2c;
}
#app .a5-result-sub {
  margin: 1vmin 0 0;
  font-size: 4.8vmin;
  line-height: 1.35;
  font-weight: 700;
  color: #2c5a3d;
}
#app .a5-back {
  margin-top: 2.4vmin;
  min-height: 12vmin;
  min-width: 32vmin;
  padding: 2.2vmin 5vmin;
  border: 0;
  border-radius: 999px;
  background: #2f8f52;
  color: #fff;
  font-family: inherit;
  font-size: 5.6vmin;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: 0 1.2vmin 0 rgba(20, 74, 44, .35);
}
#app .a5-back:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(20, 74, 44, .35); }

/* ==================================================================== *
 * THE AUDIO WAIT.
 *
 * Shown ONLY when narration genuinely failed - blocked audio, a refused play, no
 * fallback. It is the visible face of the rule "no audio is not audio completed":
 * the scene underneath is untouched and NOT advanced, and this is the one thing the
 * child can press. On a phone that press is also the user gesture the browser asks
 * for before it will let audio play, so the same tap both recovers the situation and
 * unlocks the media pipeline.
 *
 * Deliberately not an error, not a message about sound, and not a countdown: one
 * label, one button, no technical wording anywhere.
 * ==================================================================== */
#app .a5-audiowait {
  /* `absolute`, not `fixed`: the root has `perspective`, which makes a fixed
     descendant resolve against the root rather than the viewport. The root is
     `inset:0`, so absolute against it is the same box with no such subtlety. */
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 30;
  width: 78vmin;
  max-width: 82vw;
  padding: 6vmin 5vmin;
  border-radius: 4vmin;
  background: linear-gradient(180deg, #fffdf6, #faf6ea);
  box-shadow: 0 1.6vmin 5vmin rgba(24, 54, 38, .38);
  text-align: center;
  direction: rtl;
  padding: 5vmin 4vmin;
}
#app .a5-audiowait-msg {
  margin: 0 0 3vmin;
  font-size: 6vmin;
  font-weight: 800;
  color: #123c2c;
}
/* One label, one control: the panel exists to hold the button, so the button carries
   the whole invitation. */
#app .a5-audiowait-btn {
  width: 100%;
  min-height: 13vmin;
  padding: 2.6vmin 5vmin;
  border: 0;
  border-radius: 999px;
  background: #2f8f52;
  color: #fff;
  font-family: inherit;
  font-size: 5.8vmin;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: 0 1.2vmin 0 rgba(20, 74, 44, .35);
}
#app .a5-audiowait-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(20, 74, 44, .35); }