/* The cosmic layer. Background only: it never sits over text and never takes a pointer.
   The clouds and the dust lane are bitmaps baked once by cosmos.js, so nothing here runs an
   SVG filter at paint time. See DESIGN_SYSTEM.md section 2.1. */

.cosmos {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  contain: strict;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 54%, rgba(0, 0, 0, 0.35) 80%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, #000 54%, rgba(0, 0, 0, 0.35) 80%, transparent 100%);
}

.cosmos__layer {
  position: absolute;
  inset: -8% 0;
}
.cosmos__layer--neb,
.cosmos__plate {
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
}
.cosmos__plate {
  position: absolute;
  inset: 0;
}
.cosmos svg { width: 100%; height: 100%; display: block; }

.cosmos--quiet { opacity: 0.72; }
.cosmos--app {
  opacity: 0.62;
  -webkit-mask-image: none;
  mask-image: none;
}

.star { opacity: var(--o); }
.glint { opacity: calc(var(--o) * 0.5); }

.star--tw {
  animation-name: twinkle;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}
@keyframes twinkle {
  0%, 100% { opacity: var(--o); }
  50% { opacity: calc(var(--o) * 0.28); }
}

/* ---------- Shooting stars ---------- */

.cosmos__meteors {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.meteor {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--len);
  height: 1.6px;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, transparent 0%, var(--accent-line) 55%, var(--star) 94%, #fff 100%);
  opacity: 0;
  transform-origin: 0 50%;
  animation: shoot var(--dur) cubic-bezier(0.32, 0, 0.5, 1) forwards;
}
@keyframes shoot {
  0% { opacity: 0; transform: rotate(var(--rot)) translate3d(0, 0, 0) scaleX(0.25); }
  14% { opacity: 1; }
  72% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--rot)) translate3d(var(--travel), 0, 0) scaleX(1); }
}

/* Content rides above the sky. The top bar keeps its own sticky layer. */
.sitebar,
.site__body,
.sitefoot,
.login,
.shell__body,
.main { position: relative; z-index: 1; }

/* ---------- The Event Horizon ---------- */

.eh { width: 100%; }
.eh svg { width: 100%; height: auto; display: block; overflow: visible; }

/* One dash pattern per lap. The pattern divides the ellipse exactly, so the end of the
   animation lands on the start of the next dash and there is no reset to see. */
.eh__ring {
  animation-name: stream;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
@keyframes stream {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: var(--loop); }
}

.eh__aura {
  animation: aura 17s ease-in-out infinite;
  transform-origin: center;
}
@keyframes aura {
  0%, 100% { opacity: 0.88; }
  50% { opacity: 1; }
}

.eh--compact { margin: 0 auto; }

/* ---------- Low effects ----------
   Set by main.js when the machine cannot hold 50fps, or by ?fx=low. The look stays: the
   nebula, the stars, the dust lane and the object are all still there. Only the loops stop. */

:root[data-fx="low"] .star--tw,
:root[data-fx="low"] .eh__ring,
:root[data-fx="low"] .eh__aura { animation: none; }
:root[data-fx="low"] .cosmos__layer { transform: none !important; }

@media (prefers-reduced-motion: reduce) {
  .star--tw, .eh__ring, .eh__aura { animation: none; }
  .cosmos__layer { transform: none !important; }
}
