/* loaded by index.html itself, so the tube is up on the first paint, before the bundle arrives */
html, body { margin: 0; height: 100%; background: #031008; overflow: hidden; }
/* the loading page: the tube before the lab exists */
.loader {
  font-family: VT323, monospace;
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: #031008;
  transform-origin: 50% 50%;
}

.loader-tube {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px;
  background: radial-gradient(ellipse at 50% 45%, #0f4a1f 0%, #082a12 55%, #031008 100%);
}

/* scanlines and a slow roll bar over the whole tube */
.loader-tube::before,
.loader-tube::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.loader-tube::before {
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.32) 0 2px, transparent 2px 4px);
}

.loader-tube::after {
  background: linear-gradient(to bottom, transparent 0%, rgba(140, 255, 170, 0.06) 48%, transparent 56%);
  background-size: 100% 300%;
  animation: loader-roll 4s linear infinite;
}

@keyframes loader-roll {
  from {
    background-position: 0 100%;
  }
  to {
    background-position: 0 -200%;
  }
}

.loader-disk {
  width: min(62vh, 78vw);
  height: auto;
  image-rendering: pixelated;
  -webkit-mask-image: radial-gradient(closest-side, #000 72%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 72%, transparent 100%);
  animation: loader-bob 2.4s steps(6) infinite alternate;
}

@keyframes loader-bob {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-8px);
  }
}

.loader-bar,
.loader-file {
  position: relative;
  margin: 0;
  color: #78ff96;
  text-shadow: 0 0 8px rgba(120, 255, 150, 0.7);
  white-space: pre;
  text-align: center;
}

.loader-bar {
  font-size: clamp(20px, 3.4vh, 30px);
  margin-top: -2vh;
}

.loader-file {
  font-size: clamp(16px, 2.4vh, 22px);
  opacity: 0.7;
  min-height: 1.3em;
}

/* the tube switching off: a flash, the picture folds into a line, the line into a dot */
.loader-off {
  animation: loader-off 0.9s cubic-bezier(0.6, 0, 0.9, 0.4) forwards;
}

.loader-off .loader-tube {
  animation: loader-flash 0.9s linear forwards;
}

@keyframes loader-off {
  0% {
    transform: scale(1, 1);
    opacity: 1;
  }
  45% {
    transform: scale(1, 0.004);
    opacity: 1;
  }
  80% {
    transform: scale(0.002, 0.004);
    opacity: 1;
  }
  100% {
    transform: scale(0, 0);
    opacity: 0;
  }
}

@keyframes loader-flash {
  0% {
    filter: brightness(1);
  }
  35% {
    filter: brightness(3.5) saturate(0.4);
  }
  100% {
    filter: brightness(4) saturate(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .loader-disk,
  .loader-tube::after {
    animation: none;
  }
}
