/*
 * CookinBreak — Design system : carte de recette (ds-recipe) et sa grille (ds-recipes)
 * ------------------------------------------------------------------
 * Une carte = une photo plein cadre. Tout se pose dessus : la note et l'événement en haut à gauche, le cœur en haut à droite,
 * et en bas, sur un dégradé sombre, le régime, le titre et les repères (durée, difficulté). Pas de bloc blanc sous l'image.
 * Toute la carte est cliquable : la photo est un lien qui couvre la carte, et les couches du dessus laissent passer le clic
 * (sauf le titre, le cœur et la pastille de régime).
 *
 * Les pastilles en verre et le dégradé sont posés sur une photo : leurs teintes (blanc, noir translucide) ne dépendent donc
 * pas du thème, c'est voulu. Tout le reste lit les tokens (mode sombre automatique). Les teintes de régime viennent du balisage.
 *
 * Balisage : app/lib/search_view.php (cb_sv_card). Le cœur est animé (rebond + rayons) quand on ajoute un favori :
 * la classe `animating` est posée une fraction de seconde par le JavaScript de la page.
 *
 * Grille : 1 colonne, puis 2, puis 3 (jamais 4 : une publicité toutes les 6 recettes remplit alors des lignes entières).
 */

.ds-recipes {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--ds-space-5);
  margin: 0;
}
@media (min-width: 600px) { .ds-recipes { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--ds-space-6); } }
@media (min-width: 960px) { .ds-recipes { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.ds-recipes__full { grid-column: 1 / -1; min-width: 0; }

/* ------------------------------------------------------------------
 * Carte
 * ------------------------------------------------------------------ */
.ds-recipe {
  --rc-heart: #e8334a; /* cœur des favoris : rouge, quel que soit le thème (posé sur une pastille blanche) */
  position: relative; min-width: 0; aspect-ratio: 5 / 6; overflow: hidden; isolation: isolate;
  background: var(--ds-surface-2); border-radius: var(--ds-radius-lg); box-shadow: var(--ds-shadow-sm);
  transition: transform 300ms var(--ds-ease), box-shadow 300ms var(--ds-ease);
}
@media (max-width: 599px) { .ds-recipe { aspect-ratio: 1 / 1; } }
@media (hover: hover) { .ds-recipe:hover { transform: translateY(-4px); box-shadow: var(--ds-shadow-lg); } }
.ds-recipe:focus-within { box-shadow: var(--ds-focus-ring), var(--ds-shadow-sm); }

.ds-recipe__media { position: absolute; inset: 0; display: block; overflow: hidden; z-index: 0; }
.ds-recipe__media img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 700ms var(--ds-ease); }
@media (hover: hover) { .ds-recipe:hover .ds-recipe__media img { transform: scale(1.06); } }
.ds-recipe__noimg {
  display: flex; align-items: flex-start; justify-content: center; padding-top: 22%; width: 100%; height: 100%; font-size: 2.6rem;
  color: rgba(255, 255, 255, 0.4); background: linear-gradient(150deg, var(--ds-primary), var(--ds-primary-hover));
}

/* Haut : note et événement, en verre */
.ds-recipe__top { position: absolute; top: 14px; left: 14px; z-index: 2; display: flex; flex-wrap: wrap; gap: 6px; max-width: calc(100% - 72px); pointer-events: none; }
.ds-recipe__rating, .ds-recipe__event {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: var(--ds-radius-pill);
  font-size: var(--ds-text-sm); font-weight: 600; line-height: 1.2; white-space: nowrap;
}
.ds-recipe__rating { background: rgba(18, 22, 24, 0.5); color: #fff; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.ds-recipe__rating .cb-icon { color: #ffb4a0; font-size: 0.85rem; }
.ds-recipe__event { background: rgba(255, 255, 255, 0.94); }

/* Bas : dégradé, puis régime, titre, repères */
.ds-recipe__info {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  padding: 80px var(--ds-space-5) var(--ds-space-5); color: #fff; pointer-events: none;
  background: linear-gradient(to top, rgba(10, 16, 18, 0.9) 0%, rgba(10, 16, 18, 0.66) 48%, rgba(10, 16, 18, 0) 100%);
}
.ds-recipe__title {
  margin: 0; width: 100%; font-family: var(--ds-font-display); font-size: 1.1rem; font-weight: 500; line-height: 1.3; color: #fff;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}
/* La feuille globale pose `* { font-family: Poppins }` : sans cette ligne, le lien garde Poppins au lieu d'hériter du titre */
.ds-recipe__title a { font-family: var(--ds-font-display); color: inherit; text-decoration: none; pointer-events: auto; }
.ds-recipe__title a:focus-visible { outline: none; }
.ds-recipe__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--ds-space-5); margin: 0; color: rgba(255, 255, 255, 0.9); font-size: var(--ds-text-base); font-weight: 500; }
.ds-recipe__meta span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.ds-recipe__meta .cb-icon { font-size: 1rem; opacity: 0.85; }
/* Difficulté : trois barres de hauteur croissante, autant d'allumées que le niveau (1 facile, 2 moyen, 3 difficile) */
.ds-recipe__meta .ds-recipe__level { display: inline-flex; align-items: flex-end; gap: 3px; height: 14px; }
.ds-recipe__level b { display: block; width: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.35); }
.ds-recipe__level b:nth-child(1) { height: 5px; }
.ds-recipe__level b:nth-child(2) { height: 9px; }
.ds-recipe__level b:nth-child(3) { height: 14px; }
.ds-recipe__level[data-level="1"] b:nth-child(-n+1),
.ds-recipe__level[data-level="2"] b:nth-child(-n+2),
.ds-recipe__level[data-level="3"] b { background: #fff; }

/* Régime : pastille colorée, « +N » avec la liste au survol (ou au toucher) */
.ds-recipe__tags { position: relative; z-index: 3; display: flex; max-width: 100%; pointer-events: auto; }
.ds-recipe__tag {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px; border-radius: var(--ds-radius-pill);
  font-size: var(--ds-text-sm); font-weight: 600; line-height: 1.2; white-space: nowrap;
}
.ds-recipe__tag-group { position: relative; cursor: pointer; }
.ds-recipe__more {
  position: absolute; left: 0; bottom: calc(100% + 8px); display: flex; flex-direction: column; gap: 8px; min-width: 150px; padding: 10px 12px;
  background: var(--ds-surface); border: 1px solid var(--ds-border); border-radius: var(--ds-radius-sm); box-shadow: var(--ds-shadow-md);
  opacity: 0; visibility: hidden; transform: translateY(4px); transition: opacity 160ms var(--ds-ease), transform 160ms var(--ds-ease), visibility 160ms;
}
.ds-recipe__more div { display: flex; align-items: center; gap: 8px; font-size: var(--ds-text-sm); font-weight: 600; white-space: nowrap; }
.ds-recipe__tag-group.active .ds-recipe__more { opacity: 1; visibility: visible; transform: none; }
@media (hover: hover) { .ds-recipe__tag-group:hover .ds-recipe__more { opacity: 1; visibility: visible; transform: none; } }

/* ------------------------------------------------------------------
 * Cœur des favoris : rebond et rayons à l'ajout
 * ------------------------------------------------------------------ */
.ds-recipe__fav {
  position: absolute; top: 12px; right: 12px; z-index: 4; display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; padding: 0; border: 0; border-radius: 50%; cursor: pointer; font-size: 1.3rem;
  background: rgba(255, 255, 255, 0.5); color: #3d4649; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14); /* verre posé sur la photo : la pastille laisse voir l'image */
  transition: transform 200ms var(--ds-ease), color 200ms var(--ds-ease);
}
.ds-recipe__fav .cb-icon { position: relative; z-index: 2; pointer-events: none; }
/* Deux cœurs superposés dans le bouton : contour, puis plein une fois la recette enregistrée */
.ds-recipe__heart--on { display: none; }
.ds-recipe__fav.active .ds-recipe__heart { display: none; }
.ds-recipe__fav.active .ds-recipe__heart--on { display: block; }
@media (hover: hover) { .ds-recipe__fav:hover { color: var(--rc-heart); transform: scale(1.08); } }
.ds-recipe__fav:focus-visible { outline: none; box-shadow: var(--ds-focus-ring); }
.ds-recipe__fav.active { color: var(--rc-heart); }
.ds-recipe__fav.animating .cb-icon { animation: ds-heart-bounce 500ms cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.ds-recipe__fav.animating::after {
  content: ""; position: absolute; top: 50%; left: 50%; z-index: 1; width: 150%; height: 150%; border-radius: 50%; opacity: 0; pointer-events: none;
  transform: translate(-50%, -50%);
  background: repeating-conic-gradient(var(--rc-heart) 0deg 3deg, transparent 3deg 30deg);
  -webkit-mask: radial-gradient(circle, transparent 58%, #000 60%); mask: radial-gradient(circle, transparent 58%, #000 60%);
  animation: ds-heart-rays 560ms ease-out forwards;
}
@keyframes ds-heart-bounce { 0% { transform: scale(1); } 50% { transform: scale(1.45); } 100% { transform: scale(1); } }
@keyframes ds-heart-rays { 0% { opacity: 1; transform: translate(-50%, -50%) scale(0.45); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); } }

/* ------------------------------------------------------------------
 * Publicité entre les cartes : un encart pleine largeur, étiqueté, qui disparaît s'il reste vide
 * (la classe cookinbreak-ads-2 est celle que head.php retire pour les membres sans publicité)
 * ------------------------------------------------------------------ */
.ds-recipes__ad.cookinbreak-ads-2 {
  display: flex; flex-direction: column; align-items: stretch; gap: var(--ds-space-2); grid-column: 1 / -1; min-width: 0; margin: var(--ds-space-2) 0; padding: var(--ds-space-3) var(--ds-space-4) var(--ds-space-4);
  background: var(--ds-surface); border: 1px dashed var(--ds-border-strong); border-radius: var(--ds-radius-lg); overflow: hidden;
}
.ds-recipes__adlabel { text-align: center; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ds-text-3); }
.ds-recipes__ad .ads-show-cbn { width: 100%; max-width: 100%; min-height: 100px; }
.ds-recipes__ad ins.adsbygoogle { width: 100%; }
.ds-recipes__ad[hidden], .ds-recipes__ad:has(ins[data-ad-status="unfilled"]) { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .ds-recipe, .ds-recipe__media img, .ds-recipe__fav { transition: none; }
  .ds-recipe:hover { transform: none; }
  .ds-recipe__fav.animating .cb-icon, .ds-recipe__fav.animating::after { animation: none; }
}
