.media-modal {
  cursor: zoom-out;
}

.product-media-modal {
  background-color: rgb(var(--color-page-background));
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  visibility: hidden;
  opacity: 0;
  z-index: -1;
}

.product-media-modal[open] {
  visibility: visible;
  opacity: 1;
  z-index: 101;
}

.product-media-modal__dialog {
  --modal-toggle-width: 58px;
  --modal-toggle-offset-x: 150px;
  --modal-toggle-offset-y: 40px;
  display: flex;
  align-items: center;
  height: 100vh;
}

.product-media-modal__toggle {
  background-color: rgb(var(--color-page-background));
  border: 1px solid rgba(var(--color-text), 0.05);
  border-radius: 50%;
  color: rgb(var(--color-text));
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  right: var(--modal-toggle-offset-x);
  top: var(--modal-toggle-offset-y);
  padding: 20px;
  position: fixed;
  z-index: 2;
  width: var(--modal-toggle-width);
}

.product-media-modal__toggle .icon {
  height: auto;
  margin: 0;
  width: 1em;
}

.product-media-modal__content {
  max-height: 100vh;
  width: 100%;
  overflow: auto;
}

.product-media-modal__content > * {
  display: block;
  height: auto;
  margin: auto;
}

.product-media-modal__content > *:not(.active) {
  display: none;
}

.product-media-modal__content .media {
  background: none;
}

.product-media-modal__content .deferred-media {
  width: 100%;
}

@media screen and (min-width: 960px) {
  .product-media-modal__content {
    padding: 40px 250px;
  }

  .product-media-modal__content > * {
    width: 100%;
    overflow: visible;
  }

  .product-media-modal__content > * + * {
    margin-top: 20px;
  }

  .product-media-modal__content > *:not(.active) {
    display: block;
  }

  .product-media-modal__dialog .slider-buttons {
    display: none;
  }
}

@media screen and (max-width: 959px) {
  .product-media-modal__dialog {
    --modal-toggle-width: 38px;
    --modal-toggle-offset-x: 20px;
    --modal-toggle-offset-y: 20px;
    --modal-slider-height: 60px;
    position: relative;
  }

  .product-media-modal__toggle {
    padding: 10px;
  }
}

/* The ipad end responds to the mobile end in vertical screen */

/* @custom-media --tablet (max-width: 959px); */

/* @custom-media --gt-mobile (min-width: 751px); */

/* detectingScreen need to consider the configuration of the tablet */

/* === LCY FIX 2026-05-21: Mobile product image preview size ===
   Keeps the tapped product image inside the phone viewport instead of
   rendering at its original 1100px+ width. */
@media screen and (max-width: 959px) {
  .product-media-modal {
    width: 100vw !important;
    height: 100vh !important;
    height: 100svh !important;
    overflow: hidden !important;
    background: rgb(var(--color-page-background)) !important;
  }

  .product-media-modal[open] {
    display: block !important;
  }

  .product-media-modal__dialog {
    width: 100vw !important;
    height: 100vh !important;
    height: 100svh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    max-height: 100svh !important;
    padding: 56px 10px 18px !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
  }

  .product-media-modal__toggle {
    top: 12px !important;
    right: 12px !important;
    z-index: 5 !important;
  }

  .product-media-modal__content {
    width: 100% !important;
    height: calc(100vh - 74px) !important;
    height: calc(100svh - 74px) !important;
    max-width: 100% !important;
    max-height: calc(100vh - 74px) !important;
    max-height: calc(100svh - 74px) !important;
    overflow: hidden !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    touch-action: pan-y pinch-zoom;
  }

  .product-media-modal__content > * {
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
    margin: auto !important;
    object-fit: contain !important;
  }

  .product-media-modal__content > img,
  .product-media-modal__content img,
  .product-media-modal__content .global-media-settings {
    max-width: 100% !important;
    max-height: calc(100vh - 90px) !important;
    max-height: calc(100svh - 90px) !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
  }

  .product-media-modal__content .media,
  .product-media-modal__content .deferred-media {
    max-width: 100% !important;
    max-height: calc(100vh - 90px) !important;
    max-height: calc(100svh - 90px) !important;
  }
}
