#gallery .page-intro {
  margin-bottom: var(--space-7);
}

.gallery-preview-grid {
  width: min(100%, var(--content-max));
  margin: 0 auto var(--space-8);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-4);
}

.featured-preview-card {
  position: relative;
  min-width: 0;
  min-height: 176px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  color: var(--color-plum);
  transition:
    border-color var(--motion-standard) var(--motion-ease),
    box-shadow var(--motion-standard) var(--motion-ease),
    transform var(--motion-standard) var(--motion-ease);
}

.featured-preview-card img {
  display: block;
  width: 100%;
  height: 176px;
  background: var(--color-surface-lavender);
  object-fit: cover;
  transition: transform var(--motion-slow) var(--motion-ease);
}

.featured-preview-label {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  min-height: 44px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid rgba(36, 26, 42, 0.1);
  background: rgba(255, 248, 239, 0.94);
  color: var(--color-plum);
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
}

.featured-preview-card:hover,
.featured-preview-card.active {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.featured-preview-card:hover img,
.featured-preview-card.active img {
  transform: scale(1.025);
}

.featured-preview-card.active .featured-preview-label {
  background: var(--color-plum);
  color: var(--color-surface);
}

.gallery-section-divider {
  width: min(100%, var(--content-max));
  margin: 0 auto var(--space-7);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  color: var(--color-text-muted);
}

.gallery-section-divider::before,
.gallery-section-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--color-border);
}

.gallery-section-divider span {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1;
  text-transform: uppercase;
}

.gallery {
  width: min(100%, var(--content-max));
  margin: 0 auto;
  columns: 4 240px;
  column-gap: var(--space-4);
  scroll-margin-top: 112px;
}

.gallery-item {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 0 var(--space-4);
  break-inside: avoid;
  border: 1px solid rgba(36, 26, 42, 0.1);
  border-radius: var(--radius-sm);
  background: var(--color-surface-warm);
  box-shadow: var(--shadow-sm);
  color: transparent;
  opacity: 0.72;
  filter: saturate(0.7);
  transition:
    opacity var(--motion-standard) var(--motion-ease),
    filter var(--motion-standard) var(--motion-ease),
    border-color var(--motion-standard) var(--motion-ease),
    box-shadow var(--motion-standard) var(--motion-ease);
}

.gallery-item.is-loaded {
  opacity: 1;
  filter: none;
}

.gallery-item:hover,
.gallery-item:focus-visible {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-md);
}

.gallery-item.filtered-out {
  display: none;
}

.gallery-empty-message {
  display: none;
  width: min(100%, 560px);
  margin: var(--space-7) auto 0;
  padding: var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-lavender);
  color: var(--color-text-muted);
  font-family: var(--font-ui);
  text-align: center;
}

.gallery-empty-message.show {
  display: block;
}

@media (max-width: 1024px) {
  .gallery-preview-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-3);
  }

  .featured-preview-card,
  .featured-preview-card img {
    min-height: 148px;
    height: 148px;
  }

  .gallery {
    columns: 3 220px;
  }
}

@media (max-width: 768px) {
  .gallery-preview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: var(--space-7);
  }

  .featured-preview-card,
  .featured-preview-card img {
    min-height: 168px;
    height: 168px;
  }

  .gallery {
    columns: 2 160px;
    column-gap: var(--space-3);
  }

  .gallery-item {
    margin-bottom: var(--space-3);
  }
}

@media (max-width: 420px) {
  .featured-preview-card,
  .featured-preview-card img {
    min-height: 142px;
    height: 142px;
  }

  .gallery {
    columns: 1;
  }
}
