/* Gallery grid layout */
.gallery-grid {
  display: grid;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

@media (max-width: 800px) {
  .gallery-grid { grid-template-columns: 1fr; }
}
@media (min-width: 801px) and (max-width: 1200px) {
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1201px) {
  .gallery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}


/* Card styling */
.gallery-card {
  display: flex;
  flex-direction: column;
  background: var(--color-background-primary, #fff);
  border: 1px solid var(--color-background-border, #e0e0e0);
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.gallery-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  text-decoration: none;
}

/* Card image */
.gallery-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: var(--color-background-secondary, #f5f5f5);
}

/* Card body */
.gallery-card-body {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  padding: 1rem;
}

.gallery-card-body h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-foreground-primary, #333);
}

.gallery-card-body p {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--color-foreground-secondary, #666);
  flex-grow: 1;
}

/* Tags */
.gallery-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.tag {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 4px;
}

.tag-primary {
  background: #0d6efd;
  color: #fff;
}

.tag-secondary {
  background: #6c757d;
  color: #fff;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .gallery-card {
    background: var(--color-background-primary, #1a1a1a);
    border-color: var(--color-background-border, #333);
  }

  .gallery-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  }
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .gallery-grid {
    grid-template-columns: 1fr;
  }

  .gallery-card img {
    height: 140px;
  }
}

.gallery-card-body sub,
.gallery-card-body sup {
  font-size: 0.75em;
  line-height: 0;
}



/* --------------------------------------------------------------------------
   Gallery toolbar (search + tag filters)
   -------------------------------------------------------------------------- */

.gallery-toolbar {
  margin-top: 1.25rem;
  padding: 1rem;
  border: 1px solid var(--color-background-border, #e0e0e0);
  border-radius: 14px;
  background: var(--color-background-primary, #fff);
}

.gallery-search {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

#gallery-search {
  flex: 1;
  min-width: 220px;
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--color-background-border, #e0e0e0);
  background: var(--color-background-secondary, #fafafa);
  color: var(--color-foreground-primary, #1a1a1a);
  outline: none;
}

#gallery-search:focus {
  border-color: var(--color-brand-primary, #3a7bd5);
  box-shadow: 0 0 0 3px rgba(58, 123, 213, 0.15);
}

.gallery-btn {
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--color-background-border, #e0e0e0);
  background: var(--color-background-secondary, #fafafa);
  color: var(--color-foreground-primary, #1a1a1a);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.2s ease;
}

.gallery-btn:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.gallery-btn:active {
  transform: translateY(1px);
}

.gallery-meta {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.gallery-count {
  font-size: 0.95rem;
  color: var(--color-foreground-secondary, #555);
}

.gallery-tag-cloud {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.gallery-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--color-background-border, #e0e0e0);
  background: var(--color-background-secondary, #fafafa);
  color: var(--color-foreground-primary, #1a1a1a);
  cursor: pointer;
  user-select: none;
  font-size: 0.85rem;
  line-height: 1.1;
}

.gallery-tag-chip .chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.15rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--color-background-primary, #fff);
  border: 1px solid var(--color-background-border, #e0e0e0);
  font-size: 0.8rem;
  color: var(--color-foreground-secondary, #555);
}

.gallery-tag-chip.is-active {
  border-color: var(--color-brand-primary, #3a7bd5);
  background: rgba(58, 123, 213, 0.12);
}

.gallery-tag-chip.is-active .chip-count {
  border-color: var(--color-brand-primary, #3a7bd5);
}

.gallery-card.is-hidden {
  display: none !important;
}

/* Slightly tighter spacing between toolbar and grid */
.gallery-grid[data-gallery="experiments"] {
  margin-top: 1rem;
}
