/* The animated hub shares the star map's existing coordinates and pause state. */
#engine .nebula {
  background: radial-gradient(ellipse at 50% 47%, #57402d, #29241c 34%, #181914 68%);
  border-color: #5e5039;
}

#engine .nebula::before {
  background-image: linear-gradient(#e2c38f19 1px, transparent 1px), linear-gradient(90deg, #e2c38f19 1px, transparent 1px);
  background-size: 42px 42px;
}

#engine .neb-node img {
  object-position: 50% 34%;
  border-color: #e9dabb;
  background: #2a261d;
}

#engine .neb-node .nn-label {
  color: #fff6e7;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .03em;
}

#engine .neb-node .nn-ring {
  border-color: #be9e65;
}

#engine .neb-node.leader .nn-ring {
  border-color: #d59b57;
}

#agentModal .am-card {
  width: min(710px, 100%);
}

@media (min-width: 561px) {
  #agentModal .am-imgwrap {
    width: clamp(216px, 32vw, 260px);
  }

  #agentModal .am-img {
    height: auto;
    aspect-ratio: 3 / 4;
  }
}

@media (max-width: 560px) {
  #agentModal .am-img {
    height: min(38svh, 288px);
  }
}

@media (min-width: 901px) {
  #engine .nebula {
    height: clamp(472px, 37vw, 540px);
    margin-top: 27px;
    border-radius: var(--radius-frame);
  }

  #engine .neb-node {
    width: calc(var(--sz) * 1.37 + 4px);
    height: calc(var(--sz) * 1.37 + 4px);
  }

  #engine .neb-node .nn-label {
    top: calc(100% + 9px);
  }

  #engine .neb-core {
    width: 120px;
    height: 120px;
    color: #ffedc9;
    border-color: #d8a963;
    background: radial-gradient(circle at 45% 38%, #755638, #292218 77%);
    box-shadow: 0 0 44px #f3b15c47, inset 0 0 25px #f6c77824;
  }

  #engine .neb-links line {
    stroke: #eecc92;
    opacity: .36;
  }
}

@media (max-width: 900px) {
  #engine .nebula {
    padding: 21px 14px;
  }

  #engine .neb-group {
    gap: 16px 11px;
  }

  #engine .neb-node img {
    max-width: min(100%, 124px);
    border-radius: 7px;
    aspect-ratio: 1 / 1.13;
  }

  #engine .neb-node .nn-label {
    margin-top: 7px;
  }
}

@media (max-width: 620px) {
  #engine .neb-group {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  #engine .neb-node {
    grid-column: span 2;
  }

  #engine .neb-node:nth-last-child(2) {
    grid-column: 2 / span 2;
  }
}

@media (prefers-reduced-motion: no-preference) {
  #engine .neb-node img {
    animation: engine-portrait-reveal 620ms var(--ease-out) both;
    animation-delay: calc(var(--d, 0s) * -.085);
  }

  #engine .neb-node:focus-visible img {
    animation: none;
  }

  @keyframes engine-portrait-reveal {
    from { opacity: .52; transform: scale(.9); }
    to { opacity: 1; transform: none; }
  }
}

@media (min-width: 901px) and (prefers-reduced-motion: no-preference) {
  #engine .neb-signals::before, #engine .neb-signals::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 47%;
    width: 336px;
    aspect-ratio: 1;
    border-radius: 50%;
    pointer-events: none;
    background: conic-gradient(from 24deg, transparent 8%, #f2b46999 24%, #fff4d9 28%, transparent 28.5% 55%, #d68f4754 66%, #ffd991c9 75%, transparent 75.5%);
    mask-image: radial-gradient(circle, transparent 67.7%, #000 68.1% 70%, transparent 70.6%);
    animation: engine-orbit 16s linear infinite;
  }

  #engine .neb-signals::after {
    width: 238px;
    background: conic-gradient(from -43deg, #ffe7b7 0%, transparent .7% 41%, #ffbf6566 54%, #ffecc9 59%, transparent 59.5% 85%, #dc8e4255 96%, #ffe7b7);
    mask-image: radial-gradient(circle, transparent 68%, #000 68.4% 70%, transparent 70.6%);
    animation-duration: 10.5s;
    animation-direction: reverse;
  }

  #engine .neb-core::before, #engine .neb-core::after {
    border-color: #f5b76a;
    animation: engine-wave 4350ms var(--ease-out) infinite both;
  }

  #engine .neb-core::after {
    border-color: #ffe4ad;
    animation-delay: -1600ms;
  }

  #engine .neb-links line {
    animation: engine-route-light 5.5s cubic-bezier(.77, 0, .175, 1) infinite alternate;
  }

  #engine .neb-links line:nth-child(2n) { animation-delay: -1.8s; }
  #engine .neb-links line:nth-child(3n) { animation-delay: -3.6s; }

  #engine .neb-spark::before {
    width: 34px;
    height: 34px;
    inset: -17px auto auto -17px;
    background: radial-gradient(circle, #fff8e8 0 9%, var(--signal-ink) 14%, var(--signal-halo) 25%, transparent 70%);
  }

  @keyframes engine-orbit {
    from { transform: translate(-50%, -50%) rotate(0); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
  }

  @keyframes engine-wave {
    0% { opacity: .7; transform: scale(.96); }
    57%, 100% { opacity: 0; transform: scale(2.22); }
  }

  @keyframes engine-route-light {
    from { opacity: .23; }
    to { opacity: .57; }
  }
}

#engine .nebula:is(.ambient-paused, .motion-aware:not(.in-view), .picked) :is(.neb-node img, .neb-links line, .neb-spark),
#engine .nebula:is(.ambient-paused, .motion-aware:not(.in-view), .picked) .neb-core::before,
#engine .nebula:is(.ambient-paused, .motion-aware:not(.in-view), .picked) .neb-core::after,
#engine .nebula:is(.ambient-paused, .motion-aware:not(.in-view), .picked) .neb-signals::before,
#engine .nebula:is(.ambient-paused, .motion-aware:not(.in-view), .picked) .neb-signals::after {
  animation-play-state: paused;
}
