/* Mes Bret's : design v4 validé le 2026-11-23 (voir design/DESIGN.md dans le dossier du projet). */
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/bricolage.woff2") format("woff2");
  font-weight: 600 800;
  font-display: swap;
}
@font-face {
  font-family: "Geist";
  src: url("/fonts/geist.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
}

:root {
  --fond: #f5f4f1;
  --surface: #ffffff;
  --doux: #f1efea;
  --encre: #16150f;
  --gris: #6b675f;
  --gris-nav: #8e8a81;
  --trait: #e4e1da;
  --vide: #eceae5;
  --paprika: #e8590c;
  --paprika-bouton: #c2470c;
  --paprika-texte: #a8400a;
  --titre: "Bricolage Grotesque", system-ui, sans-serif;
  --texte: "Geist", system-ui, -apple-system, sans-serif;
  --courbe: cubic-bezier(0.2, 0.8, 0.2, 1);
  --nav: 64px;
  --haut: env(safe-area-inset-top, 0px);
  --bas: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--fond); }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--fond);
  color: var(--encre);
  font: 400 15px/1.45 var(--texte);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; margin: 0; text-align: inherit; }
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--encre); outline-offset: 3px; border-radius: 12px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Cadre ---------- */
.page {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--haut) + 28px) 16px calc(var(--nav) + var(--bas) + 32px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.titre-ecran {
  font: 800 38px/1 var(--titre);
  letter-spacing: -1.2px;
}
.sous { color: var(--gris); font-size: 15px; }
.sous strong { color: var(--encre); font-weight: 600; }
.bloc { background: var(--surface); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.bloc h2 { font: 700 18px/1.2 var(--titre); }
.legende { font-size: 13px; color: var(--gris); }

/* ---------- Navigation ---------- */
.nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  height: calc(var(--nav) + var(--bas));
  padding: 6px 0 var(--bas);
  background: rgba(245, 244, 241, 0.94);
  border-top: 1px solid var(--trait);
  display: flex;
  justify-content: space-around;
}
@supports (backdrop-filter: blur(12px)) {
  .nav { background: rgba(245, 244, 241, 0.82); backdrop-filter: blur(12px) saturate(1.4); -webkit-backdrop-filter: blur(12px) saturate(1.4); }
}
@media (prefers-reduced-transparency: reduce) { .nav { background: var(--fond); backdrop-filter: none; -webkit-backdrop-filter: none; } }
.nav button {
  width: 96px; height: 52px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; color: var(--gris); /* 5,1:1, le gris plus clair ne passe pas pour du texte */
}
.nav button[aria-current="page"] { color: var(--encre); }
.nav svg { width: 24px; height: 24px; }

/* ---------- En-tête de la collection ---------- */
.entete { display: flex; flex-direction: column; gap: 10px; }
.ligne-compte { display: flex; align-items: baseline; justify-content: space-between; }
.pourcent { font: 700 15px var(--titre); color: var(--paprika-texte); }
.mur { display: grid; grid-template-columns: repeat(20, minmax(0, 1fr)); gap: 3px; }
.mur span { aspect-ratio: 1; border-radius: 3px; background: var(--trait); transition: background 0.3s; }
.mur span.ok { background: var(--c); }

/* ---------- Filtres ---------- */
.outils { display: flex; align-items: center; gap: 8px; }
.segments { flex: 1; display: flex; gap: 2px; padding: 4px; border-radius: 14px; background: #eae8e3; }
.segments button {
  flex: 1 1 0; height: 36px; border-radius: 10px;
  text-align: center; font-size: 14px; font-weight: 600; color: var(--gris);
  transition: background 0.2s, color 0.2s;
}
.segments button[aria-pressed="true"] { background: var(--surface); color: var(--encre); box-shadow: 0 1px 2px rgba(22, 21, 15, 0.08); }
.colonnes {
  width: 44px; height: 44px; border-radius: 14px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: #eae8e3; color: var(--gris);
}
.colonnes[aria-pressed="true"] { background: var(--encre); color: #fff; }
.puces-defil {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 0 16px;
}
.puces-defil::-webkit-scrollbar { display: none; }
.puce {
  flex: none; height: 36px; padding: 0 14px; border-radius: 18px;
  font-size: 14px; font-weight: 500; white-space: nowrap;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--trait);
}
.puce[aria-pressed="true"] { background: var(--encre); color: #fff; box-shadow: none; }

/* ---------- Grille des paquets ---------- */
.grille { display: grid; gap: 18px 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grille.c3 { gap: 14px 8px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.carte { display: flex; flex-direction: column; gap: 8px; min-width: 0; transition: transform 0.18s var(--courbe); }
.carte:active { transform: scale(0.96); }
.tuile {
  position: relative; aspect-ratio: 1; border-radius: 22px; padding: 12px;
  background: var(--vide); transition: background 0.3s;
}
.c3 .tuile { border-radius: 16px; padding: 6px; }
.tuile img { width: 100%; height: 100%; object-fit: contain; filter: grayscale(1); opacity: 0.42; transition: filter 0.3s, opacity 0.3s; }
.ok .tuile { background: var(--c); }
.ok .tuile img { filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.25)); opacity: 1; }
.coche {
  position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 11px;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  display: none; align-items: center; justify-content: center;
}
.ok .coche { display: flex; }
.carte .nom {
  font-size: 14px; font-weight: 600; line-height: 1.25; padding: 0 2px; color: var(--gris);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ok .nom { color: var(--encre); }
.c3 .carte .nom { font-size: 12px; }
.vide-texte { text-align: center; color: var(--gris); padding: 28px 12px; }

/* ---------- Classement ---------- */
.tete-ligne { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.bouton-noir {
  height: 44px; padding: 0 16px; border-radius: 22px; flex: none;
  background: var(--encre); color: #fff; font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; gap: 8px;
}
.palier { display: flex; flex-direction: column; gap: 8px; }
.palier-tete { display: flex; align-items: baseline; justify-content: space-between; padding: 0 4px; }
.palier-tete h2 { font: 700 20px/1.2 var(--titre); letter-spacing: -0.4px; }
.palier-tete span { font-size: 13px; color: var(--gris); }
.liste { list-style: none; margin: 0; padding: 6px; background: var(--surface); border-radius: 20px; min-height: 60px; display: flex; flex-direction: column; }
.rang {
  display: flex; align-items: center; gap: 10px; padding: 4px 0 4px 8px; border-radius: 14px; background: var(--surface);
  touch-action: pan-y; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.carte, .mur-grand, .nav, .segments, .puces-defil { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.rang.glisse { position: relative; z-index: 5; box-shadow: 0 12px 28px rgba(22, 21, 15, 0.18); transition: none; }
.rang .num { width: 26px; flex: none; text-align: center; font: 700 17px var(--titre); color: var(--paprika-texte); }
.rang .lien { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 52px; }
.vignette { width: 48px; height: 48px; flex: none; border-radius: 12px; padding: 3px; background: var(--c); }
.vignette img { width: 100%; height: 100%; object-fit: contain; }
.rang .textes { display: flex; flex-direction: column; min-width: 0; }
.rang .textes b { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rang .textes small { font-size: 13px; color: var(--gris); }
.prise {
  width: 44px; height: 44px; flex: none; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; color: var(--gris);
  touch-action: none;
}
.prise:active { cursor: grabbing; }
.liste-vide { padding: 14px 10px; font-size: 14px; color: var(--gris); }

/* ---------- Profil ---------- */
.mur-grand { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
.mur-grand button { aspect-ratio: 1; border-radius: 6px; background: #eeece7; transition: background 0.3s, transform 0.18s var(--courbe); }
.mur-grand button.ok { background: var(--c); }
.mur-grand button:active { transform: scale(0.88); }
.chiffres { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.chiffre { background: var(--surface); border-radius: 20px; padding: 16px; }
.chiffre b { display: block; font: 800 34px/1.1 var(--titre); }
.chiffre span { font-size: 14px; color: var(--gris); }
.preferee { grid-column: span 2; display: flex; align-items: center; gap: 12px; padding: 12px 16px 12px 12px; background: var(--surface); border-radius: 20px; }
.preferee .vignette { width: 56px; height: 56px; border-radius: 14px; }
.preferee b { font-weight: 600; font-size: 17px; }
.barre-ligne { display: flex; flex-direction: column; gap: 6px; }
.barre-ligne div:first-child { display: flex; justify-content: space-between; font-size: 14px; }
.barre-ligne div:first-child span { color: var(--gris); }
.barre { height: 6px; border-radius: 3px; background: #eeece7; overflow: hidden; }
.barre i { display: block; height: 100%; border-radius: 3px; background: var(--encre); }
.reglages { background: var(--surface); border-radius: 20px; padding: 4px 16px; display: flex; flex-direction: column; }
.reglage { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 54px; border-bottom: 1px solid #eeece7; }
.reglage:last-child { border-bottom: 0; }
.reglage .valeur { color: var(--gris); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.action-texte { min-height: 54px; display: flex; align-items: center; font-weight: 600; color: var(--paprika-texte); width: 100%; }
.mention { font-size: 12px; color: var(--gris); text-align: center; padding: 4px 12px; }

/* ---------- Interrupteur ---------- */
.interrupteur {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  min-height: 56px; padding: 0 16px; border-radius: 18px; background: var(--fond);
  font-weight: 600; font-size: 16px;
}
.reglage .interrupteur { background: none; padding: 0; min-height: 54px; font-weight: 400; font-size: 15px; }
.sw { width: 52px; height: 32px; border-radius: 16px; position: relative; background: #d6d2ca; transition: background 0.2s; flex: none; }
.sw::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 13px;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); transition: transform 0.2s var(--courbe);
}
[aria-checked="true"] .sw { background: var(--paprika-bouton); }
[aria-checked="true"] .sw::after { transform: translateX(20px); }

/* ---------- Fiche ---------- */
.voile { position: fixed; inset: 0; z-index: 20; background: rgba(22, 21, 15, 0.38); animation: fondu 0.25s ease; }
.feuille {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-width: 560px; margin: 0 auto; max-height: calc(100dvh - var(--haut) - 24px);
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 28px 28px 0 0;
  padding: 10px 20px calc(28px + var(--bas));
  display: flex; flex-direction: column; gap: 18px;
}
.feuille.entre { animation: monte 0.34s var(--courbe); }
.feuille-haut { position: relative; display: flex; justify-content: center; padding-top: 0; touch-action: none; }
.poignee { width: 40px; height: 5px; border-radius: 3px; background: #ddd9d1; margin: 0 auto; }
.fermer {
  position: absolute; right: -8px; top: -4px; width: 44px; height: 44px; border-radius: 22px;
  display: flex; align-items: center; justify-content: center; color: var(--gris);
}
.visuel {
  width: 100%; aspect-ratio: 4 / 3; border-radius: 24px; padding: 14px;
  background: var(--vide); display: flex; align-items: center; justify-content: center; touch-action: none;
}
.visuel img { height: 100%; width: auto; object-fit: contain; filter: grayscale(1); opacity: 0.5; transition: filter 0.3s, opacity 0.3s; }
.visuel.ok { background: var(--c); }
.visuel.ok img { filter: drop-shadow(0 12px 20px rgba(0, 0, 0, 0.3)); opacity: 1; }
.feuille h2 { font: 800 28px/1.05 var(--titre); letter-spacing: -0.6px; }
.etiquettes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.etiquette { font-size: 13px; padding: 5px 10px; border-radius: 999px; background: var(--doux); }
.nutri { font-weight: 600; }
.nutri-A { background: #038141; color: #fff; }
.nutri-B { background: #85bb2f; color: var(--encre); }
.nutri-C { background: #fecb02; color: var(--encre); }
.nutri-D { background: #ee8100; color: var(--encre); }
.nutri-E { background: #e63e11; color: #fff; }
.jauges { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.jauge { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--gris); }
.segs { display: flex; gap: 3px; }
.segs i { flex: 1; height: 6px; border-radius: 3px; background: var(--trait); }
.segs i.on { background: var(--encre); }
.champ { display: flex; flex-direction: column; gap: 6px; }
.champ > span { font-size: 13px; color: var(--gris); }
.champ input, .champ textarea {
  font-size: 16px; border-radius: 14px; border: 1px solid var(--trait);
  background: var(--surface); color: var(--encre); padding: 0 14px; width: 100%;
}
.champ input { height: 48px; }
.champ input[type="date"] { -webkit-appearance: none; appearance: none; display: flex; align-items: center; }
.champ textarea { padding: 12px 14px; resize: none; min-height: 96px; line-height: 1.4; }
.paliers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.paliers button { height: 44px; border-radius: 14px; text-align: center; font-size: 14px; font-weight: 600; background: var(--fond); }
.paliers button[aria-pressed="true"] { background: var(--encre); color: #fff; }
.etat-note { font-size: 12px; color: var(--gris); min-height: 16px; }

/* ---------- Connexion ---------- */
.connexion { max-width: 460px; margin: 0 auto; min-height: 100dvh; padding: calc(var(--haut) + 72px) 24px calc(var(--bas) + 40px); display: flex; flex-direction: column; gap: 28px; }
.connexion h1 { font: 800 44px/0.95 var(--titre); letter-spacing: -1.4px; }
.connexion .intro { font-size: 17px; color: var(--gris); line-height: 1.45; margin-top: 12px; }
.connexion form { display: flex; flex-direction: column; gap: 12px; }
.connexion .champ > span { font-size: 14px; }
.connexion .champ input { height: 54px; border-radius: 16px; font-size: 17px; }
.code-champ { font: 700 30px var(--titre) !important; letter-spacing: 10px; text-align: center; height: 64px !important; }
.bouton-plein {
  height: 54px; border-radius: 16px; background: var(--paprika-bouton); color: #fff;
  font-weight: 600; font-size: 17px; text-align: center; width: 100%;
}
.bouton-plein[disabled] { opacity: 0.6; }
.lien-texte { min-height: 44px; text-align: center; font-size: 15px; font-weight: 600; color: var(--paprika-texte); width: 100%; }
.erreur { color: #a3260e; font-size: 14px; font-weight: 500; }
.mur-accueil { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
.mur-accueil span { aspect-ratio: 1; border-radius: 5px; background: var(--c); }

/* ---------- Message ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav) + var(--bas) + 14px); z-index: 30;
  transform: translateX(-50%); max-width: calc(100% - 32px);
  background: var(--encre); color: #fff; padding: 12px 16px; border-radius: 14px;
  font-size: 14px; font-weight: 500; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  animation: fondu 0.2s ease;
}
.toast:empty { display: none; }

@keyframes monte { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fondu { from { opacity: 0; } to { opacity: 1; } }

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

/* Écran tactile : jamais de champ sous 16 px, sinon Safari zoome la page (Q-ECR-19). */
@media (pointer: coarse) {
  :root :is(input, textarea, select) { font-size: max(16px, 1em); }
}
