/* ============================================================================
 * ASHTAR KATKOOT - ADVENTURE 7, PHASE 2: THE CARROT GARDEN (activity styles)
 *
 * THERE IS NO GROUND BASKET IN THIS FILE. The mechanic was replaced, not repaired:
 * the artwork already shows Rabbit carrying a basket, so a second one contradicted
 * the picture, and the basket asset is a front view with no visible cavity - carrots
 * either floated above its rim or vanished behind solid wicker. `c7-empty-basket.png`
 * is not referenced anywhere in Phase 2 any more.
 *
 * What replaces it is the project's own discovery language, from
 * `animal-rescue.css` (`.c1-chip.is-unknown` / `.c1-chipart`): a rounded slot that
 * shows the carrot as a dimmed SILHOUETTE, and turns to full colour only once the
 * carrot has physically arrived.
 *
 * Layering, top to bottom:
 *
 *   .a7-garden      the activity surface
 *   .a7-garden-bg   the artwork, object-fit:cover
 *   .a7-fly         a carrot in flight, above everything
 *   .a7-panel       the three-slot collection panel (never interactive)
 *   .a7-carrot      a findable carrot, among the foliage
 * ========================================================================== */

#app .a7-garden {
  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; the second is that the carrots are also
     inert until `open()` runs. Either one alone would already be enough. */
  pointer-events: none;
}
#app .a7-garden.is-open { pointer-events: auto; }
/* The hand-off to the closing story illustration: fade out, then the activity removes
   itself and calls `activityDone()`. Nothing interactive survives this. */
#app .a7-garden.is-closing {
  opacity: 0;
  transition: opacity .32s ease;
  pointer-events: none;
}

/* ------------------------------------------------------------------------ *
 * THE ARTWORK
 * ------------------------------------------------------------------------ */
#app .a7-garden-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}
#app .a7-garden-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Verified: rendered through these rules at 390x844, no row or column of the
     artwork lets the root colour through. */
  object-position: 50% 50%;
}

/* ------------------------------------------------------------------------ *
 * A FINDABLE CARROT
 *
 * The button is the touch target and is deliberately LARGER than the picture the
 * child sees: the image fills 78% of the button, leaving an invisible margin of
 * roughly 11% of the target on every side - the difference between a tap landing and
 * missing for small 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(...)}`. `#app .a7-carrot` outranks it for the properties
 * it sets - but a rule only overrides what it actually DECLARES. An earlier version
 * reset padding, border and background and silently inherited the box-shadow, so every
 * carrot wore a solid brown bar under it that read as a brush stroke on the garden.
 * `box-shadow` and `border-radius` are therefore reset explicitly. */
#app .a7-carrot {
  position: absolute;
  z-index: 3;
  transform: translate(-50%, -50%);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  box-shadow: none;
  border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  /* A gentle invitation that marks this as the findable kind of carrot. It never stops
     moving long enough to read as decoration. */
  animation: a7-bob 3.4s ease-in-out infinite;
}
#app .a7-carrot-img {
  position: absolute;
  inset: 11%;
  width: 78%;
  height: 78%;
  object-fit: contain;
  /* A soft contact shadow anchors the carrot in the foliage instead of letting it
     float over the painting. */
  filter: drop-shadow(0 3px 4px rgba(20, 50, 20, .45));
  transform-origin: 50% 88%;
  will-change: transform;
}
/* A soft radial glow rather than a ring: a hard outline read as a stray brush stroke
   under the carrot and made the screen look assembled rather than drawn. */
#app .a7-carrot-glow {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255, 240, 170, .34) 0%,
    rgba(255, 226, 130, .16) 45%,
    rgba(255, 226, 130, 0) 70%);
  animation: a7-glow 3.4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes a7-bob {
  0%, 100% { transform: translate(-50%, -50%) translateY(0) rotate(-1.5deg); }
  50%      { transform: translate(-50%, -50%) translateY(-5px) rotate(1.5deg); }
}
@keyframes a7-glow {
  0%, 100% { opacity: .55; transform: scale(.94); }
  50%      { opacity: 1;   transform: scale(1.1); }
}

/* DISCOVERY - a squash then a pop, in the same frame as the press. */
#app .a7-carrot.is-found .a7-carrot-img {
  animation: a7-found 300ms cubic-bezier(.34, 1.56, .64, 1) both;
}
#app .a7-carrot.is-found .a7-carrot-glow { opacity: 0; transition: opacity 160ms linear; }
@keyframes a7-found {
  0%   { transform: scale(1) rotate(0deg); }
  32%  { transform: scale(1.22, .82) rotate(-7deg); }   /* squash into the leaves */
  64%  { transform: scale(.92, 1.14) rotate(5deg); }    /* stretch up             */
  100% { transform: scale(1) rotate(0deg); }
}
#app .a7-carrot.is-gone { animation: none; opacity: 0; }
#app .a7-carrot.is-taken { pointer-events: none; }

/* ------------------------------------------------------------------------ *
 * THE COLLECTION PANEL - three adjacent slots
 *
 * Sits at the bottom, below the lowest findable carrot (which ends at y 645) and well
 * below Rabbit (who ends at y 503). It is purely a readout: it never takes a tap, so
 * it can never swallow one meant for a carrot.
 * ------------------------------------------------------------------------ */
#app .a7-panel {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  /* THE DOCUMENT IS RTL (`<html lang="ar" dir="rtl">`), and a flex ROW therefore laid
     the slots out right-to-left: slot 0 rendered on the RIGHT and slot 2 on the LEFT.
     Every class-based check still passed, because the DOM order was correct - only the
     PICTURE was wrong, and carrots visibly filled backwards. `direction: ltr` makes the
     first slot the leftmost one, so index order and visual order are the same thing and
     the carrot travels left to right as it fills the row. */
  direction: ltr;
  gap: 8px;
  padding: 8px;
  border-radius: 20px;
  /* Opaque enough to give all three slots the SAME surface. At a lower alpha the panel
     picked up whatever was behind it and the third slot read green over the grass while
     the first two read cream over the path - a row of identical slots that did not look
     identical. */
  background: rgba(255, 250, 238, .56);
  border: 2px solid rgba(255, 255, 255, .62);
  box-shadow: 0 4px 14px rgba(20, 50, 20, .30);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
}
#app .a7-slot {
  position: relative;
  width: 15.5vmin;
  height: 15.5vmin;
  border-radius: 14px;
  background: rgba(255, 255, 255, .34);
  border: 2px dashed rgba(120, 140, 120, .58);
  overflow: hidden;
  transition: background .25s ease, border-color .25s ease, box-shadow .25s ease;
}
/* One identical box for every slot, so visual weight never depends on the sprite's
   intrinsic proportions. */
#app .a7-slot-chip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#app .a7-slot-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: filter .3s ease, opacity .3s ease;
}
/* EMPTY: the same carrot picture, dimmed. Nothing is swapped in - the silhouette IS
   the asset, and it is the very element that later turns colour. That is the
   `.c1-chip.is-unknown` treatment, and it is why a slot can never look like a
   different object once filled. */
#app .a7-slot.is-unknown .a7-slot-img {
  filter: grayscale(1) brightness(.42) contrast(1.15);
  opacity: .72;
}
/* FULL: full colour, and a brief pop so the arrival is felt. */
#app .a7-slot.is-full {
  background: rgba(255, 246, 214, .78);
  border: 2px solid #fff;
  box-shadow: 0 3px 0 rgba(20, 70, 40, .32);
}
#app .a7-slot.is-full .a7-slot-img { filter: none; opacity: 1; }
#app .a7-slot.is-popping { animation: a7-pop 260ms cubic-bezier(.3, 1.5, .5, 1); }
@keyframes a7-pop {
  0%   { transform: scale(.62); }
  60%  { transform: scale(1.14); }
  100% { transform: scale(1); }
}

/* ------------------------------------------------------------------------ *
 * A CARROT IN FLIGHT - above everything, including the panel.
 * ------------------------------------------------------------------------ */
#app .a7-fly {
  position: absolute;
  z-index: 6;
  object-fit: contain;
  pointer-events: none;
  transform-origin: 50% 50%;
  will-change: transform;
  filter: drop-shadow(0 6px 8px rgba(20, 50, 20, .35));
}

/* ------------------------------------------------------------------------ *
 * THE SPARKLE - visual only. It never plays audio, so it cannot collide with the
 * narration bus.
 * ------------------------------------------------------------------------ */
#app .a7-sparkle {
  position: absolute;
  z-index: 7;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255, 246, 200, .95) 0%, rgba(255, 214, 92, 0) 70%);
  animation: a7-sparkle 600ms ease-out both;
}
@keyframes a7-sparkle {
  0%   { transform: scale(.4); opacity: .95; }
  100% { transform: scale(3.4); opacity: 0; }
}

/* A short screen still has to fit the panel and the carrots. */
@media (max-height: 620px) {
  #app .a7-panel { bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); padding: 6px; }
  #app .a7-slot { width: 13vmin; height: 13vmin; border-radius: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  #app .a7-carrot,
  #app .a7-carrot-glow { animation: none; }
  #app .a7-slot.is-popping { animation-duration: 1ms; }
  #app .a7-sparkle { animation-duration: 1ms; }
}