/* 🇲🇬 Palette Madagascar : rouge, vert, blanc — fond crème chaleureux */
:root {
  --red: #d43a2f;
  --green: #007e3a;
  --cream: #fdf6ec;
  --paper: #fffdf8;
  --ink: #2e2620;
  --ink-soft: #6b5f52;
  --accent-bg: #fbe9d0;
  --border: #e5d6bb;
  --radius: 14px;
  --font-title: 'Fraunces', Georgia, serif;
  --font-body: 'Roboto Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.65;
  font-size: 0.95rem;
  /* footer (et ses bandes drapeau) toujours collé en bas de page */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* L'écran ne s'étale pas : colonne de lecture confortable */
.wrap {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 1.1rem;
}

.site-header {
  /* Drapeau malgache en fond, fondu sous un voile crème pour la lisibilité */
  background:
    linear-gradient(rgba(255, 253, 248, 0.78), rgba(255, 253, 248, 0.78)),
    url('/images/drapeau-mada.jpg') center 30% / cover no-repeat,
    var(--paper);
  padding: 1.3rem 0 0; /* le bas est occupé par les bandes drapeau */
  position: sticky;
  top: 0;
  z-index: 10;
  transition: transform 0.28s ease; /* 📱 header escamotable au scroll (classe posée en JS) */
}
@media (max-width: 720px) {
  .site-header.header-hidden { transform: translateY(-100%); }
}

/* 🇲🇬 Drapeau : trait blanc, puis rouge, puis vert (6px chacun) */
.flag-stripes {
  height: 18px;
  background: linear-gradient(
    to bottom,
    #ffffff 0 6px,
    var(--red) 6px 12px,
    var(--green) 12px 18px
  );
}

/* Sous-header : sections + loupe — centrage béton (pas de flexbox) */
.header-sub {
  display: block;
  text-align: center;
  margin: 10px auto; /* ⚠️ auto horizontal : ne JAMAIS écraser le centrage du .wrap */
  position: relative; /* la loupe se place en absolu à droite */
}
.cat-nav {
  display: inline;
}
.cat-nav a {
  display: inline-block;
  margin: 0.15rem 0.45rem;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 0.93rem; /* ajusté pour que les 7 catégories tiennent sur une ligne */
  color: var(--red);
  text-decoration: none;
  padding: 0.15rem 0;
}

/* Halo crème derrière les textes du header : lisibilité sur la photo de fond */
.site-header .brand strong,
.site-header .brand small,
.cat-nav a {
  text-shadow: 0 0 6px rgba(255, 253, 248, 0.95), 0 1px 3px rgba(255, 253, 248, 0.9);
}
.cat-nav a:hover { text-decoration: underline; }
.cat-nav a.active { text-decoration: underline; }
.search-toggle {
  background: none;
  border: none;
  font-size: 1.35rem;
  cursor: pointer;
  padding: 0.2rem;
  display: block; /* sa propre ligne, centrée, sous les catégories */
  margin: 0.35rem auto 0;
}
#site-search { margin: 10px 0; }
/* Header : tout centré, tout fluide */
.header-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: var(--ink);
}
/* Titre : fluide, jamais plus petit que les catégories (0.93rem) —
   en-dessous, il passe sur 2 lignes plutôt que de rapetisser */
.brand strong {
  font-family: var(--font-title);
  font-size: clamp(1.05rem, 4.3vw, 2rem);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.brand small { display: block; color: var(--ink-soft); font-size: 0.85rem; font-style: italic; margin-top: 0.15rem; }
.brand-flag {
  width: 34px; height: 24px; flex: none;
  border-radius: 4px;
  background:
    linear-gradient(to right, #fff 0 33%, transparent 33%),
    linear-gradient(to bottom, var(--red) 0 50%, var(--green) 50%);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.12);
}

.lang-switch { display: flex; gap: 0.35rem; flex: none; }
.lang-switch a {
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: 1.3rem;
  line-height: 1;
}
.lang-switch a.active { background: var(--accent-bg); box-shadow: 0 0 0 2px var(--green); }

main { padding: 2.5rem 0 2.5rem; flex: 1 0 auto; width: 100%; }

h1, h2, h3 { font-family: var(--font-title); line-height: 1.2; }
h1 { color: var(--red); font-size: 2.2rem; margin-bottom: 0.9rem; }
h2 { font-size: 1.4rem; }
a { color: var(--green); }

.dish-description {
  font-size: 1.05rem;
  color: var(--ink-soft);
  font-style: italic;
  margin: 0.2rem 0 2rem; /* air avant les onglets de version */
}

/* Cartes recettes */
.recipe-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, 1fr);
}
@media (max-width: 560px) {
  .recipe-grid { grid-template-columns: 1fr; }
}
.recipe-card {
  display: block;
  background: var(--paper);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  text-decoration: none;
  color: var(--ink);
  box-shadow: 0 1px 6px rgba(46,38,32,0.06);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  position: relative; /* pour le drapeau d'origine */
}
.origin-flag {
  position: absolute;
  bottom: 0.6rem;
  right: 0.8rem;
  font-size: 1.25rem;
  line-height: 1;
}
.recipe-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(46,38,32,0.1); }
.recipe-card h3 { margin: 0 0 0.3rem; color: var(--red); min-height: 2.4em; /* 2 lignes réservées : cartes uniformes */ }
.recipe-card .meta { color: var(--ink-soft); font-size: 0.78rem; }
.category-title { margin-top: 2.2rem; border-bottom: 2px solid var(--accent-bg); padding-bottom: 0.3rem; }
section[data-cat-section] { scroll-margin-top: 190px; }
section:has(.recipe-grid) { margin-bottom: 2.5rem; }

/* 🔍 Recherche — légère, 100% côté client */
.search-box {
  width: 100%;
  padding: 0.8rem 1.1rem;
  font-family: var(--font-body);
  font-size: 1rem;
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.6rem;
}
.search-box:focus { outline: none; border-color: var(--green); }

/* Page recette */
.recipe-photo { width: 100%; border-radius: var(--radius); margin: 1rem 0; }
.recipe-video { width: 100%; border-radius: var(--radius); margin: 1rem 0; background: #1a120a; }
.meta-row {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.2rem;
  color: var(--ink-soft); font-size: 0.82rem;
  margin: 0.6rem 0 1.2rem;
}

/* Onglets variantes — LES plus importants, donc bien gros */
.tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1.6rem 0 0; }
.tab-btn {
  border: 2px solid var(--red);
  background: var(--paper);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: none;
  padding: 0.8rem 1.4rem;
  cursor: pointer;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--red);
}
.tab-btn.active { background: var(--red); color: #fff; }
.tab-panel { display: none; }
.tab-panel.active {
  display: block;
  border-top: 2px solid var(--red);
  padding-top: 1.2rem;
}
.tab-panel .meta-row { margin-top: 0; }

/* Ligne convives + bouton imprimer en vis-à-vis */
.servings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  margin: 0.4rem 0 1rem;
}
.servings-row .servings-box { margin: 0; }

/* Bouton imprimer : à droite, sous les onglets, avec de l'air */
.actions {
  display: flex;
  justify-content: flex-end;
  margin: 0.8rem 0 1.4rem;
}

/* Anecdote : dans chaque onglet */
.anecdote {
  background: var(--accent-bg);
  border-left: 4px solid var(--red);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.8rem 1rem;
  font-style: italic;
  margin: 0 0 1.2rem;
}

/* Sélecteur de convives */
.servings-box {
  display: flex; align-items: center; gap: 0.7rem;
  margin: 1rem 0;
}
.servings-box input {
  width: 4.2rem; padding: 0.35rem 0.5rem; font-size: 1rem;
  font-family: var(--font-body);
  border: 1px solid #d8c9ac; border-radius: 8px; text-align: center;
}

/* 🥘 Ingrédients : encadré, se démarque de la préparation */
.ingredients-box {
  background: var(--paper);
  border: 2px solid var(--green);
  border-radius: var(--radius);
  padding: 1rem 1.3rem;
  margin: 1rem 0 1.6rem;
}
.ingredients-box h2 { margin-top: 0; color: var(--green); }
.ingredients { list-style: none; padding: 0; margin: 0; }
.ingredients li {
  padding: 0.45rem 0;
  border-bottom: 1px dashed var(--border);
  display: flex; gap: 0.6rem;
}
.ingredients li:last-child { border-bottom: none; }
.ingredients li.ing-part {
  display: block;
  font-family: var(--font-title);
  font-weight: 700;
  color: var(--red);
  border-bottom: none;
  padding: 0.9rem 0 0.1rem;
}
.ingredients li.ing-part:first-child { padding-top: 0; }
.ingredients .qty { font-weight: 500; color: var(--green); min-width: 5.5rem; }

/* 💬 Commentaires : encadrés, bien à part, air au-dessus ET en-dessous */
.comments-section {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  margin-top: 3.5rem;
  margin-bottom: 2.5rem;
}
.comments-section h2 { margin-top: 0; }

/* 💬 Fil de commentaires : bulles façon album (validé par Lola 2026-08-30) */
.btn-upload {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 1rem;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.7rem 1.4rem;
  cursor: pointer;
}
.btn-upload:hover { background: #006330; }

.rc-form { display: flex; gap: 0.6rem; margin: 0.8rem 0 1rem; }
/* ⚠️ display:flex écrase l'attribut hidden (spécificité) — il faut une règle
   plus forte, sinon formulaire ET portillon s'affichent ensemble (vu 2026-08-31) */
.rc-form[hidden], .rc-gate[hidden] { display: none; }
.rc-form input {
  flex: 1;
  font-family: inherit;
  padding: 0.6rem 0.9rem;
  border: 1px solid #e0d5c0;
  border-radius: 10px;
  background: #fff;
}
.rc-form .btn-upload { padding: 0.6rem 1.1rem; }
.rc-comment {
  background: #fff;
  border: 1px solid #e8dcc8;
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  margin-bottom: 0.5rem;
  font-size: 0.92rem;
}
.rc-comment .rc-author { font-weight: 700; color: var(--green); }
.rc-comment .rc-date { color: #8a7a6a; font-size: 0.85em; }
.rc-comment p { margin: 0.15rem 0 0; color: #6a5a4a; }
.rc-del {
  float: right;
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  font-size: 0.85rem;
}
.rc-note { color: #8a7a6a; font-size: 0.92rem; }
.rc-gate { text-align: center; padding-top: 0.4rem; }
.rc-gate p { color: #6a5a4a; }

/* Boutons */
.btn {
  display: inline-block; background: var(--green); color: #fff;
  border: none; border-radius: 999px; padding: 0.55rem 1.3rem;
  font-family: var(--font-body); font-size: 0.9rem;
  cursor: pointer; text-decoration: none;
}
.btn.secondary { background: var(--paper); color: var(--green); border: 1px solid var(--green); }

.site-footer {
  background: var(--paper);
  padding: 0 0 1.3rem; /* bandes drapeau collées en haut, air en dessous */
  color: var(--ink-soft);
  font-size: 0.8rem;
  text-align: center;
}
.site-footer .footer-tagline { margin: 1.1rem 0 0.4rem; font-style: italic; }
.site-footer .credit { font-family: var(--font-title); font-size: 0.95rem; color: var(--ink); margin: 0; }

/* 🥚 Easter egg : invisible au repos, halo rouge au survol */
.easteregg {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.25s ease, text-shadow 0.25s ease;
}
.easteregg:hover {
  color: var(--red);
  text-shadow: 0 0 10px rgba(212, 58, 47, 0.55), 0 0 4px rgba(212, 58, 47, 0.4);
}

/* 🔐 Portillon mot de passe */
#gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
#gate[hidden] { display: none; }
.gate-card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(46,38,32,0.12);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-width: 22rem;
  width: 100%;
  text-align: center;
}
.gate-card strong { font-family: var(--font-title); font-size: 1.3rem; }
.gate-card input {
  width: 100%;
  padding: 0.7rem 1rem;
  font-family: var(--font-body);
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  text-align: center;
}
.gate-card input:focus { outline: none; border-color: var(--green); }
#gate-error { color: var(--red); margin: 0; font-size: 0.85rem; }

/* 🖨️ Impression : une page par recette, compacte et nette (pas d'emojis bitmap) */
@media print {
  @page { size: landscape; margin: 1cm; }
  .site-header, .site-footer, .actions, .tabs, [data-print], .comments-section, .lang-switch, .ico, .recipe-photo, .recipe-video, .back-home { display: none !important; }
  body { background: #fff; font-size: 10pt; line-height: 1.45; min-height: 0 !important; /* sinon page fantôme */ }
  .wrap { max-width: 100%; padding: 0; }
  main { padding: 0; }
  h1 { color: #000; font-size: 17pt; margin: 0 0 0.4rem; }
  h2 { font-size: 11pt; margin: 0 0 0.3rem; }
  .dish-description { font-size: 9.5pt; margin: 0 0 0.6rem; }
  .meta-row { font-size: 9pt; gap: 0.3rem 1.4rem; margin: 0 0 0.5rem; }
  .tab-panel { display: none !important; border-top: none !important; padding-top: 0; }
  .tab-panel.print-current::before {
    content: attr(data-label);
    display: block;
    flex: 0 0 100%; /* le nom de version a sa propre ligne */
    font-family: Georgia, serif;
    font-weight: bold;
    font-size: 10.5pt;
    margin-bottom: 0.35rem;
  }
  .anecdote { background: none; border: none; padding: 0; margin: 0 0 0.4rem; font-size: 9.5pt; }
  .servings-row { margin: 0 0 0.7rem; }
  .servings-box { margin: 0; font-size: 9.5pt; }
  .servings-box [data-servings-input] { display: none; }
  .servings-box::before { content: attr(data-count) " "; font-weight: 500; }
  /* ── Infos sur UNE ligne : prépa / cuisson / repos + convives ── */
  .tab-panel.print-current { display: flex !important; flex-wrap: wrap; }
  .tab-panel.print-current > * { flex: 0 0 100%; }
  .tab-panel.print-current .meta-row { flex: 0 0 auto; order: 1; }
  .tab-panel.print-current .servings-row { flex: 0 0 auto; order: 2; margin: 0 0 0.5rem 1.4rem; }
  .tab-panel.print-current .anecdote { order: 3; }
  .tab-panel.print-current .recipe-body { order: 4; }
  /* ── Fiche paysage : ingrédients à gauche, préparation à droite ── */
  /* Float (fiable en paged media) plutôt que grid (fragmentation buggée) */
  .recipe-body { display: block; }
  .recipe-body::after { content: ""; display: block; clear: both; }
  .ingredients-box { float: left; width: 36%; }
  .steps-col { margin-left: 40%; }
  .ingredients-box { border: 1.5pt solid #000; padding: 0.6rem 0.9rem; margin: 0; }
  .ingredients-box h2 { margin: 0 0 0.3rem; color: #000; }
  .ingredients li { padding: 0.14rem 0; font-size: 9.5pt; break-inside: avoid; }
  .ingredients .qty { color: #000; min-width: 4.2rem; }
  .ingredients.many { column-count: 1; }
  .ingredients li.ing-part { padding: 0.5rem 0 0.1rem; font-size: 10pt; break-after: avoid; }
  .steps-col h2 { margin-top: 0; }
  .tab-panel ol, .tab-panel ul { margin: 0.15rem 0; padding-left: 0.2rem; list-style-position: inside; }
  .tab-panel li, .tab-panel p { font-size: 9.5pt; margin-bottom: 0.25rem; }
  h1, h2, li, p { orphans: 3; widows: 3; }
  a { color: #000; text-decoration: none; }
}
