/*
 * Lazy-load reveal (Medium / Tanay Kedia pattern):
 * tiny image as scaled-up background, full <img> fades in on load.
 * https://medium.com/@tanay7/lazy-loading-images-basics-to-advanced-b69fa5568053
 */

.withok-blurred-img {
  position: relative;
  display: block;
  width: 100%;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  overflow: hidden;
}

.withok-blurred-img::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  animation: withok-img-pulse 2.5s infinite;
  background-color: var(--sub-color);
}

@keyframes withok-img-pulse {
  0%,
  100% {
    opacity: 0;
  }

  50% {
    opacity: 0.1;
  }
}

.withok-blurred-img.loaded::before {
  animation: none;
  opacity: 0;
}

.withok-blurred-img--empty {
  background-color: var(--background-color);
}

.withok-blurred-img img {
  display: block;
  width: 100%;
  height: auto;
  position: relative;
  z-index: 1;
  opacity: 0;
  transition: opacity 250ms ease-in-out;
}

.withok-blurred-img.loaded img {
  opacity: 1;
}

/* Parent must set height; image covers the box */
.withok-blurred-img--fill {
  width: 100%;
  min-height: 0;
}

.withok-blurred-img--fill img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Graphic detail: contain + intrinsic sizing */
.withok-blurred-img--natural {
  width: auto;
  height: 100%;
  max-height: 100%;
}

.withok-blurred-img--natural img {
  width: auto;
  height: 100%;
  max-height: 100%;
  max-width: none;
  object-fit: contain;
}

@media (prefers-reduced-motion: reduce) {
  .withok-blurred-img::before {
    animation: none;
    opacity: 0;
  }

  .withok-blurred-img img {
    transition: none;
    opacity: 1;
  }
}
