/* ==========================================================================
   PAGE ACCUEIL
   ========================================================================== */

/* ---------------------------------- */
/* 1. SECTION HÉROS
/* ---------------------------------- */

.hero-section {
  position: relative;
  z-index: 20;
  padding-top: var(--space-hero);
  padding-bottom: var(--space-hero);
  overflow: visible;
}

.hero-grid {
  display: grid;
  grid-template-columns: 800px 384px;
  justify-content: space-between;
  align-items: start;
  gap: var(--space-l);
}

/* --- Contenu Texte --- */
.hero-content {
  width: 384px;
}
.hero-content h1 {
  margin-bottom: var(--space-s);
  font-size: 3rem;
  color: var(--clr-text-main);
}
.hero-content p {
  margin-bottom: 40px;
  font-size: 1rem;
  color: var(--clr-text-main);
}

/* --- Image --- */
.hero-image img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-l);
  box-shadow: 0 4px 16px
    color-mix(in srgb, var(--clr-text-soft), transparent 92%);
}

/* --- Formulaire de Recherche (Héros) --- */
.hero-search-form {
  position: relative;
  z-index: 50;
  width: 100%;
}

.hero-search-form input[type="search"] {
  width: 100%;
  height: 56px;
  padding-left: 24px;
  padding-right: 64px;
  font-family: var(--font-sans);
  font-size: 1rem;
  background-color: var(--clr-bg-white);
  border: 1px solid rgba(46, 46, 46, 0.8);
  border-radius: 32px;
  box-shadow: inset 0 2px 8px rgba(28, 28, 28, 0.08);
  transition: border-color 0.2s ease, box-shadow 0.3s ease;
}

.hero-search-form input[type="search"]:focus {
  border-color: var(--clr-text-main);
  box-shadow: inset 0 2px 8px rgba(28, 28, 28, 0.08),
    0 0 0 4px rgba(46, 46, 46, 0.1);
  outline: none;
}

/* Bouton Loupe (Style harmonisé Gold) */
.hero-search-form button {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%) scale(1);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  color: var(--clr-text-main);
  background-color: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease,
    transform 0.2s ease-out;
}

.hero-search-form button:hover {
  background-color: var(--clr-accent-gold);
  color: var(--clr-text-soft);
  transform: translateY(-50%) scale(1.1);
}

.hero-search-form button .lucide {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
}

/* Dropdown */
.hero-search-dropdown {
  position: absolute;
  top: 100%;
  left: 24px;
  right: 24px;
  max-height: 300px;
  margin-top: 8px;
  overflow-y: auto;
  background-color: var(--clr-bg-white);
  border: 1px solid color-mix(in srgb, var(--clr-text-main), transparent 90%);
  border-radius: var(--radius-m);
  box-shadow: 0 8px 24px
    color-mix(in srgb, var(--clr-text-soft), transparent 85%);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
}

.hero-search-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.hero-search-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  text-decoration: none;
  border-bottom: 1px solid
    color-mix(in srgb, var(--clr-text-main), transparent 95%);
  transition: background-color 0.2s ease;
}
.hero-search-item:hover {
  background-color: color-mix(in srgb, var(--clr-accent-gold), transparent 92%);
}

.hero-item-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius-s);
  background: #eee;
}
.hero-item-info {
  display: flex;
  flex-direction: column;
}
.hero-item-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--clr-text-main);
}
.hero-item-tag {
  font-size: 0.75rem;
  color: color-mix(in srgb, var(--clr-text-main), transparent 40%);
}

/* --- RESPONSIVE HERO --- */
@media (max-width: 1200px) {
  .hero-grid {
    grid-template-columns: 1fr; /* Une seule colonne */
    gap: 48px;
  }

  .hero-image {
    order: -1; /* L'image passe au-dessus */
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
  }

  .hero-content {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
  }

  .hero-search-form {
    max-width: 500px;
    margin: 0 auto;
  }
}

@media (max-width: 768px) {
  .hero-section {
    padding-top: 40px;
    padding-bottom: 40px;
  }
  .hero-content h1 {
    font-size: 2.25rem;
  }
  .hero-search-form input[type="search"] {
    height: 48px;
    padding-left: 20px;
    font-size: 0.9rem;
  }
  .hero-search-form button {
    width: 36px;
    height: 36px;
  }
}

/* ---------------------------------- */
/* 2. SECTION CARROUSEL
/* ---------------------------------- */

.carousel-section {
  padding-top: var(--space-s);
  padding-bottom: var(--space-xxl);
  overflow: hidden;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-m);
}

.section-header h2 {
  margin-bottom: 0;
  font-size: 2rem;
  color: var(--clr-text-main);
}

.carousel-nav {
  display: flex;
  gap: var(--space-s);
}

/* Boutons Flèches (Style harmonisé Gold) */
.carousel-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  color: var(--clr-text-main);
  background-color: transparent;
  border: 1px solid color-mix(in srgb, var(--clr-text-main), transparent 20%);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
}

.carousel-arrow:hover {
  background-color: var(--clr-accent-gold);
  border-color: var(--clr-accent-gold);
  color: var(--clr-text-soft);
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(247, 197, 72, 0.3);
}

.carousel-arrow:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: scale(1);
  background: transparent;
  color: inherit;
  box-shadow: none;
  border-color: #ddd;
}

/* Track */
.carousel-track-container {
  width: 100%; overflow-x: scroll; 
  /* --- SCROLL SNAP MOBILE (AMÉLIORATION) --- */
  scroll-snap-type: x mandatory; 
  -webkit-overflow-scrolling: touch; /* Pour fluidité iOS */
  cursor: grab;
  scrollbar-width: none; -ms-overflow-style: none;
}
.carousel-track-container::-webkit-scrollbar { display: none; }
.carousel-track-container.is-dragging { cursor: grabbing; scroll-behavior: auto; scroll-snap-type: none; /* Désactive le snap quand on drag à la souris */ }

.carousel-track {
  display: flex; flex-wrap: nowrap; align-items: stretch;
  gap: var(--space-l); padding: 40px 0 40px 0; box-sizing: border-box;
}

.carousel-spacer {
  flex-shrink: 0;
  height: 1px;
}

/* Overrides Cartes */
.carousel-track .smart-card, .carousel-track .recipe-card {
  flex-shrink: 0; width: 384px; min-width: 384px; height: 480px; min-height: 0; margin-bottom: 0;
  transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.5s ease;
  
  /* --- SNAP ALIGN --- */
  scroll-snap-align: center; /* La carte se centrera automatiquement à l'arrêt */
}
.carousel-track .smart-card .smart-card-image {
  height: 232px;
}
.recipe-card.faded {
  opacity: 0.48;
}

/* Carte CTA */
.smart-card.cta-card {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--clr-accent-green);
  box-shadow: 0 4px 16px
    color-mix(in srgb, var(--clr-text-soft), transparent 76%);
  text-align: center;
  user-select: none;
  transition: background-color 0.3s ease, box-shadow 0.3s ease,
    transform 0.3s ease;
}
.smart-card.cta-card:hover {
  background-color: color-mix(in srgb, var(--clr-accent-green), black 10%);
  box-shadow: 0 8px 24px
    color-mix(in srgb, var(--clr-text-soft), transparent 68%);
  transform: scale(1.03);
}
.cta-card h3 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--clr-text-inverse);
}

/* Modification pour la carte CTA */
.cta-card h3 span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px; /* Un peu moins d'espace sur mobile */
  white-space: nowrap; /* OBLIGATOIRE : Empêche la flèche de tomber seule */
}

/* --- RESPONSIVE CARROUSEL --- */
@media (max-width: 768px) {
  .section-header h2 {
    font-size: 1.5rem;
  }
  .carousel-nav {
    display: none; /* On cache les flèches sur mobile */
  }

  /* On permet aux cartes d'être plus petites si l'écran est minuscule, mais 300px est un bon standard */
  .carousel-track .smart-card,
  .carousel-track .recipe-card {
    width: 300px;
    min-width: 300px;
    height: 420px;
  }
  .carousel-track .smart-card .smart-card-image {
    height: 180px;
  }
  
  /* Optimisation mobile spécifique pour CTA */
  .cta-card h3 {
    font-size: 1.25rem; /* On réduit un peu la police pour que "populaires + flèche" rentre */
    padding: 0 16px; /* Marge de sécurité pour ne pas toucher les bords */
  }
}

/* ---------------------------------- */
/* 3. SECTION DERNIÈRES RECETTES
/* ---------------------------------- */

.latest-recipes-section {
  margin-top: var(--space-xxl);
  margin-bottom: 80px;
}
.latest-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-m);
}
.latest-header h2 {
  margin-bottom: 0;
  font-size: 2rem;
  color: var(--clr-text-main);
}

.filters-container {
  display: flex;
  gap: var(--space-s);
  margin-bottom: var(--space-m);
  flex-wrap: wrap;
}

.filter-btn {
  height: 32px;
  padding: 0 16px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
}
.filter-btn:not(.active) {
  color: var(--clr-text-main);
  background-color: transparent;
  border: 1px solid color-mix(in srgb, var(--clr-text-main), transparent 20%);
}
.filter-btn:not(.active):hover {
  background-color: rgba(46, 46, 46, 0.05);
  border-color: var(--clr-text-main);
}
.filter-btn.active {
  color: var(--clr-text-inverse);
  background-color: var(--clr-text-main);
  border: 1px solid var(--clr-text-main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.recipes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: max-content; /* Chaque rangée = hauteur naturelle du contenu */
  gap: var(--space-l);
  min-height: 1050px; /* Empêche le footer de remonter */
}

/* --- RESPONSIVE GRID --- */
@media (max-width: 1024px) {
  .recipes-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .latest-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  .latest-header h2 {
    font-size: 1.5rem;
  }
  .latest-header .cta-button {
    align-self: flex-start;
  }

  .recipes-grid {
    grid-template-columns: 1fr;
  }

  .smart-card {
    height: auto;
    min-height: 0;
  }
}
