/* ===================================================================
   Slide Archive — Dark theme, track/justified layout
   =================================================================== */

/* --- Reset & base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #1a1a1a;
  --bg-surface:  #242424;
  --bg-raised:   #2e2e2e;
  --border:      #3a3a3a;
  --text:        #e0e0e0;
  --text-muted:  #888;
  --accent:      #6ea8d9;
  --accent-dim:  #3a6a8a;
  --radius:      6px;
  --row-height:  220px;     /* target height for justified rows */
  --gap:         6px;
  --header-pad:  clamp(1rem, 3vw, 2rem);

  color-scheme: dark;
}

@media (min-width: 1200px) { :root { --row-height: 260px; } }
@media (max-width: 640px)  { :root { --row-height: 150px; --gap: 4px; } }

html { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; }
img { display: block; max-width: 100%; }

/* --- Header --- */
.site-header {
  padding: var(--header-pad) var(--header-pad) 0.5rem;
}
.site-title {
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.site-description {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* --- Filter bar --- */
.filter-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem var(--header-pad);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}
.filter-section { display: flex; align-items: center; gap: 0.5rem; }
.filter-group { display: flex; align-items: center; gap: 0.4rem; }
.filter-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-right: 0.25rem;
  white-space: nowrap;
}
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.filter-status {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Pill buttons */
.pill {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.pill:hover {
  border-color: var(--accent-dim);
  color: var(--text);
}
.pill.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #fff;
}

/* Search */
.search-input {
  appearance: none;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  padding: 0.35rem 0.75rem;
  width: 220px;
  max-width: 100%;
  transition: border-color 0.15s;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ===================================================================
   Gallery — CSS flexbox justified layout (Lightroom "track" style)

   Each photo's flex-grow is set to its aspect ratio, so wider images
   naturally claim more row space. flex-basis uses the target row
   height × ratio to size correctly. The row wraps and images stretch
   to fill each line, maintaining proportions without cropping.
   =================================================================== */
.gallery {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  padding: var(--gap) var(--header-pad);
  /* The "after" pseudo-element prevents the last row from stretching */
}
.gallery::after {
  content: "";
  flex-grow: 999;
}

.photo-card {
  position: relative;
  flex-grow: var(--ratio, 1.5);
  flex-basis: calc(var(--ratio, 1.5) * var(--row-height));
  overflow: hidden;
  border-radius: 3px;
  cursor: pointer;
  background: var(--bg-surface);
  transition: opacity 0.2s;
}
.photo-card[hidden] {
  display: none !important;
}

.photo-img {
  width: 100%;
  height: var(--row-height);
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}
/* Cover is intentional for the grid rows — full images shown in lightbox */

.photo-card:hover .photo-img {
  transform: scale(1.03);
}

/* Caption overlay on hover */
.photo-meta {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 2rem 0.6rem 0.5rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  font-size: 0.75rem;
  line-height: 1.35;
  color: #ddd;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.photo-meta strong { color: #fff; font-weight: 500; }
.photo-meta time { color: var(--text-muted); font-size: 0.7rem; }
.photo-card:hover .photo-meta { opacity: 1; }

/* ===================================================================
   Lightbox
   =================================================================== */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
}
.lightbox[aria-hidden="false"] {
  display: flex;
}
.lightbox-content {
  display: flex;
  align-items: center;
  gap: 2rem;
  max-width: 95vw;
  max-height: 90vh;
  padding: 1rem;
}
.lightbox-img {
  max-height: 85vh;
  max-width: 70vw;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 40px rgba(0,0,0,0.5);
}
.lightbox-info {
  max-width: 280px;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  color: var(--text);
}
.lightbox-title {
  font-size: 1.1rem;
  font-weight: 600;
}
.lightbox-caption {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.lightbox-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.lightbox-tags .tag-chip {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
}

/* Lightbox nav buttons */
.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: fixed;
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  z-index: 1001;
  transition: color 0.15s;
}
.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover { color: #fff; }

.lightbox-close {
  top: 1rem;
  right: 1.25rem;
  font-size: 2rem;
  line-height: 1;
}
.lightbox-prev,
.lightbox-next {
  top: 50%;
  transform: translateY(-50%);
  font-size: 3rem;
  line-height: 1;
  padding: 0.5rem;
}
.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }

.lightbox-suggest {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.25rem 0.6rem;
  transition: color 0.15s, border-color 0.15s;
}
.lightbox-suggest:hover {
  color: var(--text);
  border-color: var(--accent-dim);
}

/* --- Mobile lightbox --- */
@media (max-width: 768px) {
  .filter-bar { position: static; }
  .lightbox-content {
    flex-direction: column;
    gap: 1rem;
  }
  .lightbox-img {
    max-width: 92vw;
    max-height: 60vh;
  }
  .lightbox-info {
    max-width: 92vw;
    text-align: center;
    align-items: center;
  }
  .lightbox-prev,
  .lightbox-next { font-size: 2rem; }
}

/* ===================================================================
   Utility
   =================================================================== */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}