/* Capacidades 3D — full-bleed Three.js scene with its own HUD overlay.
   Deliberately outside the .section padding model (like .hero).
   Height is capped (not 100dvh) by default: the scene captures wheel/touch
   for orbit-zoom, so if it filled the whole viewport there would be no
   visible page above/below to grab and keep scrolling from — on touch
   devices especially, that reads as the page being "stuck". Capping the
   height leaves a visible margin so normal scroll always works; the
   fullscreen toggle (below) is the opt-in way to go fully immersive. */
.planets {
  position: relative;
  width: 100%;
  height: clamp(460px, 75vh, 720px);
  background: #05040a;
  overflow: hidden;
  font-family: var(--font-mono);
  color: #fff;
  user-select: none;
}

.planets.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 300;
  width: 100vw;
  height: 100dvh;
}

/* Applied to <body> while fullscreen is active, so the page behind the
   fixed overlay can't be scrolled at the same time. */
.has-planets-fullscreen {
  overflow: hidden;
}

.planets__mount {
  position: absolute;
  inset: 0;
  z-index: 1;
  cursor: grab;
}

.planets__mount.is-dragging {
  cursor: grabbing;
}

.planets__vignette {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, transparent 40%, rgba(5, 4, 10, 0.65) 100%);
}

.planets__header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: clamp(14px, 4vw, 28px) clamp(16px, 4vw, 36px);
}

.planets__legend {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: clamp(8px, 1.8vw, 10px);
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 7px 12px 7px 9px;
}

.planets__legend-icon {
  display: flex;
  color: #8b6cff;
  animation: spin-slow 8s linear infinite;
}

.planets__ui-toggle,
.planets__fullscreen-toggle,
.planets__intro-close,
.planets__card-close {
  line-height: 0;
}

.planets__header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.planets__ui-toggle,
.planets__fullscreen-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
  transition: background 0.2s ease, transform 0.15s ease;
}

.planets__ui-toggle:hover,
.planets__fullscreen-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
}

.planets__ui-toggle:active,
.planets__fullscreen-toggle:active {
  transform: scale(0.9);
}

.planets__breadcrumb {
  position: absolute;
  top: clamp(58px, 12vw, 70px);
  left: clamp(16px, 4vw, 36px);
  right: clamp(16px, 4vw, 36px);
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  font-size: clamp(10px, 2.2vw, 12px);
  letter-spacing: 0.5px;
}

.planets__crumb {
  text-transform: uppercase;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  letter-spacing: inherit;
  transition: color 0.2s ease;
}

.planets__crumb-sep {
  color: rgba(255, 255, 255, 0.3);
}

.planets__intro {
  position: absolute;
  top: clamp(100px, 20vw, 124px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(10, 8, 20, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 10px 14px;
  width: min(90vw, 480px);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.planets__intro-text {
  font-size: clamp(10.5px, 2.4vw, 12px);
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.75);
}

.planets__intro-close {
  cursor: pointer;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.planets__card {
  position: absolute;
  top: clamp(84px, 18vw, 96px);
  right: clamp(12px, 3vw, 36px);
  z-index: 25;
  width: min(86vw, 340px);
  max-height: min(58vh, 460px);
  overflow-y: auto;
  /* Firefox; see the ::-webkit-scrollbar rules below for other browsers —
     same themed-scrollbar treatment used on .terminal__history/.nav__links. */
  scrollbar-width: thin;
  scrollbar-color: var(--accent-purple-strong) rgba(255, 255, 255, 0.06);
  background: rgba(14, 10, 26, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-top: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  padding: clamp(16px, 4vw, 26px);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  animation: panel-in 0.3s var(--ease-standard);
  transition: border-top-color 0.3s ease, box-shadow 0.3s ease;
}

.planets__card::-webkit-scrollbar {
  width: 6px;
}

.planets__card::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
}

.planets__card::-webkit-scrollbar-thumb {
  background: var(--accent-purple-strong);
  border-radius: 999px;
}

.planets__card::-webkit-scrollbar-thumb:hover {
  background: var(--accent-magenta);
}

.planets__card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.planets__card-kicker {
  font-size: 11px;
  letter-spacing: 1.5px;
}

.planets__card-close {
  cursor: pointer;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  width: 36px;
  height: 36px;
  margin: -6px -8px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  touch-action: manipulation;
  transition: color 0.2s ease;
}

.planets__card-close:hover {
  color: #fff;
}

.planets__card-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(18px, 4.5vw, 24px);
  margin-top: 8px;
}

.planets__card-desc {
  font-size: clamp(11.5px, 2.6vw, 13px);
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 10px;
}

.planets__card-back {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  font-size: 11px;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  transition: color 0.2s ease;
}

.planets__card-back:hover {
  color: rgba(255, 255, 255, 0.85);
}

.planets__card-back-icon {
  display: flex;
  transform: rotate(-90deg);
}

.planets__minimap {
  position: absolute;
  bottom: clamp(16px, 4vw, 36px);
  right: clamp(12px, 3vw, 36px);
  z-index: 20;
  width: clamp(92px, 22vw, 130px);
  height: clamp(92px, 22vw, 130px);
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: radial-gradient(circle, rgba(139, 108, 255, 0.1), transparent 70%);
}

.planets__minimap-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.planets__minimap-sun {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  margin: -3px;
  border-radius: 50%;
  background: #e8d9ff;
  box-shadow: 0 0 6px 1px rgba(232, 217, 255, 0.6);
}

.planets__minimap-dot {
  position: absolute;
  margin: -6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.planets__minimap-dot::before {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  border-radius: 50%;
  background: inherit;
  transition: transform 0.15s ease;
}

.planets__minimap-dot:hover::before {
  transform: scale(1.3);
}

.planets__nav {
  position: absolute;
  bottom: clamp(16px, 4vw, 32px);
  left: clamp(12px, 3vw, 36px);
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(3, clamp(30px, 7vw, 38px));
  grid-template-rows: repeat(2, clamp(30px, 7vw, 38px));
  gap: 4px;
}

.planets__nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.planets__nav-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
}

.planets__nav-btn:active {
  transform: scale(0.88);
  background: rgba(139, 108, 255, 0.35);
}

.planets__nav-btn--up { transform: rotate(0deg); }
.planets__nav-btn--right { transform: rotate(90deg); }
.planets__nav-btn--down { transform: rotate(180deg); }
.planets__nav-btn--left { transform: rotate(270deg); }
.planets__nav-btn--up:active { transform: rotate(0deg) scale(0.88); }
.planets__nav-btn--right:active { transform: rotate(90deg) scale(0.88); }
.planets__nav-btn--down:active { transform: rotate(180deg) scale(0.88); }
.planets__nav-btn--left:active { transform: rotate(270deg) scale(0.88); }

.planets__fact {
  position: absolute;
  bottom: clamp(90px, 16vh, 130px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  width: min(84vw, 460px);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.planets__fact.is-visible {
  opacity: 1;
}

.planets__fact-text {
  font-size: clamp(10.5px, 2.3vw, 12.5px);
  line-height: 1.5;
  color: rgba(223, 232, 255, 0.85);
  letter-spacing: 0.3px;
  font-style: italic;
  text-shadow: 0 0 12px rgba(139, 108, 255, 0.5);
}

.planets__reveal {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: #05040a;
  opacity: 1;
  transition: opacity 1.4s ease;
  pointer-events: none;
}

.planets__reveal.is-done {
  opacity: 0;
}

.planets__loading {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: #05040a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  transition: opacity 0.4s ease;
}

.planets__loading.is-done {
  opacity: 0;
  pointer-events: none;
}

.planets__loading-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #8b6cff;
  animation: pulse-dot 1.2s ease-in-out infinite;
}

.planets__loading-text {
  font-size: 12px;
  letter-spacing: 1.5px;
  color: rgba(255, 255, 255, 0.5);
}

.planets__error {
  position: absolute;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
  background: #05040a;
}

.planets__error-text {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  max-width: 420px;
  line-height: 1.6;
}

/* A brief, colored ring-flash on the tapped/clicked object reads as instant
   "yes, that registered" feedback — the kind of tactile response that makes
   an interface feel game-like rather than merely functional. */
.planets__tap-flash {
  position: absolute;
  z-index: 22;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  border: 2px solid #fff;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.4);
}

.planets__tap-flash.is-active {
  animation: tap-flash-pop 0.5s var(--ease-standard);
}

@keyframes tap-flash-pop {
  0% { opacity: 0.9; transform: scale(0.4); }
  100% { opacity: 0; transform: scale(3.2); }
}

@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Bigger, more forgiving touch targets on phones/tablets — the goal is that
   tapping around this scene never feels fiddly, closer to a game's HUD than
   a strict desktop control panel. */
@media (max-width: 640px) {
  .planets {
    /* Leave more margin proportionally on small screens — the whole point
       is that there's always page visible above/below to scroll from. */
    height: clamp(420px, 65vh, 620px);
  }
  .planets.is-fullscreen {
    height: 100dvh;
  }
  .planets__nav {
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(2, 44px);
    gap: 6px;
  }
  .planets__ui-toggle,
  .planets__fullscreen-toggle {
    width: 40px;
    height: 40px;
  }
  .planets__minimap {
    width: 104px;
    height: 104px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .planets__loading-dot,
  .planets__legend-icon {
    animation: none;
  }
  .planets__tap-flash.is-active {
    animation: none;
    opacity: 0;
  }
}
