/* Drifting — digital art space scene */

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

:root {
  --space-deep: #03010a;
  --nebula-violet: rgba(110, 55, 170, 0.55);
  --nebula-rose: rgba(160, 55, 100, 0.48);
  --nebula-teal: rgba(45, 110, 155, 0.45);
  --planet-size: 30vmin;
  --planet-light: #8aabcd;
  --planet-mid: #3a5578;
  --planet-dark: #0e1624;
  --planet-glow: rgba(100, 140, 200, 0.3);
  --parallax-factor: 0.5;
  --parallax-x: 0px;
  --parallax-y: 0px;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  cursor: crosshair;
}

/* Scene: fade in only (no scale — scale + blur children causes edge fizz) */
#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  opacity: 0;
  background:
    radial-gradient(ellipse 120% 80% at 20% 30%, #120a28 0%, transparent 55%),
    radial-gradient(ellipse 100% 70% at 80% 70%, #0a1528 0%, transparent 50%),
    radial-gradient(ellipse 80% 60% at 50% 100%, #1a0a18 0%, transparent 45%),
    linear-gradient(165deg, #05030f 0%, var(--space-deep) 40%, #020108 100%);
  animation: fade-in 4.5s ease-out forwards;
}

@keyframes fade-in {
  to {
    opacity: 1;
  }
}

/* Slow color climate shift + gentle brightness breathe */
#app::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 18;
  pointer-events: none;
  mix-blend-mode: soft-light;
  animation:
    light-shift 100s ease-in-out infinite,
    breathe 40s ease-in-out 4.5s infinite;
}

@keyframes light-shift {
  0%,
  100% {
    background: rgba(30, 40, 100, 0.12);
  }
  33% {
    background: rgba(90, 40, 70, 0.14);
  }
  66% {
    background: rgba(30, 70, 90, 0.12);
  }
}

@keyframes breathe {
  0%,
  100% {
    opacity: 0.85;
  }
  50% {
    opacity: 1;
  }
}

/* Soft cosmic dust / haze + edge vignette to hide blur clipping */
.haze {
  position: absolute;
  inset: -10%;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 50% 40% at 30% 40%, rgba(180, 190, 220, 0.04), transparent 70%),
    radial-gradient(ellipse 40% 35% at 70% 60%, rgba(200, 170, 190, 0.035), transparent 65%),
    radial-gradient(circle at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.35) 100%);
  transform: translate(
    calc(var(--parallax-x) * 0.08),
    calc(var(--parallax-y) * 0.08)
  );
  animation: haze-drift 80s ease-in-out infinite alternate;
}

@keyframes haze-drift {
  from {
    transform: translate(calc(var(--parallax-x) * 0.08), calc(var(--parallax-y) * 0.08))
      scale(1);
  }
  to {
    transform: translate(
        calc(var(--parallax-x) * 0.08 + 2vmax),
        calc(var(--parallax-y) * 0.08 - 1.5vmax)
      )
      scale(1.04);
  }
}

.title {
  position: absolute;
  top: 1.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  text-align: center;
  pointer-events: none;
  user-select: none;
  animation: title-breathe 14s ease-in-out infinite;
}

.title__name {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 300;
  font-size: clamp(1.75rem, 5vw, 2.75rem);
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  color: rgba(220, 225, 240, 0.72);
}

.title__sub {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 400;
  font-size: clamp(0.7rem, 1.6vw, 0.9rem);
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  text-transform: uppercase;
  color: rgba(200, 210, 230, 0.42);
}

@keyframes title-breathe {
  0%,
  100% {
    opacity: 0.75;
  }
  50% {
    opacity: 1;
  }
}

/* Nebulae live in a padded layer so blur has room before the clip edge */
.nebula-field {
  position: absolute;
  inset: -30%;
  z-index: 2;
  pointer-events: none;
}

.nebula {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  width: var(--nebula-w, 45vmax);
  height: var(--nebula-h, 35vmax);
  background: radial-gradient(
    ellipse at center,
    var(--nebula-color, var(--nebula-violet)) 0%,
    transparent 68%
  );
  opacity: 0;
  will-change: left, top, opacity;
  transform: translate(
    calc(var(--parallax-x) * var(--nebula-parallax, 0.15)),
    calc(var(--parallax-y) * var(--nebula-parallax, 0.15))
  );
}

/* Star layers */
.stars-far,
.stars-near {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.stars-far {
  z-index: 3;
  transform: translate(
    calc(var(--parallax-x) * 0.25),
    calc(var(--parallax-y) * 0.25)
  );
}

.stars-near {
  z-index: 7;
  transform: translate(
    calc(var(--parallax-x) * 0.55),
    calc(var(--parallax-y) * 0.55)
  );
}

.star {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  width: var(--size);
  height: var(--size);
  opacity: var(--opacity);
  box-shadow: 0 0 calc(var(--size) * 1.5) rgba(255, 255, 255, 0.35);
  animation: twinkle var(--duration) ease-in-out var(--delay) infinite;
}

.star--bright {
  background: #f0f4ff;
  box-shadow:
    0 0 calc(var(--size) * 2) rgba(200, 220, 255, 0.6),
    0 0 calc(var(--size) * 4) rgba(160, 180, 255, 0.25);
}

/* Soft nearby stars — depth of field */
.star--near {
  background: #e8eef8;
  filter: blur(0.7px);
  box-shadow: 0 0 calc(var(--size) * 3) rgba(200, 215, 255, 0.45);
}

@keyframes twinkle {
  0%,
  100% {
    opacity: var(--opacity);
    transform: scale(1);
  }
  50% {
    opacity: calc(var(--opacity) * 0.3);
    transform: scale(0.85);
  }
}

.star--flare {
  z-index: 10;
  animation: flare 2.5s ease-out forwards !important;
}

@keyframes flare {
  0% {
    opacity: var(--opacity);
    transform: scale(1);
  }
  30% {
    opacity: 1;
    transform: scale(5);
    box-shadow:
      0 0 10px 2px #fff,
      0 0 28px 6px rgba(200, 220, 255, 0.85),
      0 0 55px 12px rgba(160, 180, 255, 0.4);
  }
  100% {
    opacity: var(--opacity);
    transform: scale(1);
  }
}

/* Planets */
.planet-wrap {
  position: absolute;
  width: var(--planet-size);
  height: var(--planet-size);
  transform: translate(
    calc(var(--parallax-x) * var(--parallax-factor)),
    calc(var(--parallax-y) * var(--parallax-factor))
  );
  pointer-events: none;
}

.planet-wrap::before {
  content: "";
  position: absolute;
  inset: -18%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--planet-glow) 0%, transparent 70%);
  filter: blur(12px);
}

.planet {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(
    circle at 32% 28%,
    var(--planet-light) 0%,
    var(--planet-mid) 45%,
    var(--planet-dark) 100%
  );
  box-shadow:
    inset -14px -10px 28px rgba(0, 0, 0, 0.55),
    0 0 30px var(--planet-glow);
}

/* Shooting star */
.shooting-star {
  position: absolute;
  z-index: 8;
  width: 120px;
  height: 1.5px;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.9) 70%,
    #c8dcff
  );
  box-shadow: 0 0 6px rgba(200, 220, 255, 0.7);
  opacity: 0;
  pointer-events: none;
  top: var(--sy);
  left: var(--sx);
  transform: rotate(var(--angle));
  animation: shoot 1.4s ease-out forwards;
}

@keyframes shoot {
  0% {
    opacity: 0;
    transform: rotate(var(--angle)) translateX(0);
  }
  8% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: rotate(var(--angle)) translateX(55vmax);
  }
}

@media (prefers-reduced-motion: reduce) {
  #app {
    animation: fade-in 1s ease-out forwards;
  }

  #app::after,
  .haze,
  .star,
  .title {
    animation: none !important;
  }

  .nebula {
    transition: none !important;
  }

  .shooting-star {
    display: none;
  }
}
