// =============================================================================
// Item Card — reusable card for blocks, pages, presets, etc.
// =============================================================================

@use '../variables' as *;
@use '../mixins' as *;

// Grid container
.item-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;

  @include sm {
    grid-template-columns: repeat(3, 1fr);
  }

  @include md {
    grid-template-columns: repeat(4, 1fr);
  }

  @include lg {
    grid-template-columns: repeat(5, 1fr);
  }

  @include xl {
    grid-template-columns: repeat(6, 1fr);
  }
}

// Card
.item-card {
  display: flex;
  flex-direction: column;
  background: rgb(var(--color-surface-card));
  border: 1px solid rgb(var(--color-border-light));
  border-radius: $radius-lg;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  @include transition-fast(border-color, box-shadow);

  &:hover {
    border-color: $primary-300;
    box-shadow: $shadow-md;
  }

  .dark &:hover {
    border-color: $primary-700;
  }
}

// Thumbnail area
.item-card__thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: $neutral-100;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;

  .dark & {
    background: $neutral-800;
  }
}

.item-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item-card__placeholder {
  color: $neutral-300;
  @include transition-fast(transform, color);

  .item-card:hover & {
    transform: scale(1.15);
    color: $primary-300;
  }

  .dark & {
    color: $neutral-600;
  }

  .dark .item-card:hover & {
    color: $primary-600;
  }
}

// Hover overlay (for actions)
.item-card__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  opacity: 0;
  @include transition-fast(opacity);

  .item-card:hover & {
    opacity: 1;
  }
}

// Body (title + meta)
.item-card__body {
  padding: 0.5rem 0.625rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.item-card__title {
  font-size: $font-size-sm;
  font-weight: $font-weight-medium;
  color: rgb(var(--color-text-primary));
  @include truncate;
}

.item-card__subtitle {
  font-size: $font-size-xs;
  color: rgb(var(--color-text-muted));
  @include truncate;
}

.item-card__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

// Empty state
.item-grid__empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 1rem;
}

.item-grid__empty-icon {
  width: 3rem;
  height: 3rem;
  color: $neutral-300;
  margin: 0 auto 1rem;

  .dark & {
    color: $neutral-600;
  }
}

.item-grid__empty-title {
  font-size: $font-size-base;
  font-weight: $font-weight-medium;
  color: rgb(var(--color-text-primary));
  margin-bottom: 0.5rem;
}

.item-grid__empty-desc {
  font-size: $font-size-sm;
  color: rgb(var(--color-text-muted));
  margin-bottom: 1rem;
}
