/**
 * Mascot — the OctoFunnel octopus brand illustration.
 *
 * A self-contained, reusable brand component (Architecture §13). Five PNG layers stack via absolute
 * positioning; each tentacle wiggles on its own transform-origin + cadence, and the whole figure
 * floats. The art lives in `public/mascot/p1..p5.png` (clean-room copies — never references legacy
 * `/crm/`). All styling is class-based here so the component JSX carries no inline `style=`.
 *
 * Loading: until every part has decoded, an octopus-shaped grey skeleton (inline SVG, see
 * `octo-silhouette.ts`) shows a left→right shimmer. On ready we reveal the body first, then bounce
 * the tentacles out from their attach points — so nothing behind the head flashes through.
 *
 * Aspect ratio: source art is 700×445 → 445/700 ≈ 63% padding-top keeps every layer in register.
 */

.mascot {
  display: block;
  max-width: 300px;
  margin-inline: auto;
}

.mascot__stage {
  position: relative;
  top: 13px;
  padding-top: 63%;
  animation: mascot-float 4s ease-in-out infinite;
}

/* Only the partner-enabled gradient CTA gets an accent-colored silhouette shadow. The renderer derives
   --brand-shadow from the website accent as a restrained, deeper tonal companion. */
.mascot[data-octo-cta-mascot] .mascot__stage {
  filter: drop-shadow(
    0 0.6rem 0.4rem color-mix(in srgb, var(--brand-shadow, #96382b) 55%, transparent)
  );
}

/* ── Parts ─────────────────────────────────────────────────────────────────────────────────────
   .mascot__layer  → absolute positioning (+ p3's static tilt)
   .mascot__reveal → the one-shot scale-in on ready (kept off the art so it composes with the wiggle)
   .mascot__art    → the PNG background + its perpetual tentacle wiggle */
.mascot__layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
}
.mascot__p3 {
  transform-origin: 34% 40%;
  transform: rotate(5deg);
}

.mascot__reveal {
  display: block;
  opacity: 0; /* hidden behind the skeleton until the staged reveal runs */
}

.mascot__art {
  display: block;
  padding-top: 63%;
  background-repeat: no-repeat;
  background-size: contain;
}

/* Layer order matches paint order: p5 (back) → p1 (body, front). transform-origin is each tentacle's
   attach point — shared by the wiggle (on .art) and the pop-in scale (on .reveal). */
.mascot__p5 .mascot__art {
  background-image: url('/mascot/p5.png');
  transform-origin: 32% 40%;
  animation: mascot-wiggle 3s ease infinite;
}
.mascot__p4 .mascot__art {
  background-image: url('/mascot/p4.png');
  transform-origin: 61% 36%;
  animation: mascot-wiggle 2.5s ease infinite;
}
.mascot__p3 .mascot__art {
  background-image: url('/mascot/p3.png');
  transform-origin: 34% 40%;
  animation: mascot-wiggle 3.2s ease infinite;
}
.mascot__p2 .mascot__art {
  background-image: url('/mascot/p2.png');
  transform-origin: 51% 59%;
  animation: mascot-wiggle 2.8s ease infinite;
}
.mascot__p1 .mascot__art {
  background-image: url('/mascot/p1.png');
}

.mascot__p5 .mascot__reveal {
  transform-origin: 32% 40%;
}
.mascot__p4 .mascot__reveal {
  transform-origin: 61% 36%;
}
.mascot__p3 .mascot__reveal {
  transform-origin: 34% 40%;
}
.mascot__p2 .mascot__reveal {
  transform-origin: 51% 59%;
}
.mascot__p1 .mascot__reveal {
  transform-origin: 50% 52%;
}

/* ── Staged reveal (on ready) ──────────────────────────────────────────────────────────────────
   Head (p1) first, quick and gentle; tentacles bounce out from their attach points ~200ms later. */
.mascot[data-ready='true'] .mascot__reveal {
  animation: mascot-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.mascot[data-ready='true'] .mascot__p1 .mascot__reveal {
  animation: mascot-pop-head 0.34s ease-out both;
}
.mascot[data-ready='true'] .mascot__p5 .mascot__reveal {
  animation-delay: 0.2s;
}
.mascot[data-ready='true'] .mascot__p4 .mascot__reveal {
  animation-delay: 0.24s;
}
.mascot[data-ready='true'] .mascot__p3 .mascot__reveal {
  animation-delay: 0.28s;
}
.mascot[data-ready='true'] .mascot__p2 .mascot__reveal {
  animation-delay: 0.32s;
}

/* ── Loading skeleton ──────────────────────────────────────────────────────────────────────────
   Inline SVG octopus filled with a shimmering gradient (the sweep itself is SMIL in the markup). */
.mascot__skeleton {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 1;
  transition: opacity 0.45s ease;
}
.mascot[data-ready='true'] .mascot__skeleton {
  opacity: 0;
}
.mascot__stop--base {
  stop-color: #d4d7de;
}
.mascot__stop--hi {
  stop-color: #f1f3f6;
}
.dark .mascot__stop--base {
  stop-color: rgba(255, 255, 255, 0.1);
}
.dark .mascot__stop--hi {
  stop-color: rgba(255, 255, 255, 0.24);
}

@keyframes mascot-pop {
  from {
    opacity: 0;
    transform: scale(0.25);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes mascot-pop-head {
  from {
    opacity: 0;
    transform: scale(0.72);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes mascot-wiggle {
  0% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(-5deg);
  }
  100% {
    transform: rotate(0deg);
  }
}

@keyframes mascot-float {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3%);
  }
  100% {
    transform: translateY(0);
  }
}

/* Respect users who ask the OS to reduce motion: no float/wiggle/bounce, no shimmer transition, and
   parts appear instantly once ready (the SMIL sweep is omitted at render time for these users). */
@media (prefers-reduced-motion: reduce) {
  .mascot__stage,
  .mascot__art {
    animation: none !important;
  }
  .mascot__reveal {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .mascot__skeleton {
    transition: none !important;
  }
}
