/*
 * gallery.css — shared gallery strip + lightbox styles
 * Used by: recipe pages (via recipe.css @import) and collection member pages.
 * Depends on: tokens.css
 */

/* ============================================================
   GALLERY SECTION WRAPPER
   ============================================================ */
.recipe-gallery-section,
.collection-gallery-section {
  padding-block: var(--space-5);
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-surface);
}

.recipe-gallery-section[hidden],
.collection-gallery-section[hidden] { display: none; }

/* ── Scroll-fade wrapper (mirrors .collections-section .scroll-fade-wrap) ── */
.gallery-section__scroll-wrap {
  overflow: hidden;
}

/* ── Strip (single-row horizontal scroll) ──────────────────── */
.gallery-strip {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--space-2);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  padding-bottom: var(--space-1);
  scrollbar-width: none;
}

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

/* ── Thumbnail ──────────────────────────────────────────────── */
.gallery-thumb {
  position: relative;
  flex: 0 0 auto;
  width: clamp(100px, 22vw, 180px);
  aspect-ratio: 1 / 1;
  scroll-snap-align: start;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  opacity: 0;
  transform: translateY(6px);
}

.gallery-thumb--enter {
  animation: galleryEnter 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

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

.gallery-thumb--featured {
  /* formerly a grid-column hook; kept for back-compat, no effect in flex */
}

.gallery-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.gallery-thumb:hover img,
.gallery-thumb:focus-visible img {
  transform: scale(1.08);
}

.gallery-thumb:focus-visible {
  outline: 3px solid var(--color-primary-btn);
  outline-offset: 2px;
}

.gallery-thumb__overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 32, 40, 0);
  color: #fff;
  opacity: 0;
  transition:
    opacity 0.2s ease,
    background 0.2s ease;
}

.gallery-thumb:hover .gallery-thumb__overlay,
.gallery-thumb:focus-visible .gallery-thumb__overlay {
  opacity: 1;
  background: rgba(0, 32, 40, 0.38);
}

.gallery-thumb__overlay svg {
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
  width: 16px;
  height: 16px;
}

.gallery-thumb__count {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: var(--radius-full);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
  letter-spacing: 0.02em;
  line-height: 1.4;
}

.gallery-thumb--error {
  background: var(--color-surface-offset);
  cursor: default;
  pointer-events: none;
}

.gallery-thumb--error::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23aaa' stroke-width='1.5'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'/%3E%3Cpolyline points='21 15 16 10 5 21'/%3E%3C/svg%3E") center/24px no-repeat;
}

/* ============================================================
   LIGHTBOX
   ============================================================ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--z-lightbox);
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox[hidden] { display: none; }

.lightbox__img-wrap {
  max-width: min(92vw, 1200px);
  max-height: 88dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox__img {
  max-width: 100%;
  max-height: 88dvh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  display: block;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.lightbox__close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.12);
  color: #fff;
  display: grid;
  place-items: center;
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.lightbox__close:hover {
  background: rgba(255,255,255,0.22);
}

.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.12);
  color: #fff;
  display: grid;
  place-items: center;
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.lightbox__nav:hover {
  background: rgba(255,255,255,0.22);
}

.lightbox__nav--prev { left: var(--space-4); }
.lightbox__nav--next { right: var(--space-4); }

.lightbox__nav[hidden] { display: none; }

.lightbox__counter {
  position: absolute;
  bottom: var(--space-5);
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--text-xs);
  color: rgba(255,255,255,0.6);
  background: rgba(0,0,0,0.4);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  white-space: nowrap;
}
