/* Styles for the app card grid (responsive CSS Grid layout, hover preview,
   infinite scroll) driven by templates/app-card-grid.html and
   static/js/app-grid.js. Loaded by browse-index.html, results.html, and
   dashboard.html after the vendor theme stylesheet. */

/* Responsive card grid: cards are direct children (no row wrappers).
   auto-fill + minmax yields 5 columns at the 1920px shell cap, ~4 at
   1440, 3 at 1280, 2 on tablets, and 1 on phones with no breakpoint
   table to maintain. */
.app-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.75rem 1rem;
}

/* Uniform thumbnails: generated thumbnails are natively 2:1 (400x200),
   so aspect-ratio pins every card image to the same height per column
   width; object-fit covers any legacy deviant without distortion. */
.app-card-grid .card-img-top {
  width: 100%;
  aspect-ratio: 2 / 1;
  object-fit: cover;
}

.app-preview-panel {
  position: fixed;
  z-index: 1080;
  width: 480px;
  max-width: calc(100vw - 24px);
  padding: 0.5rem;
  background-color: #fff;
  border: 1px solid rgba(33, 50, 91, 0.125);
  border-radius: 0.5rem;
  box-shadow: 0 0.6rem 1.5rem rgba(140, 152, 164, 0.3);
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  transition: opacity 0.15s ease-out, transform 0.15s ease-out;
  pointer-events: none;
  display: none;
}

.app-preview-panel.is-open {
  display: block;
}

.app-preview-panel.is-visible {
  opacity: 1;
  transform: none;
}

.app-preview-panel-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0.375rem;
}

.app-preview-panel-caption {
  margin: 0.5rem 0.25rem 0.25rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #1e2022;
  text-align: center;
}

/* Shimmer placeholder while the full preview image is loading. */
.app-preview-panel.is-loading .app-preview-panel-img {
  min-height: 240px;
  background: linear-gradient(90deg, #f0f2f5 25%, #e4e7ec 50%, #f0f2f5 75%);
  background-size: 200% 100%;
  animation: app-preview-shimmer 1.2s linear infinite;
}

@keyframes app-preview-shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

/* Infinite-scroll sentinel row (spinner / retry button live here). */
.app-grid-sentinel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 1px;
  padding: 1rem 0 2rem;
}

/* Favorite heart chip on grid cards: circular button overlaid on the
   top-right corner of the thumbnail (the .card parent is position:
   relative). Icon swap + fill color come from the shared
   .app-favorite-toggle rules in site.css. */
.app-favorite-chip {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  font-size: 1rem;
  color: #677788;
  background-color: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(33, 50, 91, 0.1);
  border-radius: 50%;
  box-shadow: 0 0.1875rem 0.75rem rgba(33, 50, 91, 0.12);
  transition: color 0.15s ease-out, transform 0.15s ease-out, box-shadow 0.15s ease-out;
}

.app-favorite-chip:hover,
.app-favorite-chip:focus-visible {
  color: #ed4c78;
  transform: scale(1.08);
  box-shadow: 0 0.375rem 1rem rgba(33, 50, 91, 0.18);
}

/* Greyed "no longer available" favorite card (dashboard only): the card
   content is dimmed and non-interactive, but the heart chip stays fully
   opaque and clickable so the favorite can still be removed. */
.app-card-unavailable {
  background-color: #f8fafd;
}

.app-card-unavailable .card-img-top,
.app-card-unavailable .card-body {
  opacity: 0.55;
}
