/* Galeria editorial com navegação manual e scroll-snap */
.gallery-carousel {
  position: relative;
  min-width: 0;
}

.gallery .gallery-grid {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.15rem 0 0.8rem;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}

.gallery .gallery-grid::-webkit-scrollbar {
  display: none;
}

.gallery .gallery-card,
.gallery .gallery-card:nth-child(1),
.gallery .gallery-card:nth-child(2) {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  flex: 0 0 calc((100% - 3rem) / 4);
  grid-column: auto;
  min-width: 0;
  min-height: 0;
  aspect-ratio: auto;
  overflow: hidden;
  color: #2d252e;
  text-align: left;
  background: #fffdfb;
  border: 1px solid rgba(114, 89, 105, 0.17);
  border-radius: 0.72rem;
  box-shadow: 0 12px 30px rgba(45, 37, 46, 0.07);
  scroll-snap-align: start;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.gallery .gallery-card:hover,
.gallery .gallery-card:focus-visible {
  border-color: rgba(114, 89, 105, 0.38);
  box-shadow: 0 18px 34px rgba(45, 37, 46, 0.12);
  transform: translateY(-3px);
}

.gallery .gallery-card > img {
  position: static;
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  transform: none;
  transition: transform 420ms ease;
}

.gallery .gallery-card:hover > img {
  transform: scale(1.025);
}

.gallery .gallery-card::after {
  display: none;
}

.gallery .gallery-caption {
  position: static;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.8rem;
  min-height: 76px;
  padding: 1rem 1.05rem;
  color: #2d252e;
  background: #fffdfb;
}

.gallery .gallery-index {
  color: #8c6955;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.07em;
}

.gallery .gallery-caption strong {
  min-width: 0;
  color: #2d252e;
  font-family: var(--font-body);
  font-size: clamp(0.94rem, 1.1vw, 1.06rem);
  font-weight: 750;
  line-height: 1.25;
  text-shadow: none;
}

.gallery .gallery-expand-btn {
  top: 0.75rem;
  right: 0.75rem;
  width: 36px;
  height: 36px;
  color: #fff;
  background: rgba(39, 32, 40, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 0.45rem;
  backdrop-filter: blur(8px);
}

.gallery-carousel-controls {
  display: grid;
  grid-template-columns: auto minmax(100px, 1fr) auto;
  align-items: center;
  gap: 1rem;
  margin-top: 1.2rem;
}

.gallery-carousel-count {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
}

.gallery-carousel-count strong {
  color: var(--plum-dark);
  font-size: 0.92rem;
}

.gallery-carousel-progress {
  position: relative;
  width: min(280px, 100%);
  height: 2px;
  overflow: hidden;
  background: rgba(114, 89, 105, 0.17);
}

.gallery-carousel-progress span {
  display: block;
  width: calc(100% / 6);
  height: 100%;
  background: var(--mauve);
  transform-origin: left;
  transition: width 220ms ease;
}

.gallery-carousel-buttons {
  display: flex;
  gap: 0.55rem;
}

.gallery-carousel-buttons button {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  color: var(--plum-dark);
  background: #fffdfb;
  border: 1px solid rgba(114, 89, 105, 0.23);
  border-radius: 50%;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.gallery-carousel-buttons button:hover:not(:disabled),
.gallery-carousel-buttons button:focus-visible {
  color: #fff;
  background: var(--plum-dark);
  border-color: var(--plum-dark);
}

.gallery-carousel-buttons button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.gallery-carousel-buttons svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 1180px) {
  .gallery .gallery-card,
  .gallery .gallery-card:nth-child(1),
  .gallery .gallery-card:nth-child(2) {
    flex-basis: calc((100% - 2rem) / 3);
  }
}

@media (max-width: 820px) {
  .gallery .gallery-grid {
    gap: 0.8rem;
    margin-inline: 0;
    padding-right: 0;
    padding-left: 0;
  }

  .gallery .gallery-card,
  .gallery .gallery-card:nth-child(1),
  .gallery .gallery-card:nth-child(2) {
    flex-basis: calc(100% - 42px);
    border-radius: 0.62rem;
  }

  .gallery .gallery-card > img {
    aspect-ratio: 16 / 11;
  }

  .gallery .gallery-caption {
    min-height: 72px;
    padding: 0.95rem 1rem;
  }

  .gallery-carousel-controls {
    grid-template-columns: auto minmax(72px, 1fr) auto;
    gap: 0.8rem;
    margin-top: 1rem;
  }

  .gallery-carousel-progress {
    width: 100%;
  }

  .gallery-carousel-buttons button {
    width: 40px;
    height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery .gallery-grid {
    scroll-behavior: auto;
  }

  .gallery .gallery-card,
  .gallery .gallery-card > img,
  .gallery-carousel-progress span {
    transition: none;
  }
}
