/* Factory gallery. Shared page navigation and background are in responsive.css. */
.factory {
  --factory-pin-top: 236px;
  box-sizing: border-box;
}

/* Keep the factory artwork as a full viewport layer. */
.factory::before {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
background: #f5f7ff url("../img/public/content-back.png") center top / cover no-repeat;
  background-attachment: scroll;
  transform: none;
}

/* Remove the factory-only contact gap so the fixed artwork cannot show through
 * between the contact and footer modules. */
.factory + .contact,
.factory + .site-module-divider + .contact {
  margin-bottom: 0 !important;
}

.factory .section2 {
  position: relative;
  display: flex;
  align-self: flex-start;
  width: 100%;
  min-width: 0;
  height: clamp(420px, 42vw, 640px);
  overflow: hidden;
}

@media only screen and (min-width: 769px) {
  .factory > .section1,
  .factory > .section2 {
    position: sticky;
    top: var(--factory-pin-top);
  }

  .factory > .section1 {
    z-index: 2;
    align-self: flex-start;
  }

  .factory > .section2 {
    z-index: 1;
  }
}

.factory .section2 > .factory-track {
  display: flex;
  align-items: flex-start;
  gap: clamp(26px, 3vw, 58px);
  width: max-content;
  min-height: 100%;
  will-change: transform;
}

.factory .section2 > .item,
.factory .section2 > .factory-track > .item {
  position: relative;
  flex: 0 0 clamp(210px, 18vw, 294px);
  width: clamp(210px, 18vw, 294px);
  overflow: hidden;
  border-radius: 10px;
  background: #e5e9f3;
  font-size: 0;
  line-height: 0;
}

.factory .section2 > .item:nth-child(odd),
.factory .section2 > .factory-track > .item:nth-child(odd) {
  margin-top: clamp(180px, 16vw, 320px);
}

/* The image is the only element that animates on hover. */
.factory .section2 > .item > img,
.factory .section2 > .factory-track > .item > img,
.factory .factory-gallery-image,
.factory .factory-image-element,
.factory .factory-image-element .el-image,
.factory .factory-image-element .el-image__inner,
.factory .factory-el-image,
.factory .factory-el-image .el-image__inner {
  display: block;
  width: 100%;
  height: auto;
  line-height: 0;
  vertical-align: top;
  transition: transform 0.5s ease;
}

.factory .factory-image-element,
.factory .factory-image-element .el-image,
.factory .factory-el-image,
.factory .factory-el-image .el-image__placeholder,
.factory .factory-el-image .el-image__error {
  position: relative;
  overflow: hidden;
  font-size: 0;
}

.factory .factory-image-element .el-image__inner,
.factory .factory-el-image .el-image__inner {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
}

.factory .factory-el-image .el-image__placeholder,
.factory .factory-el-image .el-image__error {
  width: 100%;
  height: 100%;
}

/* Keep the gallery image proportions in the requested two-by-two sequence. */
.factory .section2 > .item:nth-child(4n + 1) .factory-el-image,
.factory .section2 > .item:nth-child(4n + 2) .factory-el-image,
.factory .section2 > .factory-track > .item:nth-child(4n + 1) .factory-el-image,
.factory .section2 > .factory-track > .item:nth-child(4n + 2) .factory-el-image {
  --factory-image-width: 227px;
  --factory-image-height: 227px;
  width: var(--factory-image-width) !important;
  height: var(--factory-image-height) !important;
}

.factory .section2 > .item:nth-child(4n + 3) .factory-el-image,
.factory .section2 > .item:nth-child(4n + 4) .factory-el-image,
.factory .section2 > .factory-track > .item:nth-child(4n + 3) .factory-el-image,
.factory .section2 > .factory-track > .item:nth-child(4n + 4) .factory-el-image {
  --factory-image-width: 227px;
  --factory-image-height: 272px;
  width: var(--factory-image-width) !important;
  height: var(--factory-image-height) !important;
}

.factory .section2 > .item:nth-child(4n + 1) .factory-el-image .el-image__inner,
.factory .section2 > .item:nth-child(4n + 2) .factory-el-image .el-image__inner,
.factory .section2 > .factory-track > .item:nth-child(4n + 1) .factory-el-image .el-image__inner,
.factory .section2 > .factory-track > .item:nth-child(4n + 2) .factory-el-image .el-image__inner,
.factory .section2 > .item:nth-child(4n + 3) .factory-el-image .el-image__inner,
.factory .section2 > .item:nth-child(4n + 4) .factory-el-image .el-image__inner,
.factory .section2 > .factory-track > .item:nth-child(4n + 3) .factory-el-image .el-image__inner,
.factory .section2 > .factory-track > .item:nth-child(4n + 4) .factory-el-image .el-image__inner {
  display: block;
  object-fit: cover;
}

.factory .section2 > .item:hover > img,
.factory .section2 > .factory-track > .item:hover > img,
.factory .section2 > .item:hover .factory-gallery-image,
.factory .section2 > .item:hover .factory-image-element .el-image__inner,
.factory .section2 > .item:hover .factory-el-image .el-image__inner {
  transform: scale(1.05);
}

@media only screen and (max-width: 1280px) {
  .factory {
    --factory-pin-top: 210px;
  }
}

@media only screen and (max-width: 1024px) {
  .factory {
    --factory-pin-top: 180px;
  }

  .factory .section2 {
    height: 390px;
  }

  .factory .section2 > .factory-track > .item {
    flex-basis: clamp(180px, 22vw, 260px);
    width: clamp(180px, 22vw, 260px);
  }
}

@media only screen and (max-width: 768px) {
  .factory {
    --factory-pin-top: 150px;
  }

  .factory .section2 {
    height: auto;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 12px;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
  }

  .factory .section2::-webkit-scrollbar {
    display: none;
  }

  .factory .section2 > .factory-track {
    gap: 14px;
    min-height: 0;
  }

  .factory .section2 > .factory-track > .item,
  .factory .section2 > .factory-track > .item:nth-child(odd) {
    flex-basis: min(72vw, 280px);
    width: min(72vw, 280px);
    margin-top: 0;
  }
}

@media only screen and (max-width: 480px) {
  .factory {
    --factory-pin-top: 128px;
  }

  .factory .section2 > .factory-track > .item,
  .factory .section2 > .factory-track > .item:nth-child(odd) {
    flex-basis: 78vw;
    width: 78vw;
  }
}

/* Every card uses the same width as the requested image frame so the card
 * background cannot remain visible beside the image at any breakpoint. */
.factory .section2 > .item,
.factory .section2 > .factory-track > .item {
  flex-basis: 227px !important;
  width: 227px !important;
}
