/* RepAs : mise en page « le prochain repas d'abord », couleurs vert et jaune. */
@font-face {
  font-family: 'Gabarito';
  src: url('../fonts/gabarito.woff2') format('woff2');
  font-weight: 400 900;
  font-display: swap;
}

:root {
  --vert: #1F6B45;
  --vert-clair: #E4F1E7;
  --jaune: #FFCF33;
  --fond: #F2F7EF;
  --carte: #FFFFFF;
  --texte: #17251C;
  --texte-doux: #4E5F54;
  --trait: #DDE8D9;
  --alerte: #A83B09;
  --alerte-fond: #FFF1E0;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-tiroir: cubic-bezier(0.32, 0.72, 0, 1);
}

* { box-sizing: border-box; }
html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: 'Gabarito', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.35;
}
h1, h2, h3, p { margin: 0; }
img { display: block; max-width: 100%; }
button, a, [role="button"] { touch-action: manipulation; }
button {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 160ms var(--ease-out);
}
button:active { transform: scale(0.97); }
button:focus-visible, input:focus-visible { outline: 3px solid var(--jaune); outline-offset: 2px; }
input { font: inherit; font-size: 16px; color: inherit; }

#app {
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--fond);
  display: flex;
  flex-direction: column;
}
.contenu { flex: 1; padding: 12px 16px 16px; }
.ecran-avec-onglets .contenu { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }

/* Bandeau du haut */
.bandeau {
  background: var(--vert);
  color: #FFF;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 20px 10px;
  border-radius: 0 0 24px 24px;
}
.bandeau-haut { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.logo { font-size: 31px; font-weight: 800; line-height: 1; }
.logo span { color: var(--jaune); margin-left: 2px; }
.date { font-size: 14px; text-align: right; }
.titre-bandeau { margin-top: 10px; font-size: 24px; font-weight: 700; line-height: 1.15; }
.segments { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.segment { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.28); }
.segment.plein { background: var(--jaune); }
.resume { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 15px; }
.resume-detail { padding-bottom: 6px; font-size: 15px; }
.lien-clair { flex: none; padding: 10px 0 8px; color: #FFF; font-size: 14px; text-decoration: underline; text-underline-offset: 2px; }

/* Cartes */
.carte { background: var(--carte); border-radius: 20px; overflow: hidden; }
.carte-corps { padding: 12px 14px 14px; }
.surtitre { font-size: 14px; font-weight: 700; color: var(--vert); }
.nom-repas { margin-top: 2px; font-size: 23px; font-weight: 700; line-height: 1.14; }
.meta { margin-top: 4px; font-size: 14px; color: var(--texte-doux); }
.etiquette { margin-top: 4px; font-size: 14px; font-weight: 700; color: var(--vert); }
.etiquette.cout { color: var(--alerte); }
.photo { width: 100%; height: 170px; object-fit: cover; background: var(--vert-clair); }
.photo-vide { display: flex; align-items: center; justify-content: center; width: 100%; height: 120px; background: var(--vert-clair); color: var(--vert); }
.photo-lien { display: block; width: 100%; padding: 0; }
.arrivee { animation: arrivee 200ms var(--ease-out) both; }
@keyframes arrivee { from { opacity: 0; transform: translateY(8px); } }

/* Boutons */
.boutons { display: flex; gap: 8px; margin-top: 12px; }
.bouton {
  flex: 1;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--texte);
  background: var(--carte);
  color: var(--texte);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}
.bouton.principal { flex: 1.25; border-color: var(--vert); background: var(--vert); color: #FFF; font-size: 17px; font-weight: 700; }
.bouton:disabled { opacity: 0.45; }
.bouton.large { display: block; width: 100%; flex: none; }
.lien { padding: 12px 0; color: var(--texte); font-size: 14px; text-decoration: underline; text-underline-offset: 2px; }
.lien.discret { color: var(--texte-doux); }

/* Lignes de la journee */
.titre-section { margin: 16px 4px 2px; font-size: 16px; font-weight: 700; }
.ligne { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 58px; padding: 6px 4px; border-top: 1px solid var(--trait); text-align: left; }
.ligne:first-of-type { border-top: 0; }
.vignette { flex: none; width: 46px; height: 46px; border-radius: 10px; object-fit: cover; background: var(--vert-clair); }
.vignette-vide { display: flex; align-items: center; justify-content: center; color: var(--vert); }
.ligne-texte { flex: 1; min-width: 0; }
.ligne-petit { display: block; font-size: 13px; line-height: 1.2; color: var(--texte-doux); }
.ligne-nom { display: block; font-size: 15px; font-weight: 500; line-height: 1.2; }
.ligne.active .ligne-nom { font-weight: 700; }
.coche { flex: none; display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #B9C7BC; }
.coche.faite { border-color: var(--vert); background: var(--vert); }
.coche svg { width: 16px; height: 16px; opacity: 0; fill: none; stroke: #FFF; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.coche.faite svg { opacity: 1; }

/* Onglets */
.onglets {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--carte);
  box-shadow: 0 -1px 0 var(--trait);
}
.onglet { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 58px; color: var(--texte-doux); font-size: 12.5px; font-weight: 600; }
.onglet svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.onglet[aria-current="page"] { color: var(--vert); }

.ligne-seance { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; padding: 8px 12px 8px 14px; border-radius: 16px; background: var(--carte); }
.ligne-seance strong { display: block; font-size: 15px; font-weight: 700; line-height: 1.2; }
.ligne-seance .ligne-petit { margin-top: 2px; }
.interrupteur { flex: none; display: flex; align-items: center; min-width: 52px; min-height: 44px; padding: 0; }
.interrupteur:active { transform: none; }
.interrupteur span { position: relative; display: block; width: 52px; height: 32px; border-radius: 16px; background: #B9C7BC; transition: background-color 160ms ease; }
.interrupteur span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #FFF; transition: transform 200ms var(--ease-out); }
.interrupteur[aria-checked="true"] span { background: var(--vert); }
.interrupteur[aria-checked="true"] span::after { transform: translateX(20px); }

/* Semaine */
.jours { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scroll-snap-type: x proximity; scrollbar-width: none; }
.jours::-webkit-scrollbar { display: none; }
.jour { flex: none; min-width: 58px; min-height: 58px; padding: 6px 8px; border-radius: 14px; background: var(--carte); text-align: center; scroll-snap-align: start; }
.jour strong { display: block; font-size: 15px; font-weight: 700; }
.jour small { display: block; font-size: 12px; color: var(--texte-doux); }
.jour[aria-current="true"] { background: var(--vert); color: #FFF; }
.jour[aria-current="true"] small { color: #FFF; }
.encart { padding: 12px 14px; border-radius: 16px; background: var(--carte); font-size: 15px; }
.encart + .encart, .encart + .carte, .carte + .encart { margin-top: 10px; }
.encart.alerte { background: var(--alerte-fond); color: #5C2206; }
.encart.vert { background: var(--vert-clair); }
.encart strong { font-weight: 700; }
.encart p + p { margin-top: 6px; }

/* Recette */
.retour { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); left: 12px; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; background: var(--carte); box-shadow: 0 1px 4px rgba(23, 37, 28, 0.25); }
.retour svg { width: 22px; height: 22px; fill: none; stroke: var(--texte); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.tete-recette { position: relative; }
.tete-recette .photo { height: 240px; }
.tete-recette .photo-vide { height: 150px; }
.liste-ingredients { margin: 6px 0 0; padding: 0; list-style: none; }
.liste-ingredients li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--trait); font-size: 16px; }
.liste-ingredients li:first-child { border-top: 0; }
.liste-ingredients span:last-child { flex: none; font-weight: 600; }
.etapes { margin: 6px 0 0; padding: 0; list-style: none; counter-reset: etape; }
.etapes li { position: relative; padding: 6px 0 8px 36px; counter-increment: etape; font-size: 16px; }
.etapes li::before { content: counter(etape); position: absolute; left: 0; top: 6px; display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: var(--vert-clair); color: var(--vert); font-size: 14px; font-weight: 700; }
.apports { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 10px; text-align: center; }
.apports strong { display: block; font-size: 19px; font-weight: 700; }
.apports span { font-size: 12.5px; color: var(--texte-doux); }

/* Courses */
.total { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.total strong { font-size: 27px; font-weight: 700; }
.rayon { margin-top: 12px; }
.article { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 6px 0; border-top: 1px solid var(--trait); }
.article:first-of-type { border-top: 0; }
.article-case { flex: none; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-left: -8px; }
.article-texte { flex: 1; min-width: 0; }
.article-nom { display: block; font-size: 16px; font-weight: 600; line-height: 1.2; }
.article-achat { display: block; font-size: 13.5px; line-height: 1.25; color: var(--texte-doux); }
.article.coche-ok .article-nom { text-decoration: line-through; color: var(--texte-doux); }
.article-prix { flex: none; min-width: 58px; min-height: 44px; padding: 0 2px; text-align: right; font-size: 15px; font-weight: 600; text-decoration: underline dotted; text-underline-offset: 3px; }
.article-prix.non-compte { text-decoration: none; font-size: 13px; font-weight: 500; color: var(--texte-doux); }

/* Tiroir du bas */
.voile { position: fixed; z-index: 10; inset: 0; background: rgba(23, 37, 28, 0.45); animation: voile 200ms ease both; }
@keyframes voile { from { opacity: 0; } }
.tiroir {
  position: fixed;
  z-index: 11;
  left: 50%;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  max-height: 86dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  transform: translateX(-50%);
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  border-radius: 20px 20px 0 0;
  background: var(--fond);
  animation: tiroir 280ms var(--ease-tiroir) both;
}
@keyframes tiroir { from { transform: translate(-50%, 100%); } }
.tiroir h2 { font-size: 21px; font-weight: 700; line-height: 1.15; }
.tiroir > p { margin-top: 4px; font-size: 14px; color: var(--texte-doux); }
.proposition { display: flex; align-items: center; gap: 12px; width: 100%; margin-top: 8px; padding: 8px; border-radius: 14px; background: var(--carte); text-align: left; }
.proposition .vignette { width: 62px; height: 62px; }
.proposition-prix { display: block; margin-top: 2px; font-size: 13.5px; font-weight: 700; color: var(--vert); }
.proposition-prix.cout { color: var(--alerte); }
.case-option { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 10px; font-size: 15px; }
.case-option input { flex: none; width: 22px; height: 22px; accent-color: var(--vert); }

/* Questionnaire */
.question { flex: 1; display: flex; flex-direction: column; padding: calc(12px + env(safe-area-inset-top, 0px)) 20px calc(20px + env(safe-area-inset-bottom, 0px)); }
.question-haut { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.fleche { flex: none; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-left: -10px; }
.fleche svg { width: 22px; height: 22px; fill: none; stroke: var(--texte); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.progression { flex: 1; height: 8px; border-radius: 4px; background: var(--trait); overflow: hidden; }
.progression div { height: 100%; width: 100%; background: var(--vert); border-radius: 4px; transform-origin: left center; transition: transform 240ms var(--ease-out); }
.question h1 { margin-top: 18px; font-size: 27px; font-weight: 700; line-height: 1.15; }
.aide { margin-top: 6px; font-size: 15px; color: var(--texte-doux); }
.options { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.options.grille { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.option { min-height: 54px; padding: 12px 14px; border-radius: 14px; background: var(--carte); border: 2px solid transparent; text-align: left; font-size: 17px; font-weight: 600; line-height: 1.2; }
.option small { display: block; margin-top: 2px; font-size: 14px; font-weight: 400; color: var(--texte-doux); }
.option[aria-pressed="true"], .option[aria-checked="true"] { border-color: var(--vert); background: var(--vert-clair); }
.champ { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.champ input { width: 100%; min-height: 56px; padding: 0 14px; border: 2px solid var(--trait); border-radius: 14px; background: var(--carte); font-size: 22px; font-weight: 600; }
.champ input:focus { border-color: var(--vert); outline: 0; }
.champ span { flex: none; font-size: 18px; font-weight: 600; color: var(--texte-doux); }
.erreur { margin-top: 8px; font-size: 15px; font-weight: 600; color: var(--alerte); }
.pied-question { margin-top: auto; padding-top: 18px; }
.accueil { flex: 1; display: flex; flex-direction: column; background: var(--vert); color: #FFF; padding: calc(40px + env(safe-area-inset-top, 0px)) 24px calc(24px + env(safe-area-inset-bottom, 0px)); }
.accueil .logo { font-size: 58px; }
.accueil h1 { margin-top: 18px; font-size: 29px; font-weight: 700; line-height: 1.15; }
.accueil p { margin-top: 10px; font-size: 17px; }
.accueil .bouton { margin-top: auto; border-color: var(--jaune); background: var(--jaune); color: var(--texte); font-size: 18px; font-weight: 700; }
.objectifs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.objectif { padding: 12px; border-radius: 16px; background: var(--carte); }
.objectif strong { display: block; font-size: 24px; font-weight: 700; line-height: 1.1; }
.objectif span { font-size: 14px; color: var(--texte-doux); }
.versions { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.version { display: block; width: 100%; padding: 14px; border-radius: 16px; background: var(--carte); text-align: left; }
.version strong { display: block; font-size: 19px; font-weight: 700; }
.version span { display: block; margin-top: 4px; font-size: 15px; color: var(--texte-doux); }
.chargement { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; font-size: 18px; font-weight: 600; }
.rond { width: 40px; height: 40px; border-radius: 50%; border: 4px solid var(--trait); border-top-color: var(--vert); animation: tourne 800ms linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }

@media (hover: hover) and (pointer: fine) {
  .option:hover, .proposition:hover, .version:hover { border-color: var(--vert); }
  .bouton:hover { filter: brightness(0.97); }
}
@media (prefers-reduced-motion: reduce) {
  button:active { transform: none; }
  .arrivee, .tiroir { animation: none; }
  .progression div { transition: none; }
  .interrupteur span::after { transition: none; }
  .rond { animation-duration: 2s; }
}
