/* ═══════════════════════════════════════════════════════════════════ */
/* ARCHIVE CARDS — a post type's cards as a content block, loaded by      */
/* infinite scroll or numbered pagination.                               */
/* (card styles live per post type in assets/css/archive-cards/)         */

.archive-cards {
  padding: 72px 0;
}

.archive-cards__header.section-header {
  margin-bottom: 30px;
  text-align: center;
}

.archive-cards__header .section-header h2,
.archive-cards__title {
  align-items: center;
}

.archive-cards__content {
  max-width: 800px;
  margin: 12px auto 0;
}

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* grid */

.archive-cards__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}

.archive-cards__empty {
  text-align: center;
  padding: 40px 0;
}

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* card entrance — JS parks each card at .is-pending, then flips it to
   .is-entering with an --enter-i index so a batch cascades 80ms apart.
   (Same grammar as the activity finder block.) */

.archive-cards__grid > article.is-pending {
  opacity: 0;
  transform: translateY(16px);
}

.archive-cards__grid > article.is-entering {
  animation: archive-cards-card-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--enter-i, 0) * 80ms);
}

@keyframes archive-cards-card-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* loading skeletons — cloned from the post type's -skeleton partial while a
   batch is in flight, so the grid holds its shape instead of jumping. */

.archive-cards__skeleton-card {
  pointer-events: none;
}

.archive-cards__skeleton-media,
.archive-cards__skeleton-line {
  background: linear-gradient(
    90deg,
    var(--gray) 0%,
    var(--gray) 35%,
    rgba(255, 255, 255, 0.85) 50%,
    var(--gray) 65%,
    var(--gray) 100%
  );
  background-size: 220% 100%;
  animation: archive-cards-shimmer 1.4s linear infinite;
}

.archive-cards__skeleton-line {
  display: block;
  width: 85%;
  height: 13px;
  margin-bottom: 8px;
  border-radius: 4px;
}

.archive-cards__skeleton-line--title {
  width: 70%;
  height: 20px;
  margin-bottom: 16px;
}

.archive-cards__skeleton-line--short {
  width: 45%;
  margin-bottom: 0;
}

/* Matches a standard .btn (16px/32px padding around 18px text) so the grid
   doesn't jump when the real card lands. */
.archive-cards__skeleton-line--button {
  width: 150px;
  height: 50px;
  margin-bottom: 0;
  border-radius: var(--btn-border-radius-sm);
}

@keyframes archive-cards-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -120% 0;
  }
}

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* infinite scroll loader — the spinner only shows while a fetch is in flight;
   the skeletons above it carry the rest of the loading story. */

.infinite-scroll-loader {
  grid-column: 1 / -1;
  padding: 2rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

.infinite-scroll-loader.disabled {
  display: none;
}

.infinite-scroll-loader .loading {
  visibility: hidden;
  width: 36px;
  height: 36px;
  border: 4px solid var(--gray-lt);
  border-top-color: var(--blue-dk);
  border-radius: 50%;
  animation: archive-cards-spin 0.8s linear infinite;
}

.infinite-scroll-loader.is-loading .loading {
  visibility: visible;
}

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

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* numbered pagination — mirrors the blog archive (.blog-posts ul.pagination) */

.archive-cards__pagination ul.pagination {
  margin: 40px 0 0;
  padding: 0;
  list-style: none;

  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  align-items: center;
}

.archive-cards__pagination li.page-item {
  width: 40px;
  height: 40px;
}

.archive-cards__pagination li.page-item .page-link {
  width: 100%;
  height: 100%;

  border: 2px solid var(--blue-lt);
  border-radius: var(--box-border-radius-sm);

  font-size: 18px;
  font-weight: 600;
  color: var(--blue-dk);
  text-decoration: none;

  padding: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.archive-cards__pagination li.page-item a.page-link:hover {
  background: var(--blue-lt);
  color: var(--white);
}

.archive-cards__pagination li.page-item.active a.page-link {
  background: var(--blue-background-gradient);
  color: var(--white);
}

.archive-cards__pagination li.page-item--ellipsis .page-link {
  border-color: transparent;
}

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* responsive */

@media (max-width: 1000px) {
  .archive-cards__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 680px) {
  .archive-cards__grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .archive-cards__grid > article.is-pending {
    opacity: 1;
    transform: none;
  }

  .archive-cards__grid > article.is-entering,
  .archive-cards__skeleton-media,
  .archive-cards__skeleton-line,
  .infinite-scroll-loader .loading {
    animation: none;
  }
}
