.portfolio__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.8rem;
  margin: 0 0 1.5rem;
  padding: 1.3rem 0;
  border-block: 1px solid #ffffff25;
}
.portfolio__filters button {
  background: transparent;
  color: #c4d2c8;
  padding: 0.8rem 0;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
  font-size: 0.83rem;
  transition:
    color 0.2s,
    border-color 0.2s;
}
.portfolio__filters button:hover,
.portfolio__filters button[aria-pressed='true'] {
  color: var(--mint);
  border-bottom-color: var(--mint);
}
.portfolio__filters button span {
  font-size: 0.65rem;
  margin-left: 0.25rem;
  opacity: 0.7;
  vertical-align: super;
}
.portfolio__status {
  margin-bottom: 2rem;
  color: #c4d2c8;
  font-size: 0.8rem;
}
.portfolio-card[hidden] {
  display: none !important;
}
.project-gallery__heading {
  margin-bottom: 2.5rem;
}
.project-gallery__heading > p {
  color: var(--mint);
  margin-bottom: 1rem;
}
.project-gallery__heading h2 {
  font-size: clamp(3rem, 6vw, 7rem);
  max-width: 1100px;
}
.project-gallery__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1.2rem, 3vw, 3rem);
}
.project-gallery__grid > figure:only-child {
  grid-column: 1 / -1;
}
.project-gallery__grid a {
  position: relative;
  display: block;
  background: #101612;
  overflow: clip;
}
.project-gallery__grid img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4/3;
  object-fit: cover;
  object-position: center 40%;
  transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.project-gallery__grid a:hover img {
  transform: scale(1.025);
}
.project-gallery__grid a > span {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  background: var(--mint);
  color: #101612;
  font-size: 1.7rem;
}
.project-gallery__grid figcaption {
  margin-top: 0.9rem;
  font-size: 0.8rem;
  color: #c4d2c8;
  line-height: 1.6;
}
.project-gallery__dialog {
  position: fixed;
  inset: 0;
  width: min(96vw, 1600px);
  max-width: 96vw;
  max-height: 96svh;
  margin: auto;
  padding: 3.8rem 1.2rem 1.1rem;
  border: 1px solid #ffffff30;
  color: #f2f7f3;
  background: #111714;
  box-shadow: 0 30px 100px #0008;
}
.project-gallery__dialog::backdrop {
  background: #030706e8;
  backdrop-filter: blur(8px);
}
.project-gallery__dialog figure {
  margin: 0;
}
.project-gallery__dialog figure img {
  display: block;
  width: 100%;
  max-height: 74svh;
  object-fit: contain;
}
.project-gallery__dialog figcaption {
  margin-top: 0.8rem;
  font-size: 0.8rem;
  text-align: center;
  color: #d0dfd6;
}
.project-gallery__close {
  position: absolute;
  top: 0.7rem;
  right: 1rem;
  background: none;
  color: #f2f7f3;
  border: 0;
  font: inherit;
  padding: 0.7rem;
  cursor: pointer;
}
.project-gallery__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}
.project-gallery__controls button {
  min-width: 44px;
  min-height: 44px;
  background: transparent;
  border: 1px solid #ffffff60;
  color: var(--mint);
  font-size: 1.3rem;
  cursor: pointer;
}
.project-gallery__controls button:disabled {
  opacity: 0.3;
  cursor: default;
}
.project-gallery__controls span {
  min-width: 4rem;
  text-align: center;
  font-size: 0.8rem;
}
@media (max-width: 700px) {
  .portfolio__filters {
    gap: 0.1rem 1rem;
  }
  .project-gallery__grid {
    grid-template-columns: 1fr;
  }
  .project-gallery__grid > figure {
    min-width: 0;
  }
  .project-gallery__grid img {
    height: auto;
    /* Reserve a stable box while native lazy images with sizes="auto" load. */
    aspect-ratio: auto 1 / 1;
    object-fit: contain;
  }
  .project-gallery__grid a:hover img {
    transform: none;
  }
  .project-gallery__grid figcaption {
    overflow-wrap: anywhere;
  }
}
/* Reserve room for the close button, caption and controls on small screens. */
@media (max-width: 700px), (max-height: 500px) {
  .project-gallery__dialog[open] {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 1rem;
    width: calc(100vw - 1rem);
    max-width: calc(100vw - 1rem);
    height: calc(100svh - 1rem);
    height: calc(100dvh - 1rem);
    max-height: calc(100svh - 1rem);
    max-height: calc(100dvh - 1rem);
    padding: calc(3.8rem + env(safe-area-inset-top)) 0.75rem
      calc(0.75rem + env(safe-area-inset-bottom));
    overflow: hidden;
  }
  .project-gallery__dialog figure {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 0.75rem;
    min-width: 0;
    min-height: 0;
  }
  .project-gallery__dialog figure img {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: none;
    object-fit: contain;
  }
  .project-gallery__dialog figcaption {
    margin: 0;
    max-height: 4.8em;
    overflow: auto;
    overflow-wrap: anywhere;
  }
  .project-gallery__close {
    top: calc(0.5rem + env(safe-area-inset-top));
    right: max(0.5rem, env(safe-area-inset-right));
    min-height: 44px;
  }
  .project-gallery__controls {
    margin-top: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .project-gallery__grid img,
  .portfolio__filters button {
    transition: none;
  }
}

.portfolio__filters[hidden] {
  display: none;
}
