/* V4: real factory photographs fill their existing media slots.
   Load after all V1/V2/V3 styles. Product, logo and document images are not targeted. */
body[data-page-key] main .v4-photo-frame {
  --v4-photo-scale:1;
  --v4-photo-shift-x:0%;
  --v4-photo-shift-y:0%;
  position:relative;
  display:block;
  width:100%;
  min-width:0;
  min-height:0;
  aspect-ratio:4/3;
  overflow:hidden;
  background:var(--tint,#F1E8D7);
  isolation:isolate;
}

/* Source PNGs contain transparent margins, rounded corners and an offset shadow.
   Clip those original canvas edges inside the slot; never alter the source bitmap.
   The small optical translation centers the actual photograph rather than its shadow. */
body[data-page-key] main .v4-photo-frame:has(>img[src$="workshop-1.png"]),
body[data-page-key] main .v4-photo-frame:has(>img[src$="workshop-2.png"]),
body[data-page-key] main .v4-photo-frame:has(>img[src$="workshop-3.png"]) {
  --v4-photo-scale:1.14;
  --v4-photo-shift-x:1.4%;
  --v4-photo-shift-y:1.4%;
}
body[data-page-key] main .v4-photo-frame > img[src] {
  position:absolute;
  inset:0;
  display:block;
  width:100%;
  height:100%;
  min-width:0;
  min-height:0;
  max-width:none;
  max-height:none;
  aspect-ratio:auto;
  margin:0;
  padding:0;
  border:0;
  border-radius:0;
  background:transparent;
  box-shadow:none;
  object-fit:cover;
  object-position:center;
  transform:translate(var(--v4-photo-shift-x),var(--v4-photo-shift-y)) scale(var(--v4-photo-scale));
  transform-origin:center;
  transition:none;
}

/* Manufacturing and quality header: preserve one tall left cell and two right cells.
   Remove intrinsic min-content sizing/max-height clamps and all inner white borders. */
body[data-page-key] main .factory-collage {
  grid-template-columns:minmax(0,1.25fr) minmax(0,1fr);
  grid-template-rows:repeat(2,minmax(0,1fr));
  align-items:stretch;
}
body[data-page-key] main .factory-collage > .v4-photo-frame {
  width:100%;
  height:100%;
  aspect-ratio:auto;
  align-self:stretch;
}
body[data-page-key] main .factory-collage > .v4-photo-frame:first-child {
  grid-column:1;
  grid-row:1 / 3;
}
body[data-page-key] main .factory-collage > .v4-photo-frame:nth-child(2) {
  grid-column:2;
  grid-row:1;
}
body[data-page-key] main .factory-collage > .v4-photo-frame:nth-child(3) {
  grid-column:2;
  grid-row:2;
}

/* Homepage production section: the caption stays a separate flex item. */
body[data-page-key="home"] main .section-figure.production-photo > .v4-photo-frame {
  flex:1 1 0;
  aspect-ratio:auto;
  width:100%;
}
/* Homepage production proof card: retain its 500:370 media area and text below. */
body[data-page-key="home"] main .about-media > figure > .v4-photo-frame {
  aspect-ratio:500/370;
}
/* The V3 short entry already has an independent media and caption row. */
body[data-page-key="home"] main .entry-grid .entry-tile.short > .v4-photo-frame {
  grid-column:1;
  grid-row:1;
  width:100%;
  height:100%;
  aspect-ratio:auto;
}

/* Manufacturing photo panels: retain panel padding and captions outside the clipping frame. */
body[data-page-key="manufacturing"] main figure.panel > .v4-photo-frame {
  aspect-ratio:4/3;
}

/* R01 and R02 fixed photo figures already establish their intended geometry. */
body[data-page-key="oem-odm"] main .oem-capability-grid figure > .v4-photo-frame,
body[data-page-key="about"] main .about-catalog-workshop > .v4-photo-frame {
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  aspect-ratio:auto;
}
/* Preserve the original overlay captions above the dedicated photo clipping area. */
body[data-page-key="oem-odm"] main .oem-capability-grid figure > figcaption,
body[data-page-key="about"] main .about-catalog-workshop > figcaption {
  z-index:1;
}

/* R05 carousel: only the photo is clipped; its label remains below the frame. */
body[data-page-key="cooperation-process"] main .r05-carousel-track figure > .v4-photo-frame {
  aspect-ratio:4/3;
  border-radius:5px;
}
/* R07: do not clip the heading, body copy or follow-up link within the same figure. */
body[data-page-key="contact"] main .r07-factory > .v4-photo-frame {
  aspect-ratio:495/357;
  border-radius:8px;
}

@media(max-width:768px) {
  body[data-page-key] main .factory-collage {
    grid-template-columns:minmax(0,1.2fr) minmax(0,1fr);
  }
}
/* The transform is a static crop, not an animation: retain it for reduced motion. */
@media(prefers-reduced-motion:reduce) {
  body[data-page-key] main .v4-photo-frame > img[src] {
    transition:none;
    animation:none;
  }
}
