/**
 * @file
 * Interior-page element_gallery: section title and constrained media.
 *
 * Slideshow uses a flex track translated by gallery.js. Drupal field
 * wrappers are flattened with display: contents so each .field__item is
 * one slide.
 */

.sml-gallery {
  margin-block: 1.5rem;
}

.sml-col > .sml-gallery {
  margin-block: 0;
}

.sml-gallery img,
.sml-gallery video {
  max-width: 100%;
  height: auto;
}

.sml-gallery .video-embed-field-responsive-video {
  max-width: 50rem;
  margin-inline: auto;
}

.sml-gallery .video-embed-field-responsive-video iframe,
.sml-gallery iframe {
  display: block;
  width: 100%;
  max-width: 100%;
  border: 0;
}

/* ---------------------------------------------------------------------------
 * Slideshow.
 * ------------------------------------------------------------------------- */
.sml-gallery__viewport {
  position: relative;
  overflow: hidden;
  transition: height 0.3s ease;
}

.sml-gallery__track {
  display: flex;
  transition: transform 0.4s ease;
  align-items: flex-start;
}

.sml-gallery__track .field--name-field-media,
.sml-gallery__track .field--name-field-media > .field__items {
  display: contents;
}

.sml-gallery__track .field__items > .field__item {
  box-sizing: border-box;
  flex: 0 0 100%;
  min-width: 0;
}

/* Without JS, only the first slide is visible so videos do not stack. */
.sml-gallery--slideshow:not(.is-initialized)
  .sml-gallery__track
  .field__items
  > .field__item:not(:first-child) {
  display: none;
}

.sml-gallery--slideshow.is-initialized
  .sml-gallery__track
  .field__items
  > .field__item:not(:first-child) {
  display: block;
}

.sml-gallery--slideshow .sml-gallery__track .field--name-field-media-image > a,
.sml-gallery--slideshow .sml-gallery__track .field--name-field-media-image a {
  display: block;
}

.sml-gallery--slideshow .sml-gallery__track img {
  display: block;
  width: 100%;
  height: auto;
}

.sml-gallery__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.75rem;
}

.sml-gallery__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  width: 100%;
}

.sml-gallery--slideshow .sml-gallery__controls {
  position: absolute;
  inset: 0;
  margin-top: 0;
  pointer-events: none;
}

.sml-gallery--slideshow .sml-gallery__nav {
  position: static;
  width: 100%;
  height: 100%;
}

.sml-gallery__arrow {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  cursor: pointer;
  transition: color 0.2s;
  color: var(--sml-black);
  border: 0;
  background: transparent;
}

.sml-gallery--slideshow .sml-gallery__arrow {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  width: 1.875rem;
  height: 100%;
  margin: 0;
  color: var(--sml-white);
  opacity: 0.4;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.75);
  transition: opacity 0.25s ease;
}

.sml-gallery--slideshow .sml-gallery__prev {
  left: 0;
}

.sml-gallery--slideshow .sml-gallery__next {
  right: 0;
}

.sml-gallery__arrow svg {
  width: 2.5rem;
  height: 2.5rem;
}

.sml-gallery--slideshow .sml-gallery__arrow svg {
  width: 1.5rem;
  height: 1.5rem;
}

.sml-gallery__arrow:hover,
.sml-gallery__arrow:focus-visible {
  color: var(--sml-purple);
  outline: none;
}

.sml-gallery--slideshow .sml-gallery__arrow:hover,
.sml-gallery--slideshow .sml-gallery__arrow:focus-visible {
  color: var(--sml-white);
  opacity: 1;
}

.sml-gallery__arrow:focus-visible {
  outline: 2px solid var(--sml-purple);
  outline-offset: 2px;
}

.sml-gallery__dots {
  display: none;
}

.sml-gallery__dot {
  width: 0.75rem;
  height: 0.75rem;
  padding: 0;
  cursor: pointer;
  border: 1px solid var(--sml-black);
  border-radius: 50%;
  background: transparent;
}

.sml-gallery__dot.is-active {
  background: var(--sml-black);
}

.sml-gallery__dot:focus-visible {
  outline: 2px solid var(--sml-orange);
  outline-offset: 2px;
}

.sml-gallery--slideshow .media-caption {
  padding-inline: 40px;
}

/* ---------------------------------------------------------------------------
 * Grid / single.
 * ------------------------------------------------------------------------- */
.sml-gallery--grid .sml-gallery__items .field__items {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

@media (min-width: 768px) {
  .sml-gallery--grid .sml-gallery__items .field__items {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 992px) {
  .sml-gallery--grid .sml-gallery__items .field__items {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.sml-gallery--single .sml-gallery__items {
  width: 100%;
  max-width: 50rem;
  margin-inline: auto;
}
