@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap");

:root {
  --bg: #050508;
  --text: #e8e4ef;
  --text-muted: #8a8498;
  --ball-glass: rgba(40, 45, 70, 0.75);
  --ball-border: rgba(255, 255, 255, 0.18);
  --modal-bg: rgba(18, 18, 28, 0.96);
  --modal-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  --accent: #e8dcc8;
  --accent-2: #c5d0de;
  --link-bg: #1a1a28;
  --link-text: #e8e4ef;
  --orbit-stroke: rgba(197, 208, 222, 0.28);
  --orbit-stroke-sub: rgba(232, 220, 200, 0.35);
}

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

html,
body {
  height: 100%;
}

body {
  font-family: "Outfit", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* —— Starfield —— */
.starfield {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, #0a0a14 0%, #050508 70%);
}

.star {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  pointer-events: none;
}

.star--bright {
  box-shadow: 0 0 4px 1px rgba(255, 255, 255, 0.5);
}

/* —— Layout —— */
.page {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.top-bar {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.back-link {
  position: absolute;
  left: 1.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
  pointer-events: auto;
}

.back-link:hover {
  color: var(--text);
}

.page-title {
  position: absolute;
  top: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(1.35rem, 3.5vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  pointer-events: none;
  white-space: nowrap;
}

.hint {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  z-index: 2;
  transform: translateX(-50%);
  max-width: min(90vw, 42rem);
  padding: 0 1rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-muted);
  text-align: center;
  opacity: 0.8;
  pointer-events: none;
}

/* —— Stage —— */
.stage {
  position: relative;
  flex: 1;
  width: 100%;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.stage:active {
  cursor: grabbing;
}

.stage-camera {
  position: absolute;
  inset: 0;
  transform: translate(0, 0) scale(1);
  transform-origin: 0 0;
  transition: transform 0.68s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.stage.is-orbit-open .memory-ball:not(.is-web-active):not(.is-sub-ball) {
  opacity: 0.12;
  pointer-events: none;
  filter: blur(2px);
}

.stage.is-orbit-open .orbit-layer:not(.sub-orbit-layer) {
  opacity: 0.06;
}

/* —— Orbit rings —— */
.orbit-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: visible;
}

.orbit-layer__ring {
  fill: none;
  stroke: rgba(255, 255, 255, 0.32);
  stroke-width: 1.5;
}

.orbit-layer__ring--faint {
  stroke: rgba(255, 255, 255, 0.12);
}

.sub-orbit-layer {
  z-index: 3;
}

.sub-orbit-layer__ring {
  fill: none;
  stroke: var(--orbit-stroke-sub);
  stroke-width: 1.5;
}

/* —— Memory ball —— */
.memory-ball {
  position: absolute;
  z-index: 1;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  border: 1.5px solid var(--ball-border);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  background: var(--ball-glass);
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  will-change: transform;
  transition:
    box-shadow 0.25s ease,
    border-color 0.25s ease,
    filter 0.25s ease;
  isolation: isolate;
}

.memory-ball::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.18) 0%,
    transparent 42%,
    rgba(0, 0, 0, 0.2) 100%
  );
  pointer-events: none;
  z-index: 2;
}

.memory-ball:hover,
.memory-ball:focus-visible {
  outline: none;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.55),
    0 0 0 3px rgba(197, 208, 222, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.35);
  filter: brightness(1.08);
}

.memory-ball:active {
  filter: brightness(0.96);
}

.memory-ball__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.planet-arc-name {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  pointer-events: none;
  overflow: visible;
}

.planet-arc-name text {
  fill: var(--text);
  font-family: "Outfit", sans-serif;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
  paint-order: stroke fill;
  stroke: rgba(5, 5, 8, 0.75);
  stroke-width: 2.5px;
  stroke-linejoin: round;
}

.memory-ball__label {
  position: relative;
  z-index: 1;
  display: block;
  flex-shrink: 1;
  min-width: 0;
  width: calc(100% - 1.1rem);
  max-width: calc(100% - 1.1rem);
  margin-inline: auto;
  font-size: clamp(0.68rem, 1.9vw, 0.92rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  text-wrap: balance;
  padding: 0.35rem 0.45rem;
  /* letter-spacing adds ink past the last glyph; keep it inside the circle */
  padding-right: calc(0.45rem + 0.04em);
  box-sizing: border-box;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.65);
  line-height: 1.2;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}

.memory-ball.has-image .memory-ball__label {
  opacity: 0;
  transition: opacity 0.25s ease;
}

.memory-ball.has-image:hover .memory-ball__label,
.memory-ball.has-image:focus-visible .memory-ball__label {
  opacity: 1;
}

.memory-ball.has-image::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.memory-ball.has-image:hover::before,
.memory-ball.has-image:focus-visible::before {
  opacity: 1;
}

/* —— Sol (centro) —— */
.memory-ball.is-sun {
  z-index: 5;
  border: none;
  cursor: default;
  background: radial-gradient(
    circle at 38% 32%,
    #fffde7 0%,
    #ffeb3b 18%,
    #ff9800 50%,
    #e65100 82%,
    #bf360c 100%
  );
  box-shadow:
    0 0 50px rgba(255, 200, 60, 0.75),
    0 0 100px rgba(255, 140, 30, 0.4),
    0 0 160px rgba(255, 100, 20, 0.15),
    0 16px 48px rgba(0, 0, 0, 0.4);
  animation: sun-pulse 4s ease-in-out infinite alternate;
}

@keyframes sun-pulse {
  to {
    box-shadow:
      0 0 60px rgba(255, 220, 80, 0.85),
      0 0 120px rgba(255, 150, 40, 0.5),
      0 0 180px rgba(255, 100, 20, 0.2),
      0 16px 48px rgba(0, 0, 0, 0.4);
  }
}

.memory-ball.is-sun::after {
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.35) 0%,
    transparent 50%,
    rgba(0, 0, 0, 0.08) 100%
  );
}

.memory-ball.is-sun:hover,
.memory-ball.is-sun:focus-visible {
  filter: brightness(1.06);
  box-shadow:
    0 0 55px rgba(255, 200, 60, 0.7),
    0 0 110px rgba(255, 120, 30, 0.4),
    0 0 0 4px rgba(255, 200, 80, 0.25);
}

.memory-ball.is-sun .memory-ball__label {
  color: rgba(80, 30, 0, 0.85);
  text-shadow: 0 1px 4px rgba(255, 255, 255, 0.4);
  font-weight: 700;
}

/* —— Planetas —— */
.memory-ball.is-planet {
  border-color: rgba(255, 255, 255, 0.2);
}

.memory-ball[data-id="CA"] .memory-ball__label,
.memory-ball[data-id="Projetos"] .memory-ball__label {
  font-size: clamp(0.56rem, 1.45vw, 0.72rem);
  line-height: 1.12;
}

.memory-ball.is-web-ball.is-web-active {
  z-index: 12;
  box-shadow:
    0 0 30px rgba(197, 208, 222, 0.35),
    0 20px 56px rgba(0, 0, 0, 0.5),
    0 0 0 5px rgba(197, 208, 222, 0.25);
}

/* —— Balão de fala (planeta) —— */
.planet-speech {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 6;
  max-width: min(11rem, 42vw);
  padding: 0.5rem 0.7rem;
  font-size: 0.78rem;
  line-height: 1.35;
  font-weight: 500;
  color: var(--text);
  background: rgba(18, 18, 28, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(197, 208, 222, 0.08);
  pointer-events: none;
  transition:
    opacity 0.35s ease,
    visibility 0.35s ease;
}

.planet-speech__text {
  margin: 0;
}

.planet-speech::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 50%;
  width: 11px;
  height: 11px;
  background: rgba(18, 18, 28, 0.94);
  border-left: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  transform: translateY(-50%) rotate(45deg);
}

.stage.is-orbit-open .planet-speech,
.stage.is-orbit-open .planet-arc-name,
body.modal-open .planet-speech,
body.modal-open .planet-arc-name {
  opacity: 0;
  visibility: hidden;
}

/* —— Luas —— */
.memory-ball.is-moon {
  z-index: 8;
  cursor: pointer;
  border-color: rgba(200, 210, 230, 0.25);
  box-shadow:
    0 6px 24px rgba(0, 0, 0, 0.4),
    inset -4px -4px 12px rgba(0, 0, 0, 0.15);
}

.memory-ball.is-moon .memory-ball__label {
  font-size: clamp(0.58rem, 1.55vw, 0.75rem);
  width: calc(100% - 0.85rem);
  max-width: calc(100% - 0.85rem);
}

/* —— Modal —— */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

.modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: min(560px, 100%);
  max-height: min(88vh, 720px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--modal-bg);
  border-radius: 28px;
  box-shadow: var(--modal-shadow);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transform: translateY(24px) scale(0.96);
  opacity: 0;
  transition:
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.3s ease;
}

.modal-overlay.is-open .modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem 1.5rem 0.75rem;
}

.modal__eyebrow {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.02em;
  margin-bottom: 0.35rem;
}

.modal__title {
  font-size: clamp(1.25rem, 3vw, 1.55rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--text);
}

.modal__close {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease;
}

.modal__close:hover {
  background: rgba(255, 255, 255, 0.14);
}

.modal__body {
  padding: 0.5rem 1.5rem 1.5rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal__desc {
  font-size: 0.98rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.modal__gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.modal__gallery:empty {
  display: none;
}

.modal__gallery img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.modal__gallery img.is-hero {
  grid-column: 1 / -1;
  aspect-ratio: 16 / 9;
}

.modal__gallery--carousel {
  display: block;
}

.modal__carousel {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  touch-action: pan-y;
}

.modal__carousel-track {
  display: flex;
  transition: transform 0.35s ease;
}

.modal__carousel-slide {
  flex: 0 0 100%;
  min-width: 100%;
}

.modal__carousel-slide img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: rgba(255, 255, 255, 0.04);
  user-select: none;
}

.modal__carousel-btn {
  position: absolute;
  top: 50%;
  z-index: 1;
  transform: translateY(-50%);
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 999px;
  background: rgba(12, 12, 20, 0.72);
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition:
    background 0.2s ease,
    opacity 0.2s ease;
}

.modal__carousel-btn:hover {
  background: rgba(12, 12, 20, 0.9);
}

.modal__carousel-btn--prev {
  left: 0.65rem;
}

.modal__carousel-btn--next {
  right: 0.65rem;
}

.modal__carousel-dots {
  display: flex;
  justify-content: center;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.modal__carousel-dot {
  width: 0.55rem;
  height: 0.55rem;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
  cursor: pointer;
  transition:
    transform 0.2s ease,
    background 0.2s ease;
}

.modal__carousel-dot.is-active {
  background: var(--text);
  transform: scale(1.15);
}

.modal__observacao {
  font-size: 0.98rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.modal__observacao[hidden] {
  display: none;
}

.modal__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.modal__links:empty {
  display: none;
}

.modal__link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  background: var(--link-bg);
  color: var(--link-text);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition:
    transform 0.15s ease,
    opacity 0.15s ease;
}

.modal__link:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

.modal__link img {
  width: 16px;
  height: 16px;
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 600px) {
  .back-link {
    left: 1rem;
  }

  .page-title {
    top: 1rem;
  }

  .hint {
    bottom: 0.85rem;
    font-size: 0.72rem;
  }

  .page-title {
    font-size: 1.15rem;
  }

  .modal {
    border-radius: 22px;
    max-height: 92vh;
  }
}
