/* catalog.css */

/* =========================
   Category tiles (Home)
   ========================= */

.category-grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  align-items: stretch;
}

.category-grid > * {
  min-width: 0;
}

.category-tile {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transform: translateY(0);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  background: var(--tile-bg);
}

.category-tile:hover,
.category-tile:focus {
  transform: translateY(-6px);
  box-shadow: var(--shadow-hover);
  outline: none;
  z-index: 2;
}

.category-tile:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.08);
  outline-offset: 2px;
}

/* Image: always cover tile without distortion */
.category-tile .category-img {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  object-position: center;
  display: block;
  transform: scale(1);
  transition: transform 0.35s ease;
  will-change: transform;
}

.category-tile:not(.no-image):hover .category-img,
.category-tile:not(.no-image):focus .category-img {
  transform: scale(1.06);
}

/* Overlay for readability when image exists */
.category-tile:not(.no-image)::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to top, var(--overlay-bottom), var(--overlay-top));
  z-index: 1;
}

/* Title: default is bottom-left (for image tiles) */
.category-title {
  position: absolute;
  left: 0.9rem;
  right: 0.9rem;
  bottom: 0.9rem;
  margin: 0;
  z-index: 2;
  font-weight: 700;
  line-height: 1.1;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.65);
  font-size: clamp(1rem, 2.3vw, 1.35rem);

  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

/* No-image tiles: dark background, centered title */
.category-tile.no-image {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  background: var(--tile-bg);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.category-tile.no-image::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(0, 0, 0, 0.0));
}

.category-tile.no-image .category-title {
  position: relative;
  inset: auto;
  text-shadow: none;
  font-size: clamp(1.05rem, 2.4vw, 1.45rem);
}

/* =========================
   Product cards (Category page)
   ========================= */

.product-card {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  background: none;
  color: var(--text);
}

.product-card:hover,
.product-card:focus {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  outline: none;
}

.product-card:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.08);
  outline-offset: 2px;
}

.product-card-img,
.img-placeholder {
  display: block;
  width: 100%;
  height: 190px;
  object-fit: cover;
  object-position: center;
  background: var(--placeholder-bg);
}

.img-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

.product-card .card-body {
  padding: 0.85rem;
}

.product-card .card-title {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  color: var(--text);

  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.product-card .text-muted {
  color: var(--muted) !important;
}

@media (max-width: 576px) {
  .product-card-img,
  .img-placeholder {
    height: 150px;
  }

  .category-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}
