/**
 * FLAMINGO — Global Image Frame Engine (CSS)
 *
 * Slot = reserved layout box (never collapses when image changes).
 * Viewport = visible crop frame (width/height/aspect from CMS).
 * Media = image/video inside viewport (zoom + focus only).
 *
 * @package Flamingo_Liqueur
 */

.fl-image-frame {
  --fl-img-zoom: 1;
  --fl-img-x: 50%;
  --fl-img-y: 50%;
  --fl-frame-w: 100%;
  --fl-frame-h: 100%;
  --fl-frame-ar: 4 / 5;

  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 0;
  /* Slot reserves space from aspect — layout stays stable */
  aspect-ratio: var(--fl-frame-ar);
  min-width: 0;
  background: transparent;
}

.fl-image-frame__viewport {
  position: relative;
  overflow: hidden;
  /* Shrink crop window inside the reserved slot — slot size stays fixed */
  width: var(--fl-frame-w);
  height: var(--fl-frame-h);
  max-width: 100%;
  max-height: 100%;
  margin: 0;
}

.fl-image-frame__viewport > img,
.fl-image-frame__viewport > video,
.fl-image-frame__viewport > a,
.fl-image-frame .fl-image-frame__media,
.fl-image-frame .fl-story__img,
.fl-image-frame .fl-product__img,
.fl-image-frame .fl-hero__image,
.fl-image-frame .fl-hero__video,
.fl-image-frame .fl-how-to-enjoy__img,
.fl-image-frame .fl-gallery__img,
.fl-image-frame .fl-shop__logo,
.fl-image-frame .fl-news__img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  border-radius: 0;
  aspect-ratio: auto;
  object-fit: cover;
  object-position: var(--fl-img-x) var(--fl-img-y);
  transform: scale(var(--fl-img-zoom));
  /* Origin is centre, NOT the focus point. object-position already decides
     which part of the photo is shown; anchoring the scale to the same point
     as well makes every zoom grow AWAY from that anchor. With a focus at
     x:100% the hover zoom pinned the right edge and shoved the picture left
     and down — it read as the image sliding diagonally rather than zooming.
     Scale from the centre and the motion is symmetric. See FIX-14. */
  transform-origin: center;
}

.fl-image-frame__viewport > a {
  overflow: hidden;
  transform: none;
}

.fl-image-frame__viewport > a > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--fl-img-x) var(--fl-img-y);
  transform: scale(var(--fl-img-zoom));
  /* Origin is centre, NOT the focus point. object-position already decides
     which part of the photo is shown; anchoring the scale to the same point
     as well makes every zoom grow AWAY from that anchor. With a focus at
     x:100% the hover zoom pinned the right edge and shoved the picture left
     and down — it read as the image sliding diagonally rather than zooming.
     Scale from the centre and the motion is symmetric. See FIX-14. */
  transform-origin: center;
}

/* Host CSS owns aspect (gallery editorial cells, etc.) */
.fl-image-frame--slot-auto {
  aspect-ratio: auto;
  display: block;
}

.fl-image-frame--slot-auto .fl-image-frame__viewport {
  position: absolute;
  inset: 0;
  width: var(--fl-frame-w);
  height: var(--fl-frame-h);
  max-width: 100%;
  max-height: 100%;
  margin: auto;
}

.fl-image-frame--contain .fl-image-frame__viewport > img,
.fl-image-frame--contain .fl-product__img,
.fl-image-frame--contain .fl-shop__logo {
  object-fit: contain;
  background: transparent;
}

/* Preserve zoom on section hover polish */
.fl-story__media.fl-image-frame:hover .fl-story__img {
  transform: scale(calc(var(--fl-img-zoom, 1) * 1.03));
}

.fl-product__media.fl-image-frame:hover .fl-product__img {
  transform: translateY(-0.35rem) scale(var(--fl-img-zoom, 1));
}

/* Story / Product: CMS aspect drives the reserved slot */
.fl-story__media.fl-image-frame,
.fl-product__media.fl-image-frame {
  aspect-ratio: var(--fl-frame-ar);
}

/* Hero: full-bleed slot; viewport may letterbox via width/height/aspect */
.fl-hero__media.fl-image-frame {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  aspect-ratio: auto;
  display: block;
  z-index: 0;
}

.fl-hero__media.fl-image-frame .fl-image-frame__viewport {
  position: absolute;
  inset: 0;
  width: var(--fl-frame-w);
  height: var(--fl-frame-h);
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  aspect-ratio: var(--fl-frame-ar);
}

.fl-hero__media.fl-image-frame .fl-hero__overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .fl-image-frame__viewport > img,
  .fl-image-frame__viewport > video,
  .fl-image-frame .fl-story__img,
  .fl-image-frame .fl-product__img,
  .fl-image-frame .fl-hero__image,
  .fl-image-frame .fl-hero__video {
    transition: none;
  }
}
