#projects .gallery-grid {
  align-items: stretch;
  gap: 2rem;
}

#projects .gallery-project {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: clamp(1.8rem, 3vw, 2.6rem);
  border: 1px solid rgba(23, 33, 31, 0.1);
  border-radius: 1.6rem;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 1rem 2.8rem rgba(23, 33, 31, 0.06);
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

#projects .gallery-project:hover {
  transform: translateY(-0.3rem);
  border-color: rgba(255, 108, 77, 0.45);
  box-shadow: 0 1.5rem 3.6rem rgba(23, 33, 31, 0.1);
}

#projects .gallery-project__header {
  align-items: center;
  min-height: 7rem;
  margin-bottom: 1.8rem;
  padding-bottom: 1.6rem;
  border-bottom: 1px solid rgba(23, 33, 31, 0.09);
}

#projects .gallery-project__category {
  display: inline-flex;
  margin-bottom: 0.9rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: rgba(96, 118, 107, 0.1);
  color: #42625f !important;
  font-size: 1rem !important;
  letter-spacing: 0.075em;
}

#projects .gallery-project__header h3 {
  color: #17211f;
  font-size: clamp(1.9rem, 2vw, 2.3rem);
  line-height: 1.3;
}

#projects .gallery-project__index {
  display: grid;
  flex: 0 0 3.8rem;
  width: 3.8rem;
  height: 3.8rem;
  place-items: center;
  border: 1px solid rgba(23, 33, 31, 0.12);
  border-radius: 50%;
  color: #60766b;
  font-size: 1.35rem;
}

#projects .gallery-project__images:not(.gallery-project__images--carousel) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 1.4rem;
}

#projects .gallery-project--featured .gallery-project__images:not(.gallery-project__images--carousel) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#projects .gallery-project__images figure {
  overflow: hidden;
  border: 1px solid rgba(23, 33, 31, 0.08);
  border-radius: 1rem;
  background: #fff;
}

#projects .gallery-image-link {
  aspect-ratio: 16 / 10;
  border: 0;
  border-radius: 0;
  background: #f0f2f1;
}

#projects .gallery-image-link img {
  padding: 0.5rem;
}

#projects .gallery-project__images figcaption {
  min-height: 4.4rem;
  padding: 0.9rem 1rem 1rem;
  color: #46534e;
  font-size: 1.2rem;
}

#projects .gallery-project__images--carousel {
  display: block;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-behavior: smooth;
  scroll-padding-inline: 0;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

#projects .gallery-project__images--carousel::-webkit-scrollbar {
  display: none;
}

#projects .gallery-carousel__track {
  display: flex;
  width: 100%;
  gap: 1.4rem;
}

#projects .gallery-carousel__track figure {
  flex: 0 0 calc((100% - 2.8rem) / 3);
  min-width: 0;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

#projects .gallery-carousel__controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 1.2rem;
}

#projects .gallery-carousel__counter {
  margin: 0 auto 0 0;
  color: #60766b;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

#projects .gallery-carousel__button {
  display: inline-flex;
  width: 4rem;
  height: 4rem;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(23, 33, 31, 0.14);
  border-radius: 50%;
  background: #fff;
  color: #17211f;
  cursor: pointer;
  letter-spacing: normal;
  transition: border-color 180ms ease, background 180ms ease, color 180ms ease;
}

#projects .gallery-carousel__button:hover:not(:disabled) {
  border-color: #ff6c4d;
  background: #ff6c4d;
  color: #fff;
}

#projects .gallery-carousel__button:focus-visible {
  outline: 3px solid #ff6c4d;
  outline-offset: 3px;
}

#projects .gallery-carousel__button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

#projects .gallery-carousel__button svg {
  width: 1.8rem;
  height: 1.8rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

html[data-theme="dark"] #projects .gallery-project {
  border-color: rgba(232, 233, 223, 0.14);
  background: #202a2b;
  box-shadow: 0 1rem 2.8rem rgba(0, 0, 0, 0.16);
}

html[data-theme="dark"] #projects .gallery-project:hover {
  border-color: rgba(255, 108, 77, 0.6);
  box-shadow: 0 1.5rem 3.6rem rgba(0, 0, 0, 0.25);
}

html[data-theme="dark"] #projects .gallery-project__header {
  border-color: rgba(232, 233, 223, 0.13);
}

html[data-theme="dark"] #projects .gallery-project__category {
  background: rgba(201, 216, 194, 0.1);
}

html[data-theme="dark"] #projects .gallery-project__header h3 {
  color: #e8e9df;
}

html[data-theme="dark"] #projects .gallery-project__index {
  border-color: rgba(232, 233, 223, 0.16);
  color: #c9d8c2;
}

html[data-theme="dark"] #projects .gallery-project__images figure {
  border-color: rgba(232, 233, 223, 0.12);
  background: #182121;
}

html[data-theme="dark"] #projects .gallery-image-link {
  background: #182121;
}

html[data-theme="dark"] #projects .gallery-project__images figcaption,
html[data-theme="dark"] #projects .gallery-carousel__counter {
  color: rgba(232, 233, 223, 0.78);
}

html[data-theme="dark"] #projects .gallery-carousel__button {
  border-color: rgba(232, 233, 223, 0.2);
  background: #182121;
  color: #e8e9df;
}

html[data-theme="dark"] #projects .gallery-carousel__button:hover:not(:disabled) {
  border-color: #ff6c4d;
  background: #ff6c4d;
  color: #fff;
}

@media screen and (max-width: 600px) {
  #projects .gallery-project--featured .gallery-project__images:not(.gallery-project__images--carousel) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #projects .gallery-carousel__track figure {
    flex-basis: 100%;
  }

  #projects .gallery-carousel__controls {
    gap: 0.8rem;
  }

  #projects .gallery-carousel__button {
    width: 3.8rem;
    height: 3.8rem;
  }
}

@media screen and (max-width: 380px) {
  #projects .gallery-project__images:not(.gallery-project__images--carousel),
  #projects .gallery-project--featured .gallery-project__images:not(.gallery-project__images--carousel) {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  #projects .gallery-project,
  #projects .gallery-carousel__button {
    scroll-behavior: auto;
    transition-duration: 0.01ms;
  }
}
