/* ==========================================================================
   hemingweb.com - Background Slideshow & Ken Burns Effect
   ========================================================================== */

#bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none !important;
  overflow: hidden;
  background-color: var(--bg-page);
  transition: background-color var(--transition-slow);
}

#bg div {
  position: absolute;
  top: 0;
  left: 0;
  width: 150%;
  height: 100%;
  background-size: cover;
  background-position: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none !important;
  will-change: transform, opacity;
  transition: opacity 3s ease-in-out, visibility 3s ease-in-out;
}

/* Pan Animation */
@keyframes bgPan {
  0% {
    transform: translate3d(0, 0, 0);
  }
  100% {
    transform: translate3d(-25%, 0, 0);
  }
}

/* --------------------------------------------------------------------------
   Default / Dark Mode: Deep Black Background + Subtle Moody Photography
   -------------------------------------------------------------------------- */
#bg div,
html[data-theme="dark"] #bg div {
  filter: brightness(0.9) contrast(1.1);
  mix-blend-mode: normal;
}

#bg div.visible,
html[data-theme="dark"] #bg div.visible {
  opacity: 0.25;
  visibility: visible;
  animation: bgPan 45s linear infinite;
}

/* --------------------------------------------------------------------------
   Light Mode: Radiograph / X-Ray Negative Effect
   Inverted tone mapping + high bone-contrast contouring + negative film density
   -------------------------------------------------------------------------- */
:root:has(> head > meta[name="color-scheme"][content="light"]) #bg div,
html[data-theme="light"] #bg div {
  filter: invert(1) grayscale(1) contrast(1.75) brightness(0.92);
  mix-blend-mode: multiply;
}

:root:has(> head > meta[name="color-scheme"][content="light"]) #bg div.visible,
html[data-theme="light"] #bg div.visible {
  opacity: 0.20;
  visibility: visible;
  animation: bgPan 45s linear infinite;
}

/* Stacking Order for smooth cross-fades */
#bg div.top {
  z-index: 1;
}

/* Responsive speed adjust */
@media screen and (max-width: 1024px) {
  #bg div.visible {
    animation-duration: 35s;
  }
}

@media screen and (max-width: 640px) {
  #bg div.visible {
    animation-duration: 25s;
  }
}

/* Accessibility: Turn off heavy panning if user requests reduced motion */
@media (prefers-reduced-motion: reduce) {
  #bg div.visible {
    animation: none !important;
    transform: translate3d(0, 0, 0) !important;
  }
}
