/* Quizzman Live mascot system — layered SVG toy renderer + reusable rig motion. */
.qz-mascot {
  --qz-mascot-size: 48px;
  position: relative;
  width: var(--qz-mascot-size);
  height: var(--qz-mascot-size);
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  isolation: isolate;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transform-origin: 50% 88%;
  perspective: 500px;
}

.qz-mascot--upper { height: calc(var(--qz-mascot-size) * 1.08); }
.qz-mascot--full { height: calc(var(--qz-mascot-size) * 1.45); }

.qz-mascot__svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: saturate(1.06);
}

.qz-mascot__rig,
.qz-mascot__head,
.qz-mascot__body,
.qz-mascot__arm,
.qz-mascot__legs,
.qz-mascot__eyes,
.qz-mascot__accessory,
.qz-mascot__medal,
.qz-mascot__equipment {
  transform-box: fill-box;
  transform-origin: center;
  will-change: transform;
}

.qz-mascot[data-animation="idle"] .qz-mascot__rig,
.qz-mascot[data-animation="breathe"] .qz-mascot__rig {
  animation: qz-mascot-breathe 3.2s ease-in-out infinite;
}

.qz-mascot[data-animation="idle"] .qz-mascot__eyes {
  animation: qz-mascot-blink 5.4s infinite;
  transform: translate(var(--qz-eye-x, 0), var(--qz-eye-y, 0));
}

.qz-mascot[data-animation="wave"] .qz-mascot__arm--right {
  animation: qz-mascot-wave .75s ease-in-out 2;
  transform-origin: 10% 15%;
}

.qz-mascot[data-animation="jump"],
.qz-mascot[data-animation="correct"] {
  animation: qz-mascot-jump .72s cubic-bezier(.2,.8,.25,1);
}

.qz-mascot[data-animation="celebrate"] .qz-mascot__arm--left,
.qz-mascot[data-animation="win"] .qz-mascot__arm--left,
.qz-mascot[data-animation="correct"] .qz-mascot__arm--left {
  animation: qz-mascot-cheer-left .6s ease-in-out 2;
}

.qz-mascot[data-animation="celebrate"] .qz-mascot__arm--right,
.qz-mascot[data-animation="win"] .qz-mascot__arm--right,
.qz-mascot[data-animation="correct"] .qz-mascot__arm--right {
  animation: qz-mascot-cheer-right .6s ease-in-out 2;
}

.qz-mascot[data-animation="clap"] .qz-mascot__arm--left { animation: qz-mascot-clap-left .42s ease-in-out 3; }
.qz-mascot[data-animation="clap"] .qz-mascot__arm--right { animation: qz-mascot-clap-right .42s ease-in-out 3; }

.qz-mascot[data-animation="wrong"],
.qz-mascot[data-animation="lose"] {
  animation: qz-mascot-lose .85s ease both;
}

.qz-mascot[data-pose="win"] .qz-mascot__arm--left { transform: rotate(-135deg) translate(-4px, 3px); }
.qz-mascot[data-pose="win"] .qz-mascot__arm--right { transform: rotate(135deg) translate(4px, 3px); }
.qz-mascot[data-pose="lose"] .qz-mascot__head { transform: translateY(5px) rotate(-4deg); }
.qz-mascot[data-pose="wave"] .qz-mascot__arm--right { transform: rotate(125deg); }

.qz-mascot__mouth--sad { display: none; }
.qz-mascot[data-expression="sad"] .qz-mascot__mouth--neutral { display: none; }
.qz-mascot[data-expression="sad"] .qz-mascot__mouth--sad { display: block; }
.qz-mascot[data-expression="happy"] .qz-mascot__mouth--neutral,
.qz-mascot[data-expression="excited"] .qz-mascot__mouth--neutral,
.qz-mascot[data-expression="proud"] .qz-mascot__mouth--neutral {
  stroke-width: 3;
  transform: translateY(-1px) scale(1.18);
  transform-origin: center;
}

.qz-mascot--face .qz-mascot__ground { display: none; }
.qz-mascot--face::after {
  content: "";
  position: absolute;
  inset: 11% 13% 8%;
  z-index: -1;
  border-radius: 48% 52% 46% 54%;
  background: color-mix(in srgb, var(--qm-primary, #6d5dfc) 24%, #111827);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / .2),
    0 7px 16px rgb(2 6 23 / .28);
}

.qz-mascot--upper::before,
.qz-mascot--full::before {
  content: "";
  position: absolute;
  inset: 14% 7% 2%;
  z-index: -1;
  border-radius: 48%;
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--qm-primary, #6d5dfc) 22%, transparent), transparent 68%);
  filter: blur(7px);
}

.qz-mascot__medal {
  animation: qz-mascot-medal 2.2s ease-in-out infinite;
  transform-origin: 50% 0%;
}

/* Screen composition contracts. */
.qz-avatar-pick .qz-mascot--face,
.qz-avatar-locked .qz-mascot--face {
  width: var(--qz-mascot-size);
  height: var(--qz-mascot-size);
  border-radius: 0;
  background: transparent;
}

.qz-lobby-player {
  min-height: 6.4rem;
  align-content: end;
}

.qz-lobby-player > .qz-mascot--upper {
  width: 4.5rem;
  height: 5rem;
}

.qz-host-player {
  min-height: 3.75rem;
  grid-template-columns: auto 3.6rem minmax(0, 1fr);
}

.qz-host-player > .qz-host-player__face {
  width: 3.6rem;
  height: 3.8rem;
  overflow: visible;
  border-radius: 0;
}

.qz-rank-row {
  grid-template-columns: 2.2rem 3.3rem minmax(0, 1fr) auto;
  min-height: 4.15rem;
}

.qz-rank-row__avatar {
  width: 3.3rem;
  height: 3.75rem;
  overflow: visible;
  border-radius: 0;
}

.qz-rank-row__avatar > .qz-mascot {
  max-width: 100%;
  max-height: 100%;
}

.qz-podium__stage {
  min-height: 21rem;
}

.qz-podium__medal {
  display: none;
}

.qz-podium__avatar,
.qz-podium__col--gold .qz-podium__avatar {
  width: clamp(5.6rem, 19vw, 7.25rem);
  height: clamp(8rem, 28vw, 10.5rem);
  overflow: visible;
}

.qz-podium__avatar > .qz-mascot {
  max-width: 100%;
  max-height: 100%;
}

@media (max-width: 420px) {
  .qz-rank-row {
    grid-template-columns: 1.8rem 2.65rem minmax(0, 1fr) auto;
    gap: .35rem;
  }

  .qz-rank-row__avatar {
    width: 2.65rem;
    height: 3.3rem;
  }

  .qz-podium__stage {
    gap: .15rem;
    min-height: 18rem;
  }
}

@keyframes qz-mascot-breathe {
  0%, 100% { transform: translateY(0) scaleY(1); }
  50% { transform: translateY(-1.5px) scaleY(1.018); }
}

@keyframes qz-mascot-blink {
  0%, 43%, 47%, 100% { transform: translate(var(--qz-eye-x, 0), var(--qz-eye-y, 0)) scaleY(1); }
  45% { transform: translate(var(--qz-eye-x, 0), var(--qz-eye-y, 0)) scaleY(.08); }
}

@keyframes qz-mascot-wave {
  0%, 100% { transform: rotate(105deg); }
  50% { transform: rotate(145deg); }
}

@keyframes qz-mascot-jump {
  0%, 100% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-18%) scale(.96, 1.04); }
  70% { transform: translateY(0) scale(1.06, .94); }
}

@keyframes qz-mascot-cheer-left {
  0%, 100% { transform: rotate(0); }
  50% { transform: rotate(-135deg) translate(-3px, 2px); }
}

@keyframes qz-mascot-cheer-right {
  0%, 100% { transform: rotate(0); }
  50% { transform: rotate(135deg) translate(3px, 2px); }
}

@keyframes qz-mascot-clap-left {
  0%, 100% { transform: rotate(0); }
  50% { transform: translate(17px, 5px) rotate(-55deg); }
}

@keyframes qz-mascot-clap-right {
  0%, 100% { transform: rotate(0); }
  50% { transform: translate(-17px, 5px) rotate(55deg); }
}

@keyframes qz-mascot-lose {
  0% { transform: translateX(0) rotate(0); }
  22% { transform: translateX(-5%) rotate(-3deg); }
  44% { transform: translateX(4%) rotate(2deg); }
  100% { transform: translateY(4%) scale(.96); }
}

@keyframes qz-mascot-medal {
  0%, 100% { transform: rotate(-2deg); }
  50% { transform: rotate(2deg); }
}

@media (prefers-reduced-motion: reduce) {
  .qz-mascot,
  .qz-mascot *,
  .qz-mascot::before,
  .qz-mascot::after {
    animation: none !important;
    transition: none !important;
  }
}
