/* ── Banque de Recettes — design system Airtable (DESIGN.md) ───────────── */
:root {
  --ink: #181d26;
  --body: #333840;
  --muted: #41454d;
  --hairline: #dddddd;
  --border-strong: #9297a0;
  --canvas: #ffffff;
  --surface-soft: #f8fafc;
  --primary: #181d26;
  --primary-active: #0d1218;
  --on-primary: #ffffff;
  --link: #1b61c9;
  --coral: #aa2d00;
  --forest: #0a2e0e;
  --cream: #f5e9d4;
  --peach: #fcab79;
  --mint: #a8d8c4;
  --yellow: #f4d35e;
  --mustard: #d9a441;
  --radius-card: 14px;
  --radius-input: 8px;
  --shadow-modal: 0 24px 64px rgba(24, 29, 38, 0.18);
  font-family: "Haas Grotesk", system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--canvas);
  color: var(--body);
  font-size: 16px;
  line-height: 1.5;
}

.hidden { display: none !important; }
h1, h2, h3 { color: var(--ink); margin: 0; }

/* ── Boutons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 48px;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  min-height: 48px;
  padding: 12px 24px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}
.btn-primary:hover { background: var(--primary-active); }
.btn-secondary {
  background: var(--canvas);
  color: var(--ink);
  border-color: var(--hairline);
}
.btn-secondary:hover { border-color: var(--border-strong); }
.btn-sm { min-height: 36px; padding: 6px 16px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-icon {
  min-height: 40px;
  width: 40px;
  padding: 0;
  border-radius: 50%;
  background: var(--canvas);
  color: var(--ink);
  border-color: var(--hairline);
}
.btn-icon:hover { border-color: var(--border-strong); }
.btn-danger {
  background: var(--canvas);
  color: var(--coral);
  border-color: var(--hairline);
}
.btn-danger:hover { border-color: var(--coral); }
.confirm-text { color: var(--body); margin: 0 0 16px; }
.detail-modified { font-size: 13px; color: var(--muted); margin: 0 0 8px; }

/* ── Champs ─────────────────────────────────────────────────────────────── */
.field { display: block; margin-bottom: 16px; }
.field span {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 6px;
}
.checkbox-field label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--body);
}
.checkbox-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}
.input, .field input, .field textarea {
  width: 100%;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-input);
  background: var(--canvas);
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  padding: 10px 14px;
  min-height: 44px;
}
.field textarea { resize: vertical; line-height: 1.6; }
.input:focus, .field input:focus, .field textarea:focus {
  outline: none;
  border-color: #458fff;
  box-shadow: 0 0 0 3px rgba(69, 143, 255, 0.25);
}

/* ── Connexion ──────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  padding: 32px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
}
.login-title { font-size: 28px; font-weight: 500; letter-spacing: -0.3px; }
.login-sub { color: var(--muted); margin: 8px 0 24px; }
.login-error {
  color: var(--coral);
  font-size: 14px;
  margin: 0 0 16px;
}

/* ── Barre supérieure ───────────────────────────────────────────────────── */
.topbar {
  border-bottom: 1px solid var(--hairline);
  background: var(--canvas);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { font-size: 18px; font-weight: 500; color: var(--ink); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--forest);
  background: var(--mint);
  border-radius: 48px;
  padding: 6px 14px;
}
.offline-badge {
  display: inline-flex;
  align-items: center;
  background: var(--cream);
  color: var(--ink);
  border: 1px solid var(--mustard);
  border-radius: 9999px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 500;
}

/* ── Conteneur & barre d'outils ─────────────────────────────────────────── */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px 96px;
}
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-input { flex: 1 1 280px; }
.sort-select { flex: 0 0 auto; width: 180px; }

/* ── Filtres et badges de catégories ────────────────────────────────────── */
/* Sobre : réutilise les tokens existants (hairline, surface-soft, muted).
   Pas de couleurs signature en mini-accents : un seul style neutre. */
.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}
.category-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 48px;
  border: 1px solid var(--hairline);
  background: var(--canvas);
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 14px;
  min-height: 32px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.category-pill:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}
.category-pill.active {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}
.category-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
#detail-body > .category-badges,
#public-body > .category-badges {
  margin-top: 6px;
  margin-bottom: 14px;
}
/* Badge unique neutre (style "version-kind"/"comments-head") : pas de
   déclinaison par catégorie pour rester sobre quel que soit leur nombre. */
.category-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--hairline);
  border-radius: 48px;
  padding: 2px 9px;
  line-height: 1.4;
}

.category-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.category-check {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}
.category-check input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  pointer-events: none;
}
.category-check span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  border: 1px solid var(--hairline);
  border-radius: 48px;
  background: var(--canvas);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  padding: 4px 14px;
  min-height: 32px;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.category-check:hover span {
  border-color: var(--border-strong);
  color: var(--ink);
}
/* Sélection douce (pas de noir plein : le CTA "Enregistrer" reste
   l'unique action primaire noire de la modale). */
.category-check input[type="checkbox"]:checked + span {
  background: var(--surface-soft);
  color: var(--ink);
  border-color: var(--ink);
}
.category-check input[type="checkbox"]:focus-visible + span {
  outline: 2px solid #458fff;
  outline-offset: 2px;
}

/* ── Grille de cartes recettes ──────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}
@media (max-width: 1024px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .grid { grid-template-columns: 1fr; } }

.card {
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease;
}
.card:hover { border-color: var(--border-strong); }
.card-banner {
  height: 8px;
  background: var(--surface-soft);
}
/* ── Vignette photo n°1 sur la carte (liste principale) ─────────────────── */
.card-cover {
  position: relative;
  height: 148px;
  background: var(--surface-soft);
  overflow: hidden;
}
.card-cover.no-photo { min-height: 148px; }
.card-cover img {
  display: block;
  width: 100%;
  height: 148px;
  object-fit: cover;
  background: var(--surface-soft);
}
/* Pastilles superposées sur l'image : propriétaire + note/étoiles */
.chip {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 16px);
  background: rgba(24, 29, 38, 0.78);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 999px;
  padding: 6px 10px;
}
.chip-owner { top: 8px; left: 8px; }
.chip-rating { bottom: 8px; left: 8px; }
.chip-rating .stars { gap: 1px; }
.chip-rating .star { font-size: 13px; color: rgba(255, 255, 255, 0.45); }
.chip-rating .star.on { color: var(--yellow); }
.chip-rating-label { overflow: hidden; text-overflow: ellipsis; }
.card-body { padding: 12px 14px; flex: 1; display: flex; flex-direction: column; }
.card-title {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta { font-size: 13px; color: var(--muted); }
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}

.empty { color: var(--muted); text-align: center; padding: 64px 0; }

/* ── Étoiles ────────────────────────────────────────────────────────────── */
.stars { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
.star {
  font-style: normal;
  font-size: 18px;
  color: var(--hairline);
  line-height: 1;
}
.star.on { color: var(--mustard); }
.stars-label { font-size: 13px; color: var(--muted); margin-left: 6px; }

.star-widget { display: inline-flex; gap: 4px; }
.star-btn {
  background: none;
  border: none;
  padding: 0 2px;
  cursor: pointer;
  font-style: normal;
  font-size: 26px;
  color: var(--border-strong);
  line-height: 1;
}
.star-btn.on { color: var(--yellow); }
.star-btn:focus-visible { outline: 2px solid #458fff; outline-offset: 2px; border-radius: 4px; }

/* ── Modales ────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(24, 29, 38, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
  overflow-y: auto;
  z-index: 50;
}
.modal {
  position: relative;
  background: var(--canvas);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 480px;
  padding: 32px;
}
.modal-lg { max-width: 720px; }
.modal-heading { font-size: 22px; font-weight: 500; margin-bottom: 16px; }
.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.modal-close:hover { color: var(--ink); }
.edit-hint {
  background: var(--cream);
  color: var(--ink);
  border-radius: var(--radius-input);
  padding: 12px 16px;
  font-size: 14px;
  margin: 0 0 16px;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

/* ── Détail d'une recette ───────────────────────────────────────────────── */
.detail-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.detail-title { font-size: 26px; font-weight: 500; }
.detail-global { font-size: 14px; color: var(--muted); }
.version {
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  padding: 24px;
  margin-top: 24px;
}
.version-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.version-kind {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-radius: 48px;
  padding: 4px 12px;
}
.kind-originale { background: var(--mint); color: var(--forest); }
.kind-variante  { background: var(--peach); color: var(--coral); }
.version-author { font-size: 13px; color: var(--muted); }
.version-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

/* ── Commentaires ─────────────────────────────────────────────────────── */
.comments { margin-top: 24px; }
.comments-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.comments-head h3 {
  font-size: 15px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 0;
}
.comment {
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  padding: 16px 20px;
  margin-top: 12px;
}
.comment-meta { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.comment-actions { display: flex; gap: 8px; margin-top: 8px; }

.recipe-section h3 {
  font-size: 15px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 20px 0 8px;
}
.recipe-section ul { margin: 0; padding-left: 20px; }
.recipe-section ol { margin: 0; padding-left: 20px; }
.recipe-section li { margin-bottom: 6px; }
.remarks-text {
  background: var(--cream);
  border-radius: var(--radius-input);
  color: var(--ink);
  padding: 12px 16px;
  margin: 0;
}

/* ── Markdown (étapes, remarques) ─────────────────────────────────────── */
.md-content :first-child { margin-top: 0; }
.md-content p { margin: 8px 0; }
.md-content ul, .md-content ol { margin: 8px 0; padding-left: 22px; }
.md-content li { margin-bottom: 6px; }
.md-heading {
  color: var(--ink);
  font-weight: 600;
  margin: 14px 0 6px;
}
h4.md-heading { font-size: 16px; }
h5.md-heading { font-size: 15px; }

/* ── Barre d'outils markdown du formulaire ─────────────────────────────── */
.md-toolbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.md-toolbar button {
  border: 1px solid var(--hairline);
  background: var(--canvas);
  border-radius: var(--radius-input);
  padding: 5px 12px;
  font-family: inherit;
  font-size: 13px;
  color: var(--body);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.md-toolbar button:hover {
  background: var(--surface-soft);
  border-color: var(--border-strong);
}
#print-area .print-md ul, #print-area .print-md ol { margin: 4pt 0; padding-left: 18pt; }
#print-area .print-md p { margin: 4pt 0; }
#print-area .print-md h3, #print-area .print-md h4, #print-area .print-md h5 {
  font-size: 12pt; margin: 10pt 0 4pt;
}

/* ── Carrousel photos (2 visibles, rotation auto) ───────────────────────── */
.carousel {
  position: relative;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--surface-soft);
  border: 1px solid var(--hairline);
}
.carousel-track {
  display: flex;
  transition: transform 0.5s ease;
}
.carousel .slide {
  flex: 0 0 calc(100% / var(--visible, 1));
  min-width: 0;
  margin: 0;
  padding: 6px;
  box-sizing: border-box;
}
.carousel img {
  display: block;
  width: 100%;
  height: 110px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--surface-strong);
}
.carousel figcaption {
  font-size: 11px;
  color: var(--muted);
  padding: 4px 22px 2px 4px;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.photo-del {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--coral);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.carousel-nav, .lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--canvas);
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.9;
}
.carousel-nav.prev, .lightbox-nav.prev { left: 8px; }
.carousel-nav.next, .lightbox-nav.next { right: 8px; }
.carousel-nav:hover, .lightbox-nav:hover { border-color: var(--border-strong); }
.carousel-counter, .lightbox-counter {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 11px;
  font-weight: 500;
  border-radius: 48px;
  padding: 3px 9px;
}
.detail-actions { display: inline-flex; gap: 8px; }

/* ── Lightbox (photo agrandie) ─────────────────────────────────────────── */
.lightbox-overlay {
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(12, 16, 22, 0.92);
  z-index: 60;
}
.lightbox {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 94vw;
}
.lightbox-figure {
  margin: 0;
  text-align: center;
}
.lightbox-figure img {
  display: block;
  max-width: 90vw;
  max-height: 82vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
  background: var(--surface-strong);
}
.lightbox-caption {
  display: inline-block;
  margin-top: 14px;
  padding: 8px 16px;
  font-size: 14px;
  color: #ecf0f4;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 48px;
}
.lightbox-overlay .lightbox-nav {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}
.lightbox-overlay .lightbox-nav:hover { border-color: rgba(255, 255, 255, 0.7); }
.lightbox-overlay .lightbox-counter { top: 18px; right: 56px; }

/* ── Impression PDF (recette seule) ─────────────────────────────────────── */
#print-area { display: none; }
@media print {
  body.printing > *:not(#print-area) { display: none !important; }
  body.printing #print-area { display: block; color: #000; }
  #print-area h1 { font-size: 24pt; margin-bottom: 4pt; }
  #print-area .pv-kind { font-style: italic; border-bottom: 0.5pt solid #999; padding-bottom: 6pt; }
  #print-area section.print-version { page-break-inside: avoid; margin-top: 12pt; }
  .print-photos-title { font-weight: bold; color: #000; margin: 8pt 0 4pt; }
  .print-photos { max-height: 8cm; overflow: hidden; margin-bottom: 4pt; }
  .print-photos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4pt; page-break-inside: avoid; }
  .print-photos-grid img { width: 100%; height: 100px; object-fit: cover; border-radius: 4px; }
}

/* ── Recettes privées ─────────────────────────────────────────────────────── */
.card-private {
  opacity: 0.65;
  filter: grayscale(0.2);
}
.card-private .card-banner {
  background: var(--muted) !important;
}
.private-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  margin-left: 8px;
}
.private-badge svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ── Partage public ─────────────────────────────────────────────────────── */
.shared-badge {
  display: inline-flex;
  align-items: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--forest);
  background: var(--mint);
  border-radius: 48px;
  padding: 6px 14px;
}
#share-link {
  font-size: 13px;
  color: var(--link);
}
#public-body .detail-header {
  margin-bottom: 8px;
}
.public-error {
  text-align: center;
  padding: 64px 0;
  color: var(--muted);
}
