/* ==========================================================================
   Pooch Meme Gallery — /gallery. Builds on the shared design system in
   styles.css (colors, fonts, header, footer, mobile menu, modal).
   ========================================================================== */

.galleryBody {
  background: var(--cream);
}

#galleryMain {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 24px 56px;
}

/* -------------------------------- hero --------------------------------- */
.galleryHero {
  padding: 8px 2px 20px;
}
.galleryHero__title {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  transform: rotate(-1.5deg);
}
.galleryHero__doodle {
  width: 0.8em;
  height: 0.8em;
}
.galleryHero__sub {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

/* ------------------------------ toolbar -------------------------------- */
.galleryTools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.gallerySearch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 1 260px;
}
.gallerySearch svg {
  position: absolute;
  left: 12px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}
.gallerySearch input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  font: inherit;
  font-size: 0.92rem;
  color: var(--text);
}
.gallerySort select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.galleryChips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1 1 auto;
}
.chip {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.chip:hover {
  background: rgba(28, 24, 13, 0.05);
}
.chip.is-active {
  background: var(--accent);
  border-color: rgba(28, 24, 13, 0.12);
  color: var(--accent-ink);
}
.galleryViewToggle {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}
.viewBtn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 30px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.viewBtn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}
.viewBtn.is-active {
  background: rgba(204, 255, 0, 0.3);
  color: var(--text);
}

/* -------------------------------- grid --------------------------------- */
.galleryGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 18px 16px;
}

.memeCard {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.memeCard__thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background: #ece7d8;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(28, 24, 13, 0.08);
}
.memeCard__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.memeCard__actions {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(16, 14, 8, 0.55);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.memeCard__thumb:hover .memeCard__actions,
.memeCard__thumb:focus-within .memeCard__actions {
  opacity: 1;
}
.memeCard__btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
.memeCard__btn svg {
  width: 18px;
  height: 18px;
}
.memeCard__btn--expand {
  background: #fff;
  color: var(--text);
}
.memeCard__btn--download {
  background: var(--accent);
  color: var(--accent-ink);
}
.memeCard__btn:hover {
  transform: translateY(-1px);
}
.memeCard__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 2px;
}
.memeCard__title {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text);
}
.memeCard__cat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: capitalize;
}
.memeCard__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

/* list view */
.galleryGrid[data-view="list"] {
  grid-template-columns: 1fr;
  gap: 10px;
}
.galleryGrid[data-view="list"] .memeCard {
  flex-direction: row;
  align-items: center;
  gap: 14px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
}
.galleryGrid[data-view="list"] .memeCard__thumb {
  width: 84px;
  height: 84px;
  aspect-ratio: 1;
  flex-shrink: 0;
  box-shadow: none;
}
.galleryGrid[data-view="list"] .memeCard__meta {
  flex: 1;
}
.galleryGrid[data-view="list"] .memeCard__actions {
  position: static;
  inset: auto;
  width: auto;
  background: none;
  opacity: 1;
  gap: 8px;
}
.galleryGrid[data-view="list"] .memeCard__btn--expand {
  border: 1px solid var(--border);
}

/* empty state */
.galleryEmpty {
  display: grid;
  gap: 8px;
  place-items: center;
  text-align: center;
  padding: 60px 20px;
  border: 1px dashed var(--border);
  border-radius: 18px;
  background: #faf7ee;
  color: var(--muted);
}
.galleryEmpty strong {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--text);
}
.galleryEmpty code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82em;
}

/* ----------------------------- pagination ------------------------------ */
.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 34px;
}
.pagination:empty {
  display: none;
}
.pageBtn {
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  font: inherit;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.pageBtn:hover:not(:disabled) {
  background: rgba(28, 24, 13, 0.05);
}
.pageBtn.is-active {
  background: rgba(204, 255, 0, 0.35);
  border-color: rgba(111, 143, 20, 0.5);
}
.pageBtn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pageEllipsis {
  color: var(--muted);
  padding: 0 2px;
}

/* ------------------------------- lightbox ------------------------------ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(16, 14, 8, 0.82);
}
.lightbox[hidden] {
  display: none;
}
.lightbox__close {
  position: absolute;
  top: 16px;
  right: 20px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 40px;
  line-height: 1;
  cursor: pointer;
}
.lightbox__figure {
  margin: 0;
  max-width: min(92vw, 720px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.lightbox__img {
  width: 100%;
  max-height: 74vh;
  object-fit: contain;
  border-radius: 16px;
  background: #ece7d8;
}
.lightbox__cap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.lightbox__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: #fff;
}
.lightbox__title {
  font-family: var(--font-display);
  font-size: 1.25rem;
}
.lightbox__cat {
  font-size: 0.85rem;
  color: #cfd3c4;
  text-transform: capitalize;
}
.lightbox__dl {
  gap: 8px;
}
.lightbox__dl svg {
  width: 18px;
  height: 18px;
}

/* ------------------------------ responsive ----------------------------- */
@media (max-width: 768px) {
  #galleryMain {
    padding: 16px 14px 44px;
  }
  .galleryGrid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 14px 12px;
  }
  .gallerySearch {
    flex: 1 1 100%;
  }
  /* touch: actions are always visible since there's no hover */
  .memeCard__actions {
    opacity: 1;
    background: linear-gradient(transparent 55%, rgba(16, 14, 8, 0.6));
    align-items: flex-end;
    padding-bottom: 8px;
  }
}
