/* ==========================================================================
   Softbnb — "Colour wash" photo loader (owner's pick A, 19 Nov 2026)

   While a listing photo loads, its frame is filled at once with the photo's
   own colours (--sb-wash: four corner colours, blurred together; set on the
   frame by the page from App\Support\PhotoWash::style() or, in JS, from
   sbWashCss()) with a slow soft glow moving over them. A photo with no wash
   yet shows the warm surface instead. When the photo arrives it comes into
   focus (blurred, pale and slightly large → sharp, true and in place, about
   1 s). Reduce Motion: still colours and a 200 ms fade only.

   Two ways in, one look:
     .sb-wash > .sb-wash__img       new frames; js/photo-wash.js adds .is-in
     .sb-lazy > .sb-img[data-src]   the classic lazy frame; the loader in
                                    common/foot.blade.php adds .sb-loaded
   States, on the frame:
     .is-in / .sb-loaded   the photo is here: it develops into focus
     .is-instant           it was already in the browser's cache: shown at
                           once, no motion
     .is-failed            it did not load: the wash stays and whatever
                           fallback the page has is shown as it is
     .is-settled           added by the loaders ~1.2 s after .is-in: the
                           develop timings step aside, so a page's own
                           transitions (a hover zoom) keep their own feel

   The loaded state sets nothing on the photo: it returns to the page's own
   opacity, filter and transform. Only the waiting state is styled here, so a
   page's hover zoom, fallback artwork and crispness transforms keep working.

   Loaded by common/head.blade.php (the main site). The dashboard shell
   (layouts/app) does not load it: its .sb-lazy thumbnails keep their own
   rules in partials/app/legacy-head and the .ap-shell page styles.
   ========================================================================== */

/* ── 1. The frame ──────────────────────────────────────────────────────────
   --sb-surface-3 is scoped to .sb-page (css/softbnb-ds.css), so a frame
   outside it falls back to the same values written out. */
.sb-wash,
.sb-lazy {
  --sb-wash-ground: var(--sb-surface-3, #EFE8E0);
  --sb-wash-glow:   rgba(255, 255, 255, 0.55);
  overflow: hidden;
  isolation: isolate;
  background: var(--sb-wash, var(--sb-wash-ground));
}
body.dark-mode .sb-wash,
body.dark-mode .sb-lazy {
  --sb-wash-ground: var(--sb-surface-3, #2C2521);
  --sb-wash-glow:   rgba(255, 236, 214, 0.10);
}
/* A frame the page already positions (absolute, fixed) keeps that. */
:where(.sb-wash) { position: relative; }
.sb-lazy { position: relative; display: block; }

/* The old logo-and-ripples loader: anything of it left in a page shows nothing. */
.sb-lazy-loader { display: none; }

/* ── 2. The glow: a soft highlight drifting slowly over the colours ──────── */
.sb-wash::before,
.sb-lazy::before {
  content: "";
  position: absolute; inset: -20%; z-index: 0;
  pointer-events: none;
  background: radial-gradient(60% 50% at 30% 30%, var(--sb-wash-glow), transparent 70%);
  opacity: 0.6;   /* under the animation; the fade-out below starts from here, never from a full-strength flash */
  animation: sb-wash-breathe 2.6s ease-in-out infinite alternate;
}
@keyframes sb-wash-breathe {
  from { opacity: 0.25; transform: translate(-4%, -3%); }
  to   { opacity: 0.9;  transform: translate(6%, 5%); }
}
.sb-wash.is-in::before,
.sb-lazy.sb-loaded::before {
  opacity: 0;
  animation: none;
  transition: opacity 400ms ease;
}
.sb-wash.is-settled::before,
.sb-lazy.is-settled::before,
.sb-wash.is-instant::before,
.sb-lazy.is-instant::before { content: none; }

/* ── 3. The photo ───────────────────────────────────────────────────────────
   Sizing for the classic frame, as before; zero-specificity defaults for the
   new one, so any page rule wins. Both sit above the glow. */
.sb-img {
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
  position: relative; z-index: 1;
}
:where(.sb-wash__img) {
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
  position: relative;
}

/* Waiting: soft, pale and slightly large. A .sb-wash photo already has its real src, so it is only hidden while
   html.sbw-on is set (common/head.blade.php sets it, and takes it off again if js/photo-wash.js never arrives):
   a missing script can never leave a photo invisible. The classic .sb-lazy photo needs the loader script anyway. */
html.sbw-on .sb-wash:not(.is-in) .sb-wash__img,
.sb-lazy:not(.sb-loaded) .sb-img {
  opacity: 0;
  filter: blur(14px) saturate(0.55) brightness(1.12);
  transform: scale(1.07);
}

/* Here: into focus and settling into place. */
.sb-wash.is-in:not(.is-settled) .sb-wash__img,
.sb-lazy.sb-loaded:not(.is-settled) .sb-img {
  transition: opacity 320ms ease,
              filter 900ms cubic-bezier(0.2, 0.8, 0.2, 1),
              transform 1100ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Already in the cache, or failed: shown at once, no develop. */
.sb-wash.is-in.is-instant .sb-wash__img,
.sb-lazy.sb-loaded.is-instant .sb-img,
.sb-wash.is-in.is-failed .sb-wash__img,
.sb-lazy.sb-loaded.is-failed .sb-img { transition: none; }

/* ── 4. Reduce Motion: still colours, no blur or scale, a 200 ms fade ───────
   !important because css/softbnb-ds.css zeroes every duration inside
   .sb-page under Reduce Motion; this fade carries no movement. */
@media (prefers-reduced-motion: reduce) {
  .sb-wash::before,
  .sb-lazy::before { animation: none; opacity: 0.6; transform: none; }
  .sb-wash.is-in::before,
  .sb-lazy.sb-loaded::before { opacity: 0; transition: opacity 200ms linear !important; }

  .sb-wash:not(.is-in) .sb-wash__img,
  .sb-lazy:not(.sb-loaded) .sb-img { filter: none; transform: none; }

  .sb-wash.is-in:not(.is-settled) .sb-wash__img,
  .sb-lazy.sb-loaded:not(.is-settled) .sb-img { transition: opacity 200ms linear !important; }

  .sb-wash.is-in.is-instant .sb-wash__img,
  .sb-lazy.sb-loaded.is-instant .sb-img,
  .sb-wash.is-in.is-failed .sb-wash__img,
  .sb-lazy.sb-loaded.is-failed .sb-img { transition: none !important; }
}
