/**
 * Shared book product tiles (homepage, no-results rails, storefront sections).
 */

:root {
  /* Fixed cover slot ≈ typical paperback; tweak one place for the whole grid */
  --home-product-cover-aspect: 5 / 7;
  --home-product-visual-pad: 0.5rem 0.55rem 0.45rem;
}

.products-home-grid {
  display: flex !important;
  flex-wrap: wrap !important;
  margin-left: -8px !important;
  margin-right: -8px !important;
  row-gap: 1rem;
  gap: 0 !important;
}

.products-home-grid > [class*="col-"] {
  padding-left: 8px !important;
  padding-right: 8px !important;
}

@media (max-width: 575.98px) {
  .products-home-grid > .col-6 {
    flex: 0 0 50% !important;
    max-width: 50% !important;
    width: 50% !important;
  }
}

@media (min-width: 768px) and (max-width: 991.98px) {
  .products-home-grid > .col-md-4 {
    flex: 0 0 33.333333% !important;
    max-width: 33.333333% !important;
  }
}

@media (min-width: 576px) and (max-width: 767.98px) {
  .featured-products-section .products-home-grid > .col-sm-4,
  .latest-products-section .products-home-grid > .col-sm-4,
  .recently-viewed-section .products-home-grid > .col-sm-4,
  .related-products-section .products-home-grid > .col-sm-4,
  .more-by-author-section .products-home-grid > .col-sm-4,
  .more-in-series-section .products-home-grid > .col-sm-4 {
    flex: 0 0 33.333333% !important;
    max-width: 33.333333% !important;
    width: 33.333333% !important;
  }
}

@media (min-width: 768px) and (max-width: 991.98px) {
  .featured-products-section .products-home-grid > .col-md-3,
  .latest-products-section .products-home-grid > .col-md-3,
  .recently-viewed-section .products-home-grid > .col-md-3,
  .related-products-section .products-home-grid > .col-md-3,
  .more-by-author-section .products-home-grid > .col-md-3,
  .more-in-series-section .products-home-grid > .col-md-3 {
    flex: 0 0 25% !important;
    max-width: 25% !important;
    width: 25% !important;
  }
}

@media (min-width: 992px) {
  .products-home-grid > .col-lg-3 {
    flex: 0 0 25% !important;
    max-width: 25% !important;
    width: 25% !important;
  }

  .featured-products-section .products-home-grid > .col-lg-2,
  .latest-products-section .products-home-grid > .col-lg-2,
  .recently-viewed-section .products-home-grid > .col-lg-2,
  .related-products-section .products-home-grid > .col-lg-2,
  .more-by-author-section .products-home-grid > .col-lg-2,
  .more-in-series-section .products-home-grid > .col-lg-2 {
    flex: 0 0 16.666667% !important;
    max-width: 16.666667% !important;
    width: 16.666667% !important;
  }

  .products-home-grid .home-product-body {
    padding: 0.6rem 0.7rem 0.8rem;
    gap: 0.3rem;
  }

  .products-home-grid .home-product-name {
    font-size: 0.78rem;
    min-height: 2.35em;
    -webkit-line-clamp: 2;
  }

  .products-home-grid .home-product-author {
    font-size: 0.58rem;
  }

  .products-home-grid .home-product-price {
    font-size: 0.875rem;
  }

  .featured-products-section .products-home-grid .home-product-body,
  .latest-products-section .products-home-grid .home-product-body,
  .recently-viewed-section .products-home-grid .home-product-body,
  .related-products-section .products-home-grid .home-product-body,
  .more-by-author-section .products-home-grid .home-product-body,
  .more-in-series-section .products-home-grid .home-product-body {
    padding: 0.5rem 0.55rem 0.65rem;
    gap: 0.25rem;
  }

  .featured-products-section .products-home-grid .home-product-name,
  .latest-products-section .products-home-grid .home-product-name,
  .recently-viewed-section .products-home-grid .home-product-name,
  .related-products-section .products-home-grid .home-product-name,
  .more-by-author-section .products-home-grid .home-product-name,
  .more-in-series-section .products-home-grid .home-product-name {
    font-size: 0.72rem;
    min-height: 2.3em;
  }

  .featured-products-section .products-home-grid .home-product-author,
  .latest-products-section .products-home-grid .home-product-author,
  .recently-viewed-section .products-home-grid .home-product-author,
  .related-products-section .products-home-grid .home-product-author,
  .more-by-author-section .products-home-grid .home-product-author,
  .more-in-series-section .products-home-grid .home-product-author {
    font-size: 0.55rem;
  }

  .featured-products-section .products-home-grid .home-product-price,
  .latest-products-section .products-home-grid .home-product-price,
  .recently-viewed-section .products-home-grid .home-product-price,
  .related-products-section .products-home-grid .home-product-price,
  .more-by-author-section .products-home-grid .home-product-price,
  .more-in-series-section .products-home-grid .home-product-price {
    font-size: 0.8125rem;
  }

  .featured-products-section .products-home-grid .home-product-arrow,
  .latest-products-section .products-home-grid .home-product-arrow,
  .recently-viewed-section .products-home-grid .home-product-arrow,
  .related-products-section .products-home-grid .home-product-arrow,
  .more-by-author-section .products-home-grid .home-product-arrow,
  .more-in-series-section .products-home-grid .home-product-arrow {
    width: 24px;
    height: 24px;
    font-size: 0.5625rem;
  }
}

.home-product-card-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

article.home-product-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  color: inherit;
  background: #ffffff;
  border: 1px solid #e8edf2;
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 4px 12px rgba(15, 23, 42, 0.04);
  overflow: hidden;
  transition: border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
  height: 100%;
}

a.home-product-visual {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
  width: 100%;
  aspect-ratio: var(--home-product-cover-aspect);
  min-height: 0;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.home-product-title-link {
  color: inherit;
  text-decoration: none;
}

.home-product-title-link:hover {
  color: #0e7490;
}

.storefront-product-rail .home-product-card-shell:hover article.home-product-card,
.featured-products-section .home-product-card-shell:hover article.home-product-card,
.latest-products-section .home-product-card-shell:hover article.home-product-card,
.products-grid-pricecompare .home-product-card-shell:hover article.home-product-card {
  border-color: rgba(23, 162, 184, 0.55);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.1), 0 2px 8px rgba(23, 162, 184, 0.08);
  transform: translateY(-3px);
}

.home-product-card-shell:focus-within article.home-product-card {
  outline: 2px solid var(--color-primary, #17a2b8);
  outline-offset: 2px;
}

.home-product-wishlist {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.92);
  color: #64748b;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.home-product-wishlist:hover,
.home-product-wishlist.active {
  color: #ef4444;
}

.home-product-badge--discount {
  bottom: 6px;
  left: 6px;
  top: auto;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.home-product-price-original {
  font-size: 0.72rem;
  font-weight: 600;
  color: #94a3b8;
  text-decoration: line-through;
}

.home-product-author--links a {
  color: #0d9488;
  text-decoration: none;
}

.home-product-author--links a:hover {
  text-decoration: underline;
}

.home-product-visual {
  position: relative;
  width: 100%;
  aspect-ratio: var(--home-product-cover-aspect);
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
  padding: var(--home-product-visual-pad);
  background: linear-gradient(180deg, #f8fafc 0%, #eef2f6 100%);
  overflow: hidden;
  flex-shrink: 0;
}

.home-product-cover {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-width: 100%;
  margin: 0;
  position: relative;
  z-index: 1;
}

.home-product-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: bottom center;
  padding: 0;
  border-radius: 2px 5px 5px 2px;
  filter: drop-shadow(0 8px 16px rgba(15, 23, 42, 0.14)) drop-shadow(0 2px 4px rgba(15, 23, 42, 0.06));
}

.home-product-badge {
  position: absolute;
  z-index: 2;
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
}

.home-product-badge--new {
  top: 6px;
  left: 6px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
}

.home-product-badge--offers {
  top: 6px;
  right: 6px;
  background: rgba(15, 23, 42, 0.88);
  color: #ffffff;
  backdrop-filter: blur(6px);
}

.home-product-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: linear-gradient(145deg, #f1f5f9, #e2e8f0);
  color: #94a3b8;
  font-size: 1.5rem;
  border-radius: 4px;
  filter: none;
}

.home-product-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 0.75rem 0.85rem 0.9rem;
  gap: 0.35rem;
  border-top: 1px solid #f1f5f9;
  background: #ffffff;
}

.home-product-author,
.home-product-brand {
  font-size: 0.6rem;
  font-weight: 700;
  color: #0d9488;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.home-product-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.35;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.5em;
  transition: color 0.2s ease;
}

.home-product-card-shell:hover .home-product-name,
.home-product-title-link:hover {
  color: #0e7490;
}

.home-product-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.35rem;
  margin-top: auto;
  padding-top: 0.35rem;
}

.home-product-pricing {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.home-product-price-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.2rem 0.35rem;
  line-height: 1.1;
}

.home-product-price-from {
  font-size: 0.625rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: lowercase;
}

.home-product-price {
  font-size: 0.9rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.home-product-price--muted {
  font-size: 0.78rem;
  font-weight: 650;
  color: #64748b;
}

.home-product-extra-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.1rem;
}

.home-product-merchants {
  font-size: 0.6rem;
  font-weight: 600;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-product-time {
  font-size: 0.6rem;
  color: #94a3b8;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.home-product-rating {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.12rem;
  font-size: 0.6875rem;
  color: #64748b;
  line-height: 1;
}

.home-product-rating .fa-star,
.home-product-rating .fa-star-half-alt,
.home-product-rating .far.fa-star {
  display: inline-block;
  flex-shrink: 0;
  font-size: 0.8125rem;
  line-height: 1;
  letter-spacing: 0.02em;
}

.home-product-rating .fa-star,
.home-product-rating .fa-star-half-alt {
  color: #f59e0b;
}

.home-product-rating .far.fa-star {
  color: #cbd5e1;
}

.home-product-rating-count {
  font-size: 0.6875rem;
  font-weight: 600;
  color: #94a3b8;
}

.home-product-arrow {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  color: #94a3b8;
  font-size: 0.625rem;
  flex-shrink: 0;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.home-product-card-shell:hover .home-product-arrow {
  background: #17a2b8;
  color: #ffffff;
  transform: translateX(2px);
}

/* Search result list view — shared card layout */
.products-grid-pricecompare.srm-grid.list-view .home-product-card-shell {
  width: 100%;
}

.products-grid-pricecompare.srm-grid.list-view article.home-product-card {
  flex-direction: row;
  align-items: center;
  gap: 0;
  padding: 0.75rem 1rem;
  min-height: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  transform: none;
}

.products-grid-pricecompare.srm-grid.list-view .home-product-card-shell:hover article.home-product-card {
  transform: none;
  background: #f8fafc;
}

.products-grid-pricecompare.srm-grid.list-view .home-product-visual {
  flex: 0 0 64px;
  width: 64px;
  max-width: 64px;
  aspect-ratio: 3 / 4;
  height: auto;
  min-height: 0;
}

.products-grid-pricecompare.srm-grid.list-view .home-product-cover {
  height: 100%;
}

.products-grid-pricecompare.srm-grid.list-view .home-product-image {
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
}

.products-grid-pricecompare.srm-grid.list-view .home-product-body {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 0 0 0.875rem;
  border-top: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto auto;
  column-gap: 1rem;
  row-gap: 0.2rem;
  align-items: center;
}

.products-grid-pricecompare.srm-grid.list-view .home-product-author {
  grid-column: 1;
  grid-row: 1;
}

.products-grid-pricecompare.srm-grid.list-view .home-product-name {
  grid-column: 1;
  grid-row: 2;
  min-height: 0;
}

.products-grid-pricecompare.srm-grid.list-view .home-product-extra-meta {
  grid-column: 1;
  grid-row: 3;
}

.products-grid-pricecompare.srm-grid.list-view .home-product-footer {
  grid-column: 2;
  grid-row: 1 / span 3;
  align-self: center;
  margin-top: 0;
  padding-left: 0.5rem;
  text-align: right;
}

.products-grid-pricecompare.srm-grid.list-view .home-product-arrow {
  display: none;
}

.products-grid-pricecompare.srm-grid.list-view .home-product-price-row {
  justify-content: flex-end;
}

@media (prefers-reduced-motion: reduce) {
  .featured-products-section .home-product-card-shell:hover article.home-product-card,
  .latest-products-section .home-product-card-shell:hover article.home-product-card,
  .products-grid-pricecompare .home-product-card-shell:hover article.home-product-card,
  .storefront-product-rail .home-product-card-shell:hover article.home-product-card {
    transform: none;
  }
}

@media (max-width: 575.98px) {
  .home-product-body {
    padding: 0.55rem 0.65rem 0.7rem;
  }

  .home-product-name {
    font-size: 0.72rem;
    min-height: 2.35em;
  }

  .home-product-arrow {
    width: 22px;
    height: 22px;
    font-size: 0.55rem;
  }
}