/**
 * @file
 * Basic adjustments for Drupal swiper formatter.
 *
 * Theming hooks (set them on `.swiper-container`, or anywhere above it):
 */

/**
 * See the note in swiper_formatter.caption.css — registered so the hook is
 * discoverable and resolvable, with no change in behaviour.
 */
@property --swiper-navigation-scale {
  syntax: "*";
  inherits: true;
}

.swiper-container {
  /* Starting point for the arrow sizing further down; Swiper's own default is 44px. */
  --swiper-navigation-size-base: var(--swiper-navigation-size, 44px);

  /* It seems like Swiper may be quite unstable without this two first rules. */
  position: relative;
  overflow: hidden;
  margin: 1rem auto;

  /* @todo: Check if this is the case/relevant only for CDN Swiper library.
     On the fly width calculation by Swiper might be wrong.
   */
  &:not(.slides-multiple) {
    .swiper-slide {
      width: inherit !important;
    }
  }

  /* Some adjusting on "progressbar" type of pagination. */
  &.swiper-horizontal.progressbar {
    > .swiper-wrapper {
      padding: 1rem 0;
    }
  }
  &.swiper-vertical.progressbar {
    > .swiper-wrapper {
      padding: 0 1rem;
    }
  }

  /* An effort to try having slide image feels the whole swiper area. */
  .swiper-slide-image {
    img {
      width: 100%;
    }
  }

  > .swiper-button-prev,
  > .swiper-button-next {
    /* Floor keeps the arrow a usable tap target, and min() keeps that floor. */
    --swiper-navigation-size: max(min(var(--swiper-navigation-size-base), 2rem), calc(var(--swiper-navigation-size-base) * var(--swiper-navigation-scale, 1)));
  }

  /* Compact navigation arrows on small screens. */
  @media (max-width: 47.99rem) {
    --swiper-navigation-scale: 0.6;
  }
}
