/* Living MOSS presence. The host gives the square stage its width (the app's
   Talk hero passes a square canvas). Layers follow MossLivingFormView: bio light,
   soft ground and intelligence glow behind the form. Without JS or WebGL, and
   under Reduce Motion, the original artwork stands still in the same place. */

.moss-presence {
  /* MossLivingMotion.fittedScale(.92) at idle strength 1. presence.js keeps it exact. */
  --moss-fit: 0.845905;
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  isolation: isolate;
  line-height: 0;
  pointer-events: none;
  user-select: none;
}

.moss-presence__bio,
.moss-presence__ground,
.moss-presence__glow {
  position: absolute;
  z-index: 0;
  display: block;
  pointer-events: none;
}

/* EllipticalGradient, side * 1.35 wide and side tall, centred (0.5 + drift, 0.52). */
.moss-presence__bio {
  top: 0;
  left: -17.5%;
  width: 135%;
  height: 100%;
  background: radial-gradient(50% 50% at 50% 52%,
    rgba(169, 201, 175, 0.16) 0%,
    rgba(169, 201, 175, 0.05) 42%,
    rgba(169, 201, 175, 0) 100%);
}

/* edge * 0.58 x edge * 0.085, offset y edge * 0.50: mossInk at 10%. */
.moss-presence__ground {
  width: calc(58% * var(--moss-fit));
  height: calc(8.5% * var(--moss-fit));
  left: calc(50% - 29% * var(--moss-fit));
  top: calc(50% + 45.75% * var(--moss-fit));
  background: radial-gradient(50% 50% at 50% 50%, rgba(18, 21, 18, 0.10), rgba(18, 21, 18, 0));
}

/* edge * 0.42 x edge * 0.07, offset y edge * 0.47: intelligence to sage. */
.moss-presence__glow {
  width: calc(42% * var(--moss-fit));
  height: calc(7% * var(--moss-fit));
  left: calc(50% - 21% * var(--moss-fit));
  top: calc(50% + 43.5% * var(--moss-fit));
  background: radial-gradient(50% 50% at 50% 50%,
    rgba(55, 92, 71, 0.09) 0%,
    rgba(118, 146, 126, 0.03) 55%,
    rgba(118, 146, 126, 0) 100%);
}

.moss-presence > .moss-presence__form {
  position: absolute;
  z-index: 1;
  left: calc(50% - 50% * var(--moss-fit));
  top: calc(50% - 50% * var(--moss-fit));
  width: calc(100% * var(--moss-fit));
  height: calc(100% * var(--moss-fit));
  max-width: none;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
}

.moss-presence > .moss-presence__stage {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: transparent;
  opacity: 0;
  visibility: hidden;
}

/* Hand-off: the live canvas fades in over the original, then the original is
   removed from rendering. Leaving live (context loss, Reduce Motion) is instant. */
.moss-presence--live > .moss-presence__stage {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.42s cubic-bezier(0.2, 0.6, 0.2, 1);
}

.moss-presence--live > .moss-presence__form {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease 0.14s, visibility 0s linear 0.44s;
}

.moss-presence[data-surround="off"] > .moss-presence__bio,
.moss-presence[data-surround="off"] > .moss-presence__ground,
.moss-presence[data-surround="off"] > .moss-presence__glow,
.moss-presence[data-surround="light"] > .moss-presence__ground,
.moss-presence[data-surround="light"] > .moss-presence__glow {
  display: none;
}

/* Reduce Motion: strength 0, so the fit is the pose scale and there is no soft ground. */
@media (prefers-reduced-motion: reduce) {
  .moss-presence {
    --moss-fit: 0.92;
  }
  .moss-presence__ground,
  .moss-presence__glow {
    display: none;
  }
  .moss-presence > * {
    transition: none !important;
  }
}

/* Increase Contrast / Reduce Transparency: the app drops the decorative light. */
@media (prefers-contrast: more), (prefers-reduced-transparency: reduce) {
  .moss-presence__bio,
  .moss-presence__ground,
  .moss-presence__glow {
    display: none;
  }
}
