/* Adapted from the user-supplied WIKI night theme. */
.night-sky {
  position: fixed;
  z-index: -1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background: var(--paper, #030305);
}
.night-star {
  position: absolute;
  border-radius: 50%;
  background: var(--sky-dot, #eef2ff);
  box-shadow: 0 0 4px rgba(var(--sky-rgb,238,242,255), .45);
  animation: star-twinkle var(--star-duration, 6s) ease-in-out var(--star-delay, 0s) infinite;
}
.night-star-bright { box-shadow: 0 0 7px rgba(var(--sky-rgb,238,242,255), .6); }
@keyframes star-twinkle {
  0%, 100% { opacity: .22; }
  50% { opacity: .78; }
}

/* Two brief white streaks travel in opposite directions every 7.5 seconds. */
.night-meteor {
  position: absolute;
  width: clamp(100px, 15vw, 190px);
  height: 2px;
  border-radius: 50%;
  background: linear-gradient(to right, var(--sky-dot, #fff), rgba(var(--sky-rgb,238,242,255), .65) 12%, transparent);
  opacity: 0;
  transform-origin: left center;
  --meteor-start-x: 100px;
  --meteor-start-y: -60px;
  --meteor-end-x: -420px;
  --meteor-end-y: 300px;
  --meteor-angle: -35deg;
  animation: meteor-pass 7.5s cubic-bezier(.2, .5, .5, 1) 7.5s infinite;
}
.night-meteor::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--sky-dot, #fff);
  box-shadow: 0 0 8px rgba(var(--sky-rgb,238,242,255), .8);
}
.night-meteor-up {
  --meteor-start-x: -100px;
  --meteor-start-y: 60px;
  --meteor-end-x: 420px;
  --meteor-end-y: -300px;
  --meteor-angle: 145deg;
}
@keyframes meteor-pass {
  0% { opacity: 0; transform: translate3d(var(--meteor-start-x), var(--meteor-start-y), 0) rotate(var(--meteor-angle)); }
  3% { opacity: .95; }
  20% { opacity: .75; }
  26%, 100% { opacity: 0; transform: translate3d(var(--meteor-end-x), var(--meteor-end-y), 0) rotate(var(--meteor-angle)); }
}
/* Brief four-point flares brighten 3–4 randomly selected stars, then fade away. */
.night-star.is-flaring {
  background: var(--sky-dot, #fff);
  animation: star-flare-core 2.4s cubic-bezier(.22, .61, .36, 1) both;
}
.night-star::before, .night-star::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  pointer-events: none;
  opacity: 0;
}
.night-star::before {
  width: 34px;
  height: 34px;
  background: radial-gradient(circle, rgba(var(--sky-rgb,238,242,255), .95), rgba(var(--sky-rgb,238,242,255), .3) 20%, transparent 65%);
}
.night-star::after {
  width: 22px;
  height: 22px;
  background: var(--sky-dot, #fff);
  clip-path: polygon(50% 0, 57% 42%, 100% 50%, 57% 58%, 50% 100%, 43% 58%, 0 50%, 43% 42%);
}
.night-star.is-flaring::before, .night-star.is-flaring::after {
  animation: star-flare-rays 2.4s cubic-bezier(.22, .61, .36, 1) both;
}
@keyframes star-flare-core {
  0%, 100% { opacity: .25; }
  28%, 40% { opacity: 1; }
}
@keyframes star-flare-rays {
  0%, 100% { opacity: 0; transform: translate(-50%, -50%) scale(.15); }
  28% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  45% { opacity: .75; transform: translate(-50%, -50%) scale(.9); }
}


.night-sky.is-paused * { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) {
 .night-star { animation: none; opacity: .5; }
 .night-meteor { display: none; }
 .night-star::before, .night-star::after { animation: none !important; opacity: 0 !important; }
}

.night-star-still{animation:none;opacity:var(--star-opacity,.6);box-shadow:none}
[data-theme=light] .night-star-still{opacity:.75}

/* Steadier, clearer background stars; existing flares and meteor timings stay intact. */
.night-star-still{opacity:clamp(.7,calc(var(--star-opacity,.6) + .2),1);box-shadow:0 0 3px rgba(var(--sky-rgb,238,242,255),.4)}
[data-theme=light] .night-star-still{opacity:.95;box-shadow:0 0 3px rgba(255,255,255,.6)}
