/* =====================================================================
   ТЕЗАУРУС · 3D-пространство вселенных
   Маленькие круги-звёзды летают в объёме. Камера: ПКМ — поворот,
   WASD — полёт, колесо — ближе/дальше.
   ===================================================================== */

#screen-hub .hub-stage{
  position: relative;
  flex: 1;
  min-width: 0;
  display: block;
  overflow: hidden;
  cursor: default;
  touch-action: none;
}
#screen-hub .hub-stage.rotating{ cursor: grabbing; }

/* ---------- звёздная пыль ---------- */
.space-scene{
  position: absolute;
  inset: 0;
  z-index: 1;
}

#starCanvas{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

/* ---------- слой вселенных ---------- */
.space-world{
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
}

.star{
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  will-change: transform, opacity;
  --s: 1;
}

.star-body{
  position: absolute;
  left: 0;
  top: 0;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  pointer-events: auto;
  cursor: pointer;
  transform: scale(var(--s));
  transform-origin: 50% 50%;
  transition: box-shadow .2s, filter .2s;
}

.star-face{
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 34% 28%, rgba(255,255,255,.98), rgba(255,255,255,.78) 58%, rgba(255,255,255,.66)),
    linear-gradient(135deg, hsl(var(--h) 90% 72% / .55), hsl(calc(var(--h) + 60) 90% 72% / .4));
  box-shadow:
    0 6px 18px hsl(var(--h) 80% 45% / .35),
    inset 0 0 16px rgba(255,255,255,.7),
    0 0 0 1px rgba(255,255,255,.7);
}
.star-face img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.star-ini{
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .02em;
  background: linear-gradient(135deg, hsl(var(--h) 85% 42%), hsl(calc(var(--h) + 50) 85% 50%));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  user-select: none;
}

/* кольцо-орбита вокруг круга */
.star-ring{
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, hsl(var(--h) 95% 62%), var(--violet), var(--pink), hsl(var(--h) 95% 62%));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px));
  opacity: .85;
  pointer-events: none;
  animation: starSpin 14s linear infinite;
}
@keyframes starSpin{ to{ transform: rotate(360deg); } }

/* закрытая вселенная — тусклая, с замком */
.star.closed .star-face{
  background: rgba(232,236,244,.86);
  box-shadow: 0 4px 14px rgba(13,20,36,.18), inset 0 0 14px rgba(255,255,255,.6), 0 0 0 1px rgba(255,255,255,.6);
}
.star.closed .star-ring{
  background: conic-gradient(from 0deg, rgba(120,130,150,.7), rgba(180,190,210,.5), rgba(120,130,150,.7));
}
.star.closed .star-ini{ color: #8892a6; background: none; -webkit-text-fill-color: #8892a6; }
/* замок закрытой вселенной — слева внизу, чтобы не спорить с огоньком сети */
.star-lock{
  position: absolute;
  left: -4px;
  bottom: -4px;
  font-size: 13px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(13,20,36,.25));
}

/* корона создателя сети — над кругом */
.star-crown{
  position: absolute;
  left: 50%;
  top: -11px;
  transform: translateX(-50%);
  font-size: 14px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(13,20,36,.3));
  pointer-events: none;
}

/* моя вселенная */
.star.me .star-face{
  box-shadow:
    0 8px 26px rgba(123,92,255,.5),
    inset 0 0 18px rgba(255,255,255,.8),
    0 0 0 2px rgba(123,92,255,.55);
}
.star.me .star-ring{ opacity: 1; animation-duration: 7s; }
.star.me::after{
  content:'';
  position: absolute;
  left: 0; top: 0;
  width: 56px; height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  border: 1px solid rgba(123,92,255,.5);
  animation: mePulse 2.6s ease-out infinite;
  pointer-events: none;
}
@keyframes mePulse{
  0%  { transform: scale(var(--s)); opacity: .8; }
  100%{ transform: scale(calc(var(--s) * 2.1)); opacity: 0; }
}

/* наведение и фокус */
.star.hot .star-body{
  box-shadow: 0 0 0 3px rgba(0,194,255,.35), 0 10px 30px rgba(0,194,255,.4);
  filter: brightness(1.06);
}
.star.hot .star-ring{ opacity: 1; }
.star.picked .star-body{
  box-shadow: 0 0 0 4px rgba(255,47,208,.35), 0 12px 34px rgba(255,47,208,.42);
}
.star-demo{
  position: absolute;
  left: -6px;
  top: -6px;
  font-size: 11px;
  line-height: 1;
  opacity: .8;
}

/* ---------- жизнь и присутствие прямо на круге ---------- */

/* вспышка: внутри вселенной что-то произошло — это видно всем */
.star-flare{
  position: absolute;
  left: 0;
  top: 0;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  transform: scale(var(--s));
  background: radial-gradient(circle,
    hsl(var(--h) 100% 68% / .55),
    hsl(calc(var(--h) + 60) 100% 62% / .22) 45%,
    transparent 72%);
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s linear;
  will-change: opacity, transform;
}
.star.alive .star-flare{
  opacity: var(--flare, 0);
  transform: scale(calc(var(--s) * (1 + var(--flare, 0) * .9)));
}
.star.alive .star-body{ filter: brightness(calc(1 + var(--flare, 0) * .22)); }
.star.alive .star-ring{ opacity: 1; }

/* присутствие: этот человек сейчас в сети */
.star-alive{
  position: absolute;
  left: 0;
  top: 0;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  border: 1px dashed rgba(34,197,94,.7);
  transform: scale(calc(var(--s) * 1.18));
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
}
.star:not(.me).awake .star-alive{
  opacity: .8;
  animation: starAlive 4.5s linear infinite;
}
@keyframes starAlive{
  from{ transform: scale(calc(var(--s) * 1.14)) rotate(0deg); }
  to  { transform: scale(calc(var(--s) * 1.14)) rotate(360deg); }
}

/* огонёк у круга: зелёный — человек в сети, серый — не в сети */
.star-online{
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #c3cad6;
  border: 2px solid rgba(255,255,255,.92);
  opacity: .55;
  pointer-events: none;
}
.star.awake .star-online{
  background: #22c55e;
  opacity: 1;
  box-shadow: 0 0 9px rgba(34,197,94,.85);
}

/* состыкованная вселенная держится рядом с хозяйкой */
.star.docked .star-body{
  box-shadow: 0 0 0 2px rgba(0,194,255,.35), 0 10px 26px rgba(0,194,255,.32);
}

/* подпись под кругом — фиксированного размера, появляется рядом */
.star-label{
  position: absolute;
  left: 0;
  top: calc(32px * var(--s) + 6px);
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 11px;
  letter-spacing: .03em;
  color: var(--ink);
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(13,20,36,.08);
  border-radius: 20px;
  padding: 3px 10px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s;
  /* имя целиком: длинную фамилию переносим, а не обрезаем многоточием */
  max-width: 280px;
  text-align: center;
  white-space: normal;
  line-height: 1.3;
}
.star-label.show{ opacity: 1; }
.star-label .lbl-sub{ color: var(--muted); font-size: 9.5px; }
.star.me .star-label{
  background: linear-gradient(135deg, rgba(0,194,255,.92), rgba(123,92,255,.92));
  color: #fff;
  border-color: transparent;
}
.star.me .star-label .lbl-sub{ color: rgba(255,255,255,.85); }

/* ---------- подсказка управления (сверху слева, под счётчиком) ----------
   Свёрнута: видно только заголовок, чтобы не закрывать галактику.
   Клик по заголовку — разворачивается, и так же сворачивается обратно. */
.space-help{
  position: absolute;
  left: 18px;
  top: 62px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 9px 12px;
  border-radius: 13px;
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-s);
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--ink-2);
  letter-spacing: .03em;
  max-width: 300px;
}
.space-help b{
  display: inline-block;
  min-width: 62px;
  color: var(--violet);
  font-weight: 700;
}
.space-help .hint-head{
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: 9px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}
.space-help .hint-head:hover{ color: var(--violet); }
.space-help .hh-ico{
  margin-left: auto;
  font-size: 10px;
  transition: transform .18s ease;
}
.space-help.open .hh-ico{ transform: rotate(180deg); }

/* тело подсказки: по умолчанию скрыто */
.space-help .hint-body{
  display: none;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
  max-height: 46vh;
  overflow-y: auto;
  scrollbar-width: thin;
}
.space-help.open .hint-body{ display: flex; }

/* ---------- счётчик и кнопки вида ---------- */
.space-hud{
  position: absolute;
  left: 18px;
  top: 18px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 30px;
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-s);
  font-size: 10.5px;
  letter-spacing: .06em;
  color: var(--ink-2);
}
.space-hud b{ color: var(--violet); }

.space-controls{
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.space-controls button{
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0 0 2px;
  box-shadow: var(--shadow-s);
  transition: .15s;
}
.space-controls button:hover{
  border-color: var(--cyan);
  color: #0079a8;
  background: #fff;
  transform: translateY(-1px);
}

/* ---------- карточка выбранной вселенной ---------- */
.space-focus{
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 12px);
  z-index: 7;
  display: none;
  align-items: center;
  gap: 13px;
  padding: 11px 15px;
  border-radius: 18px;
  /* непрозрачный фон: сквозь карточку ничего не должно просвечивать */
  background: #fdfeff;
  border: 1px solid var(--line);
  box-shadow: 0 18px 44px rgba(13,20,36,.16), 0 0 0 4px rgba(123,92,255,.06);
  max-width: min(680px, calc(100% - 132px));
  opacity: 0;
  transition: opacity .2s, transform .2s;
}
.space-focus.show{ display: flex; opacity: 1; transform: translate(-50%, 0); }

.space-focus .sf-txt{ min-width: 0; flex: 1; }
.space-focus .sf-name{
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.space-focus .sf-meta{
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: .05em;
}
.space-focus .sf-meta b{ color: var(--ink-2); }
.space-focus .sf-chips{ display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.space-focus .sf-btns{ display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.space-focus .btn{ padding: 7px 11px; font-size: 10.5px; }

/* ---------- значки-подсказки на пустом поле ---------- */
.space-splash{
  position: absolute;
  left: 50%;
  top: 20px;
  transform: translateX(-50%);
  z-index: 5;
  padding: 8px 16px;
  border-radius: 30px;
  background: rgba(255,255,255,.88);
  border: 1px solid rgba(123,92,255,.25);
  box-shadow: var(--shadow-s);
  font-size: 10.5px;
  letter-spacing: .06em;
  color: var(--ink-2);
  animation: dropIn .3s ease;
}

/* на телефоне прячем длинную подсказку */
@media (max-width: 660px){
  .space-help{ display: none; }
  .space-hud{ left: 10px; top: 10px; font-size: 9.5px; padding: 6px 11px; }
  .space-controls{ right: 10px; bottom: 10px; }
  .space-focus{
    left: 10px;
    right: 64px;
    bottom: 10px;
    transform: translateY(12px);
    max-width: none;
    flex-wrap: wrap;
    padding: 10px 12px;
  }
  .space-focus.show{ transform: translateY(0); }
  .space-focus .sf-btns{ width: 100%; }
  .space-focus .sf-btns .btn{ flex: 1; }
}

/* ---------- перетаскивание вселенной мышкой ---------- */
.star.moving{ cursor: grabbing; }
.star.moving .star-body{
  cursor: grabbing;
  box-shadow: 0 0 0 3px rgba(255,47,208,.4), 0 14px 34px rgba(255,47,208,.45);
  filter: brightness(1.08);
}
.star.moving .star-label{ opacity: 1; }

/* подсказка «перетащи» показывается у круга под курсором */
.star.draggable .star-body{ cursor: grab; }

/* ---------- разгон при полёте ---------- */
.space-warp{
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,0) 30%, rgba(123,92,255,.14) 100%);
  transition: opacity .25s;
}
.space-warp.on{ opacity: 1; animation: warpPulse .55s ease-in-out infinite; }
@keyframes warpPulse{
  0%,100%{ opacity: .35; }
  50%    { opacity: .75; }
}

/* ---------- стыковка: круг прилетел к чужой вселенной ---------- */
.star.docking .star-body{
  box-shadow: 0 0 0 4px rgba(0,194,255,.45), 0 0 40px rgba(0,194,255,.75);
  animation: dockPulse 1s ease-out 2;
}
@keyframes dockPulse{
  0%  { transform: scale(var(--s)) translateZ(0); }
  40% { transform: scale(calc(var(--s) * 1.22)); }
  100%{ transform: scale(var(--s)); }
}
.star-label .lbl-dock{
  color: #0090c8;
  font-weight: 700;
}
