/* ==========================================================================
   Premium profile avatar — /main (gaming / VIP theme)
   Frontend-only; works with existing Vue profile markup.
   ========================================================================== */

:root {
  --tw-avatar-neon: #22d3ee;
  --tw-avatar-neon-deep: #0ea5e9;
  --tw-avatar-gold: #facc15;
  --tw-avatar-gold-deep: #f59e0b;
  --tw-avatar-ring-size: 2.08rem;
  --tw-avatar-edit-size: 0.58rem;
  --tw-avatar-transition: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hide legacy standalone "Change Avatar" controls */
body #app .userInfo__container[data-v-5bd44e74]:not(.setting-page-container)
  .userInfo__container-content-right[data-v-5bd44e74],
body #app .tw-change-avatar-btn,
body #app .userInfo__container[data-v-5bd44e74]:not(.setting-page-container)
  .userInfo__container-setting-center-header-edit[data-v-5bd44e74] {
  display: none !important;
}

/* Wrapper injected around avatar */
.profile-avatar-wrapper {
  position: relative;
  width: var(--tw-avatar-ring-size);
  height: var(--tw-avatar-ring-size);
  margin: 0 auto 0.14rem;
  border-radius: 50%;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--tw-avatar-transition);
}

.profile-avatar-wrapper::before {
  content: "";
  position: absolute;
  inset: -0.1rem;
  border-radius: 50%;
  background: conic-gradient(
    from 210deg,
    rgba(34, 211, 238, 0.15),
    rgba(34, 211, 238, 0.85),
    rgba(14, 165, 233, 0.55),
    rgba(250, 204, 21, 0.35),
    rgba(34, 211, 238, 0.85),
    rgba(34, 211, 238, 0.15)
  );
  opacity: 0.92;
  filter: blur(0.5px);
  z-index: 0;
  animation: tw-avatar-ring-pulse 3.2s ease-in-out infinite;
  transition: opacity var(--tw-avatar-transition), box-shadow var(--tw-avatar-transition);
}

.profile-avatar-wrapper::after {
  content: "";
  position: absolute;
  inset: -0.22rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.28) 0%, transparent 68%);
  z-index: -1;
  pointer-events: none;
  opacity: 0.65;
  transition: opacity var(--tw-avatar-transition), transform var(--tw-avatar-transition);
}

.profile-avatar-wrapper:hover,
.profile-avatar-wrapper:focus-visible {
  transform: scale(1.04);
}

.profile-avatar-wrapper:hover::before,
.profile-avatar-wrapper:focus-visible::before {
  opacity: 1;
  box-shadow:
    0 0 0.22rem rgba(34, 211, 238, 0.55),
    0 0 0.44rem rgba(34, 211, 238, 0.28);
}

.profile-avatar-wrapper:hover::after,
.profile-avatar-wrapper:focus-visible::after {
  opacity: 1;
  transform: scale(1.06);
}

.profile-avatar-wrapper:active {
  transform: scale(0.98);
}

.profile-avatar-wrapper:focus-visible {
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.55);
}

/* Avatar image */
.profile-avatar-wrapper .profile-avatar,
.profile-avatar-wrapper img.userAvatar {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.22);
  background: rgba(10, 15, 24, 0.65);
  box-shadow:
    inset 0 0 0.12rem rgba(255, 255, 255, 0.08),
    0 0.1rem 0.28rem rgba(0, 0, 0, 0.42);
  transition:
    border-color var(--tw-avatar-transition),
    box-shadow var(--tw-avatar-transition);
  pointer-events: none;
}

.profile-avatar-wrapper:hover .profile-avatar,
.profile-avatar-wrapper:focus-visible .profile-avatar {
  border-color: rgba(34, 211, 238, 0.55);
  box-shadow:
    inset 0 0 0.14rem rgba(34, 211, 238, 0.2),
    0 0 0.2rem rgba(34, 211, 238, 0.35);
}

/* Gold camera / edit button */
.profile-avatar-wrapper .avatar-edit-btn {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 4;
  width: var(--tw-avatar-edit-size);
  height: var(--tw-avatar-edit-size);
  padding: 0;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #0a0f18;
  background: linear-gradient(145deg, var(--tw-avatar-gold) 0%, var(--tw-avatar-gold-deep) 100%);
  border: 2px solid rgba(10, 15, 24, 0.92);
  box-shadow:
    0 0 0.14rem rgba(250, 204, 21, 0.55),
    0 0.06rem 0.14rem rgba(0, 0, 0, 0.45);
  transition:
    transform var(--tw-avatar-transition),
    box-shadow var(--tw-avatar-transition),
    filter var(--tw-avatar-transition);
  -webkit-tap-highlight-color: transparent;
}

.profile-avatar-wrapper .avatar-edit-btn i {
  font-size: 0.26rem;
  line-height: 1;
  pointer-events: none;
}

.profile-avatar-wrapper .avatar-edit-btn:hover,
.profile-avatar-wrapper .avatar-edit-btn:focus-visible {
  transform: scale(1.12);
  box-shadow:
    0 0 0.2rem rgba(250, 204, 21, 0.75),
    0 0.08rem 0.18rem rgba(0, 0, 0, 0.5);
  filter: brightness(1.05);
  outline: none;
}

.profile-avatar-wrapper .avatar-edit-btn:active {
  transform: scale(1.02);
}

.profile-avatar-wrapper .avatar-edit-btn:focus-visible {
  box-shadow:
    0 0 0 2px rgba(34, 211, 238, 0.65),
    0 0 0.18rem rgba(250, 204, 21, 0.65);
}

/* Pending save — clickable green tick (stays until user taps to save) */
.profile-avatar-wrapper.tw-avatar-pending .profile-avatar,
.profile-avatar-wrapper.tw-avatar-pending img.userAvatar {
  border-color: rgba(34, 197, 94, 0.55);
  box-shadow:
    inset 0 0 0.12rem rgba(34, 197, 94, 0.2),
    0 0 0.18rem rgba(34, 197, 94, 0.35);
}

.tw-avatar-save-tick {
  position: absolute;
  top: -0.04rem;
  right: -0.04rem;
  z-index: 6;
  width: 0.5rem;
  height: 0.5rem;
  padding: 0;
  border: 2px solid rgba(10, 15, 24, 0.92);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #052e16;
  background: linear-gradient(145deg, #4ade80 0%, #22c55e 55%, #16a34a 100%);
  box-shadow:
    0 0 0.18rem rgba(34, 197, 94, 0.65),
    0 0.06rem 0.14rem rgba(0, 0, 0, 0.4);
  animation: tw-avatar-save-pulse 1.8s ease-in-out infinite;
  transition:
    transform var(--tw-avatar-transition),
    box-shadow var(--tw-avatar-transition),
    filter var(--tw-avatar-transition);
  -webkit-tap-highlight-color: transparent;
}

.tw-avatar-save-tick i {
  font-size: 0.24rem;
  line-height: 1;
  pointer-events: none;
}

.tw-avatar-save-tick:hover,
.tw-avatar-save-tick:focus-visible {
  transform: scale(1.14);
  box-shadow:
    0 0 0.24rem rgba(74, 222, 128, 0.85),
    0 0.08rem 0.18rem rgba(0, 0, 0, 0.45);
  outline: none;
  filter: brightness(1.06);
}

.tw-avatar-save-tick:active {
  transform: scale(1.02);
}

.tw-avatar-save-tick.is-saving {
  animation: none;
  opacity: 0.72;
  pointer-events: none;
  cursor: wait;
}

.tw-avatar-save-tick.is-saved {
  animation: none;
  background: linear-gradient(145deg, #86efac 0%, #22c55e 100%);
  pointer-events: none;
}

@keyframes tw-avatar-save-pulse {
  0%, 100% {
    box-shadow:
      0 0 0.14rem rgba(34, 197, 94, 0.5),
      0 0.06rem 0.14rem rgba(0, 0, 0, 0.4);
  }
  50% {
    box-shadow:
      0 0 0.28rem rgba(74, 222, 128, 0.85),
      0 0.06rem 0.14rem rgba(0, 0, 0, 0.4);
  }
}

/* Neutralize conflicting legacy avatar shell styles when wrapped */
body #app .userInfo__container-content__avatar[data-v-5bd44e74].tw-avatar-shell {
  width: auto !important;
  height: auto !important;
  padding: 0 !important;
  margin: 0 auto 0.14rem !important;
  background: none !important;
  box-shadow: none !important;
  border: none !important;
  overflow: visible !important;
  animation: none !important;
}

body #app .userInfo__container-content__avatar[data-v-5bd44e74].tw-avatar-shell::before,
body #app .userInfo__container-content__avatar[data-v-5bd44e74].tw-avatar-shell::after {
  content: none !important;
  display: none !important;
}

/* -------------------------------------------------------------------------- */
/* Premium avatar picker modal                                                */
/* -------------------------------------------------------------------------- */

.tw-avatar-modal {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0.2rem;
  background: rgba(3, 7, 18, 0.62);
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  animation: tw-avatar-modal-in 0.28s ease-out;
}

.tw-avatar-modal__sheet {
  width: 100%;
  max-width: 10rem;
  max-height: min(78vh, 640px);
  overflow: auto;
  border-radius: 0.3rem 0.3rem 0.12rem 0.12rem;
  background:
    linear-gradient(165deg, rgba(34, 211, 238, 0.08) 0%, transparent 42%),
    linear-gradient(180deg, rgba(21, 27, 40, 0.96) 0%, rgba(10, 14, 22, 0.98) 100%);
  border: 1px solid rgba(34, 211, 238, 0.22);
  box-shadow:
    0 -0.16rem 0.48rem rgba(0, 0, 0, 0.5),
    0 0 0.36rem rgba(34, 211, 238, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  padding: 0.3rem 0.24rem calc(0.36rem + env(safe-area-inset-bottom, 0px));
}

.tw-avatar-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.2rem;
  margin-bottom: 0.22rem;
  padding-bottom: 0.16rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.tw-avatar-modal__head h3 {
  margin: 0;
  font-size: 0.34rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #f2f7ff;
  text-shadow: 0 0 0.16rem rgba(34, 211, 238, 0.2);
}

.tw-avatar-modal__head p {
  margin: 0.06rem 0 0;
  font-size: 0.22rem;
  color: rgba(186, 203, 226, 0.78);
}

.tw-avatar-modal__close {
  width: 0.58rem;
  height: 0.58rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  font-size: 0.36rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--tw-avatar-transition), transform var(--tw-avatar-transition);
}

.tw-avatar-modal__close:hover,
.tw-avatar-modal__close:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  outline: none;
  transform: scale(1.05);
}

.tw-avatar-modal__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.14rem;
}

.tw-avatar-modal__item {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 0.08rem;
  border-radius: 0.18rem;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition:
    transform var(--tw-avatar-transition),
    box-shadow var(--tw-avatar-transition),
    border-color var(--tw-avatar-transition),
    background var(--tw-avatar-transition);
}

.tw-avatar-modal__item img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.tw-avatar-modal__item.is-active {
  background: rgba(34, 211, 238, 0.1);
  border-color: rgba(34, 211, 238, 0.55);
  box-shadow: 0 0 0.16rem rgba(34, 211, 238, 0.35);
}

.tw-avatar-modal__item:hover,
.tw-avatar-modal__item:focus-visible {
  transform: translateY(-0.02rem) scale(1.02);
  border-color: rgba(250, 204, 21, 0.45);
  outline: none;
}

.tw-avatar-modal__item:active {
  transform: scale(0.97);
}

.tw-avatar-modal__toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.2rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 10060;
  padding: 0.16rem 0.3rem;
  border-radius: 999px;
  background: rgba(12, 18, 30, 0.94);
  border: 1px solid rgba(34, 211, 238, 0.35);
  color: #e2e8f0;
  font-size: 0.24rem;
  pointer-events: none;
  box-shadow: 0 0.1rem 0.28rem rgba(0, 0, 0, 0.4);
  animation: tw-avatar-toast-in 0.24s ease-out;
}

@keyframes tw-avatar-ring-pulse {
  0%, 100% {
    opacity: 0.88;
    filter: blur(0.5px) brightness(1);
  }
  50% {
    opacity: 1;
    filter: blur(0.5px) brightness(1.08);
  }
}

@keyframes tw-avatar-modal-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes tw-avatar-toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(0.12rem);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Responsive */
@media (max-width: 360px) {
  :root {
    --tw-avatar-ring-size: 1.92rem;
    --tw-avatar-edit-size: 0.54rem;
  }

  .tw-avatar-modal__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .profile-avatar-wrapper,
  .profile-avatar-wrapper::before,
  .profile-avatar-wrapper .avatar-edit-btn,
  .tw-avatar-save-tick,
  .tw-avatar-modal,
  .tw-avatar-modal__item {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}
