/* Courses : styles de l'application, repris de la maquette validée (docs/maquette.html).
   Écarts voulus : couleurs foncées d'un cran pour atteindre le contraste AA (4,5:1) sur les textes,
   vue « ordinateur » choisie par la largeur de l'écran, zones sûres des téléphones (encoche). */

:root {
  --accent: #0b7d57;          /* fonds porteurs de texte blanc : 5,1:1 */
  --accent-vif: #0e9f6e;      /* traits et icônes (sans texte) */
  --accent-fonce: #0a6b4b;
  --accent-pale: #e3f5ee;
  --texte: #1d2329;
  --texte-doux: #5b6670;      /* 5,3:1 sur le fond */
  --fond: #f4f6f8;
  --carte: #fff;
  --trait: #d5dbe1;
  --danger: #b3261e;
  --danger-pale: #fdecea;
  --rayon: 14px;
  --ombre: 0 2px 10px rgba(0, 0, 0, .08);
  --haut: env(safe-area-inset-top, 0px);
  --bas: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--texte);
  background: var(--fond);
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; padding: 0; }
button:disabled { cursor: default; opacity: .55; }
input { font: inherit; }
:focus-visible { outline: 3px solid var(--accent-vif); outline-offset: 2px; }
.cache { display: none !important; }
.lecteur { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sans-javascript { padding: 24px; text-align: center; }

/* ---------- Cadre ---------- */
.app { display: flex; height: 100dvh; overflow: hidden; }
.cote { display: none; }
.principal { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }

/* ---------- En-tête ---------- */
.entete {
  background: var(--accent); color: #fff;
  padding: calc(10px + var(--haut)) 8px 10px 16px;
  display: flex; align-items: center; gap: 4px; min-height: calc(64px + var(--haut)); flex: none;
}
.entete h1 { font-size: 20px; margin: 0; flex: 1; min-width: 0; display: flex; }
.entete .titre {
  display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%;
  font-weight: 700; text-align: left; border-radius: 8px; padding: 4px 6px; margin-left: -6px;
}
.entete .titre span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entete button.titre:hover, .entete .icone:hover { background: rgba(255, 255, 255, .18); }
.entete .retour { margin-left: -8px; }
.entete .icone { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.entete svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.entete .titre svg { width: 18px; height: 18px; flex: none; }
.bandeau-hl { background: #fff4d6; color: #6b4b00; font-size: 14px; padding: 6px 16px; flex: none; }

/* ---------- Liste ---------- */
.zone { flex: 1; overflow: auto; padding: 8px 12px calc(110px + var(--bas)); }
.colonne { max-width: 640px; margin: 0 auto; width: 100%; }
.article {
  background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre);
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; margin: 8px 0;
  transition: transform .25s, opacity .25s, max-height .3s, margin .3s, padding .3s; max-height: 120px; overflow: hidden;
}
.article.parti { transform: translateX(60px); opacity: 0; max-height: 0; margin: 0; padding-top: 0; padding-bottom: 0; }
.article .nom { flex: 1; min-width: 0; text-align: left; padding: 4px 0; overflow-wrap: anywhere; }
.article .nom strong { display: block; font-weight: 600; }
.article .nom small { color: var(--texte-doux); }
.qte {
  background: var(--accent-pale); color: var(--accent-fonce); font-size: 13px; padding: 2px 8px;
  border-radius: 10px; margin-left: 6px; font-weight: 600; white-space: nowrap;
}
.caddie {
  width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--accent-vif);
  display: grid; place-items: center; flex: none; transition: background .15s;
}
.caddie svg { width: 22px; height: 22px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.caddie.ok { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; font-size: 14px; }
.vide { text-align: center; color: var(--texte-doux); padding: 60px 20px; }
.vide svg { width: 64px; height: 64px; stroke: var(--accent-vif); fill: none; stroke-width: 1.5; opacity: .5; }

.plus {
  position: absolute; right: 20px; bottom: calc(24px + var(--bas)); width: 62px; height: 62px; border-radius: 50%;
  background: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(11, 125, 87, .45);
  display: grid; place-items: center; z-index: 5;
}
.plus svg { width: 30px; height: 30px; stroke: #fff; stroke-width: 2.5; fill: none; stroke-linecap: round; }

/* ---------- Feuilles (fenêtres du bas) ---------- */
.voile { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 20; display: flex; align-items: flex-end; }
.feuille {
  background: var(--carte); width: 100%; border-radius: 20px 20px 0 0; max-height: 88dvh;
  display: flex; flex-direction: column; animation: monte .2s; padding-bottom: var(--bas);
}
@keyframes monte { from { transform: translateY(40px); opacity: .4; } }
.feuille header { display: flex; align-items: center; padding: 14px 12px 6px 16px; }
.feuille header h2 { flex: 1; margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.feuille .corps { padding: 6px 16px 18px; overflow: auto; }
.fermer { font-size: 26px; line-height: 1; color: var(--texte-doux); width: 44px; height: 44px; border-radius: 50%; flex: none; }
.fermer:hover { background: var(--fond); }

/* ---------- Formulaires ---------- */
.champ {
  width: 100%; padding: 13px 14px; border: 1.5px solid var(--trait); border-radius: 12px;
  background: #fff; color: var(--texte); outline: none;
}
.champ:focus { border-color: var(--accent-vif); }
.champ[aria-invalid="true"] { border-color: var(--danger); }
.etiquette { display: block; font-size: 14px; color: var(--texte-doux); margin: 12px 0 4px; }
.bouton { display: block; width: 100%; padding: 14px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; margin-top: 16px; text-align: center; }
.bouton.second { background: var(--accent-pale); color: var(--accent-fonce); }
.bouton.danger { background: var(--danger-pale); color: var(--danger); }
.lien { color: var(--accent-fonce); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.note { font-size: 14px; color: var(--texte-doux); margin-top: 10px; }
.centre { text-align: center; }
.erreur { color: var(--danger); font-size: 14px; margin: 10px 0 0; }
.erreur:empty { display: none; }
.piege { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.altcha-zone { margin-top: 14px; }
altcha-widget { display: block; }
.altcha { max-width: 100% !important; }

/* ---------- Suggestions (ajout) ---------- */
.ajout-ligne { display: flex; gap: 8px; }
.ajout-ligne .nom-article { flex: 2; }
.ajout-ligne .qte-article { flex: 1; min-width: 0; }
.ajout-ligne .valider { flex: none; width: 52px; border-radius: 12px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.ajout-ligne .valider svg { width: 24px; height: 24px; stroke: #fff; stroke-width: 2.5; fill: none; stroke-linecap: round; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.sugg { border: 1.5px solid var(--trait); border-radius: 20px; padding: 8px 14px; background: #fff; }
.sugg:hover { border-color: var(--accent-vif); }
.sugg small { color: var(--texte-doux); margin-left: 6px; font-size: 12px; }
.sugg.nouveau { border-style: dashed; border-color: var(--accent-vif); color: var(--accent-fonce); }
.ajoutes { font-size: 14px; color: var(--accent-fonce); min-height: 20px; margin-top: 10px; }

/* ---------- Lignes (menus) ---------- */
.ligne { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--trait); }
.ligne:last-child { border-bottom: 0; }
.ligne .t { flex: 1; min-width: 0; overflow-wrap: anywhere; text-align: left; }
.ligne .t small { display: block; color: var(--texte-doux); font-size: 14px; }
.ligne button.t { padding: 0; }
.mini { font-size: 14px; padding: 8px 12px; border-radius: 8px; background: var(--fond); flex: none; min-height: 40px; }
.mini.rouge { color: var(--danger); }
.ligne.choisie .t strong { color: var(--accent-fonce); }
.pastille-n { background: var(--accent); color: #fff; border-radius: 10px; font-size: 13px; padding: 1px 8px; flex: none; }
.section { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--texte-doux); margin: 18px 0 2px; font-weight: 600; }

/* ---------- Bandeau du bas ---------- */
.bandeau {
  position: fixed; left: 12px; right: 12px; bottom: calc(100px + var(--bas)); background: #263238; color: #fff;
  border-radius: 12px; padding: 12px 14px; display: flex; align-items: center; gap: 10px; z-index: 30;
  transform: translateY(20px); opacity: 0; pointer-events: none; transition: .2s;
}
.bandeau.vu { transform: none; opacity: 1; pointer-events: auto; }
.bandeau span { flex: 1; overflow-wrap: anywhere; }
.bandeau button { color: #7ee2b8; font-weight: 700; text-transform: uppercase; font-size: 14px; padding: 8px; }

/* ---------- Pages hors connexion ---------- */
.page {
  flex: 1; overflow: auto; padding: calc(32px + var(--haut)) 24px calc(32px + var(--bas));
  display: flex; flex-direction: column; justify-content: center; max-width: 440px; margin: 0 auto; width: 100%;
}
.page.longue { justify-content: flex-start; max-width: 640px; }
.page h2 { font-size: 20px; margin: 0 0 8px; }
.page h3 { font-size: 16px; margin: 20px 0 6px; }
.page p, .page li { overflow-wrap: anywhere; }
.marque { text-align: center; margin-bottom: 24px; }
.marque .rond { width: 72px; height: 72px; border-radius: 20px; background: var(--accent); display: inline-grid; place-items: center; }
.marque svg { width: 40px; height: 40px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.marque h1 { margin: 10px 0 0; font-size: 26px; }
.encadre { background: var(--accent-pale); border-radius: 12px; padding: 14px; font-size: 15px; margin-bottom: 8px; overflow-wrap: anywhere; }
.encadre.alerte { background: #fff4d6; color: #6b4b00; }
.liens-bas { text-align: center; margin-top: 18px; font-size: 14px; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; }

/* ---------- Accueil (liste des listes) ---------- */
.carte-liste {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 14px 16px; margin: 8px 0;
}
.carte-liste .t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.carte-liste small { display: block; color: var(--texte-doux); font-size: 14px; }

/* ---------- Colonne de gauche (ordinateur) ---------- */
.cote .entete .titre { font-size: 22px; } /* la marque, un cran au-dessus du titre de liste (20 px) */
.cote h2 { margin: 16px 16px 6px; font-size: 13px; text-transform: uppercase; color: var(--texte-doux); letter-spacing: .04em; }
.cote .listes { overflow: auto; }
.cote .liste-cote { padding: 12px 16px; display: flex; justify-content: space-between; gap: 8px; text-align: left; width: 100%; }
.cote .liste-cote span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cote .liste-cote:hover { background: var(--fond); }
.cote .liste-cote.choisie { background: var(--accent-pale); color: var(--accent-fonce); font-weight: 600; }
.cote .nouvelle { color: var(--accent-fonce); font-weight: 600; }
.cote .bas { margin-top: auto; border-top: 1px solid var(--trait); padding: 8px 0; }
.cote .bas button { display: block; width: 100%; text-align: left; padding: 12px 16px; color: var(--texte-doux); }
.cote .bas button:hover { background: var(--fond); }

/* ---------- Vue ordinateur ---------- */
@media (min-width: 900px) {
  .app.connecte .cote {
    display: flex; flex-direction: column; width: 280px; flex: none;
    background: var(--carte); border-right: 1px solid var(--trait);
  }
  .app.connecte .entete .choix-liste svg { display: none; }
  .app.connecte .entete .retour { display: none; } /* la colonne de gauche mène aux autres listes */
  .voile { align-items: center; justify-content: center; }
  .feuille { width: 480px; border-radius: 16px; max-height: 80dvh; }
  .bandeau { left: auto; right: 24px; width: 380px; bottom: 24px; }
  .plus { right: 32px; bottom: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
