/* Simple lists : 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 dark;
}

* { box-sizing: border-box; }
/* La page ne défile jamais : seul le contenu des listes défile. Sans cela, sur téléphone, la page
   entière glisse et l'en-tête comme le bouton « + » sortent de l'écran visible. */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  margin: 0;
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-optical-sizing: auto;
  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; }

/* Retour à l'appui : répondre au toucher, pas au relâchement (apple-design §1). */
.bouton, .caddie, .mini, .sugg, .plus, .fermer, .carte-liste, .ajout-ligne .valider,
.voir, .entete .icone, .entete .titre, .ligne button.t, .cote .liste-cote {
  transition: transform 100ms ease-out, background-color 150ms ease-out;
  user-select: none; -webkit-user-select: none;
}
.bouton:active, .caddie:active, .mini:active, .sugg:active, .plus:active, .fermer:active,
.carte-liste:active, .ajout-ligne .valider:active, .voir:active, .entete .icone:active,
.ligne button.t:active, .cote .liste-cote:active { transform: scale(.97); }
.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: 100%; overflow: hidden; }
.cote { display: none; }
.principal { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }

/* ---------- En-tête ---------- */
.entete {
  position: relative; z-index: 1;
  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; letter-spacing: -.01em; }
.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; }
/* Le contenu s'estompe sous l'en-tête dès qu'on fait défiler, au lieu d'une barre opaque (apple-design §12). */
.entete::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 10px; pointer-events: none;
  background: linear-gradient(rgba(0, 0, 0, .16), transparent);
  opacity: 0; transition: opacity 160ms ease-out;
}
.entete.estompe::after { opacity: 1; }

/* ---------- Liste ---------- */
.zone { flex: 1; overflow: auto; overscroll-behavior: contain; 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;
  max-height: 120px; overflow: hidden;
  touch-action: pan-y; user-select: none; -webkit-user-select: none;
  transition: transform 180ms ease-out, opacity 180ms ease-out;
}
.article.parti { transform: translateX(40px); opacity: 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;
  opacity: 0; transition: opacity 180ms ease-out;
}
.voile.vu { opacity: 1; }
.feuille {
  background: var(--carte); width: 100%; border-radius: 20px 20px 0 0; max-height: 88dvh;
  display: flex; flex-direction: column; padding-bottom: var(--bas);
  transform: translateY(16px); opacity: .7;
  transition: transform 240ms cubic-bezier(.32, .72, 0, 1), opacity 180ms ease-out;
}
.voile.vu .feuille { transform: none; opacity: 1; }
.voile.sortie { opacity: 0; }
.voile.sortie .feuille { transform: translateY(100%); }
.poignee { flex: none; display: flex; justify-content: center; padding: 8px 0 0; touch-action: none; cursor: grab; }
.poignee span { width: 36px; height: 5px; border-radius: 3px; background: var(--trait); }
.feuille header { display: flex; align-items: center; padding: 14px 12px 6px 16px; }
.feuille header h2 { flex: 1; margin: 0; font-size: 18px; letter-spacing: -.01em; 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; }
/* Mot de passe : l'œil se pose dans le champ, à droite, sans lui retirer sa largeur (cible de 44 px). */
.champ-voir { position: relative; }
.champ-voir .champ { padding-right: 52px; }
.voir {
  position: absolute; top: 3px; right: 3px; bottom: 3px; width: 44px; border-radius: 50%;
  display: grid; place-items: center; color: var(--texte-doux);
}
.voir:hover { background: var(--fond); color: var(--accent-fonce); }
.voir svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.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;
  display: inline-flex; align-items: center; min-height: 44px; }
.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: 44px; }
.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; letter-spacing: -.01em; }
.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; letter-spacing: -.02em; }
.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; }

/* Écran de démarrage : marque zerofuss, retiré dès que l'application est prête (après 1,5 s). */
.demarrage {
  position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; padding: 24px;
  background: #f4f6f8; color: #5b6670;
  transition: opacity 320ms ease-out;
}
.demarrage.parti { opacity: 0; pointer-events: none; }
.demarrage-logo { width: min(64vw, 260px); height: auto; }
.demarrage-baseline { margin: 0; font-size: 15px; letter-spacing: .01em; text-align: center; }
@media (prefers-reduced-motion: reduce) { .demarrage { transition: none; } }

/* Invitation : un seul écran, deux onglets (connexion par défaut, création sur demande). */
.onglets { display: flex; gap: 4px; padding: 4px; background: var(--accent-pale); border-radius: 12px; margin-bottom: 18px; }
.onglet {
  flex: 1; min-height: 44px; padding: 10px 12px; border-radius: 9px;
  color: var(--accent-fonce); font-weight: 600;
  transition: transform 100ms ease-out, background-color 150ms ease-out, color 150ms ease-out;
}
.onglet:active { transform: scale(.97); }
.onglet[aria-selected="true"] { background: var(--carte); color: var(--texte); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

/* ---------- 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; }
  /* la poignée reste visible : le geste doit être essayable aussi à la souris */
  .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; }
  /* On garde les fondus, qui aident à comprendre ; on coupe déplacements et changements d'échelle. */
  .feuille, .voile.sortie .feuille, .article, .bouton:active, .caddie:active, .mini:active,
  .sugg:active, .plus:active, .fermer:active, .carte-liste:active, .ajout-ligne .valider:active,
  .voir:active, .entete .icone:active, .ligne button.t:active, .cote .liste-cote:active { transform: none !important; }
  .feuille, .voile { transition-duration: 120ms !important; }
}

/* ---------- Mode sombre ----------
   Mêmes rôles de couleur, valeurs retournées : le vert de l'accent reste porteur de texte blanc,
   le vert clair sert de texte sur les fonds pâles, et les gris gardent les contrastes AA. */
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #0b7d57;
    --accent-vif: #17b884;
    --accent-fonce: #6fe0b4;
    --accent-pale: #123a2f;
    --texte: #e8eef3;
    --texte-doux: #a3b0bb;
    --fond: #101417;
    --carte: #1a2026;
    --trait: #2b343c;
    --danger: #ff8a80;
    --danger-pale: #3a1f1d;
    --ombre: 0 2px 10px rgba(0, 0, 0, .45);
  }
  .sugg { background: var(--carte); }
  .champ { background: var(--carte); }
  .bandeau-hl { background: #3a3115; color: #f0d79a; }
  .entete::after { background: linear-gradient(rgba(0, 0, 0, .45), transparent); }
}
