:root {
  color-scheme: dark;
  --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: transparent;
}

body {
  position: fixed;
  inset: 0;
  overscroll-behavior: none;
}

.viewport {
  position: fixed;
  inset: 0;
  isolation: isolate;
}

.world-zone {
  position: fixed;
  inset: auto 0 0;
  width: 100%;
  height: 34vh;
  height: 34dvh;
  overflow: visible;
  contain: layout style;
  pointer-events: none;
  background: transparent;
}

.world-entity {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: var(--depth, 1);
  transform: translate3d(var(--x, 0px), var(--y, 0px), 0);
  transition: transform var(--move-duration, 0ms) linear;
  will-change: transform;
}

html[data-mobile-reference="1"] .world-zone { height: 58vh; }

.entity-shell {
  position: relative;
  opacity: 1;
  transform: translate3d(0, var(--ground-offset, 0%), 0) scale(1);
  filter: blur(0);
  clip-path: inset(0 0 0 0);
  transition:
    opacity 760ms var(--ease-out-quint),
    transform 760ms var(--ease-out-quint),
    filter 640ms var(--ease-out-quint),
    clip-path 760ms var(--ease-out-quint);
  will-change: opacity, transform, filter, clip-path;
}

.world-entity.is-entering .entity-shell {
  opacity: 0;
  transform: translate3d(0, calc(var(--ground-offset, 0%) + 12px), 0) scale(0.96);
  filter: blur(7px);
  clip-path: inset(28% 0 0 0);
}

.world-entity.is-leaving .entity-shell {
  opacity: 0;
  transform: translate3d(0, calc(var(--ground-offset, 0%) + 10px), 0) scale(0.97);
  filter: blur(5px);
  clip-path: inset(18% 0 0 0);
  transition-duration: 620ms;
}

.entity-media {
  display: block;
  width: auto;
  height: var(--entity-height, 12vh);
  max-height: 34vh;
  max-height: 34dvh;
  border: 0;
  outline: 0;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.entity-video {
  background: #000;
}

.entity-image {
  background: transparent;
}

.world-entity.is-ambient .entity-video {
  background: transparent;
}

.world-entity.is-swapping .entity-media {
  opacity: 0.16;
  transition: opacity 110ms ease-out;
}

.world-entity.is-thing .entity-media {
  width: var(--entity-width, var(--entity-height, 12vh));
  height: auto;
  /* Preserve the decoded image ratio, including when max-height clamps the box. */
  aspect-ratio: auto;
  object-fit: contain;
  object-position: center bottom;
  transform-origin: 50% 100%;
  animation: bottom-world-thing-float var(--spin-duration, 4600ms) ease-in-out infinite;
  animation-direction: var(--spin-direction, normal);
  will-change: transform;
}

@keyframes bottom-world-thing-float {
  from {
    transform: translateY(0) scale(1);
  }

  to {
    transform: translateY(-4px) scale(1.02);
  }
}

@media (max-width: 639px) {
  .entity-media {
    max-width: 38vw;
  }

  .world-entity.is-thing .entity-media {
    width: min(var(--entity-width, 38vw), 38vw);
    height: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .world-entity {
    transition-duration: 0ms !important;
  }

  .entity-shell {
    filter: none !important;
    clip-path: none !important;
    transform: translate3d(0, var(--ground-offset, 0%), 0) !important;
    transition: opacity 160ms linear !important;
  }

  .world-entity.is-thing .entity-media {
    animation: none !important;
  }
}

/* Agent height is calibrated to the visible subject, excluding transparent padding. */
.world-entity.is-agent .entity-media {
  max-height: none;
  max-width: none;
}
.world-entity.is-agent .entity-shell {
  transition-property: opacity, filter, clip-path;
}
