/* ==========================================================
   Estate Web — shared lazy image loader   (prefix: lz-)
   Usage:
     <div class="lz-wrap">
       <img class="lz-img" src="..." alt="..." loading="lazy" width="640" height="400">
     </div>
   The wrapper must have a fixed shape (aspect-ratio or height).

   Loading look:  soft grey box + faint house icon + slow light sweep
   Reveal look:   image fades in while settling from 106% to 100% size
   Only `opacity` and `transform` are animated: both are handled by the
   phone's graphics chip, so they stay smooth on weak processors.
   ========================================================== */

.lz-wrap {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, #e9eef1, #dde5e9);
}

/* Faint house icon in the middle of the empty box */
.lz-wrap::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  content: "";
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23aebcc4' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 10.5 12 3l9 7.5V20a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

/* Slow light sweep across the box */
.lz-wrap::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(
    100deg,
    transparent 20%,
    rgba(255, 255, 255, 0.6) 50%,
    transparent 80%
  );
  transform: translateX(-100%);
  animation: lz-sweep 1.7s ease-in-out infinite;
  pointer-events: none;
}

@keyframes lz-sweep {
  to {
    transform: translateX(100%);
  }
}

/* The image sits above the placeholder, so once it is visible it covers it */
.lz-img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Hide images only while JS is running (JS adds .lz-ready to <html>).
   If JS ever fails, images simply show normally. */
.lz-ready .lz-img {
  opacity: 0;
  transform: scale(1.06);
  transition:
    opacity 0.6s ease-out,
    transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.lz-ready .lz-wrap.is-loaded .lz-img {
  opacity: 1;
  transform: scale(1);
}

/* Stop the sweep once the image is ready, so it stops using power */
.lz-wrap.is-loaded::after,
.lz-wrap.is-error::after {
  animation: none;
  visibility: hidden;
}

/* Broken image: keep the calm box with the icon, hide the broken picture */
.lz-ready .lz-wrap.is-error .lz-img {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .lz-wrap::after {
    animation: none;
  }

  .lz-ready .lz-img {
    transform: none;
    transition: opacity 0.2s ease;
  }
}
