.kotynek-portfolio-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1rem;
  margin-block: 0 2.5rem;
  padding: 0;
  list-style: none;
  color: #5c5c5c;
  font-size: 0.875rem;
}

.kotynek-portfolio-nav li {
  margin: 0;
  padding: 0;
}

.kotynek-portfolio-nav a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

.kotynek-portfolio-nav a:hover,
.kotynek-portfolio-nav a:focus-visible {
  color: #1f1f1f;
  text-decoration-color: currentColor;
}

/*
 * A real grid prevents Core Gallery's incomplete final flex row from
 * stretching one image across the full gallery width.
 */
.wp-block-gallery.kotynek-portfolio-gallery {
  display: grid !important;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: start;
  gap: clamp(1rem, 2vw, 1.75rem);
}

.wp-block-gallery.kotynek-portfolio-gallery > figure.wp-block-image {
  position: static !important;
  display: flex !important;
  flex-direction: column;
  grid-column: auto / span 2;
  align-self: start;
  width: 100% !important;
  min-width: 0;
  margin: 0 !important;
}

/* Center incomplete desktop rows on the gallery's vertical axis. */
@media (min-width: 782px) {
  .wp-block-gallery.kotynek-portfolio-gallery > figure.wp-block-image:nth-last-child(1):nth-child(3n + 1) {
    grid-column: 3 / span 2;
  }

  .wp-block-gallery.kotynek-portfolio-gallery > figure.wp-block-image:nth-last-child(2):nth-child(3n + 1) {
    grid-column: 2 / span 2;
  }

  .wp-block-gallery.kotynek-portfolio-gallery > figure.wp-block-image:nth-last-child(1):nth-child(3n + 2) {
    grid-column: 4 / span 2;
  }
}

/* Preserve each photograph's natural aspect ratio in the overview. */
.wp-block-gallery.kotynek-portfolio-gallery > figure.wp-block-image > a {
  display: block;
  width: 100%;
}

.wp-block-gallery.kotynek-portfolio-gallery > figure.wp-block-image img {
  display: block;
  width: 100% !important;
  height: auto !important;
}

/* Captions belong to the opened lightbox, not to the portfolio overview. */
.wp-block-gallery.kotynek-portfolio-gallery > figure.wp-block-image > figcaption.wp-element-caption {
  position: static !important;
  display: none !important;
}

@media (min-width: 521px) and (max-width: 781px) {
  .wp-block-gallery.kotynek-portfolio-gallery {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .wp-block-gallery.kotynek-portfolio-gallery > figure.wp-block-image {
    grid-column: auto / span 2;
  }

  .wp-block-gallery.kotynek-portfolio-gallery > figure.wp-block-image:nth-last-child(1):nth-child(2n + 1) {
    grid-column: 2 / span 2;
  }
}

.wp-block-gallery.kotynek-home-gallery {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
}

.wp-block-gallery.kotynek-home-gallery > figure.wp-block-image {
  width: auto !important;
  margin: 0 !important;
}

@media (max-width: 520px) {
  .wp-block-gallery.kotynek-portfolio-gallery {
    grid-template-columns: minmax(0, 1fr);
  }

  .wp-block-gallery.kotynek-portfolio-gallery > figure.wp-block-image {
    grid-column: auto / span 1;
  }

  /* Stack the curated Home selection for larger, more legible mobile photos. */
  .wp-block-gallery.kotynek-home-gallery {
    grid-template-columns: minmax(0, 1fr);
  }

  .wp-block-gallery.kotynek-home-gallery > figure.wp-block-image {
    grid-column: auto / span 1;
    width: 100% !important;
  }
}

/* Home photo metadata is available in the lightbox, not over the thumbnails. */
.wp-block-gallery.kotynek-home-gallery > figure.wp-block-image > a {
  display: block;
  width: 100%;
}

.wp-block-gallery.kotynek-home-gallery > figure.wp-block-image img {
  display: block;
  width: 100% !important;
  height: auto !important;
}

.wp-block-gallery.kotynek-home-gallery > figure.wp-block-image > figcaption.wp-element-caption {
  position: static !important;
  display: none !important;
}

.kotynek-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  background: rgba(20, 20, 20, 0.92);
}

.kotynek-lightbox[hidden] {
  display: none;
}

.kotynek-lightbox__figure {
  margin: 0;
  max-width: min(92vw, 1400px);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.kotynek-lightbox__img {
  max-width: 100%;
  max-height: 72vh;
  width: auto;
  height: auto;
  object-fit: contain;
}

.kotynek-lightbox__caption {
  color: #f1f1f1;
  font-size: 0.9rem;
  text-align: center;
  max-width: 70ch;
}

.kotynek-lightbox__count {
  color: #cfcfcf;
  font-size: 0.8rem;
}

.kotynek-lightbox__control {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  background: transparent;
  border: 0;
  color: #f1f1f1;
  font-size: 2rem;
  line-height: 1;
  padding: 0 1rem;
  cursor: pointer;
}

.kotynek-lightbox__control:hover {
  color: #ffffff;
}

.kotynek-lightbox__control--prev {
  left: 0;
}

.kotynek-lightbox__control--next {
  right: 0;
}

.kotynek-lightbox__close {
  position: absolute;
  z-index: 1;
  top: 0.75rem;
  right: 1rem;
  background: transparent;
  border: 0;
  color: #f1f1f1;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.5rem;
}

.kotynek-lightbox__close:hover {
  color: #ffffff;
}

.kotynek-lightbox__control:focus-visible,
.kotynek-lightbox__close:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.wp-block-gallery a[href] {
  cursor: zoom-in;
}
