/* =========================================================================
   Le Garde-Manger — design system
   Inspiration : africablanco.com
   Papier blanc, encre presque noire, filets d'1 pixel, aucun arrondi,
   aucune ombre, beaucoup de vide. La typographie porte toute la hiérarchie.

   Deux voix typographiques : Libre Baskerville pour la marque et les grands
   titres, un grotesque système pour tout le reste.
   ========================================================================= */

/* Police auto-hébergée : pas d'appel à Google Fonts (RGPD), et l'application
   reste identique sans connexion. `unicode-range` fait que le fichier
   latin-ext n'est téléchargé que si la page contient vraiment ces caractères. */
@font-face {
  font-family: 'Libre Baskerville';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/libre-baskerville-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                 U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
                 U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Libre Baskerville';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/libre-baskerville-400-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
                 U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF,
                 U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --papier:  #fffef9;   /* blanc cassé, très légèrement chaud */
  --encre:   #282828;
  --gris:    #757575;   /* 4.5:1 sur le papier — lisible en rayon, bras tendu */
  --filet:   #dcd9cf;   /* filet réchauffé pour rester dans la même famille */
  --lavis:   #f5f2e8;   /* aplat de remplissage : un cran sous le papier */
  --alerte:  #9a2b2b;

  --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica,
          "Segoe UI", Roboto, Arial, sans-serif;

  /* Georgia en secours : mêmes proportions généreuses, le basculement
     une fois la police chargée reste discret. */
  --serif: "Libre Baskerville", Georgia, "Times New Roman", serif;

  --marge:  1.25rem;
  --barre-h: 3.5rem;
}

@media (min-width: 48rem) {
  :root { --marge: 2.5rem; --barre-h: 4rem; }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--papier);
  color: var(--encre);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 0.2em; }

img { max-width: 100%; display: block; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
  border-radius: 0;
}

:focus-visible {
  outline: 1px solid var(--encre);
  outline-offset: 3px;
}

hr.filet {
  border: 0;
  border-top: 1px solid var(--filet);
  margin: 2rem 0;
}

/* --- Typographie ------------------------------------------------------- */

.micro {
  font-size: 0.6875rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--gris);
  margin: 0 0 0.5rem;
}

.titre-page {
  /* Libre Baskerville a une grande hauteur d'x : à taille égale il « pèse »
     plus qu'un grotesque, d'où une échelle un peu resserrée et un interlignage
     légèrement plus généreux que pour du sans serif. */
  font-family: var(--serif);
  font-size: clamp(1.625rem, 5.2vw, 2.5rem);
  font-weight: 400;
  letter-spacing: -0.012em;
  line-height: 1.14;
  margin: 0 0 0.75rem;
}

.titre-section {
  font-size: 1.0625rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  margin: 0;
}

.chapo {
  color: var(--gris);
  max-width: 34rem;
  margin: 0 0 2rem;
}

.note { color: var(--gris); font-size: 0.875rem; }

.vide {
  color: var(--gris);
  padding: 3rem 0;
  border-top: 1px solid var(--filet);
}

/* --- Barre de navigation ----------------------------------------------- */

.barre {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: var(--barre-h);
  padding: 0 var(--marge);
  background: var(--papier);
  border-bottom: 1px solid var(--filet);
}

.marque {
  font-family: var(--serif);
  font-size: 1.0625rem;
  letter-spacing: -0.005em;
  white-space: nowrap;
  flex: none;
}
.marque:hover { text-decoration: none; }

.nav {
  display: flex;
  gap: 1.25rem;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.nav::-webkit-scrollbar { display: none; }

.nav a {
  font-size: 0.9375rem;
  color: var(--gris);
  white-space: nowrap;
  padding: 0.25rem 0;
  border-bottom: 1px solid transparent;
}
.nav a:hover { color: var(--encre); text-decoration: none; }
.nav a[aria-current="page"] {
  color: var(--encre);
  border-bottom-color: var(--encre);
}

.deconnexion {
  flex: none;
  font-size: 0.9375rem;
  color: var(--gris);
}
.deconnexion:hover { color: var(--encre); }

@media (max-width: 47.99rem) {
  .barre {
    flex-wrap: wrap;
    height: auto;
    padding: 0.875rem var(--marge) 0;
    gap: 0.75rem 1rem;
  }
  .nav {
    order: 3;
    width: 100%;
    margin: 0;
    padding-bottom: 0.625rem;
    gap: 1rem;
  }
  .nav a { font-size: 0.875rem; }
  .deconnexion { margin-left: auto; }
}

/* --- Mise en page ------------------------------------------------------- */

.vue {
  padding: clamp(2rem, 6vw, 4.5rem) var(--marge) 6rem;
  max-width: 68rem;
  margin: 0 auto;
}

.entete {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 2.5rem;
}

.entete-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.chargement { color: var(--gris); padding: 4rem 0; }

/* --- Boutons ------------------------------------------------------------ */

.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  min-height: 2.5rem;
  background: transparent;
  color: var(--encre);
  border: 1px solid var(--encre);
  font-size: 0.9375rem;
  cursor: pointer;
  text-align: center;
  transition: background-color 0.12s linear, color 0.12s linear;
}
.bouton:hover { background: var(--encre); color: var(--papier); text-decoration: none; }
.bouton:disabled { opacity: 0.35; cursor: not-allowed; }
.bouton:disabled:hover { background: transparent; color: var(--encre); }

.bouton-plein { background: var(--encre); color: var(--papier); }
.bouton-plein:hover { background: var(--papier); color: var(--encre); }

.bouton-nu {
  border-color: transparent;
  padding-left: 0;
  padding-right: 0;
  color: var(--gris);
  min-height: 2rem;
}
.bouton-nu:hover {
  background: transparent;
  color: var(--encre);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.bouton-danger { color: var(--alerte); border-color: var(--alerte); }
.bouton-danger:hover { background: var(--alerte); color: var(--papier); }

.bouton-petit { font-size: 0.8125rem; padding: 0.3rem 0.6rem; min-height: 2rem; }

/* --- Formulaires --------------------------------------------------------- */

.formulaire { display: grid; gap: 0.9rem; max-width: 32rem; }

.champ { display: block; }

/* L'étiquette est collée à son champ : c'est ce qui fait l'essentiel de
   l'encombrement vertical d'un formulaire, plus que le champ lui-même. */
.champ > .micro { display: block; margin-bottom: 0.2rem; }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 0.25rem 0;
  line-height: 1.4;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--filet);
  -webkit-appearance: none;
  appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--encre) 50%),
                    linear-gradient(135deg, var(--encre) 50%, transparent 50%);
  background-position: calc(100% - 9px) 55%, calc(100% - 4px) 55%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 1.25rem;
}
textarea { min-height: 4.5rem; resize: vertical; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-bottom-color: var(--encre);
}

input::placeholder, textarea::placeholder { color: var(--gris); }

.ligne-champs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.9rem 1.25rem;
}

.case {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  font-size: 0.9375rem;
}
.case input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--encre);
  flex: none;
}

.alerte {
  border-left: 2px solid var(--alerte);
  padding: 0.5rem 0 0.5rem 0.875rem;
  color: var(--alerte);
  font-size: 0.9375rem;
  margin: 0 0 1.5rem;
}

/* --- Pages d'accueil simples (connexion, installation) ------------------ */

.page-simple {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 2rem var(--marge);
}
.carte-simple { width: 100%; max-width: 22rem; }
.carte-large { max-width: 34rem; }

/* Sur la carte étroite, « Le Garde-Manger » se couperait à son trait d'union :
   on descend d'un cran pour qu'il tienne sur une ligne. */
.carte-simple .titre-page { font-size: clamp(1.5rem, 7vw, 2.125rem); }

.journal {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem;
  border-top: 1px solid var(--filet);
}
.journal li {
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--filet);
  font-size: 0.9375rem;
}

/* --- Liste de courses ---------------------------------------------------- */

.rayon-bloc { margin-bottom: 2.5rem; }

.rayon-titre {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--encre);
  margin-bottom: 0;
}
.rayon-titre .micro { margin: 0; }

.article {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.7rem 0;
}

.article input[type="checkbox"] {
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  flex: none;
  accent-color: var(--encre);
  cursor: pointer;
}

.article-corps { flex: 1; min-width: 0; }

.article-nom { display: block; }

.article-detail {
  display: block;
  font-size: 0.8125rem;
  color: var(--gris);
  margin-top: 0.1rem;
}

.article.coche .article-nom {
  text-decoration: line-through;
  color: var(--gris);
}

.article-quantite {
  /* C'est un bouton (on peut corriger la quantité), mais il doit se lire
     comme du texte : pas de cadre natif, juste un soulignement au survol. */
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--gris);
  cursor: pointer;
  border-bottom: 1px dotted transparent;
}
.article-quantite:hover {
  color: var(--encre);
  border-bottom-color: var(--gris);
}

.article-supprimer {
  border: 0;
  background: none;
  color: var(--filet);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  font-size: 1.125rem;
  flex: none;
}
.article-supprimer:hover { color: var(--alerte); }

/* Bouton d'ajout, épinglé en bas : ouvre la popup, aucun champ affiché
   en permanence sur la page. */
.ajout-sticky {
  position: sticky;
  bottom: 0;
  z-index: 10;
  padding: 0.6rem 0 calc(0.6rem + env(safe-area-inset-bottom));
  background: var(--papier);
  border-top: 1px solid var(--encre);
  margin-top: 2rem;
}
.ajout-sticky .bouton { width: 100%; }

.suggestions {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  max-height: 14rem;
  overflow-y: auto;
  background: var(--papier);
  border: 1px solid var(--encre);
  margin-bottom: 0.5rem;
  z-index: 30;
}
.suggestions button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.75rem;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--filet);
  cursor: pointer;
  font-size: 0.9375rem;
}
.suggestions button:last-child { border-bottom: 0; }
.suggestions button:hover, .suggestions button[aria-selected="true"] { background: var(--lavis); }
.suggestions .sugg-rayon { color: var(--gris); font-size: 0.8125rem; }

.zone-suggestions { position: relative; }

/* --- Recettes ------------------------------------------------------------ */

.grille-recettes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 2.5rem 1.75rem;
}

.carte-recette { display: block; }
.carte-recette:hover { text-decoration: none; }

.vignette {
  aspect-ratio: 1 / 1;
  background: var(--lavis);
  border: 1px solid var(--filet);
  overflow: hidden;
  margin-bottom: 0.75rem;
}
.vignette img { width: 100%; height: 100%; object-fit: cover; }
.vignette-vide {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--filet);
  font-size: 2rem;
}
.carte-recette:hover .vignette { border-color: var(--encre); }

.carte-titre { font-size: 1rem; margin: 0 0 0.15rem; font-weight: 400; }
.carte-meta { font-size: 0.8125rem; color: var(--gris); }

/* Fiche recette */
.fiche { display: grid; gap: 3rem; }
@media (min-width: 56rem) {
  .fiche { grid-template-columns: 22rem 1fr; align-items: start; gap: 4rem; }
}

.fiche-image {
  border: 1px solid var(--filet);
  background: var(--lavis);
  aspect-ratio: 1 / 1;
  overflow: hidden;
}
.fiche-image img { width: 100%; height: 100%; object-fit: cover; }

.liste-ingredients { list-style: none; padding: 0; margin: 0 0 2.5rem; }
.liste-ingredients li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0;
}
.liste-ingredients .qte {
  color: var(--gris);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.etapes { list-style: none; counter-reset: etape; padding: 0; margin: 0; }
.etapes li {
  counter-increment: etape;
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.75rem;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--filet);
}
.etapes li::before {
  content: counter(etape, decimal-leading-zero);
  color: var(--gris);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  padding-top: 0.15rem;
}
.etapes li:first-child { border-top: 1px solid var(--filet); }

/* --- Ingrédients (groupés par rayon) ------------------------------------ */

.rangee-ingredient {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.6rem 0;
}
.rangee-ingredient .nom {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.rangee-ingredient .unite {
  color: var(--gris);
  font-size: 0.875rem;
  white-space: nowrap;
}
.rangee-ingredient .actions {
  display: flex;
  gap: 0.35rem;
  flex: none;
}

/* Au doigt : le nom et son unité restent sur la même ligne — c'est le couple
   qu'on lit —, les actions passent dessous, alignées à droite. */
@media (max-width: 34rem) {
  .rangee-ingredient { flex-wrap: wrap; gap: 0.35rem 0.75rem; }
  .rangee-ingredient .actions { flex-basis: 100%; justify-content: flex-end; }
}

.etiquette {
  display: inline-block;
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--filet);
  padding: 0.1rem 0.4rem;
  color: var(--gris);
}

/* Rayons réordonnables */
.rangee-rayon {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--filet);
  background: var(--papier);
}
.rangee-rayon:first-child { border-top: 1px solid var(--encre); }
.rangee-rayon.attrape { opacity: 0.4; }
.rangee-rayon.survol { border-top: 1px solid var(--encre); }

.poignee {
  cursor: grab;
  color: var(--filet);
  font-size: 1rem;
  line-height: 1;
  user-select: none;
  padding: 0.25rem;
  flex: none;
}
.poignee:active { cursor: grabbing; }
.rangee-rayon:hover .poignee { color: var(--gris); }

/* Numéro d'ordre + nom : côte à côte en desktop, empilés au doigt (voir
   media query plus bas) — le numéro reste toujours le repère principal. */
.rayon-corps {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.rang-position {
  font-variant-numeric: tabular-nums;
  color: var(--gris);
  font-size: 0.8125rem;
  flex: none;
}
.rayon-corps .nom {
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
}
.rangee-rayon .note { flex: none; white-space: nowrap; }
.rangee-rayon .fleches { display: flex; gap: 0.25rem; flex: none; position: relative; }

/* Menu contextuel « ⋯ » : Renommer / Supprimer */
.menu-contextuel {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 40;
  margin-top: 0.25rem;
  min-width: 9rem;
  background: var(--papier);
  border: 1px solid var(--encre);
}
.menu-contextuel button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.85rem;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--filet);
  font-size: 0.9375rem;
  cursor: pointer;
}
.menu-contextuel button:last-child {
  border-bottom: 0;
  color: var(--alerte);
}
.menu-contextuel button:hover { background: var(--lavis); }

@media (max-width: 30rem) {
  .rangee-rayon { align-items: flex-start; }
  .rangee-rayon .note { display: none; }
  .rayon-corps {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
  }
}

/* --- Idées (Claude) ------------------------------------------------------ */

.idee {
  border-top: 1px solid var(--encre);
  padding: 1.75rem 0;
}
.idee-entete {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.idee-titre { font-size: 1.25rem; font-weight: 400; letter-spacing: -0.01em; margin: 0 0 0.25rem; }
.idee-colonnes { display: grid; gap: 2rem; margin-top: 1.25rem; }
@media (min-width: 44rem) {
  .idee-colonnes { grid-template-columns: 16rem 1fr; gap: 3rem; }
}
.idee-ing { list-style: none; padding: 0; margin: 0; font-size: 0.9375rem; }
.idee-ing li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--filet);
}
.idee-ing .nouveau { color: var(--gris); }
.idee-etapes { padding-left: 1.1rem; margin: 0; font-size: 0.9375rem; }
.idee-etapes li { padding: 0.3rem 0; }

.travail {
  border-top: 1px solid var(--filet);
  padding-top: 2rem;
  color: var(--gris);
}
.travail::after {
  content: "";
  display: block;
  width: 100%;
  height: 1px;
  margin-top: 1rem;
  background: linear-gradient(90deg, var(--encre) 0 30%, var(--filet) 30% 100%);
  background-size: 300% 100%;
  animation: glisse 1.4s linear infinite;
}
@keyframes glisse {
  from { background-position: 100% 0; }
  to   { background-position: -100% 0; }
}

/* --- Modale -------------------------------------------------------------- */

.voile {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(40, 40, 40, 0.25);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.5rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modale {
  background: var(--papier);
  border: 1px solid var(--encre);
  width: 100%;
  max-width: 34rem;
  margin: auto;
  padding: 1.75rem;
}
.modale-large { max-width: 46rem; }
.modale-entete {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.modale-pied {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--filet);
}
.fermer {
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--gris);
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.25rem;
}
.fermer:hover { color: var(--encre); }

/* Lignes d'ingrédients dans l'éditeur de recette */
.ligne-ingredient {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 4.5rem 7.5rem auto;
  gap: 0.75rem;
  align-items: end;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--filet);
}
@media (max-width: 32rem) {
  .ligne-ingredient {
    grid-template-columns: minmax(0, 1fr) 4rem auto;
  }
  .ligne-ingredient .champ:first-child { grid-column: 1 / -1; }
}
.ligne-etape {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: end;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--filet);
}

/* --- Notifications ------------------------------------------------------- */

.notes {
  position: fixed;
  left: var(--marge);
  right: var(--marge);
  bottom: calc(1rem + env(safe-area-inset-bottom));
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  pointer-events: none;
}
.notes p {
  margin: 0;
  background: var(--encre);
  color: var(--papier);
  padding: 0.6rem 1rem;
  font-size: 0.9375rem;
  max-width: 30rem;
}
.notes p.mauvais { background: var(--alerte); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .barre, .ajout-rapide, .entete-actions, .notes, .article-supprimer { display: none !important; }
  .vue { padding-top: 0; }
  .article { break-inside: avoid; }
}
