/* Preview V2 uniquement : grille de cartes cliquables + fiche recette + mode cuisine (2 dialogs dédiés,
   indépendants de la modale globale #modal). Ne touche à aucun style existant. */

/* Verrouillage de scroll dédié aux dialogs V2 (fiche recette + mode cuisine) : position: fixed
   plutôt que overflow: hidden, car sur ce document overflow: hidden sur body se propage au
   viewport et réinitialise window.scrollY à 0 instantanément (perte de la position d'origine). */
body.v2-scroll-lock { position: fixed; left: 0; right: 0; width: 100%; }

.v2-devnotice { background: #3a2a12; border-color: #7a5a1f; }
.v2-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 14px; }

.v2-card { display: flex; flex-direction: column; width: 100%; height: 100%; text-align: left; background: linear-gradient(145deg, var(--card2), var(--card)); border: 1px solid #ffffff0d; border-radius: var(--radius); padding: 0; overflow: hidden; cursor: pointer; box-shadow: 0 10px 30px #0002; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.v2-card:hover { transform: translateY(-3px); box-shadow: 0 16px 36px #0004; border-color: #ffffff1f; }
.v2-card:active { transform: translateY(-1px) scale(.99); }
.v2-card:focus-visible { outline: 3px solid var(--focus, #9bc0ff); outline-offset: 2px; }
.v2-card-media { aspect-ratio: 3/2; background: #1b2230; overflow: hidden; }
.v2-card-media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.v2-card-body { display: flex; flex: 1; flex-direction: column; padding: 13px 15px 16px; }
.v2-card-badges, .v2-modal-badges { justify-content: flex-start; align-items: center; gap: 8px; }
.v2-category { border: 1px solid transparent; font-weight: 700; }
.v2-category-breakfast { border-color: #d99b3d66; background: #4b351b; color: #ffd892; }
.v2-category-lunch { border-color: #57b98a66; background: #193d30; color: #9aebc1; }
.v2-category-dinner { border-color: #8585d966; background: #292b50; color: #c6c8ff; }
.v2-category-snack { border-color: #c778b566; background: #45253e; color: #f0b6df; }
.v2-category-dessert { border-color: #d7796766; background: #4b2925; color: #ffc0ad; }
.v2-tag { border: 1px solid #ffffff12; background: #283143; color: #d5dcea; }
.v2-card-body h3 { display: -webkit-box; min-height: 42.5px; margin: 6px 0 10px; overflow: hidden; font-size: 17px; line-height: 1.25; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
.v2-card-body .macro-strip { margin-top: auto; gap: 9px; }
.v2-card-body .macro { padding-block: 10px; }
.v2-card-body .macro small { color: #aeb8c8; font-size: 11px; }

/* Fiche recette + mode cuisine : dialogs dédiés, plus larges que la modale générique de l'app. */
/* position: fixed + inset: 0 + margin: auto ancre la fiche recette et le mode cuisine au
   viewport de façon explicite, sans dépendre de l'algorithme de centrage interne du navigateur
   pour <dialog> (qui, sur ce document, utilise position: absolute et se recalcule au scroll). */
#v2-recipe-modal, #v2-cook-modal { position: fixed; inset: 0; margin: auto; width: min(94vw, 1000px); max-width: 1000px; max-height: 90vh; padding: 0; border: 1px solid var(--line); border-radius: 22px; background: #171c27; color: var(--text); overflow: hidden; }
#v2-recipe-modal { border-width: 2px; border-color: #eef3ff52; box-shadow: 0 28px 76px #000a, 0 0 0 1px #ffffff12, 0 0 42px #eef4ff20; }
#v2-cook-modal { border-width: 2px; border-color: #eef3ff4a; box-shadow: 0 28px 76px #000a, 0 0 0 1px #ffffff10, 0 0 38px #eef4ff1c; }
#v2-recipe-modal::backdrop, #v2-cook-modal::backdrop { background: #000b; backdrop-filter: blur(4px); }
#v2-recipe-content, #v2-cook-content { width: 100%; max-width: 100%; max-height: 90vh; box-sizing: border-box; overflow-y: auto; }

.v2-hero { position: relative; margin: 18px 18px 0; overflow: hidden; border: 2px solid #f4f7ff8c; border-radius: 17px; background: #1b2230; box-shadow: 0 16px 38px #0006, 0 0 22px #f1f5ff20; aspect-ratio: 16/8.8; }
.v2-hero img { display: block; width: 100%; height: 100%; object-fit: cover; }
.v2-hero .modal-close { position: absolute; top: 10px; right: 10px; float: none; margin: 0; }
.v2-modal-body { padding: 18px 22px 24px; }
.v2-title { font-size: clamp(22px, 3.4vw, 30px); line-height: 1.1; margin: 4px 0 12px; }
.v2-modal-body .macro-strip { margin-bottom: 16px; }

.v2-facts { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; }
.v2-fact { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.v2-stepper { display: inline-flex; align-items: center; gap: 10px; background: #111620; border: 1px solid var(--line); border-radius: 12px; padding: 4px 6px; }
.v2-stepper button { min-height: 32px; min-width: 32px; padding: 0; border: 0; border-radius: 9px; background: #232c3c; color: var(--text); font-size: 17px; line-height: 1; }
.v2-stepper button:disabled { opacity: .35; cursor: not-allowed; }
.v2-stepper strong { min-width: 20px; text-align: center; font-size: 15px; color: var(--text); }

.v2-modal-body h3 { font-size: 15px; letter-spacing: .01em; margin: 22px 0 8px; }
.v2-ingredient-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid #ffffff0e; }
.v2-ingredient-list li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 2px; border-bottom: 1px solid #ffffff0e; font-size: 14px; }
.v2-ingredient-list li span:first-child { color: var(--text); }
.v2-qty { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.v2-steps-preview { margin: 0; padding-left: 20px; display: grid; gap: 9px; color: #cdd3de; font-size: 14px; line-height: 1.5; }
.v2-steps-preview li::marker { color: var(--green); font-weight: 700; }

.v2-cta { display: block; width: 100%; margin-top: 22px; font-size: 15px; }

/* Mode cuisine — #v2-cook-content a deux enfants directs : .v2-modal-body (contenu, scrollable) et
   .v2-cook-nav (barre Précédent/Suivant), afin que la barre puisse rester hors du flux qui défile. */
.v2-cook-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.v2-cook-head h3 { flex: 1; margin: 0; font-size: 16px; font-weight: 600; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v2-cook-progress-label { margin: 6px 0 20px; }
.v2-cook-step { background: #111620; border: 1px solid var(--line); border-radius: 18px; padding: 26px 24px; margin-bottom: 18px; min-height: 140px; display: flex; align-items: center; }
.v2-cook-step p { margin: 0; font-size: clamp(18px, 2.6vw, 23px); line-height: 1.45; font-weight: 600; }
.v2-timer-row { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.v2-timer-label { font-variant-numeric: tabular-nums; color: var(--green); font-size: 15px; }
.v2-cook-nav { display: flex; gap: 10px; flex-shrink: 0; background: #171c27; padding: 14px 22px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid #ffffff0e; }
.v2-cook-nav button { flex: 1; }

@media (max-width: 759px) {
  #v2-recipe-modal, #v2-cook-modal { width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }
  #v2-recipe-content { max-height: 100vh; }
  .v2-hero { margin: 12px 12px 0; border-radius: 15px; box-shadow: 0 12px 28px #0006, 0 0 18px #f1f5ff1c; aspect-ratio: 4/3; }
  .v2-modal-body { padding: 16px 16px 90px; }
  .v2-cook-step { padding: 22px 18px; min-height: 160px; }
  .v2-cook-step p { font-size: 20px; }

  /* Le contenu du mode cuisine tient toujours en moins d'un écran (peu de texte par étape) : en position
     sticky classique, la barre Précédent/Suivant resterait collée juste sous le contenu, à mi-écran, au
     lieu du bas de l'écran (sticky ne "voyage" que s'il y a un vrai débordement à combler). Sur mobile,
     #v2-cook-content devient donc une colonne flex pleine hauteur : .v2-modal-body (flex:1, scrollable)
     absorbe tout l'espace restant et repousse mécaniquement .v2-cook-nav en bas de l'écran, quelle que
     soit la longueur du texte de l'étape — sans dépendre du sticky. */
  #v2-cook-content { max-height: 100vh; height: 100%; display: flex; flex-direction: column; overflow: hidden; }
  #v2-cook-content .v2-modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 16px; }
  #v2-cook-content .v2-cook-nav { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
}
