/* Spazio Casa product gallery viewer v1
 * Mobile: crop the responsive image to its frame and open a stable fullscreen gallery.
 * Desktop: keep the main arrows visible and the thumbnail rail fixed.
 */

@media (max-width: 767px) {
  /*
   * Owl used the intrinsic height of each image, so the product card jumped
   * when a landscape/detail image followed the square cover.  Give the media
   * viewport one stable mobile height and make every Owl layer inherit it.
   */
  /*
   * The legacy theme forces every image block to 250px below 480px.  Reserve
   * the final mobile width before Owl and the thumbnail rail initialise.  This
   * removes the visible expand/shrink jump and lets one-image products use the
   * space that would otherwise be left for thumbnails.
   */
  body#product #image-block {
    box-sizing: border-box !important;
    width: calc(100vw - 16px) !important;
    min-width: calc(100vw - 16px) !important;
    max-width: none !important;
    margin-right: 0 !important;
    margin-left: calc(50% - 50vw + 8px) !important;
  }

  body#product #image-block.sc-single-image-v8 {
    display: block !important;
    overflow: hidden !important;
    border: 1px solid #ededed !important;
    border-radius: 12px !important;
    background: #fff !important;
  }

  body#product #image-block.sc-single-image-v8 #view_full_size,
  body#product #image-block.sc-single-image-v8 #bigpic_list_frame,
  body#product #image-block.sc-single-image-v8 #bigpic_list_frame .owl-wrapper-outer {
    width: 100% !important;
    max-width: 100% !important;
  }

  body#product #view_full_size {
    box-sizing: border-box !important;
    width: 100% !important;
    height: min(calc((100vw - 24px) * 1.12), 560px) !important;
    overflow: hidden !important;
  }

  body#product #image-block,
  body#product #view_full_size,
  body#product #bigpic_list_frame,
  body#product #bigpic_list_frame .owl-wrapper-outer,
  body#product #bigpic_list_frame .owl-wrapper,
  body#product #bigpic_list_frame .owl-item,
  body#product #bigpic_list_frame .item,
  body#product #bigpic_list_frame .bigpic_item,
  body#product #bigpic_list_frame .bigpic_item > a {
    touch-action: pan-y !important;
  }

  body#product #bigpic_list_frame,
  body#product #bigpic_list_frame .owl-wrapper-outer,
  body#product #bigpic_list_frame .owl-wrapper,
  body#product #bigpic_list_frame .owl-item,
  body#product #bigpic_list_frame .item,
  body#product #bigpic_list_frame .bigpic_item {
    height: 100% !important;
    min-height: 100% !important;
    max-height: 100% !important;
  }

  body#product #bigpic_list_frame .bigpic_item > a {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
  }

  body#product #bigpic_list_frame .bigpic_item img {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: cover !important;
    object-position: center !important;
  }

}

/* Keep JivoChat out of product pages so the purchase CTA keeps its full width. */
body#product #jivo-iframe-container,
body#product #jivo_container,
body#product #jcont,
body#product iframe[src*="jivo"],
body#product jdiv.__jivoMobileButton,
body#product jdiv.__jivoDesktopButton,
body#product jdiv[class*="__jivoMobileButton"],
body#product jdiv[class*="__jivoDesktopButton"] {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

@media (min-width: 768px) {
  body#product.sc-desktop-v2-ready #bigpic_list_frame .owl-prev,
  body#product.sc-desktop-v2-ready #bigpic_list_frame .owl-next {
    display: flex !important;
    visibility: visible !important;
    align-items: center;
    justify-content: center;
    opacity: .88 !important;
    pointer-events: auto !important;
  }

  body#product.sc-desktop-v2-ready #bigpic_list_frame .owl-prev:hover,
  body#product.sc-desktop-v2-ready #bigpic_list_frame .owl-next:hover,
  body#product.sc-desktop-v2-ready #bigpic_list_frame .owl-prev:focus,
  body#product.sc-desktop-v2-ready #bigpic_list_frame .owl-next:focus {
    opacity: 1 !important;
  }

  body#product.sc-desktop-v2-ready #bigpic_list_frame .owl-prev.disabled,
  body#product.sc-desktop-v2-ready #bigpic_list_frame .owl-next.disabled {
    display: flex !important;
    visibility: visible !important;
    opacity: .32 !important;
    pointer-events: none !important;
  }

  body#product.sc-desktop-v2-ready #thumbs_list_frame .owl-wrapper {
    left: 0 !important;
    width: 84px !important;
    transform: none !important;
  }

  body#product.sc-desktop-v2-ready #thumbs_list_frame .owl-item {
    width: 84px !important;
    min-width: 84px !important;
    max-width: 84px !important;
  }
}

html.sc-pdp-viewer-open,
html.sc-pdp-viewer-open body {
  overflow: hidden !important;
}

.sc-pdp-viewer-v1 {
  position: fixed;
  inset: 0;
  z-index: 2147483600;
  display: none;
  box-sizing: border-box;
  width: 100vw;
  height: 100dvh;
  min-height: 100%;
  overflow: hidden;
  background: #f7f7f5;
  color: #111;
  opacity: 0;
  transition: opacity 160ms ease;
}

.sc-pdp-viewer-v1.is-open {
  display: flex;
  flex-direction: column;
}

.sc-pdp-viewer-v1.is-visible {
  opacity: 1;
}

.sc-pdp-viewer-v1 *,
.sc-pdp-viewer-v1 *::before,
.sc-pdp-viewer-v1 *::after {
  box-sizing: border-box;
}

.sc-pdp-viewer-v1__header {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  grid-template-rows: 44px auto;
  align-items: center;
  gap: 2px 8px;
  min-height: 92px;
  padding: calc(6px + env(safe-area-inset-top)) 12px 8px;
  border-bottom: 1px solid #d8d8d5;
  background: #f7f7f5;
}

.sc-pdp-viewer-v1__back,
.sc-pdp-viewer-v1__close,
.sc-pdp-viewer-v1__arrow,
.sc-pdp-viewer-v1__rail-arrow,
.sc-pdp-viewer-v1__thumb {
  border: 0;
  -webkit-tap-highlight-color: transparent;
}

.sc-pdp-viewer-v1__back {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  min-height: 44px;
  padding: 0 4px;
  background: transparent;
  color: #111;
  font-size: 17px;
  font-weight: 500;
  white-space: nowrap;
}

.sc-pdp-viewer-v1__heading {
  grid-column: 1 / -1;
  grid-row: 2;
  margin: 0;
  color: #111;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
}

.sc-pdp-viewer-v1__close {
  position: relative;
  justify-self: end;
  grid-column: 2;
  grid-row: 1;
  width: 44px;
  height: 44px;
  border: 1px solid #c9c9c5;
  border-radius: 50%;
  background: #fff;
  color: transparent;
}

.sc-pdp-viewer-v1__close::before,
.sc-pdp-viewer-v1__close::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 19px;
  height: 2px;
  border-radius: 2px;
  content: '';
  background: #222;
}

.sc-pdp-viewer-v1__close::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.sc-pdp-viewer-v1__close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.sc-pdp-viewer-v1__stage {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  background: #fff;
}

.sc-pdp-viewer-v1__viewport {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.sc-pdp-viewer-v1__image {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
  transform-origin: 50% 50%;
  transition: opacity 120ms ease, transform 150ms ease;
  will-change: transform;
  -webkit-user-drag: none;
}

.sc-pdp-viewer-v1.is-loading .sc-pdp-viewer-v1__image {
  opacity: .82;
}

.sc-pdp-viewer-v1.is-gesturing .sc-pdp-viewer-v1__image {
  transition: opacity 120ms ease;
}

.sc-pdp-viewer-v1__loader {
  position: absolute;
  top: 50%;
  left: 50%;
  display: none;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border: 3px solid rgba(0, 0, 0, .16);
  border-top-color: #222;
  border-radius: 50%;
  animation: sc-pdp-viewer-spin 750ms linear infinite;
}

.sc-pdp-viewer-v1.is-loading .sc-pdp-viewer-v1__loader {
  display: block;
}

@keyframes sc-pdp-viewer-spin {
  to { transform: rotate(360deg); }
}

.sc-pdp-viewer-v1__arrow {
  position: absolute;
  top: 50%;
  z-index: 3;
  width: 44px;
  height: 52px;
  margin-top: -26px;
  border: 1px solid rgba(0, 0, 0, .18);
  border-radius: 24px;
  background: rgba(255, 255, 255, .9);
  color: #202020;
  font-size: 34px;
  line-height: 44px;
  text-align: center;
}

.sc-pdp-viewer-v1__arrow--prev { left: 10px; }
.sc-pdp-viewer-v1__arrow--next { right: 10px; }

.sc-pdp-viewer-v1__arrow[disabled],
.sc-pdp-viewer-v1__rail-arrow[disabled] {
  opacity: .28;
}

.sc-pdp-viewer-v1__footer {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 4px;
  min-height: 96px;
  padding: 10px 6px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid #e3e3e0;
  background: #f7f7f5;
}

.sc-pdp-viewer-v1__rail-arrow {
  width: 38px;
  height: 52px;
  border-radius: 19px;
  background: #e7e7e4;
  color: #222;
  font-size: 26px;
}

.sc-pdp-viewer-v1__thumbs {
  display: flex;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-behavior: smooth;
  scrollbar-width: none;
}

.sc-pdp-viewer-v1__thumbs::-webkit-scrollbar {
  display: none;
}

.sc-pdp-viewer-v1__thumb {
  position: relative;
  width: 56px;
  min-width: 56px;
  height: 56px;
  overflow: hidden;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #171717;
  opacity: .62;
}

.sc-pdp-viewer-v1__thumb.is-active {
  border-color: #111;
  opacity: 1;
}

.sc-pdp-viewer-v1__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sc-pdp-viewer-v1 button:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
}

@media (max-width: 374px) {
  .sc-pdp-viewer-v1__heading {
    font-size: 18px;
  }

  .sc-pdp-viewer-v1__back { font-size: 15px; }
}

@media (min-width: 768px) {
  .sc-pdp-viewer-v1 {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sc-pdp-viewer-v1,
  .sc-pdp-viewer-v1__image,
  .sc-pdp-viewer-v1__thumbs {
    scroll-behavior: auto;
    transition: none;
  }
}
