/* Carousel gallery: big picture with slide animation, arrows, caption bar
   and a clickable thumbnail strip. Built on the Bootstrap 5 carousel.
   See galeria.html for the markup. */
.gallery-carousel {
  --gc-accent: var(--main-red, #d62f32);
  --gc-band: var(--main-red, #d62f32);
  --gc-ratio: 16 / 9;
  --gc-thumb: 130px;
  --gc-thumb-gap: 14px;
  --gc-pad: 1.5rem;      /* space around the big picture */
  --gc-cap-h: 3.2rem;    /* height of the caption row */
  --gc-band-h: .7;       /* colour band height, as a share of the big picture's height */
  position: relative;
  margin: 2em 0;
}

.gallery-carousel .carousel {
  --gc-below: var(--gc-cap-h);   /* space under the big picture inside .carousel */
  position: relative;
  padding: var(--gc-pad) var(--gc-pad) 0;
}

/* Colour band behind the big picture, vertically centred on it; only the
   stripes at its sides show. The picture's height is the .carousel box minus
   the top padding and the caption row (as for the arrows below). */
.gallery-carousel .carousel::before {
  --gc-pic-h: calc(100% - var(--gc-pad) - var(--gc-below));
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--gc-pad) + var(--gc-pic-h) * (1 - var(--gc-band-h)) / 2);
  height: calc(var(--gc-pic-h) * var(--gc-band-h));
  background: var(--gc-band);
  z-index: -1;
}

/* Picture frame (the caption row sits below it) */
.gallery-carousel .carousel-item a {
  position: relative;
  display: block;
  aspect-ratio: var(--gc-ratio);
  max-height: 80vh;
  overflow: hidden;
  padding: 0;
  background-color: var(--gray-dark, #252525);
}

/* Portrait photos: shown whole, over a blurred copy of themselves.
   The thumbnail is set inline on .carousel-item; only the frame shows it. */
.gallery-carousel .carousel-item.gc-fit {
  background-size: 0 0;
  background-repeat: no-repeat;
}

.gallery-carousel .carousel-item.gc-fit a {
  background-image: inherit;
}

.gallery-carousel .carousel-item.gc-fit a::before {
  content: "";
  position: absolute;
  inset: -30px;
  background-image: inherit;
  background-size: cover;
  background-position: center;
  filter: blur(13px) brightness(1.25);
}

.gallery-carousel .carousel-item.gc-fit img {
  position: relative;
  object-fit: contain;
}

/* A single picture keeps its own proportions */
.gallery-carousel--single .carousel-item a {
  aspect-ratio: auto;
}

.gallery-carousel--single .carousel-item img {
  height: auto;
  max-height: 80vh;
  object-fit: contain;
}

.gallery-carousel .carousel-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Description label under the picture */
.gallery-carousel .gc-caption {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--gc-cap-h);
  margin: 0;
  padding: .5em 4.5em;
  line-height: 1.3;
  background: rgba(255, 255, 255, .7);
  color: #000;
  font-family: Lato, sans-serif;
  font-size: 1.1rem;
  font-weight: 400;
  text-align: center;
}

.gallery-carousel .gc-count {
  position: absolute;
  right: 1.25em;
  top: 50%;
  transform: translateY(-50%);
  font-size: .85em;
  color: rgba(0, 0, 0, .65);
}

/* Only one picture: no arrows or thumbnails, even frame around the picture */
.gallery-carousel--single .carousel {
  --gc-below: calc(var(--gc-cap-h) + var(--gc-pad));
  padding-bottom: var(--gc-pad);
}

/* Arrow buttons: white outlined circles, centred on the picture (not the caption) */
.gallery-carousel .carousel-control-prev,
.gallery-carousel .carousel-control-next {
  top: calc(50% + (var(--gc-pad) - var(--gc-cap-h)) / 2);
  bottom: auto;
  width: 3.2rem;
  height: 3.2rem;
  margin: 0 1.25rem;
  transform: translateY(-50%);
  border: 2px solid #fff;
  border-radius: 50%;
  background: rgba(0, 0, 0, .15);
  color: #fff;
  font-size: 1.4rem;
  opacity: .85;
  transition: opacity .2s ease, background-color .2s ease;
}

.gallery-carousel .carousel-control-prev { left: var(--gc-pad); }
.gallery-carousel .carousel-control-next { right: var(--gc-pad); }

.gallery-carousel .carousel-control-prev:hover,
.gallery-carousel .carousel-control-next:hover,
.gallery-carousel .carousel-control-prev:focus-visible,
.gallery-carousel .carousel-control-next:focus-visible {
  opacity: 1;
  background: var(--gc-accent);
  border-color: var(--gc-accent);
}

/* Thumbnail strip (scrolls horizontally when it doesn't fit) */
.gallery-carousel .gc-thumbs {
  position: relative;
  display: flex;
  gap: var(--gc-thumb-gap);
  overflow-x: auto;
  scroll-behavior: smooth;
  scroll-snap-type: x proximity;
  padding: 1.5rem 1.5rem 1rem;
  margin: 0;
  list-style: none;
}

.gallery-carousel .gc-thumbs li {
  flex: 0 0 var(--gc-thumb);
  scroll-snap-align: center;
}

.gallery-carousel .gc-thumbs button {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: none;
  opacity: .6;
  outline: 3px solid transparent;
  outline-offset: -3px;
  transition: opacity .25s ease, outline-color .25s ease;
  cursor: pointer;
}

.gallery-carousel .gc-thumbs img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-carousel .gc-thumbs button:hover,
.gallery-carousel .gc-thumbs button:focus-visible { opacity: 1; }

.gallery-carousel .gc-thumbs button.active {
  opacity: 1;
  outline-color: var(--gc-accent);
}

@media (max-width: 767.98px) {
  .gallery-carousel {
    --gc-ratio: 4 / 3;
    --gc-thumb: 90px;
    --gc-thumb-gap: 10px;
    --gc-pad: 1rem;
    --gc-cap-h: 2.8rem;
  }
  .gallery-carousel .gc-thumbs { padding: 1rem; }
  .gallery-carousel .carousel-control-prev,
  .gallery-carousel .carousel-control-next {
    width: 2.6rem;
    height: 2.6rem;
    margin: 0 .5rem;
    font-size: 1.1rem;
  }
  .gallery-carousel .gc-caption {
    font-size: .95rem;
    padding: .4em 3.5em .4em 1em;
  }
}

@media (max-width: 575.98px) {
  .gallery-carousel {
    --gc-ratio: 1;
    --gc-thumb: 70px;
    --gc-cap-h: 2.5rem;
  }
  .gallery-carousel .carousel-control-prev,
  .gallery-carousel .carousel-control-next {
    width: 2.2rem;
    height: 2.2rem;
    margin: 0 .25rem;
    font-size: 1rem;
  }
  .gallery-carousel .gc-caption {
    font-size: .85rem;
    padding: .3em 3.5em .3em .75em;
  }
  .gallery-carousel .gc-count { right: .75em; }
}
