/* The mask follows the photograph's cover crop and keeps the cat untouched. */
.night-ambient {
  display: none;
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  --ambient-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1536' height='1024' viewBox='0 0 1536 1024'%3E%3Cdefs%3E%3CradialGradient id='space'%3E%3Cstop offset='0' stop-color='white'/%3E%3Cstop offset='.6' stop-color='white'/%3E%3Cstop offset='1' stop-color='white' stop-opacity='0'/%3E%3C/radialGradient%3E%3C/defs%3E%3Cellipse cx='960' cy='430' rx='400' ry='430' fill='url(%23space)'/%3E%3C/svg%3E");
  -webkit-mask-image: var(--ambient-mask);
  mask-image: var(--ambient-mask);
  -webkit-mask-position: var(--scene-position);
  mask-position: var(--scene-position);
  -webkit-mask-size: cover;
  mask-size: cover;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  mask-mode: alpha;
}

@supports ((mask-image: linear-gradient(white, white)) or (-webkit-mask-image: linear-gradient(white, white))) {
  .night-ambient { display: block; }
}

.night-ambient::before,
.night-ambient::after {
  content: '';
  position: absolute;
  pointer-events: none;
}

.night-ambient::before {
  left: 37%;
  top: -7%;
  width: min(62vw, 920px);
  height: min(79vh, 830px);
  background: radial-gradient(ellipse, rgba(72, 132, 238, .17), rgba(27, 88, 173, .065) 42%, transparent 72%);
  opacity: .5;
  animation: ambient-breathe 19s cubic-bezier(.45, 0, .55, 1) -6s infinite alternate;
}

.night-ambient::after {
  left: 51%;
  top: 43%;
  width: min(43vw, 660px);
  height: min(54vh, 560px);
  background: radial-gradient(ellipse, rgba(95, 194, 240, .10), rgba(30, 124, 186, .035) 42%, transparent 72%);
  opacity: .35;
  animation: ambient-breathe 25s cubic-bezier(.45, 0, .55, 1) -15s infinite alternate-reverse;
}

.ambient-point {
  position: absolute;
  left: 56%;
  top: 9%;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #c7eaff;
  box-shadow: 0 0 8px 2px rgba(73, 166, 255, .22);
  opacity: 0;
  --point-drift: 12px;
  animation: ambient-point 17s ease-in-out -4s infinite;
}

.ambient-point:nth-child(2) {
  left: 78%;
  top: 17%;
  --point-drift: -9px;
  animation-duration: 21s;
  animation-delay: -13s;
}

.ambient-point:nth-child(3) {
  left: 84%;
  top: 42%;
  width: 3px;
  height: 3px;
  --point-drift: -14px;
  animation-duration: 24s;
  animation-delay: -7s;
}

.ambient-point:nth-child(4) {
  left: 65%;
  top: 57%;
  animation-duration: 19s;
  animation-delay: -16s;
}

.ambient-point:nth-child(5) {
  left: 76%;
  top: 79%;
  --point-drift: -8px;
  animation-duration: 23s;
  animation-delay: -2s;
}

@keyframes ambient-breathe {
  from { opacity: .4; transform: translate3d(-12px, -9px, 0) scale(.94); }
  to { opacity: .85; transform: translate3d(18px, 14px, 0) scale(1.06); }
}

@keyframes ambient-point {
  0% { opacity: 0; transform: translate3d(0, 12px, 0) scale(.7); }
  18%, 82% { opacity: .12; }
  42%, 58% { opacity: .46; }
  100% { opacity: 0; transform: translate3d(var(--point-drift), -16px, 0) scale(.9); }
}

@media (max-width: 750px) {
  .night-ambient { opacity: .7; }
  .night-ambient::before { left: 19%; width: 92vw; }
  .night-ambient::after { left: 38%; width: 75vw; }
  .ambient-point:nth-child(3),
  .ambient-point:nth-child(5) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .night-ambient { display: none; }
  .night-ambient::before,
  .night-ambient::after,
  .ambient-point { animation: none; }
}
