/* Safe baseline */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* 1) Section wrapper: spacing only (generic) */
.grid-section {
  width: 100%;
  padding: 0 0 32px;
}

.card-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  justify-content: center;
  align-items: start;
}

/* 3) Tile/card */
.pack-item {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  /* Important: do not fight the grid sizing */
  width: 100%;
  max-width: 100%;
  margin: 0;
  text-align: left;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.pack-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

/* 4) Image — reserve 2.5×3.5 trading-card space before the file loads (CLS) */
.pack-item a,
.card-item a {
  width: 100%;
  display: block;
}

.pack-item-top img {
  width: 100%;
  height: auto;
  aspect-ratio: 2.5 / 3.5;
  object-fit: contain;
  display: block;
  border-radius: 0;
  background-color: #ededed;
}

.card-image-section {
  position: relative;
  width: 100%;
  aspect-ratio: 2.5 / 3.5;
  background-color: #ededed;
  overflow: hidden;
  flex-shrink: 0;
}

.card-image-section .card-link {
  position: absolute;
  inset: 0;
}

.card-image-section img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 0;
}

.pack-item-bottom {
  width: 100%;
  padding: 0px 10px 10px 10px;
}

.pack-item-top {
  width: 100%;
  background: #ededed;
  padding: 10px 10px 10px 10px;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.pack-item-top {
  position: relative;
}

.pack-price-tag {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;

  padding: 4px 10px;
  border-radius: var(--radius-full);

  background: #111827;
  color: #fff;

  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  line-height: 1;
}

.card-item {
  background: transparent;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  margin: 0;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

/* =========================
   Badge / Chip (shared base)
   ========================= */
.badge,
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  padding: 4px 10px;
  border-radius: 10px;

  font-size: 12px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;

  border: 1px solid transparent;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* Row when multiple badges/chips are shown together */
.badge-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge--grail {
  background: linear-gradient(135deg, #ffeaa7, #fdcb6e);
  color: #7d6608;
  border: 1px solid #ffd700;
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
}

.card-supply-numbered {
  color: #ffd700;
}

.badge--chase {
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  color: #1e40af;
}

.badge--rare {
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
  color: #ffffff;
}

.badge--base {
  background: #e5e7eb;
  color: #6b7280;
  border-color: #d1d5db;
}

.card-link {
  position: relative;
  display: block;
}

.card-rarity {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
}

.pack-meta {
  margin-top: 8px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #6b7280;
  /* no padding-right */
}
.pack-set-count {
  /* no margin-right */
}

.grid-pack-price {
  font-size: 0.8rem;
  color: #6b7280;
}

.pack-meta-right {
  font-size: 0.8rem;
  color: #6b7280;
}

.drop-series {
  font-weight: 500;
  font-size: 0.85em;
  color: #6b7280;
}

.card-meta {
  margin-top: 6px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #6b7280;
}

.card-meta-left {
  font-weight: 500;
}

.card-title-row,
.pack-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
}

.card-title,
.pack-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #333;
  overflow-wrap: anywhere;
  margin: 0;
}

.card-supply {
  white-space: nowrap;
  font-size: 0.75rem;
  color: #6b7280;
  flex-shrink: 0;
  margin: 0;
}

.card-linked-pack img {
  width: 25px;
}

.card-linked-pack {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  padding-left: 2px;
  width: 100%;
  box-sizing: border-box;
}

.card-linked-pack::before {
  content: "";
  position: absolute;
  top: 0;
  left: 2px;
  right: 2px;
  height: 1px;
  background: #e5e7eb;
}

.card-linked-pack a,
.card-linked-pack a:visited {
  width: auto;
  display: flex;
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.8rem;
}

.card-content-section {
  padding: 0px 8px 10px 8px;
  width: 100%;
  border: 1px solid #e5e7eb;
  border-radius: 0 0 16px 16px;
  transition:
    box-shadow 0.2s ease,
    border-color 0.2s ease;
}

.card-item:hover .card-content-section {
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
  border-color: #d1d5db;
}
.card-image-section,
.card-content-section {
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.card-item:hover .card-image-section,
.card-item:hover .card-content-section {
  transform: translateY(-4px);
}

.card-item:hover .card-content-section {
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
  border-color: #d1d5db;
}

.pack-set-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: #6b7280;
}
.pack-set-count svg {
  width: 14px;
  height: 14px;
  opacity: 0.7;
}

.pack-item-top {
  position: relative;
}
.pack-stack-badge {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #3b82f6;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
  z-index: 3;
  padding-bottom: 2px;
}

/* Tablet */
@media (max-width: 900px) {
  .grid-section {
    padding: 0 0 24px;
  }
}
@media (max-width: 900px) {
  .card-grid {
    /* auto-fill keeps empty tracks so a single tile cannot stretch to full width */
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
  }
}

@media (max-width: 768px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .pack-item {
    width: 100%;
    max-width: 100%;
  }
  .pack-title,
  .card-title {
    font-size: 0.85rem;
  }

  .pack-grid-title,
  .card-grid-title {
    font-size: 0.8rem !important;
  }
}

@media (max-width: 600px) {
  .grid-section-header h2 {
    font-size: 1rem;
    line-height: 1.2;
    margin: 0;
  }
}

/* smaller badges in feed items */
.feed-item .badge {
  font-size: 11px;
  padding: 3px 8px;
  gap: 4px;
}

@media (max-width: 768px) {
  .feed-item .badge {
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 8px;
  }
}
