*,
::before,
::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
img {
  max-width: 100%;
  display: block;
}

.gallerySection {
   min-height: 100svh; 
  padding: 2rem;
  background-color: #071f2f;
  color: white;
  display: grid;
  place-content: center;
}
.gallery button {
  -webkit-appearance: none;
  border-radius: 0;
  text-align: inherit;
  background: none;
  box-shadow: none;
  padding: 0;
  cursor: pointer;
  color: inherit;
  font: inherit;
  outline: none;
  border: none;
}

.gallery {
  --_size: 120px; /* width and heigh of iamges */
  --_grid-cols: repeat(2, 1fr);

  --_gap: 5px;
  --_translate-img: 0 calc(var(--_size) * 3 * -1); /* define where we want to translate the image from*/
  --_translate-bio: 0 calc(var(--_size) * 3); /* define where we want to translate the text from */
  --_hover-opacity: 0.2; /* opacity of images when one of them is "active"*/
  --_img-offset: calc(var(--_size) / 4);
  --_bio-top: 50%; /* positioning of the bio when active */

  width: 100%;
  max-width: fit-content;
  display: grid;
  grid-template-columns: var(--_grid-cols);

  gap: var(--_gap);
  position: relative;
  overflow: hidden;
}
@media (min-width: 600px) {
  .gallery {
    --_size: 200px;
    --_grid-cols: repeat(4, 1fr);
    --_translate-bio: calc(var(--_size) * 3) 0;
    --_bio-top: 0;
  }
}

.gallery > article {
  height: var(--_size);
  aspect-ratio: 1;
  background-image: var(--bg-img);
  background-position: center;
  background-size: 0%;
  background-repeat: no-repeat;
}
.gallery > article > button {
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 500ms ease-in-out;
}

.gallery > article > div {
  position: absolute;
  top: var(--_bio-top);
  right: 0;
  width: calc((var(--_size) + var(--_gap)) * 2);
  height: calc((var(--_size) + var(--_gap)) * 3);
  background-color: white;
  color: #555;
  padding: 2rem;
  transition: 500ms ease-in-out;
  opacity: 0;
  translate: var(--_translate-bio);
  z-index: 1;
}

.gallery > article > div > h2 {
  font-size: 1.2rem;
}
.gallery > article > div > p {
  margin-top: 1rem;
  font-size: 0.9rem;
  opacity: 0.8;
  
    max-height: 50%; /* this could be better */
    overflow-y: auto;
}
.gallery > article > div > button {
  border: none;
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2;
  cursor: pointer;
  transition: rotate 300ms;
}

.gallery > article > div > button:focus-visible,
.gallery > article > div > button:hover {
  rotate: 90deg;
}

.gallery > article::before {
  content: "";
  position: absolute;
  inset: var(--_img-offset);
  width: calc((var(--_size) + var(--_gap)) * 1.5);
  height: calc((var(--_size) + var(--_gap)) * 1.5);
  aspect-ratio: 1;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  z-index: 1;
  opacity: 0;
  translate: var(--_translate-img);
  transition: 500ms ease-in-out;
  background-image: inherit;
  transform: translate(0%, 30%);

}

/* set opacity on images */
.gallery:has(article > button:focus-within) > article img {
  opacity: var(--_hover-opacity); 
}

/* slide in photo */
/*.gallery > article:has(>button:focus-within)::before {*/
.gallery > article:focus-within::before {
  translate: 0;
  opacity: 1;
}
/* slide in bio */
/*.gallery article:has(>button:focus-within) > div {*/
.gallery article:focus-within > div {
  opacity: 1;
  translate: 0;
}

/* close buttons */
/* 
these are not really needed, the important thing is taking the focus aways from the "open" button 
I have given them tabindex -1 so that they don't get keyboard focus which means that tabbing on the keyboard will automatically open the next image and bio. 
Removing the tabindex -1 will give a pause (and extra keyboard action) between each iamge opening, it depends on how you want this to work.
*/

.gallery:has(button[data-close]:focus-within) > article::before {
    translate: var(--_translate-img);
}
.gallery:has(button[data-close]:focus-within) > article > div {
  translate: var(--_translate-bio);
}


/* ...................................................................................................... */
.imgMove{
  opacity: 1 !important;background-size: contain !important;object-fit: contain !important;margin-top: -100px !important;
}