:root {
  --bg-deep: #02040a;
  --bg-nebula: #091326;
  --ice-blue: #7dd3fc;
  --ice-glow: rgba(110, 203, 255, 0.34);
  --rust-warm: rgba(212, 114, 78, 0.2);
  --text-main: #f1f5f9;
  --text-muted: rgba(226, 232, 240, 0.62);
  --glass-bg: rgba(10, 16, 30, 0.56);
  --glass-border: rgba(148, 197, 255, 0.16);
  --planet-size: clamp(250px, 44vmin, 470px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: 'Space Grotesk', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

.space-stage {
  position: relative;
  width: 100%;
  height: 100dvh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 48%, rgba(28, 52, 92, 0.22) 0%, rgba(7, 13, 26, 0.6) 44%, var(--bg-deep) 82%);
  overflow: hidden;
}

.space-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.space-canvas--back {
  z-index: 1;
}

.space-canvas--front {
  z-index: 5;
}

/* HUD Superior */
.hud-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: clamp(16px, 3vw, 32px) clamp(20px, 4vw, 44px);
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  pointer-events: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ice-blue);
  box-shadow: 0 0 12px var(--ice-blue);
  animation: beacon 3.6s ease-in-out infinite;
}

.telemetry {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.telemetry__sep {
  opacity: 0.35;
}

/* Palco Central */
.planet-viewport {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 3vh, 30px);
  perspective: 1100px;
  animation: scene-enter 1.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.planet-rig {
  position: relative;
  width: var(--planet-size);
  height: var(--planet-size);
  display: grid;
  place-items: center;
  transform-style: preserve-3d;
  will-change: transform;
}

/* Brilho atmosférico característico de Plutão */
.atmosphere-aura {
  position: absolute;
  inset: -16%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 36%, var(--ice-glow) 0%, rgba(92, 165, 255, 0.12) 48%, rgba(212, 114, 78, 0.06) 64%, transparent 74%);
  filter: blur(22px);
  opacity: 0.85;
  pointer-events: none;
  animation: aura-breathe 7s ease-in-out infinite;
}

.atmosphere-ring {
  position: absolute;
  inset: -2.2%;
  border-radius: 50%;
  background: conic-gradient(
    from 210deg,
    rgba(125, 211, 252, 0.55) 0deg,
    rgba(125, 211, 252, 0.12) 95deg,
    rgba(244, 162, 122, 0.14) 195deg,
    rgba(125, 211, 252, 0.04) 275deg,
    rgba(125, 211, 252, 0.55) 360deg
  );
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 1px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 1px));
  filter: blur(1.4px);
  opacity: 0.78;
  pointer-events: none;
  animation: ring-spin 26s linear infinite;
}

/* Esfera recortada perfeitamente alinhada às coordenadas da foto */
.planet-sphere {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: #020306;
  box-shadow:
    0 0 42px rgba(125, 211, 252, 0.16),
    0 0 90px rgba(34, 86, 158, 0.18),
    inset 0 0 28px rgba(2, 4, 10, 0.85);
  transform: translateZ(0);
}

/*
 * Medição exata de images/plutao.jpg (450x450):
 * O disco do planeta ocupa x=[40..404], y=[37..399]
 * Centro: (49.33%, 48.44%), Diâmetro: ~80.67%
 * Escala 124.2% e deslocamento compensam as margens pretas para preencher a esfera 1:1.
 */
.planet-image {
  position: absolute;
  width: 124.2%;
  height: 124.2%;
  left: -11.25%;
  top: -10.15%;
  max-width: none;
  object-fit: cover;
  transform-origin: 49.33% 48.44%;
  will-change: transform, filter;
  filter: contrast(1.04) saturate(1.06);
}

.planet-terminator {
  position: absolute;
  inset: -2%;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(
    circle at 30% 34%,
    rgba(255, 255, 255, 0.06) 0%,
    rgba(125, 211, 252, 0.03) 34%,
    rgba(3, 6, 14, 0.24) 68%,
    rgba(1, 2, 6, 0.78) 100%
  );
  mix-blend-mode: multiply;
  transition: opacity 0.4s ease;
}

.planet-rim {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  box-shadow:
    inset 6px 6px 26px rgba(155, 222, 255, 0.24),
    inset -18px -16px 38px rgba(1, 3, 9, 0.86);
}

/* Tipografia */
.hero-caption {
  text-align: center;
  pointer-events: none;
}

.hero-title {
  font-size: clamp(1.45rem, 3.2vw, 2.35rem);
  font-weight: 500;
  letter-spacing: 0.44em;
  text-indent: 0.44em;
  color: var(--text-main);
  text-shadow: 0 4px 28px rgba(125, 211, 252, 0.22);
}

.hero-subtitle {
  margin-top: 6px;
  font-size: clamp(0.78rem, 1.4vw, 0.92rem);
  font-weight: 300;
  letter-spacing: 0.16em;
  color: var(--text-muted);
}

/* Controles */
.hud-controls {
  position: absolute;
  bottom: clamp(18px, 3.2vh, 34px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.control-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  border-radius: 999px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.ctrl-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.ctrl-btn:hover {
  color: var(--text-main);
  background: rgba(148, 197, 255, 0.1);
}

.ctrl-btn.is-active {
  color: #04111f;
  background: linear-gradient(135deg, #bae6fd, #7dd3fc);
  box-shadow: 0 0 16px rgba(125, 211, 252, 0.35);
}

.ctrl-btn:focus-visible {
  outline: 2px solid var(--ice-blue);
  outline-offset: 2px;
}

/* Estado pausado */
.space-stage.is-paused .atmosphere-aura,
.space-stage.is-paused .atmosphere-ring,
.space-stage.is-paused .brand__dot {
  animation-play-state: paused;
}

/* Keyframes */
@keyframes scene-enter {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(14px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes aura-breathe {
  0%, 100% {
    transform: scale(1);
    opacity: 0.78;
  }
  50% {
    transform: scale(1.06);
    opacity: 1;
  }
}

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

@keyframes beacon {
  0%, 100% {
    opacity: 0.55;
    transform: scale(0.92);
  }
  50% {
    opacity: 1;
    transform: scale(1.12);
  }
}

@media (max-width: 600px) {
  .telemetry {
    display: none;
  }

  .ctrl-btn {
    padding: 6px 11px;
    font-size: 0.74rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .planet-viewport,
  .atmosphere-aura,
  .atmosphere-ring,
  .brand__dot {
    animation: none;
  }
}
