/* ==========================================================================
   ASUNA PARFUMERIE — Section « Nos catégories »
   Dépend de tokens.css et section.css. Aucun JavaScript nécessaire.
   >= 1200px    : 5 cartes sur une ligne
   768–1199px   : grille 3 + 2 (les deux dernières cartes s'élargissent pour remplir la ligne)
   < 768px      : 4 cartes sur une ligne + la 5e seule en bandeau pleine largeur
   ========================================================================== */

.categories__list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(14px, 1.4vw, 20px);
  max-width: var(--section-max);
  margin: clamp(18px, 1.6vw, 24px) auto 0;
  padding: 0 var(--section-pad-x);
  list-style: none;
}

.cat-card {
  position: relative;
  display: block;
  aspect-ratio: 5 / 4;
  max-width: 100%;
  overflow: hidden;
  border-radius: 16px;
  background: var(--asuna-night);
  color: var(--asuna-white);
  text-decoration: none;
  isolation: isolate;
}

.cat-card__media {
  position: absolute;
  inset: 0;
  z-index: -1;
}

.cat-card__media img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: var(--cat-pos, 50% 50%);
  transition: transform 0.9s var(--asuna-ease);
}

/* Voile chocolat concentré en bas : lisibilité du titre sans éteindre la couleur des produits */
.cat-card__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(39, 19, 13, 0.82) 0%,
    rgba(39, 19, 13, 0.46) 30%,
    rgba(39, 19, 13, 0.08) 58%,
    rgba(39, 19, 13, 0) 72%
  );
}

.cat-card__footer {
  position: absolute;
  right: 16px;
  bottom: 14px;
  left: 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.cat-card__title {
  margin: 0;
  color: var(--asuna-white);
  font-family: var(--asuna-font-display);
  font-size: clamp(18px, 1.45vw, 22px);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: 0.005em;
  text-wrap: balance;
  text-shadow: 0 1px 12px rgba(28, 13, 5, 0.25);
}

.cat-card__arrow {
  flex: none;
  width: 16px;
  height: 16px;
  margin-bottom: 3px;
  transition: transform 0.35s var(--asuna-ease);
}

.cat-card:hover .cat-card__media img {
  transform: scale(1.04);
}

.cat-card:hover .cat-card__arrow {
  transform: translateX(4px);
}

.cat-card:focus-visible {
  outline: 2px solid var(--asuna-champagne);
  outline-offset: 3px;
}

/* --------------------------------------------------------------------------
   Tablette : 3 + 2
   -------------------------------------------------------------------------- */
@media (max-width: 1199.98px) {
  .categories__list {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .categories__item {
    grid-column: span 2;
  }

  .categories__item:nth-child(4),
  .categories__item:nth-child(5) {
    grid-column: span 3;
  }

  .categories__item:nth-child(4) .cat-card,
  .categories__item:nth-child(5) .cat-card {
    aspect-ratio: 16 / 9;
  }

  .cat-card__title {
    font-size: 21px;
  }
}

/* --------------------------------------------------------------------------
   Mobile : toutes les catégories visibles
   -------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
  /* Les 4 premières catégories sur une ligne, la 5e seule en bandeau pleine largeur */
  .categories__list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .categories__item,
  .categories__item:nth-child(4) {
    grid-column: span 1;
  }

  .categories__item:nth-child(5) {
    grid-column: 1 / -1;
  }

  .categories__item .cat-card,
  .categories__item:nth-child(4) .cat-card {
    aspect-ratio: 4 / 5;
  }

  .categories__item:nth-child(5) .cat-card {
    aspect-ratio: 2.1 / 1;
    --cat-pos: 50% 58%;
  }

  .cat-card {
    border-radius: 12px;
  }

  .cat-card__media::after {
    background: linear-gradient(
      to top,
      rgba(39, 19, 13, 0.86) 0%,
      rgba(39, 19, 13, 0.5) 34%,
      rgba(39, 19, 13, 0) 64%
    );
  }

  .cat-card__footer {
    right: 7px;
    bottom: 8px;
    left: 8px;
  }

  .cat-card__title {
    font-size: clamp(11px, 3.1vw, 14px);
    line-height: 1.12;
  }

  /* Petites cartes : le titre prend toute la largeur, la flèche n'apparaît que sur le bandeau */
  .categories__item:not(:nth-child(5)) .cat-card__arrow {
    display: none;
  }

  .categories__item:nth-child(5) .cat-card__footer {
    right: 14px;
    bottom: 12px;
    left: 14px;
  }

  .categories__item:nth-child(5) .cat-card__title {
    font-size: clamp(17px, 4.8vw, 21px);
  }

  .cat-card__arrow {
    width: 14px;
    height: 14px;
    margin-bottom: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cat-card__media img,
  .cat-card__arrow {
    transition: none;
  }

  .cat-card:hover .cat-card__media img {
    transform: none;
  }
}
