/* Parallax box-follower panel. A box chases the cursor along a center line,
   with parallaxed background + foreground layers. Scoped to .parallax-stage and
   wired up by js/parallax.js. Adapted from a full-viewport demo to sit inside a
   bounded section and pull its colors from the active theme. */

.parallax-stage {
  position: relative;
  height: 260px;
  margin: 0.5rem 0 0.75rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev);
  cursor: crosshair;
  touch-action: none;
}

/* Horizontal line the box rides along. */
.parallax-line {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--border);
  z-index: 3;
}

/* Tileable background strips — scrolled via background-position-x in JS.
   Placeholders are inline SVG silhouettes; drop real sprites in
   public/assets/parallax/ and swap the background-image url (see that
   folder's README). */
.parallax-bg {
  position: absolute;
  left: 0;
  width: 100%;
  background-repeat: repeat-x;
  background-size: auto 100%;
  pointer-events: none;
  will-change: background-position;
  image-rendering: pixelated;
  opacity: 0.7;
}
.parallax-bg-far {
  z-index: 1;
  height: 140px;
  top: calc(50% - 140px); /* bottom edge sits on the line */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='400' height='180' viewBox='0 0 400 180' preserveAspectRatio='none'><path d='M0,180 L0,90 L70,40 L140,90 L210,30 L280,80 L350,55 L400,90 L400,180 Z' fill='%232a2a35'/></svg>");
}
.parallax-bg-mid {
  z-index: 2;
  height: 95px;
  top: calc(50% - 95px);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='120' viewBox='0 0 300 120'><rect x='20' y='40' width='40' height='80' fill='%23394a6b'/><rect x='80' y='60' width='30' height='60' fill='%23394a6b'/><rect x='130' y='30' width='50' height='90' fill='%23394a6b'/><rect x='200' y='55' width='35' height='65' fill='%23394a6b'/><rect x='255' y='45' width='30' height='75' fill='%23394a6b'/></svg>");
}

/* Foreground container — translated as one group for parallax. */
.parallax-fg {
  position: absolute;
  inset: 0;
  z-index: 5; /* in front of the box (z:4) */
  pointer-events: none;
  will-change: transform;
}
.parallax-prop {
  position: absolute;
  transform: translate(-50%, -50%);
  background: color-mix(in srgb, var(--accent) 65%, transparent);
  border: 2px solid var(--border);
  border-radius: 4px;
}

/* The box. JS sets --facing (1 = right, -1 = left) and the .moving/.resting/
   .idle state class; translate centers it, scaleX flips it. */
.parallax-box {
  position: absolute;
  top: 50%;
  left: 0;
  width: 60px;
  height: 60px;
  --facing: 1;
  transform: translate(-50%, -50%) scaleX(var(--facing));
  z-index: 4;
  background: var(--accent);
  border: 2px solid var(--bg);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--bg);
  transition: background 0.2s ease;
  user-select: none;
  pointer-events: none; /* so the stage stays the pointer target */
}
/* Counter-flip the label so it stays readable when the box mirrors. */
.parallax-box::before {
  content: attr(data-state);
  transform: scaleX(var(--facing));
}
.parallax-box.moving { background: #ff8c42; }
.parallax-box.resting { background: var(--accent); }
.parallax-box.idle { background: var(--fg-muted); }
