/**
 * Catalog archive (posts listing): grid cards, excerpt preview.
 */

/* Full width inside wide (1160px) alignment */
.booklex-catalog-archive.alignwide {
  width: 100%;
  max-width: var(--wp--style--global--wide-size, 1160px);
  margin-left: auto !important;
  margin-right: auto !important;
}

.booklex-catalog-archive .wp-block-query {
  width: 100%;
  max-width: 100%;
}

.booklex-catalog-archive .wp-block-query-pagination {
  margin-top: 2.5rem;
}

/* Title → grid spacing */
.booklex-catalog-archive > * + * {
  margin-top: 2rem;
}

.booklex-catalog-archive > .wp-block-heading,
.booklex-catalog-archive > .wp-block-query-title {
  max-width: 100%;
  margin-bottom: 0;
}

.booklex-catalog-archive .wp-block-post-template,
.booklex-catalog-archive ul.wp-block-post-template {
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
  padding: 0;
  list-style: none;
}

/* Grid */
.booklex-catalog-archive .booklex-post-template-grid.is-layout-grid {
  display: grid;
  width: 100%;
  gap: clamp(1.25rem, 3vw, 1.75rem);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
}

/* Card shell */
.booklex-post-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  border-radius: 18px;
  background: var(--wp--preset--color--surface);
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 12px 40px rgba(0, 0, 0, 0.35);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease;
}

.booklex-post-card:hover {
  transform: translateY(-3px);
  border-color: rgba(212, 96, 60, 0.35);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 16px 48px rgba(0, 0, 0, 0.45);
}

/*
 * Media area — do NOT position:absolute the img: WP wraps img in <a> and sets
 * width/height on the figure; absolute img collapses the link and hides the image.
 */
.booklex-post-card .wp-block-post-featured-image {
  flex-shrink: 0;
  width: 100%;
  margin: 0;
  align-self: stretch;
  overflow: hidden;
  border-radius: 18px 18px 0 0;
  background: linear-gradient(145deg, rgba(212, 96, 60, 0.1), rgba(28, 25, 23, 0.88));
  line-height: 0;
}

.booklex-post-card .wp-block-post-featured-image figure {
  margin: 0;
  width: 100%;
}

.booklex-post-card .wp-block-post-featured-image a {
  display: block;
  width: 100%;
  overflow: hidden;
}

.booklex-post-card .wp-block-post-featured-image img {
  display: block;
  width: 100%;
  max-width: 100%;
  vertical-align: middle;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.booklex-post-card:hover .wp-block-post-featured-image img {
  transform: scale(1.03);
}

/* Text block — generous inner padding */
.booklex-post-card .booklex-post-card__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  min-height: 0;
  padding: 1.35rem 1.4rem 1.5rem;
}

.booklex-post-card .wp-block-post-title {
  margin: 0;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.booklex-post-card .wp-block-post-title a {
  text-decoration: none;
  color: var(--wp--preset--color--text);
}

.booklex-post-card .wp-block-post-title a:hover {
  color: var(--wp--preset--color--accent);
}

.booklex-post-card .wp-block-post-excerpt {
  margin: 0;
  flex: 1;
}

.booklex-post-card .wp-block-post-excerpt__excerpt,
.booklex-post-card .wp-block-post-excerpt p {
  margin: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  line-height: 1.55;
  font-size: 0.95rem;
  color: var(--wp--preset--color--muted);
}

.booklex-post-card .wp-block-read-more {
  display: none;
}

/* Empty media placeholder */
.booklex-post-card .wp-block-post-featured-image:not(:has(img)) {
  min-height: 11rem;
}

@media (max-width: 1024px) {
  .booklex-catalog-archive .booklex-post-template-grid.is-layout-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .booklex-catalog-archive .booklex-post-template-grid.is-layout-grid {
    grid-template-columns: 1fr;
  }

  .booklex-post-card .booklex-post-card__body {
    padding: 1.2rem 1.25rem 1.35rem;
  }
}
