#background {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
}

#bg-stage {
  position: absolute;
  inset: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  transform-origin: center;
}

#bg-rotator {
    display: flex;
    align-items: center;
    justify-content: center;
}

#bg-frame {
  width: 100vw;
  height: 100vh;

  overflow: hidden;
  display: flex;
}

/* background image layer */
#bg-image {
  width: 100%;
  height: 100%;

  background-image: url("../assets/background.webp");
  background-repeat: no-repeat;
  background-size: 100% 100%;
  overflow: hidden;
  
  -webkit-mask-image:
    linear-gradient(to bottom, transparent 0%, black 18%, black 82%, transparent 100%),
    linear-gradient(to right,  transparent 0%, black 12%, black 88%, transparent 100%);
  -webkit-mask-composite: intersect;

  mask-image:
    linear-gradient(to bottom, transparent 0%, black 18%, black 82%, transparent 100%),
    linear-gradient(to right,  transparent 0%, black 12%, black 88%, transparent 100%);
  mask-composite: intersect;

  /* filter: blur(3px) brightness(0.9) contrast(1.1);
  transform: scale(1.05); */

  /* will-change: transform; */
  
}

@media (orientation: portrait) {
  /* #bg-stage {
    width: 100vh;
    height: 100vw;
  } */
  #bg-rotator {
    transform: rotate(-90deg);
  }
  #bg-frame {
    width: 100vh;
    height: 130vw;
  }
}

#bg-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;

  background-image:
    repeating-linear-gradient(
      0deg,
      rgba(255,255,255,0.1) 0px,
      rgba(255,255,255,0.1) 1px,
      transparent 1px,
      transparent 3px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(255,255,255,0.1) 0px,
      rgba(255,255,255,0.1) 1px,
      transparent 1px,
      transparent 3px
    );

  opacity: 0.15;
  mix-blend-mode: soft-light;

  animation: interferenceFlicker 6s steps(8) infinite;
}

#bg-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;

  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.25), transparent 40%),
    radial-gradient(circle at 70% 60%, rgba(255,255,255,0.18), transparent 45%),
    radial-gradient(circle at 40% 80%, rgba(255,255,255,0.22), transparent 35%);

  mix-blend-mode: screen;
  filter: blur(2px);

  animation: radiationBloom 14s infinite;

  opacity: var(--burst-opacity, 0);
}

@keyframes interferenceFlicker {
  0%   { opacity: 0.12; }
  10%  { opacity: 0.16; }
  20%  { opacity: 0.13; }
  35%  { opacity: 0.18; }
  50%  { opacity: 0.14; }
  65%  { opacity: 0.27; }
  80%  { opacity: 0.13; }
  100% { opacity: 0.15; }
}

@keyframes radiationBloom {
  0%, 85% {
    opacity: 0;
    filter: blur(4px);
  }

  88% {
    opacity: 0.32;
    filter: blur(2px);
  }

  92% {
    opacity: 0.28;
    filter: blur(1px);
  }

  100% {
    opacity: 0;
    filter: blur(6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  #bg-frame::after,
  #bg-frame::before {
    animation: none;
  }
}