/* ==========================================================================
   FUNDER — editorial photo fit (pairs with assets/js/fn-img-fit.js)
   --------------------------------------------------------------------------
   Every article photo frame is 3:2. The files are not all 3:2, and one fit
   for all of them left grey bands in the frames whose file was a little off,
   so cards in the same row looked different (Yoav, /searchAll). The script
   measures each picture once it loads and marks its frame:

     data-fn-fit="cover"    within 2% of 3:2 — fill the frame; at most 1%
                            per side (3–4px) is trimmed.
     data-fn-fit="contain"  further off — the whole picture, never cut
                            (infographics run text to the edge), with the
                            bands filled by a blurred copy of the same photo
                            (--fn-img-fill, the URL already downloaded).

   A frame the script has not marked keeps the old default (contain on the
   plate), so a page without the script looks exactly as before.

   The backdrop is a ::before at z-index -1 inside an isolated frame: it
   paints over the frame's plate and under the photo without giving the img
   a position, which the real-estate lead (position: absolute) depends on.
   ========================================================================== */

.fn-ui .fn-feed__media[data-fn-fit] > img:not(.fn-feed__wm),
.fn-ui .fn-hero__media[data-fn-fit] > img:not(.fn-hero__wm),
.fn-ui .fn-chrono__media[data-fn-fit] > img {
  object-position: center;
}

.fn-ui .fn-feed__media[data-fn-fit="cover"] > img:not(.fn-feed__wm),
.fn-ui .fn-hero__media[data-fn-fit="cover"] > img:not(.fn-hero__wm),
.fn-ui .fn-chrono__media[data-fn-fit="cover"] > img {
  object-fit: cover;
}

.fn-ui .fn-feed__media[data-fn-fit="contain"] > img:not(.fn-feed__wm),
.fn-ui .fn-hero__media[data-fn-fit="contain"] > img:not(.fn-hero__wm),
.fn-ui .fn-chrono__media[data-fn-fit="contain"] > img {
  object-fit: contain;
}

.fn-ui .fn-feed__media[data-fn-fit="contain"],
.fn-ui .fn-hero__media[data-fn-fit="contain"],
.fn-ui .fn-chrono__media[data-fn-fit="contain"] {
  position: relative;
  isolation: isolate;
}

.fn-ui .fn-feed__media[data-fn-fit="contain"]::before,
.fn-ui .fn-hero__media[data-fn-fit="contain"]::before,
.fn-ui .fn-chrono__media[data-fn-fit="contain"]::before {
  content: "";
  position: absolute;
  /* Overscan: a blur fades to transparent at its own edge, so the layer
     starts outside the frame and the frame's overflow clips it. */
  inset: -16px;
  z-index: -1;
  background: var(--fn-img-fill, none) center / cover no-repeat;
  filter: blur(14px);
  opacity: 0.9;
  pointer-events: none;
}

/* The feed watermark has no z-index of its own; keep it over the photo. */
.fn-ui .fn-feed__media[data-fn-fit] .fn-feed__wm {
  z-index: 2;
}
