/* ═══════════════════════════════════════════
   Gallery Styles — Family Site
   Light theme, warm tones
   ═══════════════════════════════════════════ */

/* --- Filter Bar --- */
.gallery-filter-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  border-top: 1px solid var(--border);
  padding: 1rem 3rem;
}

.filter-bar-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.filter-group {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  /* WHY: Hide scrollbar — tabs scroll via swipe on mobile */
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.filter-group::-webkit-scrollbar { display: none; }

.filter-btn {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  white-space: nowrap;
  transition: all 0.3s;
}
.filter-btn:hover {
  border-color: var(--border-hover);
  color: var(--ink);
}
.filter-btn.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.gallery-search {
  flex: 1;
  min-width: 0;
  max-width: 280px;
  margin-left: auto;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0;
  outline: none;
  transition: border-color 0.3s;
}
.gallery-search:focus { border-bottom-color: var(--accent); }
.gallery-search::placeholder { color: var(--text-muted); }

/* --- Gallery Grid --- */
.gallery-container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem;
  min-height: 40vh;
}

.gallery-grid {
  display: grid;
  /* WHY: auto-fill with minmax creates a responsive grid without media queries */
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.gallery-no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 5rem 0;
  font-family: var(--serif);
  font-size: 1.3rem;
  font-style: italic;
  color: var(--text-muted);
}

/* --- Gallery Card --- */
.gallery-card {
  cursor: pointer;
  opacity: 0;
  transform: translateY(20px);
  animation: galleryFadeIn 0.5s ease forwards;
}

@keyframes galleryFadeIn {
  to { opacity: 1; transform: translateY(0); }
}

.gallery-card-image {
  position: relative;
  overflow: hidden;
  background: var(--bg-elevated);
  /* WHY: Fixed aspect ratio prevents layout shift as images lazy-load */
  aspect-ratio: 4 / 3;
  border-radius: 6px;
}

.gallery-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.gallery-card:hover .gallery-card-image img {
  transform: scale(1.05);
}

.gallery-card-category {
  position: absolute;
  top: 12px;
  left: 12px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 4px 10px;
  border-radius: 3px;
}

.gallery-card-caption {
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink);
  margin-top: 0.75rem;
  /* WHY: Clamp to 2 lines to keep cards uniform height */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gallery-card-people {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 0.5rem;
}

.gallery-card-person {
  font-family: var(--mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 3px;
}

.gallery-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 0.5rem;
}

.gallery-card-tag {
  font-family: var(--mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 3px 8px;
  border-radius: 3px;
}

/* --- Lightbox --- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(26,26,26,0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}

.lightbox-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 90vw;
  max-height: 90vh;
}

.lightbox-img {
  max-width: 90vw;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 4px;
}

.lightbox-close {
  position: absolute;
  top: 24px;
  right: 32px;
  font-size: 2rem;
  color: var(--bg);
  background: none;
  border: none;
  cursor: pointer;
  z-index: 1001;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.lightbox-close:hover { opacity: 1; }

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 3rem;
  color: var(--bg);
  background: none;
  border: none;
  cursor: pointer;
  z-index: 1001;
  padding: 16px;
  line-height: 1;
  opacity: 0.5;
  transition: opacity 0.2s;
}
.lightbox-prev:hover,
.lightbox-next:hover { opacity: 1; }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }

.lightbox-meta {
  color: var(--bg);
  text-align: center;
  margin-top: 20px;
  max-width: 600px;
}

.lightbox-caption {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-style: italic;
  line-height: 1.5;
  margin-bottom: 12px;
}

.lightbox-details {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.7;
}

.lightbox-people {
  font-style: italic;
  text-transform: none;
  letter-spacing: 0;
}

/* --- Feed States --- */
.feed-empty {
  text-align: center;
  padding: 5rem 0;
}

.empty-text {
  font-family: var(--serif);
  font-size: 2rem;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.empty-sub {
  font-family: var(--mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}
.empty-sub a {
  color: var(--accent);
  border-bottom: 1px solid var(--accent);
}

.feed-loading {
  display: flex;
  justify-content: center;
  padding: 4rem 0;
}

.loader {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .gallery-filter-bar { padding: 0.75rem 1.5rem; }
  .filter-bar-inner {
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
  }
  .gallery-search { max-width: none; margin-left: 0; }
  .gallery-container { padding: 1.5rem; }
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
  }
  .lightbox-prev { left: 4px; font-size: 2rem; }
  .lightbox-next { right: 4px; font-size: 2rem; }
  .lightbox-close { top: 12px; right: 16px; }
}
