/**
 * Calder Kamin Shop product gallery
 *
 * Desktop:
 *
 * [ thumbnails ] [ active image ] [ purchase/details ]
 *
 * Mobile:
 *
 * [ active image ]
 * [ horizontal thumbnails ]
 * [ purchase/details ]
 */


/* ---------------------------------------------------------
   Overall product layout
   --------------------------------------------------------- */

.calder-shop article > .layout--twocol-section {
  display: grid;
  grid-template-columns:
    minmax(0, 2fr)
    minmax(280px, 0.8fr);
  gap: clamp(1.5rem, 3vw, 3rem);
  align-items: start;
}


/* ---------------------------------------------------------
   Gallery
   --------------------------------------------------------- */

.calder-shop .product-gallery {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  min-width: 0;
}


/* ---------------------------------------------------------
   Main image
   --------------------------------------------------------- */

.calder-shop .product-gallery__viewer {
  min-width: 0;
}

.calder-shop .product-gallery__main-image {
  display: block;

  width: 100%;
  max-width: 100%;
  height: auto;

  margin: 0;
}


/* ---------------------------------------------------------
   Thumbnail rail
   --------------------------------------------------------- */

.calder-shop .product-gallery__thumbnails {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;

  min-width: 0;
}


/* ---------------------------------------------------------
   Thumbnail buttons
   --------------------------------------------------------- */

.calder-shop .product-gallery__thumbnail {
  appearance: none;

  display: block;

  width: 100%;
  margin: 0;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  opacity: 0.72;
  transition:
    opacity 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.calder-shop .product-gallery__thumbnail:hover,
.calder-shop .product-gallery__thumbnail:focus-visible {
  opacity: 1;
}

.calder-shop .product-gallery__thumbnail:hover {
  transform: scale(1.025);
}

.calder-shop .product-gallery__thumbnail.is-active {
  border-color: currentColor;
  opacity: 1;
}

.calder-shop .product-gallery__thumbnail:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}


/* ---------------------------------------------------------
   Thumbnail images
   --------------------------------------------------------- */

.calder-shop .product-gallery__thumbnail img {
  display: block;

  width: 100%;
  aspect-ratio: 1 / 1;

  object-fit: cover;

  margin: 0;
}


/* ---------------------------------------------------------
   Right-hand purchase/details column
   --------------------------------------------------------- */

.calder-shop article > .layout--twocol-section >
.layout__region--second {
  min-width: 0;
}


/* Keep the purchasing interface comfortably aligned
   with the top of the gallery. */

.calder-shop article > .layout--twocol-section >
.layout__region--second > :first-child {
  margin-top: 0;
}


/* ---------------------------------------------------------
   Mobile
   --------------------------------------------------------- */

@media (max-width: 767px) {

  .calder-shop article > .layout--twocol-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
  }

  /*
   * Gallery becomes:
   *
   * main image
   * thumbnails
   */

  .calder-shop .product-gallery {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;

    width: 100%;
  }

  .calder-shop .product-gallery__viewer {
    order: 1;
    width: 100%;
  }

  .calder-shop .product-gallery__thumbnails {
    order: 2;

    display: flex;
    flex-direction: row;
    gap: 0.625rem;

    width: 100%;

    overflow-x: auto;
    overflow-y: hidden;

    padding: 0.125rem 0 0.5rem;

    -webkit-overflow-scrolling: touch;

    overscroll-behavior-inline: contain;

    scrollbar-width: thin;
  }

  .calder-shop .product-gallery__thumbnail {
    flex: 0 0 72px;
    width: 72px;
  }

  /*
   * Prevent mobile image dimensions from being affected
   * by Drupal's original image attributes.
   */

  .calder-shop .product-gallery__main-image {
    width: 100%;
    height: auto;
  }

}


/* ---------------------------------------------------------
   Very small phones
   --------------------------------------------------------- */

@media (max-width: 420px) {

  .calder-shop .product-gallery__thumbnail {
    flex-basis: 64px;
    width: 64px;
  }

}


/* ---------------------------------------------------------
   Reduced motion
   --------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {

  .calder-shop .product-gallery__thumbnail {
    transition: none;
  }

}