/* The Pocket Galaxy view (galaxy.js), wherever it is mounted: the 小星系 page and the home page
   hero. The stage is any element with data-galaxy; galaxy.js places the labels over their
   planets and adds is-ready, is-pointing, is-dragging, is-leaving and is-flat. */

[data-galaxy] {
  position: relative;
  overflow: hidden;
}

[data-galaxy] > canvas[data-gx-canvas] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  opacity: 0;
  transition: opacity 700ms ease;
}

[data-galaxy].is-ready > canvas[data-gx-canvas] {
  opacity: 1;
}

[data-galaxy].is-pointing > canvas[data-gx-canvas] {
  cursor: pointer;
}

[data-galaxy].is-dragging > canvas[data-gx-canvas] {
  cursor: grabbing;
}

/* Labels: just the name, the line about the game opens on hover or keyboard focus. */
.gx-label {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  display: grid;
  max-width: 16em;
  padding: 5px 14px 6px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 999px;
  background: rgba(8, 12, 18, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #eef1ee;
  text-align: center;
  text-decoration: none;
  opacity: 0;
  transition: border-color 160ms ease, background 160ms ease, opacity 300ms ease;
  will-change: transform;
}

[data-galaxy].is-ready .gx-label {
  opacity: 1;
}

[data-galaxy].is-ready .gx-label.is-off {
  opacity: 0;
  pointer-events: none;
}

.gx-label strong {
  font-family: var(--gh-font-display);
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--accent);
}

.gx-more {
  display: none;
  gap: 2px;
}

.gx-more > span {
  color: #b9c3cc;
  font-size: 0.78rem;
  line-height: 1.45;
}

.gx-label em {
  justify-self: center;
  margin-top: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  font-size: 0.74rem;
  font-style: normal;
  font-weight: 700;
}

.gx-label.is-hot,
.gx-label:focus-visible {
  z-index: 4;
  min-width: 11em;
  padding: 8px 12px 9px;
  border-color: var(--accent);
  border-radius: 12px;
  background: rgba(12, 18, 26, 0.9);
}

.gx-label.is-hot .gx-more,
.gx-label:focus-visible .gx-more {
  display: grid;
  animation: gx-more-in 180ms ease both;
}

@keyframes gx-more-in {
  from {
    opacity: 0;
  }
}

.gx-label:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* The view buttons: nearer, farther, back to the whole system; and a hint how to move it. */
.gx-tools {
  position: absolute;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: opacity 400ms ease;
}

[data-galaxy].is-ready .gx-tools {
  opacity: 1;
}

.gx-tools button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  background: rgba(8, 12, 18, 0.62);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #e8edf2;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, opacity 200ms ease;
}

.gx-tools button:hover {
  border-color: rgba(255, 220, 140, 0.6);
  background: rgba(30, 40, 56, 0.8);
}

.gx-tools button:focus-visible {
  outline: 2px solid #ffcf5a;
  outline-offset: 2px;
}

.gx-tools button:disabled,
.gx-tools button.is-off {
  opacity: 0.35;
  cursor: default;
}

.gx-tools svg {
  width: 18px;
  height: 18px;
}

.gx-hint {
  margin-left: 4px;
  color: rgba(214, 222, 232, 0.62);
  font-size: 0.78rem;
  white-space: nowrap;
}

@media (pointer: coarse) {
  .gx-hint-mouse {
    display: none;
  }
}

@media (pointer: fine) {
  .gx-hint-touch {
    display: none;
  }
}

/* Flying into a planet: everything else fades away. */
[data-galaxy].is-leaving .gx-label,
[data-galaxy].is-leaving .gx-tools,
[data-galaxy].is-leaving [data-gx-fade] {
  opacity: 0;
  transition: opacity 400ms ease;
}

[data-galaxy].is-flat .gx-label,
[data-galaxy].is-flat .gx-tools {
  display: none;
}

@media (max-width: 760px) {
  .gx-label {
    padding: 3px 10px 4px;
  }

  .gx-label strong {
    font-size: 0.95rem;
  }

  .gx-label.is-hot,
  .gx-label:focus-visible {
    min-width: 0;
    padding: 5px 14px 6px;
    border-radius: 999px;
  }

  .gx-label.is-hot .gx-more,
  .gx-label:focus-visible .gx-more {
    display: none;
  }

  .gx-hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gx-label,
  [data-galaxy] > canvas[data-gx-canvas] {
    transition: none;
  }

  .gx-label .gx-more {
    animation: none;
  }
}
