/* Grid */
.pf-archive { --pf-gap: 16px; }
.pf-archive__header { margin: 1rem 0 1.5rem; }
.pf-grid {
  display: grid;
  grid-template-columns: repeat(var(--pf-cols, 3), minmax(0, 1fr));
  gap: var(--pf-gap);
}
@media (max-width: 1024px) { .pf-grid { --pf-cols: 2; } }
@media (max-width: 600px)  { .pf-grid { --pf-cols: 1; } }

/* Filter bar */
.pf-filters {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 0 0 16px 0;
}
.pf-filter {
  display: inline-block;
  border: 1px solid rgba(0,0,0,.15);
  border-radius: 999px;
  padding: .35rem .8rem;
  background: transparent;
  text-decoration: none;
  color: inherit;
}
.pf-filter.is-active {
  background: currentColor; color: #fff; border-color: currentColor;
}

/* Card */
.pf-card { border: 1px solid rgba(0,0,0,.08); border-radius: 8px; overflow: hidden; background: inherit; color: inherit; }
.pf-card__link { display: block; color: inherit; text-decoration: none; }
.pf-card__media img { display: block; width: 100%; height: auto; }
.pf-card__placeholder { aspect-ratio: 16/9; background: #f2f2f2; }
.pf-card__title { margin: 0; padding: .75rem 1rem; font-size: 1.1rem; font-weight: 600; }

/* Lightbox */
.pf-lightbox { position: fixed; inset: 0; display: none; }
.pf-lightbox.is-open { display: block; }
.pf-lightbox__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.pf-lightbox__dialog {
  position: relative;
  z-index: 1;
  width: min(100% - 32px, 1100px);
  margin: 5vh auto;
  background: #fff;
  color: #111;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
  outline: none;
}
.pf-lightbox__close {
  position: absolute; top: 8px; right: 8px;
  border: 0; background: transparent; font-size: 28px; line-height: 1; cursor: pointer;
}
.pf-lightbox__media {
  position: relative; padding: 16px; display: grid; align-items: center; justify-items: center;
}
.pf-lightbox__img { max-width: 100%; height: auto; opacity: 0; transition: opacity .2s ease; }
.pf-lightbox__img.is-loaded { opacity: 1; }
.pf-lightbox__caption { margin-top: 8px; font-size: .9rem; color: #444; text-align: center; min-height: 1.2em; }

.pf-lightbox__nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  border: 0; background: rgba(0,0,0,.5); color: #fff; width: 36px; height: 36px; border-radius: 50%;
  cursor: pointer;
}
.pf-lightbox__prev { left: 8px; }
.pf-lightbox__next { right: 8px; }

.pf-lightbox__content { padding: 8px 16px 20px; }
.pf-lightbox__title { margin: 8px 0; font-size: 1.25rem; }
.pf-lightbox__desc :where(p,ul,ol,figure){ margin: .5rem 0; }
.pf-lightbox__desc img { max-width: 100%; height: auto; display: block; }

/* Loading hint */
.pf-grid.is-loading { pointer-events: none; }

/* Make the dialog fill (most of) the viewport height */
.pf-lightbox__dialog {
  display: flex;
  flex-direction: column;
  height: 90vh;        /* near-full height */
  margin: 5vh auto;    /* keep it visually centered */
  max-width: 1100px;
  width: min(100% - 32px, 1100px);
  overflow: hidden;    /* contain inner scrolling */
}

/* The media area takes remaining height and can scroll if the image is tall */
.pf-lightbox__media {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column; /* caption below the image */
  align-items: center;
  justify-content: top;
  overflow: auto;         /* 👈 allow scroll when needed */
  padding: 16px;
  position: relative;     /* keeps prev/next positioned */
}

/* Image scales to width, and if it's taller than the space, you can scroll */
.pf-lightbox__img {
  display: block;
  max-width: 100%;
  height: auto;           /* width controls size; height can exceed and scroll */
  object-fit: contain;    /* keeps full image visible within its own box */
}

/* Keep caption visible as you scroll the media area */
.pf-lightbox__caption {display: none;
  width: 100%;
  margin-top: 8px;
  font-size: .9rem;
  color: #444;
  text-align: center;
  min-height: 1.2em;
  position: sticky;       /* 👈 sticks at the bottom of the media viewport */
  bottom: 0;
  background: rgba(255,255,255,.9);
  backdrop-filter: saturate(180%) blur(4px);
  padding: 6px 8px;
}

/* Ensure nav buttons stay usable even when media scrolls */
.pf-lightbox__nav {
  position: sticky;
  top: 50%;
  transform: translateY(-50%);
}
.pf-lightbox__prev { align-self: flex-start; }
.pf-lightbox__next { align-self: flex-end; }

/* The textual content area (title + description) scrolls independently if long */
.pf-lightbox__content {
  flex: 0 0 auto;
  max-height: 35vh;       /* cap description height */
  overflow: auto;
  padding: 8px 16px 20px;
  border-top: 1px solid rgba(0,0,0,.1);
}

/* Optional: full-screen variant (100% height) — swap this in if you prefer */
@supports (inset: 0) {
  /* Uncomment to go true fullscreen:
  .pf-lightbox__dialog {
    position: fixed; inset: 0; margin: 0; width: 100%; height: 100%;
    border-radius: 0;
  }
  */
}


/* Infinite scroll sentinel */
.pf-sentinel {
  display: grid;
  place-items: center;
  padding: 16px 0 24px;
}
.pf-spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid rgba(0,0,0,.15);
  border-top-color: currentColor;
  animation: pf-spin 0.8s linear infinite;
  opacity: 0.4;
}
.pf-sentinel:not(.is-loading) .pf-spinner { display: none; }

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

