/* ============================================================================
 * ASHTAR KATKOOT - ADVENTURE 8, ACTIVITY 1: THE THREE PATH MARKERS (activity styles)
 *
 * This is the `a8-` prefix of Adventure 7's proven carrot-garden stylesheet. The
 * mechanic is reused, so the geometry and the comments are deliberately IDENTICAL - only
 * the sprite changed, from a carrot to a path marker.
 *
 * The one genuinely new measurement is the marker itself. `c8-path-marker.png` is
 * 1536x1024 - LANDSCAPE, and it carries wide blank margins either side of the sign: the
 * visible sign occupies roughly the middle 72% of the image width. Two consequences, both
 * handled below rather than guessed at:
 *
 *   - the picture is sized with `object-fit: contain` inside a SQUARE button, so a
 *     landscape sprite is letterboxed by the art itself and never squashed;
 *   - the touch target is deliberately much larger than the visible sign, because the
 *     blank margins are not tappable-looking but ARE tappable.
 *
 * Layering, top to bottom:
 *
 *   .a8-garden      the activity surface
 *   .a8-garden-bg   the artwork, object-fit:cover
 *   .a8-fly         a marker in flight, above everything
 *   .a8-panel       the three-slot tracker (never interactive)
 *   .a8-marker      a findable sign, among the rocks
 * ========================================================================== */

#app .a8-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 markers are also
     inert until `open()` runs. Either one alone would already be enough. */
  pointer-events: none;
}
#app .a8-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 .a8-garden.is-closing {
  opacity: 0;
  transition: opacity .32s ease;
  pointer-events: none;
}

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

/* ------------------------------------------------------------------------ *
 * A FINDABLE MARKER
 *
 * The button is the touch target and is deliberately LARGER than the picture the child
 * sees, because the sign's own blank margins would otherwise shrink the real target to
 * about 72% of its apparent size.
 *
 * 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 wore a
 * solid brown bar under it that read as a brush stroke on the sand. */
#app .a8-marker {
  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 sign. It never stops
     moving long enough to read as decoration. */
  animation: a8-marker-bob 3.4s ease-in-out infinite;
}
#app .a8-marker-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* The sign is landscape; `contain` letterboxes it inside the square button instead of
     stretching it, and keeps its proportions exactly as drawn. */
  object-fit: contain;
  /* A soft contact shadow anchors the sign in the sand instead of letting it float over
     the painting. */
  filter: drop-shadow(0 3px 4px rgba(90, 60, 20, .40));
  transform-origin: 50% 90%;
  will-change: transform;
}
/* A soft radial glow rather than a ring: a hard outline read as a stray brush stroke and
   made the screen look assembled rather than drawn. */
#app .a8-marker-glow {
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255, 244, 190, .34) 0%,
    rgba(255, 230, 150, .16) 45%,
    rgba(255, 230, 150, 0) 70%);
  animation: a8-marker-glow 3.4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes a8-marker-bob {
  0%, 100% { transform: translate(-50%, -50%) translateY(0) rotate(-1.2deg); }
  50%      { transform: translate(-50%, -50%) translateY(-4px) rotate(1.2deg); }
}
@keyframes a8-marker-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 .a8-marker.is-found .a8-marker-img {
  animation: a8-marker-found 300ms cubic-bezier(.34, 1.56, .64, 1) both;
}
#app .a8-marker.is-found .a8-marker-glow { opacity: 0; transition: opacity 160ms linear; }
@keyframes a8-marker-found {
  0%   { transform: scale(1) rotate(0deg); }
  32%  { transform: scale(1.18, .86) rotate(-5deg); }   /* squash into the sand */
  64%  { transform: scale(.94, 1.10) rotate(3deg); }     /* stretch up            */
  100% { transform: scale(1) rotate(0deg); }
}
#app .a8-marker.is-gone { animation: none; opacity: 0; }
#app .a8-marker.is-taken { pointer-events: none; }

/* ------------------------------------------------------------------------ *
 * THE TRACKER - three adjacent slots
 *
 * Sits at the bottom, below the lowest findable marker (which ends at y ~700) and well
 * below Camel (whose hooves end near y 627). It is purely a readout: it never takes a
 * tap, so it can never swallow one meant for a marker.
 * ------------------------------------------------------------------------ */
#app .a8-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 lays the
     slots out right-to-left. Every class-based check still passed, because the DOM order
     was correct - only the PICTURE was wrong. `direction: ltr` makes the first slot the
     leftmost one, so index order and visual order are the same thing. */
  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 one slot read over sand while another read over
     a plant - a row of identical slots that did not look identical. */
  background: rgba(255, 248, 226, .60);
  border: 2px solid rgba(255, 255, 255, .62);
  box-shadow: 0 4px 14px rgba(90, 60, 20, .30);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
}
#app .a8-slot {
  position: relative;
  width: 17vmin;
  height: 15.5vmin;
  border-radius: 14px;
  background: rgba(255, 255, 255, .34);
  border: 2px dashed rgba(150, 125, 80, .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 .a8-slot-chip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#app .a8-slot-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: filter .3s ease, opacity .3s ease;
}
/* EMPTY: the same sign picture, dimmed. Nothing is swapped in - the silhouette IS the
   asset, and it is the very element that later turns colour. That is why a slot can never
   look like a different object once filled. */
#app .a8-slot.is-unknown .a8-slot-img {
  filter: grayscale(1) brightness(.46) contrast(1.12);
  opacity: .70;
}
/* FULL: full colour, and a brief pop so the arrival is felt. */
#app .a8-slot.is-full {
  background: rgba(255, 246, 214, .78);
  border: 2px solid #fff;
  box-shadow: 0 3px 0 rgba(90, 56, 16, .32);
}
#app .a8-slot.is-full .a8-slot-img { filter: none; opacity: 1; }
#app .a8-slot.is-popping { animation: a8-slot-pop 260ms cubic-bezier(.3, 1.5, .5, 1); }
@keyframes a8-slot-pop {
  0%   { transform: scale(.62); }
  60%  { transform: scale(1.14); }
  100% { transform: scale(1); }
}

/* ------------------------------------------------------------------------ *
 * A MARKER IN FLIGHT - above everything, including the tracker.
 * ------------------------------------------------------------------------ */
#app .a8-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(90, 60, 20, .35));
}

/* ------------------------------------------------------------------------ *
 * THE SPARKLE - visual only. It never plays audio, so it cannot collide with the
 * narration bus.
 * ------------------------------------------------------------------------ */
#app .a8-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: a8-sparkle 600ms ease-out both;
}
@keyframes a8-sparkle {
  0%   { transform: scale(.4); opacity: .95; }
  100% { transform: scale(3.4); opacity: 0; }
}

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

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