/* Sunlit effect - adapted from jackyzha0/sunlit */

#dappled-light {
  pointer-events: none;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 100vw;
  z-index: 1;
  opacity: 1;
  transition: opacity 0.5s ease;
}

/* Hide in dark mode */
[data-theme="dark"] #dappled-light {
  opacity: 0;
}

#dappled-light #glow {
  position: absolute;
  background: linear-gradient(309deg, #f5d7a6, #f5d7a6 20%, transparent);
  height: 100%;
  width: 100%;
  opacity: 0.35;
}

#dappled-light #glow-bounce {
  position: absolute;
  background: linear-gradient(355deg, #f5d7a6 0%, transparent 30%, transparent 100%);
  opacity: 0.3;
  height: 100%;
  width: 100%;
  bottom: 0;
}

#dappled-light .perspective {
  position: absolute;
  top: -30vh;
  right: 0;
  width: 80vw;
  height: 130vh;
  opacity: 0.06;
  transform-origin: top right;
  transform-style: preserve-3d;
  transform: matrix3d(0.7500, -0.0625, 0.0000, 0.0008,
      0.0000, 1.0000, 0.0000, 0.0000,
      0.0000, 0.0000, 1.0000, 0.0000,
      0.0000, 0.0000, 0.0000, 1.0000);
}

#dappled-light #leaves {
  position: absolute;
  background-size: cover;
  background-repeat: no-repeat;
  bottom: -20px;
  right: -700px;
  width: 1600px;
  height: 1400px;
  background-image: url("../leaves.png");
  filter: url(#wind);
  animation: sunlit-billow 8s ease-in-out infinite;
}

#dappled-light #blinds {
  position: relative;
  width: 100%;
}

#dappled-light #blinds .shutter,
#dappled-light #blinds .bar {
  background-color: #1a1917;
}

#dappled-light #blinds > .shutters {
  display: flex;
  flex-direction: column;
  align-items: end;
  gap: 60px;
}

#dappled-light #blinds > .vertical {
  top: 0;
  position: absolute;
  height: 100%;
  width: 100%;
  display: flex;
  justify-content: space-around;
}

#dappled-light .vertical > .bar {
  width: 5px;
  height: 100%;
}

#dappled-light .shutter {
  width: 100%;
  height: 40px;
}

/* Progressive blur */
#dappled-light #progressive-blur {
  position: absolute;
  height: 100%;
  width: 100%;
}

#dappled-light #progressive-blur > div {
  position: absolute;
  height: 100%;
  width: 100%;
  inset: 0;
  backdrop-filter: blur(var(--blur-amount));
  mask-image: linear-gradient(252deg, transparent, transparent var(--stop1), black var(--stop2), black);
}

#dappled-light #progressive-blur > div:nth-child(1) {
  --blur-amount: 6px;
  --stop1: 0%;
  --stop2: 0%;
}

#dappled-light #progressive-blur > div:nth-child(2) {
  --blur-amount: 12px;
  --stop1: 40%;
  --stop2: 80%;
}

#dappled-light #progressive-blur > div:nth-child(3) {
  --blur-amount: 48px;
  --stop1: 40%;
  --stop2: 70%;
}

#dappled-light #progressive-blur > div:nth-child(4) {
  --blur-amount: 96px;
  --stop1: 70%;
  --stop2: 80%;
}

@keyframes sunlit-billow {
  0% {
    transform: perspective(400px) rotateX(0deg) rotateY(0deg) scale(1);
  }
  25% {
    transform: perspective(400px) rotateX(1deg) rotateY(2deg) scale(1.02);
  }
  50% {
    transform: perspective(400px) rotateX(-4deg) rotateY(-2deg) scale(0.97);
  }
  75% {
    transform: perspective(400px) rotateX(1deg) rotateY(-1deg) scale(1.04);
  }
  100% {
    transform: perspective(400px) rotateX(0deg) rotateY(0deg) scale(1);
  }
}

/* Mobile: simplify effect to avoid performance issues */
@media (max-width: 768px) {
  #dappled-light .perspective {
    width: 120vw;
    opacity: 0.04;
  }
  #dappled-light #leaves {
    filter: none;
    animation: none;
  }
  #dappled-light #progressive-blur {
    display: none;
  }
}
