/*
 * MEV2 — R2-PAT-020 industrial family gallery slots.
 * Draft-only until Eric validates the LUX witness.
 * Slot geometry governs; source files remain untouched.
 */
body.mev-cs-galleries :is(
  .mev2a-wave-series--slots.mev-cs-family-gallery,
  .mev-cs-gallery--slots .mev-cs-gallery__grid
){
  display:grid!important;
  grid-template-rows:minmax(0,1fr)!important;
  grid-auto-rows:minmax(0,1fr)!important;
  gap:1px!important;
  width:100%!important;
  height:auto!important;
  min-height:0!important;
  max-height:none!important;
  align-items:stretch!important;
  align-content:stretch!important;
  overflow:hidden!important;
  background:transparent!important;
  box-sizing:border-box!important;
}
body.mev-cs-galleries :is(
  .mev2a-wave-series--slots.mev-cs-family-gallery,
  .mev-cs-gallery--slots[data-mev-gallery-count]
)[data-mev-gallery-count="1"],
body.mev-cs-galleries .mev-cs-gallery--slots[data-mev-gallery-count="1"] .mev-cs-gallery__grid{
  grid-template-columns:1fr!important;
}
body.mev-cs-galleries :is(
  .mev2a-wave-series--slots.mev-cs-family-gallery,
  .mev-cs-gallery--slots[data-mev-gallery-count]
)[data-mev-gallery-count="2"],
body.mev-cs-galleries .mev-cs-gallery--slots[data-mev-gallery-count="2"] .mev-cs-gallery__grid{
  grid-template-columns:repeat(2,minmax(0,1fr))!important;
}
body.mev-cs-galleries :is(
  .mev2a-wave-series--slots.mev-cs-family-gallery,
  .mev-cs-gallery--slots[data-mev-gallery-count]
)[data-mev-gallery-count="3"],
body.mev-cs-galleries .mev-cs-gallery--slots[data-mev-gallery-count="3"] .mev-cs-gallery__grid{
  grid-template-columns:repeat(3,minmax(0,1fr))!important;
}
body.mev-cs-galleries :is(
  .mev2a-wave-series--slots.mev-cs-family-gallery,
  .mev-cs-gallery--slots[data-mev-gallery-count]
)[data-mev-gallery-count="4"],
body.mev-cs-galleries .mev-cs-gallery--slots[data-mev-gallery-count="4"] .mev-cs-gallery__grid{
  grid-template-columns:repeat(4,minmax(0,1fr))!important;
}
body.mev-cs-galleries :is(
  .mev2a-wave-series--slots .mev2a-wave-series__item,
  .mev2a-wave-series--slots .mev-cs-gallery__open,
  .mev-cs-gallery--slots .mev-cs-gallery__cell,
  .mev-cs-gallery--slots .mev-cs-gallery__open
){
  display:block!important;
  position:relative!important;
  grid-column:auto!important;
  grid-row:auto!important;
  width:100%!important;
  height:auto!important;
  min-width:0!important;
  min-height:0!important;
  max-height:none!important;
  margin:0!important;
  padding:0!important;
  overflow:hidden!important;
  background:transparent!important;
  box-sizing:border-box!important;
}
body.mev-cs-galleries #post-330 .mev-cs-gallery--slots .mev-cs-gallery__grid{
  grid-template-rows:minmax(0,1fr)!important;
  grid-auto-rows:minmax(0,1fr)!important;
  height:auto!important;
  min-height:0!important;
  max-height:none!important;
}
body.mev-cs-galleries #post-330 .mev-cs-gallery--slots[data-mev-gallery-count="1"] .mev-cs-gallery__grid{grid-template-columns:1fr!important}
body.mev-cs-galleries #post-330 .mev-cs-gallery--slots[data-mev-gallery-count="2"] .mev-cs-gallery__grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}
body.mev-cs-galleries #post-330 .mev-cs-gallery--slots[data-mev-gallery-count="3"] .mev-cs-gallery__grid{grid-template-columns:repeat(3,minmax(0,1fr))!important}
body.mev-cs-galleries #post-330 .mev-cs-gallery--slots[data-mev-gallery-count="4"] .mev-cs-gallery__grid{grid-template-columns:repeat(4,minmax(0,1fr))!important}
body.mev-cs-galleries #post-330 .mev-cs-gallery--slots .mev-cs-gallery__cell{
  height:auto!important;
  min-height:0!important;
  max-height:none!important;
}
body.mev-cs-galleries :is(.mev2a-wave-series--slots,.mev-cs-gallery--slots) .mev-cs-gallery__open{
  height:100%!important;
}

body.mev-cs-galleries :is(
  .mev2a-wave-series--slots.mev-cs-series--landscape .mev2a-wave-series__item,
  .mev-cs-gallery--slots.mev-cs-gallery--landscape .mev-cs-gallery__cell
){
  aspect-ratio:3 / 2!important;
}
body.mev-cs-galleries :is(
  .mev2a-wave-series--slots.mev-cs-series--portrait .mev2a-wave-series__item,
  .mev-cs-gallery--slots.mev-cs-gallery--portrait .mev-cs-gallery__cell
){
  aspect-ratio:4 / 5!important;
  max-height:78vh!important;
}
body.mev-cs-galleries :is(
  .mev2a-wave-series--slots[data-mev-gallery-count="1"] .mev2a-wave-series__item,
  .mev-cs-gallery--slots[data-mev-gallery-count="1"] .mev-cs-gallery__cell
){
  aspect-ratio:2 / 1!important;
  max-height:none!important;
}
body.mev-cs-galleries :is(
  .mev2a-wave-series--slots .mev2a-wave-series__item img,
  .mev-cs-gallery--slots .mev-cs-gallery__img
){
  display:block!important;
  position:absolute!important;
  inset:0!important;
  width:100%!important;
  height:100%!important;
  min-width:0!important;
  min-height:0!important;
  max-width:none!important;
  max-height:100%!important;
  margin:0!important;
  object-fit:cover!important;
  object-position:var(--mev-gallery-focal,50% 50%)!important;
  transform:none!important;
  transition:none!important;
}

/* Mobile parity: same order, one defined slot per row, top to bottom. */
/* Desktop row height is owned by the gallery frame, never by intrinsic image ratios. */
@media(min-width:901px){
  body.mev-cs-galleries .mev2a-wave-series--slots.mev-cs-series--landscape[data-mev-gallery-count="1"],
  body.mev-cs-galleries #post-330 .mev-cs-gallery--slots.mev-cs-gallery--landscape[data-mev-gallery-count="1"] .mev-cs-gallery__grid{aspect-ratio:2 / 1!important}
  body.mev-cs-galleries .mev2a-wave-series--slots.mev-cs-series--landscape[data-mev-gallery-count="2"],
  body.mev-cs-galleries #post-330 .mev-cs-gallery--slots.mev-cs-gallery--landscape[data-mev-gallery-count="2"] .mev-cs-gallery__grid{aspect-ratio:3 / 1!important}
  body.mev-cs-galleries .mev2a-wave-series--slots.mev-cs-series--landscape[data-mev-gallery-count="3"],
  body.mev-cs-galleries #post-330 .mev-cs-gallery--slots.mev-cs-gallery--landscape[data-mev-gallery-count="3"] .mev-cs-gallery__grid{aspect-ratio:9 / 2!important}
  body.mev-cs-galleries .mev2a-wave-series--slots.mev-cs-series--landscape[data-mev-gallery-count="4"],
  body.mev-cs-galleries #post-330 .mev-cs-gallery--slots.mev-cs-gallery--landscape[data-mev-gallery-count="4"] .mev-cs-gallery__grid{aspect-ratio:6 / 1!important}

  body.mev-cs-galleries .mev2a-wave-series--slots.mev-cs-series--portrait[data-mev-gallery-count="2"],
  body.mev-cs-galleries #post-330 .mev-cs-gallery--slots.mev-cs-gallery--portrait[data-mev-gallery-count="2"] .mev-cs-gallery__grid{aspect-ratio:8 / 5!important;max-height:78vh!important}
  body.mev-cs-galleries .mev2a-wave-series--slots.mev-cs-series--portrait[data-mev-gallery-count="3"],
  body.mev-cs-galleries #post-330 .mev-cs-gallery--slots.mev-cs-gallery--portrait[data-mev-gallery-count="3"] .mev-cs-gallery__grid{aspect-ratio:12 / 5!important;max-height:78vh!important}
  body.mev-cs-galleries .mev2a-wave-series--slots.mev-cs-series--portrait[data-mev-gallery-count="4"],
  body.mev-cs-galleries #post-330 .mev-cs-gallery--slots.mev-cs-gallery--portrait[data-mev-gallery-count="4"] .mev-cs-gallery__grid{aspect-ratio:16 / 5!important;max-height:78vh!important}

  /* Valid viewport units make the row height definite before legacy content participates in grid sizing. */
  body.mev-cs-galleries .mev2a-wave-series--slots.mev-cs-series--landscape[data-mev-gallery-count="1"],
  body.mev-cs-galleries #post-330 .mev-cs-gallery--slots.mev-cs-gallery--landscape[data-mev-gallery-count="1"] .mev-cs-gallery__grid{height:auto!important;max-height:none!important}
  body.mev-cs-galleries .mev2a-wave-series--slots.mev-cs-series--landscape[data-mev-gallery-count="2"],
  body.mev-cs-galleries #post-330 .mev-cs-gallery--slots.mev-cs-gallery--landscape[data-mev-gallery-count="2"] .mev-cs-gallery__grid{height:33.333333vw!important}
  body.mev-cs-galleries .mev2a-wave-series--slots.mev-cs-series--landscape[data-mev-gallery-count="3"],
  body.mev-cs-galleries #post-330 .mev-cs-gallery--slots.mev-cs-gallery--landscape[data-mev-gallery-count="3"] .mev-cs-gallery__grid{height:22.222222vw!important}
  body.mev-cs-galleries .mev2a-wave-series--slots.mev-cs-series--landscape[data-mev-gallery-count="4"],
  body.mev-cs-galleries #post-330 .mev-cs-gallery--slots.mev-cs-gallery--landscape[data-mev-gallery-count="4"] .mev-cs-gallery__grid{height:16.666667vw!important}

  body.mev-cs-galleries .mev2a-wave-series--slots.mev-cs-series--portrait[data-mev-gallery-count="2"],
  body.mev-cs-galleries #post-330 .mev-cs-gallery--slots.mev-cs-gallery--portrait[data-mev-gallery-count="2"] .mev-cs-gallery__grid{height:min(78vh,62.5vw)!important}
  body.mev-cs-galleries .mev2a-wave-series--slots.mev-cs-series--portrait[data-mev-gallery-count="3"],
  body.mev-cs-galleries #post-330 .mev-cs-gallery--slots.mev-cs-gallery--portrait[data-mev-gallery-count="3"] .mev-cs-gallery__grid{height:min(78vh,41.666667vw)!important}
  body.mev-cs-galleries .mev2a-wave-series--slots.mev-cs-series--portrait[data-mev-gallery-count="4"],
  body.mev-cs-galleries #post-330 .mev-cs-gallery--slots.mev-cs-gallery--portrait[data-mev-gallery-count="4"] .mev-cs-gallery__grid{height:min(78vh,31.25vw)!important}

  body.mev-cs-galleries :is(
    .mev2a-wave-series--slots .mev2a-wave-series__item,
    #post-330 .mev-cs-gallery--slots .mev-cs-gallery__cell
  ){
    height:100%!important;
    aspect-ratio:auto!important;
  }
}

/* LUX witness adapter: outrank historical per-role gallery heights without altering legacy galleries. */
@media(min-width:901px){
  body.mev2a-wave.mev2a-wave-r1.mev-p25-h0.mev-p25-master.mev-cs-galleries #post-330 .mev-cs-gallery.mev-cs-gallery--slots.mev-cs-gallery--landscape[data-mev-gallery-count="4"] .mev-cs-gallery__grid{
    height:16.666667vw!important;
  }
  body.mev2a-wave.mev2a-wave-r1.mev-p25-h0.mev-p25-master.mev-cs-galleries #post-330 .mev-cs-gallery.mev-cs-gallery--slots.mev-cs-gallery--portrait[data-mev-gallery-count="4"] .mev-cs-gallery__grid{
    height:min(78vh,31.25vw)!important;
  }
}

@media(max-width:900px){
  /* One full-width image per row, in source order, for every family gallery. */
  body.mev-cs-galleries .mev2a-wave-series--slots.mev-cs-family-gallery[data-mev-gallery-count],
  body.mev-cs-galleries .mev-cs-gallery--slots[data-mev-gallery-count] .mev-cs-gallery__grid,
  body.mev-cs-galleries #post-330 .mev-cs-gallery--slots[data-mev-gallery-count] .mev-cs-gallery__grid{
    aspect-ratio:auto!important;
    grid-template-columns:minmax(0,1fr)!important;
    grid-template-rows:none!important;
    grid-auto-flow:row!important;
    grid-auto-rows:auto!important;
    height:auto!important;
    max-height:none!important;
  }

  /* Mobile contract: all multi-image family galleries are landscape 3:2,
     one asset per row, while the desktop geometry remains untouched. */
  body.mev-cs-galleries [data-mev-gallery-key="LUX-G01"].mev2a-wave-series--slots.mev-cs-family-gallery[data-mev-gallery-count="4"]{
    grid-template-columns:minmax(0,1fr)!important;
    grid-template-rows:none!important;
    grid-auto-flow:row!important;
    grid-auto-rows:auto!important;
  }
  body.mev-cs-galleries :is(
    .mev2a-wave-series--slots.mev-cs-family-gallery:not([data-mev-gallery-count="1"]) .mev2a-wave-series__item,
    .mev-cs-gallery--slots:not([data-mev-gallery-count="1"]) .mev-cs-gallery__cell
  ){
    width:100%!important;
    height:auto!important;
    aspect-ratio:3 / 2!important;
    max-height:none!important;
  }

  /* LUX adapter: neutralize historical mobile cell heights so 3:2 wins. */
  body.mev2a-wave.mev2a-wave-r1.mev-p25-h0.mev-p25-master.mev-cs-galleries #post-330 .mev-cs-gallery.mev-cs-gallery--slots:not([data-mev-gallery-count="1"]) .mev-cs-gallery__cell{
    height:auto!important;
    aspect-ratio:3 / 2!important;
    max-height:none!important;
  }

  body.mev-cs-galleries :is(
    .mev2a-wave-series--slots[data-mev-gallery-count="1"] .mev2a-wave-series__item,
    .mev-cs-gallery--slots[data-mev-gallery-count="1"] .mev-cs-gallery__cell
  ){
    height:auto!important;
    aspect-ratio:3 / 2!important;
    max-height:none!important;
  }

  /* Per-image mobile crops. Source order and desktop focal points are preserved. */
  body.mev-cs-galleries [data-mev-gallery-key="LUX-G01"] .mev2a-wave-series__item:nth-child(2) .mev-cs-gallery__img{
    --mev-gallery-focal:50% 42%!important;
  }
  body.mev-cs-galleries [data-mev-gallery-key="LUX-G01"] .mev2a-wave-series__item:nth-child(4) .mev-cs-gallery__img{
    --mev-gallery-focal:50% 60%!important;
  }
  body.mev-cs-galleries [data-mev-gallery-key="LUX-G02"] .mev-cs-gallery__cell:nth-child(1) .mev-cs-gallery__img{
    --mev-gallery-focal:50% 18%!important;
  }
  body.mev-cs-galleries [data-mev-gallery-key="LUX-G02"] .mev-cs-gallery__cell:nth-child(2) .mev-cs-gallery__img{
    --mev-gallery-focal:50% 60%!important;
  }
  body.mev-cs-galleries [data-mev-gallery-key="LUX-G02"] .mev-cs-gallery__cell:nth-child(3) .mev-cs-gallery__img{
    --mev-gallery-focal:50% 50%!important;
  }
  body.mev-cs-galleries [data-mev-gallery-key="LUX-G04"] .mev-cs-gallery__cell:nth-child(1) .mev-cs-gallery__img{
    --mev-gallery-focal:50% 47%!important;
  }
}
