/* CloudZoom renders in essential_top, then moves into nop's gallery on ready.
   Show the core fallback in its final column until that move; never hide the page. */
.product-details-page .product-essential > .sevenspikes-cloudzoom-gallery {
  display: none;
}

.product-details-page .gallery > .picture-gallery {
  display: block;
}

.product-details-page .gallery > .picture-gallery:not(.sevenspikes-cloudzoom-gallery) > .picture-thumbs {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  margin: 18px auto 0;
  padding: 10px 16px;
}

.product-details-page .gallery > .picture-gallery:not(.sevenspikes-cloudzoom-gallery) > .picture-thumbs > .thumb-item {
  flex: 0 0 100px;
  height: 74px;
  margin: 0;
}

/* The plugin appends the inside zoom and the fading image beside .picture. */
.product-details-page .cloudzoom-zoom-inside,
.product-details-page .sevenspikes-cloudzoom-gallery .picture-wrapper > img,
.product-details-page .sevenspikes-cloudzoom-gallery .cloudzoom-blank {
  border-radius: 14px;
}

/* A failed/delayed Slick load must not stretch each thumbnail across the page. */
.product-details-page .picture-thumbs-list:not(.slick-initialized) {
  display: flex;
  overflow-x: auto;
}

.product-details-page .picture-thumbs-list:not(.slick-initialized) > .picture-thumbs-item {
  flex: 0 0 100px;
}

.product-details-page .sevenspikes-cloudzoom-gallery .picture-thumbs:not(.in-carousel) {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.product-details-page .sevenspikes-cloudzoom-gallery .picture-thumbs:not(.in-carousel) > .cloudzoom-gallery {
  flex: 0 0 100px;
}

/* Tint only the existing padding around the selected photo. */
.product-details-page .sevenspikes-cloudzoom-gallery .picture-thumbs a.cloudzoom-gallery.thumb-item[aria-pressed="true"] {
  background: var(--lea-surface-warm-soft);
  background: color-mix(in srgb, var(--lea-accent-gold-soft) 22%, var(--lea-surface-plain));
}

.product-details-page .cloudzoom-gallery:focus-visible,
.product-details-page .sevenspikes-cloudzoom-gallery .picture-wrapper:focus-visible {
  outline: 2px solid var(--lea-accent-gold-soft);
  outline-offset: 2px;
}

/* Use the rail's outer padding for arrows instead of covering thumbnail edges. */
.product-details-page .sevenspikes-cloudzoom-gallery .slick-arrow {
  background-size: 10px 18px;
  background-position: center;
  background-color: transparent;
}

.product-details-page .sevenspikes-cloudzoom-gallery .slick-prev {
  left: auto;
  right: auto;
  inset-inline-start: -14px;
}

.product-details-page .sevenspikes-cloudzoom-gallery .slick-next {
  left: auto;
  right: auto;
  inset-inline-end: -14px;
}

/* Attribute content belongs to the selected value, even when photos are shared. */
.lea-attribute-gallery-description {
  margin: 8px 0 0;
  padding: 8px 12px;
  border: 1px solid #e9dfd2;
  border-radius: 8px;
  background-color: #fbf8f3;
  color: #584735;
  font-size: 13px;
  line-height: 1.5;
  text-align: left;
  overflow-wrap: anywhere;
}
.lea-attribute-gallery-description-text { white-space: normal; }
.lea-attribute-gallery-description[hidden] { display: none !important; }

@media (max-width: 1000px) {
  .lea-attribute-gallery-description {
    max-width: 100%;
    min-width: 0;
    /* Use 9px of the existing thumbnail gap without moving the rail. */
    padding: 5px 0 14px;
    margin-bottom: -9px;
    border: 0;
    border-radius: 0;
    background-color: transparent;
    color: var(--lea-page-title-ink);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.5;
    overflow-x: auto;
    overflow-y: hidden;
    overflow-wrap: normal;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
  }
  .lea-attribute-gallery-description::-webkit-scrollbar { display: none; }
  .lea-attribute-gallery-description-text {
    display: block;
    width: max-content;
    white-space: nowrap;
  }
}

/* The optional attribute title overlays the photo; its description remains below. */
.lea-attribute-gallery-picture { position: relative; }
.lea-attribute-gallery-title,
.lea-attribute-gallery-name {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  z-index: 10;
  padding: 12px 16px;
  border-radius: 0 0 14px 14px;
  background: rgba(31, 20, 47, .72);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  overflow-wrap: anywhere;
  pointer-events: none;
}
.lea-attribute-gallery-name {
  top: 0;
  bottom: auto;
  border-radius: 14px 14px 0 0;
  background: rgba(255, 255, 255, .55);
  color: var(--lea-page-title-ink, #183b6b);
}
.lea-attribute-gallery-title[hidden],
.lea-attribute-gallery-name[hidden] { display: none !important; }

@media (max-width: 1000px) {
  /* Move the existing gallery and its documents between the intro and selectors. */
  .product-details-page .overview > .gallery {
    float: none;
    clear: both;
    width: 100%;
    max-width: none;
    margin: 16px 0 20px;
    text-align: center;
  }
}
