/* Pixel world: sprites are drawn at 3x with nearest-neighbour scaling. */

.spr {
  position: absolute;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  pointer-events: none;
}

.px-thumb,
.floor-chunk,
.mm-map-preview,
.pv-floor-canvas {
  image-rendering: pixelated;
}

.px-thumb {
  display: block;
}

/* Objects */

.obj > .spr,
.obj-over > .spr {
  bottom: 0;
}

.obj-over {
  position: absolute;
  pointer-events: none;
}

.obj.pet {
  transition: left 0.95s linear, top 0.95s linear, opacity 0.2s;
}

.obj.pet.flip > .spr {
  transform: scaleX(-1);
}

.entities-layer .obj.hl > .spr.spr,
.entities-layer .obj.hl > .spr.spr:not(.x) {
  filter: drop-shadow(3px 0 0 #fff) drop-shadow(-3px 0 0 #fff) drop-shadow(0 3px 0 #fff) drop-shadow(0 -3px 0 #fff) drop-shadow(0 0 6px rgba(255, 210, 80, 0.85));
  animation: pxHighlight 1.3s ease-in-out infinite;
}

@keyframes pxHighlight {
  50% {
    filter: drop-shadow(3px 0 0 #fff8d6) drop-shadow(-3px 0 0 #fff8d6) drop-shadow(0 3px 0 #fff8d6) drop-shadow(0 -3px 0 #fff8d6) drop-shadow(0 0 12px rgba(255, 210, 80, 0.95));
  }
}

.entities-layer .obj.erase-target > .spr.spr {
  filter: drop-shadow(3px 0 0 var(--accent)) drop-shadow(-3px 0 0 var(--accent)) drop-shadow(0 3px 0 var(--accent)) drop-shadow(0 -3px 0 var(--accent));
  animation: none;
}

.world[data-tool='erase'] .entities-layer .obj.erase-target > .spr.spr {
  filter: drop-shadow(3px 0 0 var(--bad)) drop-shadow(-3px 0 0 var(--bad)) drop-shadow(0 3px 0 var(--bad)) drop-shadow(0 -3px 0 var(--bad)) saturate(0.6);
}

.obj.ghost,
.obj-over.ghost {
  opacity: 0.8;
  filter: none;
}

.obj.ghost > .spr {
  filter: drop-shadow(0 0 3px rgba(62, 207, 142, 0.9));
}

.obj.ghost.bad > .spr,
.obj-over.ghost.bad > .spr {
  filter: drop-shadow(0 0 3px rgba(255, 92, 122, 0.9)) grayscale(0.6);
}

.obj.ghost::after {
  z-index: -1;
}

.obj-music .spr {
  position: absolute;
  top: -18px;
  animation: notes 2.2s ease-out infinite;
}

.obj-music .spr.n2 {
  left: auto;
  right: 0;
  animation-delay: 1.1s;
}

.obj-music .fa-solid {
  position: absolute;
  top: -16px;
  left: 50%;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  animation: notes 2.2s ease-out infinite;
}

/* Portals */

.portal-mark .spr {
  left: 0;
  top: 0;
}

.portal-mark .spr + * {
  display: none;
}

/* Players */

.player.pixel-av .av-bob {
  left: 0;
  bottom: 0;
  width: 48px;
  height: 48px;
  margin: 0;
  transition: transform 0.15s ease;
}

.player.pixel-av .av-spr {
  bottom: 3px;
}

.player.pixel-av .av-shadow {
  bottom: 1px;
  width: 30px;
  height: 9px;
  margin-left: -15px;
  background: rgba(20, 18, 40, 0.26);
  filter: none;
}

.player.pixel-av.walking .av-shadow {
  animation: none;
}

.player.pixel-av.sitting .av-bob {
  transform: translateY(var(--seat, -9px));
}

.player.pixel-av.sitting .av-shadow {
  opacity: 0;
}

.player.pixel-av.sitting .av-spr {
  clip-path: inset(0 0 12px 0);
}

.player.pixel-av.away .av-spr {
  filter: grayscale(0.5) brightness(0.92);
  opacity: 0.85;
}

.player.pixel-av.located .av-spr {
  filter: drop-shadow(0 0 6px #ffd84d);
}

/* Held items sit at the character's hand for each facing (hand columns from the character art). */
.player.pixel-av .av-item {
  left: 34px;
  right: auto;
  bottom: 18px;
  width: 0;
  height: auto;
  display: flex;
  justify-content: center;
  z-index: 1;
}

.player.pixel-av .av-item[data-dir='left'] {
  left: 22px;
}

.player.pixel-av .av-item[data-dir='right'] {
  left: 26px;
}

.player.pixel-av .av-item[data-dir='up'] {
  left: 14px;
  z-index: -1;
}

.player.pixel-av.sitting .av-item {
  bottom: 24px;
}

.av-item[hidden] {
  display: none;
}

.av-item .spr {
  position: relative;
  display: block;
}

.av-item .spr {
  flex: none;
}

/* Effects */

.emote-wrap .spr {
  position: relative;
  display: block;
}

.emote-missing {
  font-size: 24px;
  color: #fff;
}

.trail-particle.spr,
.poof-particle.spr,
.obj-float.spr {
  position: absolute;
}

/* Thumbnails that show a pixel avatar in UI lists. */

.px-av-thumb {
  position: relative;
  display: inline-flex;
  align-items: flex-start;
  justify-content: center;
  overflow: hidden;
  flex: none;
  border-radius: 30%;
  background: color-mix(in srgb, var(--ring, #7c8cff) 22%, transparent);
}

.px-av-thumb.full {
  align-items: flex-end;
}

.px-av-thumb canvas {
  image-rendering: pixelated;
  flex: none;
}

.px-av-thumb.off,
.av-thumb.off {
  opacity: 0.45;
  filter: grayscale(0.6);
}

/* Hovering something you can use: a crisp white outline. */

.world.hovering-obj {
  cursor: pointer;
}

.entities-layer .obj.hover:not(.hl) > .spr.spr,
.entities-layer .obj-over.hover > .spr.spr {
  filter: drop-shadow(3px 0 0 rgba(255, 255, 255, 0.92)) drop-shadow(-3px 0 0 rgba(255, 255, 255, 0.92)) drop-shadow(0 3px 0 rgba(255, 255, 255, 0.92)) drop-shadow(0 -3px 0 rgba(255, 255, 255, 0.92));
  animation: none;
}

.player.pixel-av .av-spr {
  pointer-events: auto;
}

/* Build mode */

.obj.ghost,
.obj.ghost.pet {
  transition: none;
}

.obj.moving-src,
.obj-over.moving-src {
  visibility: hidden;
}

/* Press and hold to teleport */

.hold-ring {
  position: fixed;
  z-index: 40;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  pointer-events: none;
  --p: 0%;
  background: conic-gradient(var(--accent) var(--p), rgba(255, 255, 255, 0.18) 0);
  -webkit-mask: radial-gradient(circle, transparent 15px, #000 16px);
  mask: radial-gradient(circle, transparent 15px, #000 16px);
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 60%, transparent));
}

.hold-ring[hidden] {
  display: none;
}

@property --p {
  syntax: '<percentage>';
  inherits: false;
  initial-value: 0%;
}

.hold-ring.fill {
  animation: holdFill 0.59s linear forwards;
}

@keyframes holdFill {
  to {
    --p: 100%;
  }
}

/* Sprinting */

.dust-particle.spr {
  position: absolute;
  opacity: 0.85;
  animation: dustPuff 0.52s ease-out forwards;
}

@keyframes dustPuff {
  from {
    transform: scale(0.7);
    opacity: 0.85;
  }
  to {
    transform: translateY(-8px) scale(1.25);
    opacity: 0;
  }
}

.player.pixel-av.running .av-shadow {
  width: 34px;
  margin-left: -17px;
}

/* Profile pictures worn in the world instead of a character. */

.player.photo-av .av-bob {
  bottom: 8px;
  width: 38px;
  height: 38px;
  margin-left: -19px;
}

.player.photo-av.sitting .av-bob {
  bottom: 3px;
}

.player.photo-av .av-flip,
.player.photo-av.face-left .av-flip {
  transform: none;
}

.av-photo {
  border-radius: 50%;
  object-fit: cover;
  background: var(--panel-2, #24283a);
  box-shadow: 0 0 0 2.5px var(--ring), 0 3px 6px rgba(20, 22, 40, 0.35);
  filter: none;
}

.player.photo-av.away .av-face {
  filter: grayscale(0.6) opacity(0.8);
}

img.av-thumb.photo-thumb {
  object-fit: cover;
  border-radius: 30%;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ring, var(--accent)) 30%, transparent);
}
