/**
 * Custom profile badge visual effects.
 * Uses --badge-color / --badge-bg / --badge-border when provided.
 */

.profile-rank.custom,
.admin-profile-badge.custom {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

/* ----- Glow ----- */
.badge-fx-glow {
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--badge-color, #38bdf8) 35%, transparent),
    0 0 14px color-mix(in srgb, var(--badge-color, #38bdf8) 45%, transparent);
  animation: badge-fx-glow-pulse 2.4s ease-in-out infinite;
}

@keyframes badge-fx-glow-pulse {
  0%, 100% {
    box-shadow:
      0 0 0 1px color-mix(in srgb, var(--badge-color, #38bdf8) 30%, transparent),
      0 0 10px color-mix(in srgb, var(--badge-color, #38bdf8) 35%, transparent);
  }
  50% {
    box-shadow:
      0 0 0 1px color-mix(in srgb, var(--badge-color, #38bdf8) 55%, transparent),
      0 0 22px color-mix(in srgb, var(--badge-color, #38bdf8) 65%, transparent);
  }
}

/* ----- Shimmer ----- */
.badge-fx-shimmer::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    transparent 18%,
    rgba(255, 255, 255, 0.42) 45%,
    transparent 72%
  );
  transform: translateX(-130%);
  animation: badge-fx-shimmer-sweep 2.6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes badge-fx-shimmer-sweep {
  0% { transform: translateX(-130%); }
  55%, 100% { transform: translateX(130%); }
}

/* ----- Pulse ----- */
.badge-fx-pulse {
  animation: badge-fx-pulse-scale 1.8s ease-in-out infinite;
}

@keyframes badge-fx-pulse-scale {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.045); filter: brightness(1.12); }
}

/* ----- Neon ----- */
.badge-fx-neon {
  background: rgba(0, 0, 0, 0.35) !important;
  border-color: var(--badge-color, #38bdf8) !important;
  text-shadow:
    0 0 6px color-mix(in srgb, var(--badge-color, #38bdf8) 80%, transparent),
    0 0 14px color-mix(in srgb, var(--badge-color, #38bdf8) 55%, transparent);
  box-shadow:
    0 0 8px color-mix(in srgb, var(--badge-color, #38bdf8) 55%, transparent),
    inset 0 0 10px color-mix(in srgb, var(--badge-color, #38bdf8) 18%, transparent);
  animation: badge-fx-neon-flicker 3.2s ease-in-out infinite;
}

@keyframes badge-fx-neon-flicker {
  0%, 19%, 21%, 100% { opacity: 1; }
  20% { opacity: 0.72; }
  50% {
    box-shadow:
      0 0 16px color-mix(in srgb, var(--badge-color, #38bdf8) 75%, transparent),
      inset 0 0 14px color-mix(in srgb, var(--badge-color, #38bdf8) 28%, transparent);
  }
}

/* ----- Rainbow ----- */
.badge-fx-rainbow {
  border: 1px solid transparent !important;
  background:
    linear-gradient(rgba(10, 10, 12, 0.92), rgba(10, 10, 12, 0.92)) padding-box,
    linear-gradient(120deg, #ff6b6b, #fbbf24, #34d399, #38bdf8, #a78bfa, #ff6b6b) border-box !important;
  background-size: 100% 100%, 300% 300% !important;
  color: #f8fafc !important;
  animation: badge-fx-rainbow-shift 4s linear infinite;
}

@keyframes badge-fx-rainbow-shift {
  0% { background-position: 0 0, 0% 50%; }
  100% { background-position: 0 0, 100% 50%; }
}

/* ----- Sparkle ----- */
.badge-fx-sparkle::before,
.badge-fx-sparkle::after {
  content: '';
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 6px #fff;
  pointer-events: none;
  animation: badge-fx-sparkle-twinkle 1.6s ease-in-out infinite;
}

.badge-fx-sparkle::before {
  top: 18%;
  left: 14%;
}

.badge-fx-sparkle::after {
  right: 16%;
  bottom: 20%;
  animation-delay: 0.7s;
}

@keyframes badge-fx-sparkle-twinkle {
  0%, 100% { opacity: 0.15; transform: scale(0.6); }
  50% { opacity: 1; transform: scale(1.25); }
}

/* ----- Holographic ----- */
.badge-fx-holographic {
  border-color: transparent !important;
  background:
    linear-gradient(
      125deg,
      color-mix(in srgb, var(--badge-color, #38bdf8) 35%, #0a0a0c) 0%,
      color-mix(in srgb, var(--badge-color, #38bdf8) 18%, #1a1030) 35%,
      color-mix(in srgb, #f472b6 40%, transparent) 55%,
      color-mix(in srgb, var(--badge-color, #38bdf8) 28%, #0a0a0c) 100%
    ) !important;
  background-size: 220% 220% !important;
  color: #fff !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  box-shadow:
    0 0 12px color-mix(in srgb, var(--badge-color, #38bdf8) 35%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  animation: badge-fx-holo-shift 5s ease-in-out infinite;
}

.badge-fx-holographic::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 30%,
    rgba(255, 255, 255, 0.35) 48%,
    transparent 66%
  );
  mix-blend-mode: soft-light;
  animation: badge-fx-shimmer-sweep 3.4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes badge-fx-holo-shift {
  0%, 100% { background-position: 0% 40%; }
  50% { background-position: 100% 60%; }
}

/* Dashboard sidebar badges can use the same effect hooks */
.dashboard-role.custom {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

@media (prefers-reduced-motion: reduce) {
  .badge-fx-glow,
  .badge-fx-shimmer::after,
  .badge-fx-pulse,
  .badge-fx-neon,
  .badge-fx-rainbow,
  .badge-fx-sparkle::before,
  .badge-fx-sparkle::after,
  .badge-fx-holographic,
  .badge-fx-holographic::after {
    animation: none !important;
  }
}
