/* AIDEV-NOTE: SSR-owned styles for gallery listing — grid layout, cards, bar, sidebar, and section breaks */

/* ========================================================================
   Grid container
   ======================================================================== */

/* AIDEV-NOTE: padding-top clears the fixed v4 nav — uses --nav-height set by nav.js */
.gallery-v2 {
  padding: calc(var(--nav-height, 64px) + 24px) 24px 120px;
  max-width: 1200px;
  margin: 0 auto;
}

.gallery-v2__results-count {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  margin: 12px 0;
}

/* AIDEV-NOTE: SSR fallback — flex-wrap grid with L→R ordering before JS hydrates into masonry columns */
.gallery-v2__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.gallery-v2__grid > .gallery-v2-card {
  width: calc((100% - 3 * 12px) / 4);
}

@media (max-width: 1024px) {
  .gallery-v2__grid > .gallery-v2-card {
    width: calc((100% - 2 * 12px) / 3);
  }
}

@media (max-width: 768px) {
  .gallery-v2__grid > .gallery-v2-card {
    width: calc((100% - 1 * 12px) / 2);
  }
  /* AIDEV-NOTE: Preserve nav-height top clearance on mobile — only reduce horizontal padding */
  .gallery-v2 {
    padding: calc(var(--nav-height, 64px) + 24px) 12px 120px;
  }
}

/* AIDEV-NOTE: After JS hydrates, grid becomes a vertical stack of segments + section breaks.
   Each segment is a horizontal flex row of column containers. */
.gallery-v2__grid.masonry-ready {
  flex-wrap: nowrap;
  flex-direction: column;
  gap: 0;
}

.gallery-v2__grid-segment {
  display: flex;
  gap: 12px;
}

.gallery-v2__grid-segment > .gallery-v2__column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* AIDEV-NOTE: Section breaks span full width in both SSR fallback and masonry-ready states */
.gallery-v2__grid > .gallery-v2-section-break {
  width: 100%;
  flex-basis: 100%;
}

.gallery-v2__grid.masonry-ready > .gallery-v2-section-break {
  width: 100%;
}

/* ========================================================================
   Card
   ======================================================================== */

/* AIDEV-NOTE: border-radius 8px matches ww2 Tailwind rounded-lg */
.gallery-v2-card {
  display: block;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  background: var(--muted);
}

.gallery-v2-card__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.gallery-v2-card:hover .gallery-v2-card__img {
  transform: scale(1.03);
}

/* Video play indicator overlay */
.gallery-v2-card__play-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  pointer-events: none;
  opacity: 0.9;
  transition: opacity 0.2s;
}

.gallery-v2-card:hover .gallery-v2-card__play-indicator {
  opacity: 1;
}

/* ========================================================================
   Section breaks (full-width promotional banners interspersed in grid)
   ======================================================================== */

.gallery-v2-section-break {
  margin: 24px 0;
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
}

.gallery-v2-section-break__bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-v2-section-break__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.gallery-v2-section-break__content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 40px 24px;
  color: #fff;
}

.gallery-v2-section-break__title {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 8px;
}

.gallery-v2-section-break__subtitle {
  font-size: 1rem;
  margin: 0 0 16px;
  opacity: 0.9;
}

.gallery-v2-section-break__cta {
  display: inline-block;
  padding: 10px 24px;
  background: #fff;
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
  border-radius: 6px;
  transition: background 0.2s;
}

.gallery-v2-section-break__cta:hover {
  background: var(--border);
}

/* ========================================================================
   Infinite scroll sentinel & spinner
   ======================================================================== */

.gallery-v2__sentinel {
}

.gallery-v2__loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
}

.gallery-v2__spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--foreground);
  border-radius: 50%;
  animation: gallery-spin 0.7s linear infinite;
}

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

.gallery-v2__no-results {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted-foreground);
  font-size: 1rem;
}

/* ========================================================================
   Bottom bar (search, filters, favorites)
   ======================================================================== */

/* AIDEV-NOTE: Floating centered bar — max-width keeps it from stretching full viewport width */
.gallery-v2-bar {
  position: fixed;
  bottom: 12px;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  padding: 10px 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.gallery-v2-bar__search {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  background: var(--muted);
  border-radius: 8px;
  padding: 8px 12px;
}

.gallery-v2-bar__search svg {
  flex-shrink: 0;
  color: var(--muted-foreground);
}

.gallery-v2-bar__input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.875rem;
  width: 100%;
  font-family: inherit;
}

.gallery-v2-bar__btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  position: relative;
}

.gallery-v2-bar__btn:hover {
  background: var(--muted);
}

.gallery-v2-bar__btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.gallery-v2-bar__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
}

.gallery-v2-bar__btn.active .gallery-v2-bar__badge {
  background: #fff;
  color: var(--primary);
}

/* ========================================================================
   Overlay + filter sidebar
   ======================================================================== */

.gallery-v2-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.gallery-v2-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.gallery-v2-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 300;
  width: 320px;
  max-width: 90vw;
  background: #fff;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.1);
}

.gallery-v2-sidebar.open {
  transform: translateX(0);
}

.gallery-v2-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.gallery-v2-sidebar__title {
  font-size: 1.125rem;
  font-weight: 700;
}

.gallery-v2-sidebar__close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
}

.gallery-v2-sidebar__close:hover {
  color: var(--primary);
}

.gallery-v2-sidebar__body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.gallery-v2-sidebar__section {
  margin-bottom: 24px;
}

.gallery-v2-sidebar__section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
  margin: 0 0 10px;
}

.gallery-v2-sidebar__option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.gallery-v2-sidebar__option:hover {
  background: var(--muted);
}

.gallery-v2-sidebar__option.active {
  background: var(--muted);
  font-weight: 600;
}

.gallery-v2-sidebar__check {
  opacity: 0;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.gallery-v2-sidebar__option.active .gallery-v2-sidebar__check {
  opacity: 1;
}

.gallery-v2-sidebar__footer {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.gallery-v2-sidebar__clear-btn,
.gallery-v2-sidebar__apply-btn {
  flex: 1;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.gallery-v2-sidebar__clear-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--foreground);
}

.gallery-v2-sidebar__clear-btn:hover {
  background: var(--muted);
}

.gallery-v2-sidebar__apply-btn {
  border: none;
  background: var(--primary);
  color: #fff;
}

.gallery-v2-sidebar__apply-btn:hover {
  background: var(--foreground);
}
