/* ==========================================================
   Меню пользователя — киберпанк / техно, красные тона
   Аватарка закреплена в углу (position: fixed), при наведении
   раскрывается панель: ник, звание, меню.
   Переменные --cp-* берутся из auth-cyberpunk.css
   ========================================================== */

@property --cp-a { syntax: '<angle>'; initial-value: 0deg; inherits: false; }

.cp-user {
  position: fixed;
  top: 14px;
  right: 18px;
  z-index: 1040;
  font-family: 'Rajdhani', 'Orbitron', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- аватарка ---------- */
.cp-user__avatar {
  --cut: 12px;
  position: relative;
  display: block;
  width: 58px;
  height: 58px;
  text-decoration: none;
  outline: none;
  cursor: pointer;
  filter: drop-shadow(0 0 10px rgba(255, 34, 69, .45));
  transition: transform .35s cubic-bezier(.2, .8, .2, 1), filter .35s;
}
.cp-user:hover .cp-user__avatar,
.cp-user.is-open .cp-user__avatar {
  transform: scale(1.07);
  filter: drop-shadow(0 0 16px rgba(255, 34, 69, .8));
}

.cp-user__ring,
.cp-user__pic {
  position: absolute;
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
}
/* бегущий красный свет по рамке */
.cp-user__ring {
  inset: 0;
  background: conic-gradient(from var(--cp-a), rgba(255, 34, 69, .15) 0 40%, var(--cp-red) 70%, #ff8a9b 78%, rgba(255, 34, 69, .15) 90%);
  animation: cpAngle 3s linear infinite;
}
/* радар-пульс */
.cp-user__ring--rev {
  background: none;
  border: 1px solid var(--cp-red);
  box-sizing: border-box;
  animation: cpPulse 2.6s ease-out infinite;
  opacity: 0;
}
.cp-user__pic {
  inset: 2px;
  --cut: 10px;
  background: var(--cp-void, #050406);
  overflow: hidden;
  display: block;
}
.cp-user__pic img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .5s cubic-bezier(.2, .8, .2, 1), filter .4s;
}
.cp-user:hover .cp-user__pic img,
.cp-user.is-open .cp-user__pic img { transform: scale(1.1); filter: saturate(1.15) contrast(1.05); }
/* «сканлайны» поверх аватарки */
.cp-user__pic::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(255, 34, 69, .07) 0 1px, transparent 1px 3px);
  pointer-events: none;
}
/* рамка-фрейм из магазина: подгоняем под размер аватарки */
.cp-user .playground.m-40,
.cp-user .playground.m-40 .frame,
.cp-user .playground.m-40 img,
.cp-user .playground.m-40 .frame img {
  width: 100% !important;
  height: 100% !important;
  float: none;
  margin: 0;
}
.cp-user .playground.m-40 { position: relative; }
.cp-user .playground.m-40 .frame { position: absolute; top: 0; left: 0; z-index: 2; }

/* индикатор новых событий */
.cp-user__dot {
  position: absolute;
  top: -3px;
  right: -3px;
  z-index: 3;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--cp-red);
  border: 2px solid var(--cp-void, #050406);
  box-shadow: 0 0 10px var(--cp-red);
  animation: cpDot 1.4s ease-in-out infinite;
}
#check_mess { display: none; }

/* ---------- выпадающая панель ---------- */
.cp-user__drop {
  position: absolute;
  top: 100%;
  right: 0;
  width: 276px;
  padding-top: 12px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-10px) scale(.96);
  transform-origin: top right;
  filter: drop-shadow(0 14px 34px rgba(255, 34, 69, .28));
  transition: opacity .25s ease, transform .35s cubic-bezier(.2, .9, .25, 1.15), visibility 0s linear .35s;
}
.cp-user:hover .cp-user__drop,
.cp-user.is-open .cp-user__drop {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  transition-delay: 0s;
}

.cp-user__panel {
  --cut: 18px;
  position: relative;
  padding: 1px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--cp-red) 0%, var(--cp-red-deep) 38%, rgba(255, 34, 69, .35) 100%);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
}
.cp-user__panel::before {
  content: '';
  position: absolute;
  inset: 1px;
  background:
    radial-gradient(120% 60% at 100% 0%, rgba(255, 34, 69, .22), transparent 60%),
    repeating-linear-gradient(0deg, rgba(255, 34, 69, .04) 0 1px, transparent 1px 4px),
    linear-gradient(155deg, #1a0d12, var(--cp-panel, #0f0a0d) 55%, #08050a);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
}
.cp-user__panel > * { position: relative; z-index: 1; }

/* луч сканера при открытии */
.cp-user__scan {
  position: absolute !important;
  left: 0;
  right: 0;
  top: -70px;
  height: 70px;
  z-index: 3 !important;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(255, 34, 69, .28), transparent);
  border-bottom: 1px solid rgba(255, 120, 140, .55);
  opacity: 0;
}
.cp-user:hover .cp-user__scan,
.cp-user.is-open .cp-user__scan { animation: cpScan .95s ease-out .05s 1; }

/* шапка панели: ник + звание */
.cp-user__head {
  position: relative;
  padding: 18px 20px 14px;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .25s, transform .3s;
}
.cp-user:hover .cp-user__head,
.cp-user.is-open .cp-user__head { opacity: 1; transform: none; transition-delay: .1s; }
.cp-user__head::after {
  content: '';
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--cp-red), rgba(255, 34, 69, 0));
  transform-origin: left;
  transform: scaleX(0);
  transition: transform .6s cubic-bezier(.2, .8, .2, 1) .25s;
}
.cp-user:hover .cp-user__head::after,
.cp-user.is-open .cp-user__head::after { transform: scaleX(1); }

.cp-user__nick {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .06em;
  line-height: 1.25;
  word-break: break-word;
  text-shadow: 0 0 12px rgba(255, 34, 69, .45);
}
.cp-user__nick-text { position: relative; display: inline-block; }
/* короткий глитч ника при открытии */
.cp-user__nick-text::before,
.cp-user__nick-text::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  opacity: 0;
  pointer-events: none;
}
.cp-user__nick-text::before { color: #ff2245; }
.cp-user__nick-text::after  { color: #4df3ff; mix-blend-mode: screen; }
.cp-user:hover .cp-user__nick-text::before,
.cp-user.is-open .cp-user__nick-text::before { animation: cpGlitchA .6s steps(2, end) .2s 1; }
.cp-user:hover .cp-user__nick-text::after,
.cp-user.is-open .cp-user__nick-text::after  { animation: cpGlitchB .6s steps(2, end) .2s 1; }

.cp-user__rank {
  margin-top: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--cp-text-mute, #948e93);
}
.cp-user__rank i { color: var(--cp-red); margin-right: 4px; font-size: 10px; }

/* ---------- пункты меню ---------- */
.cp-user__menu {
  list-style: none;
  margin: 0;
  padding: 8px 8px 12px;
}
.cp-user__menu li {
  list-style: none;
  margin: 0;
  padding: 0;
  opacity: 0;
  transform: translateX(16px);
  transition: opacity .2s ease, transform .2s ease;
}
.cp-user:hover .cp-user__menu li,
.cp-user.is-open .cp-user__menu li {
  opacity: 1;
  transform: none;
  transition: opacity .35s ease, transform .45s cubic-bezier(.2, .9, .25, 1.1);
  transition-delay: calc(var(--i, 1) * 32ms + 140ms);
}
.cp-user__menu a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 12px 0 14px;
  overflow: hidden;
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .05em;
  color: var(--cp-text-mute, #948e93);
  transition: color .2s, background .25s, padding-left .25s;
}
.cp-user__menu a i {
  width: 18px;
  text-align: center;
  font-size: 14px;
  color: var(--cp-steel, #6d6470);
  transition: color .2s, transform .3s, text-shadow .2s;
}
.cp-user__menu a span { position: relative; z-index: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* красная планка слева */
.cp-user__menu a::before {
  content: '';
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 2px;
  background: var(--cp-red);
  box-shadow: 0 0 10px var(--cp-red);
  transform: scaleY(0);
  transition: transform .25s cubic-bezier(.2, .8, .2, 1);
}
/* блик, пробегающий по строке */
.cp-user__menu a::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 90, 110, .22) 50%, transparent 70%);
  transform: translateX(-120%);
  pointer-events: none;
}
.cp-user__menu a:hover,
.cp-user__menu a:focus-visible {
  color: var(--cp-text-hi, #f4f1f2);
  background: linear-gradient(90deg, rgba(255, 34, 69, .24), rgba(255, 34, 69, 0));
  padding-left: 20px;
  outline: none;
}
.cp-user__menu a:hover::before,
.cp-user__menu a:focus-visible::before { transform: scaleY(1); }
.cp-user__menu a:hover::after { transform: translateX(120%); transition: transform .7s ease; }
.cp-user__menu a:hover i,
.cp-user__menu a:focus-visible i {
  color: var(--cp-red);
  transform: scale(1.2);
  text-shadow: 0 0 10px var(--cp-red-glow, rgba(255, 34, 69, .55));
}
.cp-user__menu font { color: var(--cp-text-hi, #f4f1f2); }

.cp-user__exit { margin-top: 6px !important; position: relative; }
.cp-user__exit::before {
  content: '';
  position: absolute;
  left: 14px;
  right: 14px;
  top: -3px;
  height: 1px;
  background: linear-gradient(90deg, var(--cp-line, rgba(255, 34, 69, .28)), transparent);
}
.cp-user__exit a:hover { background: linear-gradient(90deg, rgba(255, 34, 69, .4), rgba(255, 34, 69, 0)); }

/* задержки для каскадного появления */
.cp-user__menu li:nth-child(1){ --i:1; }
.cp-user__menu li:nth-child(2){ --i:2; }
.cp-user__menu li:nth-child(3){ --i:3; }
.cp-user__menu li:nth-child(4){ --i:4; }
.cp-user__menu li:nth-child(5){ --i:5; }
.cp-user__menu li:nth-child(6){ --i:6; }
.cp-user__menu li:nth-child(7){ --i:7; }
.cp-user__menu li:nth-child(8){ --i:8; }
.cp-user__menu li:nth-child(9){ --i:9; }
.cp-user__menu li:nth-child(10){ --i:10; }
.cp-user__menu li:nth-child(11){ --i:11; }
.cp-user__menu li:nth-child(12){ --i:12; }
.cp-user__menu li:nth-child(13){ --i:13; }
.cp-user__menu li:nth-child(14){ --i:14; }
.cp-user__menu li:nth-child(15){ --i:15; }
.cp-user__menu li:nth-child(16){ --i:16; }
/* ---------- анимации ---------- */
@keyframes cpAngle { to { --cp-a: 360deg; } }
@keyframes cpPulse {
  0%   { transform: scale(1);    opacity: .75; }
  100% { transform: scale(1.5);  opacity: 0; }
}
@keyframes cpDot {
  0%, 100% { transform: scale(1);   box-shadow: 0 0 6px var(--cp-red); }
  50%      { transform: scale(1.25); box-shadow: 0 0 14px var(--cp-red); }
}
@keyframes cpScan {
  0%   { top: -70px; opacity: 0; }
  15%  { opacity: 1; }
  100% { top: 100%;  opacity: 0; }
}
@keyframes cpGlitchA {
  0%   { opacity: .9; transform: translate(-2px, 0);  clip-path: inset(10% 0 55% 0); }
  50%  { opacity: .9; transform: translate(2px, 1px); clip-path: inset(55% 0 10% 0); }
  100% { opacity: 0;  transform: none; }
}
@keyframes cpGlitchB {
  0%   { opacity: .8; transform: translate(2px, 0);   clip-path: inset(50% 0 15% 0); }
  50%  { opacity: .8; transform: translate(-2px, -1px); clip-path: inset(15% 0 50% 0); }
  100% { opacity: 0;  transform: none; }
}

/* ---------- мобильная версия ---------- */
@media (max-width: 767.99px) {
  .cp-user { top: 10px; right: 10px; }
  .cp-user__avatar { width: 50px; height: 50px; --cut: 10px; }
  .cp-user__drop { width: min(276px, calc(100vw - 20px)); }
  .cp-user__menu a { height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .cp-user *, .cp-user *::before, .cp-user *::after { animation: none !important; transition-duration: .01s !important; transition-delay: 0s !important; }
}
