/* ============================================================
   Skill Galaxy — scoped styles for the 3D Three.js host.

   Visual reference: the "工具的 宇宙" cosmic atlas — gold sun,
   wide elliptical orbits over a Milky Way panorama, glowing
   cluster-tinted planets with persistent names, and a warm
   paper-tone detail card to the right.

   All rules live under .skill-galaxy so they cannot leak into
   the surrounding site shell. The host is the existing
   .skill-sphere-stage element on the homepage, modified by
   .skill-sphere-stage--galaxy to override aspect-ratio.
============================================================ */

/* ─── Full-bleed: galaxy IS the section ───
   When .skill-sphere-section--galaxy is the wrapper, drop the centered
   1440-grid + padding and let the stage own the entire viewport block. */
.skill-sphere-section.skill-sphere-section--galaxy {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  padding: 0;
  background: #000005;
}
.about-skills.has-skill-galaxy::before,
.about-skills.has-skill-galaxy::after {
  display: none;
}

.skill-sphere-stage.skill-sphere-stage--galaxy {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
  perspective: none;
}

.skill-galaxy {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 0;
  /* Painted Milky Way — a diagonal galactic dust lane sweeping
     top-right to bottom-left, with a bright golden bulge near the
     core and cool nebulosity in the opposite quadrant. Matches the
     cartographic reference much closer than a procedural starfield. */
  background:
    /* Hot galactic core highlight (top-right bulge) — softer, less competing with the title */
    radial-gradient(circle at 84% 16%, rgba(255, 218, 158, 0.50) 0%, rgba(245, 168, 100, 0.34) 7%, rgba(180, 100, 56, 0.20) 17%, transparent 32%),
    /* Wider warm halo around the core */
    radial-gradient(ellipse 60% 45% at 78% 24%, rgba(232, 168, 100, 0.28) 0%, rgba(176, 108, 64, 0.14) 38%, transparent 75%),
    /* Distant warm dust trailing down the diagonal toward the lower-left */
    radial-gradient(ellipse 48% 32% at 26% 76%, rgba(214, 156, 100, 0.22) 0%, rgba(160, 100, 64, 0.11) 50%, transparent 80%),
    /* Cool blue dust scattering on the opposite side */
    radial-gradient(ellipse 42% 30% at 20% 42%, rgba(86, 130, 198, 0.16) 0%, transparent 75%),
    /* Pink h-alpha emission knot */
    radial-gradient(circle at 56% 56%, rgba(214, 102, 132, 0.11) 0%, transparent 55%),
    /* Diagonal Milky Way dust lane — bright streak top-right to bottom-left */
    linear-gradient(118deg,
      transparent 18%,
      rgba(255, 196, 130, 0.05) 32%,
      rgba(255, 204, 138, 0.10) 44%,
      rgba(255, 196, 130, 0.13) 50%,
      rgba(255, 196, 130, 0.10) 56%,
      rgba(255, 196, 130, 0.05) 68%,
      transparent 82%),
    /* Deep cosmos base — slightly violet at edges, near-black at center */
    radial-gradient(ellipse 120% 120% at 50% 50%, #050714 0%, #02030a 70%, #010207 100%);
  isolation: isolate;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  color: #e8e8f0;
  cursor: grab;
  contain: layout paint;

  /* Local design tokens (scoped to the galaxy theme) */
  --gx-gold: #f0c977;
  --gx-gold-soft: #d8b46e;
  --gx-gold-deep: #c5934a;
  --gx-cream: #f3ede1;
  --gx-cream-dim: #b8b1a3;
  --gx-cream-muted: #8b8579;
  --gx-agent: #7fb3d5;
  --gx-design: #c39bd3;
  --gx-gen: #d4af7a;
  --gx-panel-bg: rgba(14, 12, 22, 0.62);
  --gx-panel-border: rgba(240, 201, 119, 0.22);
  --gx-z-canvas: 1;
  --gx-z-orbit-label: 2;
  --gx-z-planet-label: 3;
  --gx-z-chrome: 4;
  --gx-z-tooltip: 5;
  --gx-z-panel: 6;
}
.skill-galaxy:active { cursor: grabbing; }

.skill-galaxy__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: var(--gx-z-canvas);
  /* Allow vertical scroll to bubble. Horizontal drag still orbits the camera. */
  touch-action: pan-y;
}

/* ─── Editorial overlay header ───
   Top-left eyebrow + display title in Noto Serif SC for the
   ceremonial Chinese hero; top-right meta in mono. */
.skill-galaxy__header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--gx-z-chrome);
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: clamp(20px, 4vw, 64px);
  /* Top padding clears site sticky header; left padding clears the
     .return-welcome fixed back-arrow (22px + 46px + breathing room). */
  padding: clamp(84px, 9vh, 112px) clamp(40px, 5vw, 72px) 0 clamp(92px, 7vw, 132px);
}

.skill-galaxy__header-left {
  pointer-events: auto;
  max-width: min(560px, 65%);
}

.skill-galaxy__header-right {
  pointer-events: auto;
  text-align: right;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.skill-galaxy__eyebrow {
  font-family: "Courier New", Consolas, ui-monospace, monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--gx-gold);
  margin: 0 0 22px;
  opacity: 0;
  animation: skill-galaxy-rise 1s 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.skill-galaxy__title {
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
  font-size: clamp(56px, 6.8vw, 96px);
  font-weight: 700;
  line-height: 0.96;
  letter-spacing: 0.01em;
  color: var(--gx-cream);
  margin: 0;
  opacity: 0;
  animation: skill-galaxy-rise 1.1s 0.85s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.skill-galaxy__title em {
  font-style: italic;
  font-weight: 700;
  color: var(--gx-gold);
  margin-left: 0.12em;
}

/* Status dot before "运行中" reads as a live-feed indicator. */
.skill-galaxy__meta-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--gx-gold);
  margin: 0;
  opacity: 0;
  animation: skill-galaxy-rise 1s 1.05s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.skill-galaxy__meta-label::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gx-gold);
  box-shadow: 0 0 10px var(--gx-gold);
  animation: skill-galaxy-blink 2.4s ease-in-out infinite;
}

.skill-galaxy__meta-value {
  font-family: "Courier New", Consolas, ui-monospace, monospace;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  color: var(--gx-cream-dim);
  margin: 0;
  opacity: 0;
  animation: skill-galaxy-rise 1s 1.15s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes skill-galaxy-rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes skill-galaxy-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

/* ─── Cluster chips ─── */
.skill-galaxy__clusters {
  position: absolute;
  z-index: var(--gx-z-chrome);
  top: clamp(210px, 24vh, 268px);
  left: clamp(92px, 7vw, 132px);
  right: clamp(40px, 5vw, 72px);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  opacity: 0;
  animation: skill-galaxy-rise 0.9s 1.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.skill-galaxy__chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  white-space: nowrap;
  padding: 9px 20px;
  background: rgba(18, 16, 28, 0.55);
  border: 1px solid rgba(240, 201, 119, 0.22);
  border-radius: 999px;
  color: rgba(245, 240, 230, 0.82);
  font: 600 13px/1 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.02em;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition:
    background 220ms ease,
    color 220ms ease,
    border-color 220ms ease,
    transform 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

.skill-galaxy__chip:hover {
  background: rgba(38, 32, 52, 0.72);
  color: rgba(255, 251, 240, 0.96);
  transform: translateY(-1px);
}

.skill-galaxy__chip.is-active {
  background: rgba(245, 240, 230, 0.95);
  color: #1a1620;
  border-color: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 1px rgba(240, 201, 119, 0.25), 0 8px 28px rgba(0, 0, 0, 0.35);
}

.skill-galaxy__chip:focus-visible {
  outline: 2px solid var(--gx-gold);
  outline-offset: 3px;
}

.skill-galaxy__cta {
  position: absolute;
  z-index: var(--gx-z-chrome);
  top: clamp(264px, 30vh, 326px);
  left: clamp(92px, 7vw, 132px);
  right: clamp(40px, 5vw, 72px);
  max-width: 520px;
  margin: 0;
  font: 400 13px/1.55 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.02em;
  color: rgba(220, 214, 200, 0.82);
  opacity: 0;
  animation: skill-galaxy-rise 0.9s 1.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ─── Persistent planet labels ───
   DOM nodes positioned by JS each frame, anchored to projected 3D
   coordinates of every planet. Plain serif text + thin underline tick
   so they read like cartographic place-names, not chips. */
.skill-galaxy__labels {
  position: absolute;
  inset: 0;
  z-index: var(--gx-z-planet-label);
  pointer-events: none;
}
.skill-galaxy__label {
  position: absolute;
  transform: translate(var(--gx-tx, 12px), -50%);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--gx-cream);
  white-space: nowrap;
  opacity: var(--gx-op, 1);
  transition: color 220ms ease;
  text-shadow:
    0 1px 8px rgba(0, 0, 0, 0.95),
    0 0 14px rgba(0, 0, 0, 0.85),
    0 0 4px rgba(0, 0, 0, 0.9);
  cursor: pointer;
  pointer-events: auto;
  padding: 3px 6px;
  border: 0;
  background: transparent;
}
.skill-galaxy__label::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 1px;
  margin-right: 8px;
  vertical-align: middle;
  background: currentColor;
  opacity: 0.55;
}
.skill-galaxy__label--agent  { color: var(--gx-agent); }
.skill-galaxy__label--design { color: var(--gx-design); }
.skill-galaxy__label--gen    { color: var(--gx-gen); }
.skill-galaxy__label:hover,
.skill-galaxy__label.is-active {
  color: #fff;
}

/* ─── Legend (bottom-left) ─── */
.skill-galaxy__legend {
  position: absolute;
  z-index: var(--gx-z-chrome);
  left: clamp(40px, 5vw, 72px);
  bottom: clamp(36px, 5vh, 56px);
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font: 500 12px/1 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.04em;
  color: rgba(220, 214, 200, 0.82);
  opacity: 0;
  animation: skill-galaxy-rise 1s 1.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.skill-galaxy__legend-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.skill-galaxy__legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 10px currentColor;
}
.skill-galaxy__legend-row--agent  { color: var(--gx-agent); }
.skill-galaxy__legend-row--agent  span:last-child  { color: rgba(220, 214, 200, 0.86); }
.skill-galaxy__legend-row--design { color: var(--gx-design); }
.skill-galaxy__legend-row--design span:last-child  { color: rgba(220, 214, 200, 0.86); }
.skill-galaxy__legend-row--gen    { color: var(--gx-gen); }
.skill-galaxy__legend-row--gen    span:last-child  { color: rgba(220, 214, 200, 0.86); }
.skill-galaxy__legend-row span:last-child {
  font-weight: 500;
  letter-spacing: 0.08em;
}
.skill-galaxy__legend-row .skill-galaxy__legend-dot { background: currentColor; }

/* ─── Bottom interaction hint ─── */
.skill-galaxy__guide {
  position: absolute;
  z-index: var(--gx-z-chrome);
  left: 50%;
  bottom: clamp(28px, 4vh, 48px);
  transform: translateX(-50%);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  color: rgba(220, 214, 200, 0.78);
  opacity: 0;
  animation: skill-galaxy-rise 1s 1.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.skill-galaxy__guide-icon {
  width: 18px;
  height: 24px;
  color: rgba(220, 214, 200, 0.55);
  animation: skill-galaxy-bob 3.2s ease-in-out infinite;
}
.skill-galaxy__guide-text {
  font: 500 12px/1 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.08em;
}
@keyframes skill-galaxy-bob {
  0%, 100% { transform: translateY(0); opacity: 0.55; }
  50%      { transform: translateY(3px); opacity: 0.85; }
}

/* ─── Tooltip (small hover label on canvas) ─── */
.skill-galaxy__tooltip {
  position: absolute;
  z-index: var(--gx-z-tooltip);
  pointer-events: none;
  padding: 8px 14px;
  background: rgba(20, 18, 28, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(240, 201, 119, 0.30);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: #f5f0e6;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s, transform 0.2s;
}
.skill-galaxy__tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.skill-galaxy__tooltip .ttcat {
  font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  color: var(--gx-gold);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* ─── Detail panel (right side) ───
   Paper-tone translucent card. Keeps the welcome-screen mood
   (gold + warm cream over deep cosmos) without diluting it. */
.skill-galaxy__panel {
  position: absolute;
  top: 50%;
  right: clamp(24px, 3vw, 48px);
  transform: translateY(-50%) translateX(40px);
  width: min(340px, calc(100% - 32px));
  max-height: calc(100% - 260px);
  z-index: var(--gx-z-panel);
  padding: 34px 30px 30px;
  background:
    linear-gradient(180deg, rgba(28, 24, 36, 0.84), rgba(14, 12, 22, 0.86)),
    radial-gradient(120% 80% at 50% -10%, rgba(240, 201, 119, 0.16), transparent 60%);
  backdrop-filter: blur(28px) saturate(1.4);
  -webkit-backdrop-filter: blur(28px) saturate(1.4);
  border: 1px solid rgba(240, 201, 119, 0.22);
  border-radius: 14px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 30px 90px rgba(0, 0, 0, 0.55),
    0 0 60px rgba(240, 201, 119, 0.06);
  opacity: 0;
  pointer-events: none;
  overflow-y: auto;
  transition:
    opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.skill-galaxy__panel.is-visible {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
  pointer-events: auto;
}
.skill-galaxy__panel::-webkit-scrollbar { width: 2px; }
.skill-galaxy__panel::-webkit-scrollbar-thumb { background: rgba(240, 201, 119, 0.25); }

.skill-galaxy__panel-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid rgba(240, 201, 119, 0.30);
  color: var(--gx-cream-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  transition: color 0.3s, border-color 0.3s, background 0.3s;
}
.skill-galaxy__panel-close:hover {
  color: var(--gx-gold);
  border-color: var(--gx-gold);
  background: rgba(240, 201, 119, 0.08);
}

.skill-galaxy__panel-name {
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(28px, 2.6vw, 34px);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--gx-cream);
  margin: 0 0 4px;
  line-height: 1.08;
}
.skill-galaxy__panel-coords {
  font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--gx-cream-muted);
  letter-spacing: 0.05em;
  margin: 14px 0 24px;
}
.skill-galaxy__panel-desc {
  font-size: 13.5px;
  line-height: 1.65;
  color: rgba(220, 214, 200, 0.86);
  margin: 0;
  font-weight: 400;
}

/* ─── Mobile / narrow viewports ─── */
@media (max-width: 880px) {
  .skill-galaxy__title { font-size: clamp(40px, 9vw, 56px); }
  .skill-galaxy__legend {
    bottom: clamp(96px, 14vh, 130px);
    left: 18px;
    gap: 6px;
    font-size: 11px;
  }
  .skill-galaxy__panel {
    top: auto;
    bottom: clamp(96px, 13vh, 130px);
    right: 16px;
    left: 16px;
    width: auto;
    max-height: 52%;
    transform: translateY(40px);
    padding: 28px 22px 24px;
  }
  .skill-galaxy__panel.is-visible { transform: translateY(0); }
  .skill-galaxy__panel-name { font-size: 24px; }
  .skill-galaxy__label { font-size: 11px; }
}

@media (max-width: 600px) {
  .skill-galaxy__header { padding: 76px 18px 0 22px; }
  .skill-galaxy__header-left { max-width: 100%; }
  .skill-galaxy__header-right { display: none; }
  .skill-galaxy__title { font-size: clamp(40px, 11vw, 52px); }
  .skill-galaxy__eyebrow { margin-bottom: 14px; font-size: 10px; }
  .skill-galaxy__clusters {
    top: clamp(170px, 22vh, 210px);
    left: 22px;
    right: 18px;
    gap: 8px;
  }
  .skill-galaxy__chip { padding: 7px 14px; font-size: 12px; min-height: 32px; }
  .skill-galaxy__cta {
    top: clamp(220px, 30vh, 270px);
    left: 22px;
    right: 18px;
  }
  .skill-galaxy__guide-text { font-size: 10px; letter-spacing: 0.06em; }
}

/* ─── Reduced motion ─── */
@media (prefers-reduced-motion: reduce) {
  .skill-galaxy__eyebrow,
  .skill-galaxy__title,
  .skill-galaxy__meta-label,
  .skill-galaxy__meta-value,
  .skill-galaxy__clusters,
  .skill-galaxy__cta,
  .skill-galaxy__legend,
  .skill-galaxy__guide {
    animation: none;
    opacity: 1;
    transform: none;
  }
  .skill-galaxy__meta-label::before,
  .skill-galaxy__guide-icon {
    animation: none;
  }
}
