/* 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;
}

.app-card-grid .card,
.similar-app-card-wrapper .card {
  isolation: isolate;
}

/* 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. The
   cards state that size as width and height attributes so the box is
   reserved before the file arrives; `height: auto` keeps the attribute
   from fixing the height, which would override the aspect-ratio. */
.app-card-grid .card-img-top {
  width: 100%;
  height: auto;
  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-wrap {
  position: relative;
  border-radius: 0.375rem;
  overflow: hidden;
}

.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 on the WRAPPER so it stays visible when the img has opacity: 0. */
.app-preview-panel.is-loading .app-preview-panel-img-wrap {
  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;
}

.app-preview-panel.is-loading .app-preview-panel-img {
  opacity: 0;
}

@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;
}

/* ------------------------------------------------------------------ *
 * Similar Apps Carousel (app-details.html)
 * ------------------------------------------------------------------ */

.similar-apps-section {
  margin-top: 2.5rem;
  margin-bottom: 0.5rem;
}

.similar-apps-carousel-wrapper {
  position: relative;
  width: 100%;
}

.similar-apps-fade {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50px;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.similar-apps-fade-left {
  left: 0;
  background: linear-gradient(to right, #ffffff 15%, rgba(255, 255, 255, 0));
}

.similar-apps-fade-right {
  right: 0;
  background: linear-gradient(to left, #ffffff 15%, rgba(255, 255, 255, 0));
}

.similar-apps-fade.is-visible {
  opacity: 1;
}

.similar-apps-track {
  display: flex;
  gap: 1.25rem;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0.5rem 0.25rem 1.25rem 0.25rem;
}

.similar-apps-track::-webkit-scrollbar {
  display: none;
}

.similar-app-card-wrapper {
  flex: 0 0 260px;
  min-width: 260px;
  max-width: 260px;
}

.similar-app-card-wrapper .card-img-top {
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;
  object-fit: cover;
}

@media (max-width: 576px) {
  .similar-app-card-wrapper {
    flex: 0 0 220px;
    min-width: 220px;
    max-width: 220px;
  }
}

/* Similar Apps Carousel Navigation Arrows */
.similar-apps-arrow-btn {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  min-height: 34px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 0.875rem !important;
  line-height: 1 !important;
  border-radius: 50% !important;
  transition: all 0.2s ease;
}

.similar-apps-arrow-btn i {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 1em !important;
  height: 1em !important;
  line-height: 1 !important;
  margin: 0 !important;
  padding: 0 !important;
}

.similar-apps-arrow-btn i::before {
  display: block !important;
  line-height: 1 !important;
  vertical-align: 0 !important;
}

.similar-apps-arrow-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.similar-skeleton-thumb {
  width: 100%;
  aspect-ratio: 2 / 1;
  background: linear-gradient(90deg, #f0f2f5 25%, #e4e7ec 50%, #f0f2f5 75%);
  background-size: 200% 100%;
  animation: app-preview-shimmer 1.2s linear infinite;
  border-top-left-radius: 0.375rem;
  border-top-right-radius: 0.375rem;
}

.similar-skeleton-title {
  height: 18px;
  width: 65%;
  border-radius: 4px;
  background: linear-gradient(90deg, #f0f2f5 25%, #e4e7ec 50%, #f0f2f5 75%);
  background-size: 200% 100%;
  animation: app-preview-shimmer 1.2s linear infinite;
}

.similar-skeleton-text {
  height: 12px;
  width: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #f0f2f5 25%, #e4e7ec 50%, #f0f2f5 75%);
  background-size: 200% 100%;
  animation: app-preview-shimmer 1.2s linear infinite;
}

.similar-skeleton-btn {
  height: 31px;
  width: 65px;
  border-radius: 4px;
  background: linear-gradient(90deg, #f0f2f5 25%, #e4e7ec 50%, #f0f2f5 75%);
  background-size: 200% 100%;
  animation: app-preview-shimmer 1.2s linear infinite;
}

