/* Feuille de style commune : l'accueil et chaque module la chargent (/static/style.css).
   Une maison chaleureuse : fond crème, une couleur vive par module, coins bien ronds, titres arrondis (la police
   arrondie de l'iPhone, sans téléchargement), boutons en relief. Pensée d'abord pour le téléphone ; thème clair ou
   sombre selon l'appareil, le sombre restant chaud (bruns profonds plutôt que gris). */
:root {
  color-scheme: light dark;
  --fond: #fff7ee;
  --surface: #ffffff;
  --surface-2: #fdeee0;
  --texte: #2d2019;
  --texte-2: #7a6454;
  --bord: #f0ddca;
  --accent: #cf3f24; /* corail profond : le texte blanc y reste lisible */
  --accent-vif: #ff7a59; /* corail décoratif */
  --accent-texte: #ffffff;
  --accent-doux: #ffe4d9;
  --accent-ombre: #9a2b15;
  --soleil: #ffc93c;
  --danger: #c0262d;
  --ok: #1f7a4d;
  --rayon: 22px;
  --ombre: 0 1px 0 rgb(120 70 30 / 0.05), 0 14px 30px -16px rgb(120 70 30 / 0.32);
  --police-titre: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", system-ui, sans-serif;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #1b1411;
    --surface: #271d17;
    --surface-2: #33261e;
    --texte: #fbeee3;
    --texte-2: #c8b09e;
    --bord: #45342a;
    --accent: #ff8a6b;
    --accent-vif: #ff8a6b;
    --accent-texte: #2a0f05;
    --accent-doux: #4a2419;
    --accent-ombre: #b5543a;
    --soleil: #ffd25e;
    --danger: #ff8a80;
    --ok: #7fd6a4;
    --ombre: 0 14px 30px -18px rgb(0 0 0 / 0.7);
  }
}

/* Une couleur par module : l'accueil la met sur chaque tuile, et la page d'un module porte module-<id> sur <body>. */
.module-rappels {
  --accent: #cf3f24;
  --accent-vif: #ff7a59;
  --accent-doux: #ffe4d9;
  --accent-ombre: #9a2b15;
}

.module-scanner {
  --accent: #6b3fd4;
  --accent-vif: #9b7bff;
  --accent-doux: #ece5ff;
  --accent-ombre: #4a2a9c;
}

.module-recettes {
  --accent: #b45309;
  --accent-vif: #f5a524;
  --accent-doux: #ffefd2;
  --accent-ombre: #7a3806;
}

.module-courses {
  --accent: #0f7a55;
  --accent-vif: #2fc48d;
  --accent-doux: #d8f4e7;
  --accent-ombre: #075a3e;
}

.module-budget {
  --accent: #1f56c9;
  --accent-vif: #5b8def;
  --accent-doux: #dfe8ff;
  --accent-ombre: #143c8f;
}

.module-repas {
  --accent: #b5246a;
  --accent-vif: #f0619f;
  --accent-doux: #fde0ee;
  --accent-ombre: #84144b;
}

@media (prefers-color-scheme: dark) {
  .module-rappels {
    --accent: #ff8a6b;
    --accent-vif: #ff8a6b;
    --accent-doux: #4a2419;
    --accent-ombre: #b5543a;
  }

  .module-scanner {
    --accent: #b6a0ff;
    --accent-vif: #b6a0ff;
    --accent-doux: #31285a;
    --accent-ombre: #7b62d8;
  }

  .module-recettes {
    --accent: #ffb547;
    --accent-vif: #ffb547;
    --accent-doux: #4a3314;
    --accent-ombre: #c27f1c;
  }

  .module-courses {
    --accent: #54d8a5;
    --accent-vif: #54d8a5;
    --accent-doux: #163f30;
    --accent-ombre: #2a9c70;
  }

  .module-budget {
    --accent: #8aabff;
    --accent-vif: #8aabff;
    --accent-doux: #1f2b4d;
    --accent-ombre: #5878cc;
  }

  .module-repas {
    --accent: #ff8cc0;
    --accent-vif: #ff8cc0;
    --accent-doux: #4a1d33;
    --accent-ombre: #c8588b;
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--fond);
  color: var(--texte);
  font-size: 17px;
  line-height: 1.45;
}

/* Deux taches de couleur douces en haut de page : le soleil et la couleur du module. */
body::before {
  position: fixed;
  inset: 0 0 auto;
  z-index: -1;
  height: 420px;
  pointer-events: none;
  background:
    radial-gradient(260px 220px at 12% 8%, color-mix(in srgb, var(--soleil) 32%, transparent), transparent 70%),
    radial-gradient(300px 240px at 92% 0%, color-mix(in srgb, var(--accent-vif) 28%, transparent), transparent 70%);
  content: "";
}

h1,
h2,
h3 {
  font-family: var(--police-titre);
  letter-spacing: -0.01em;
}

.entete,
.contenu {
  max-width: 720px;
  margin: 0 auto;
  padding-inline: 16px;
}

.entete {
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: 14px;
}

.entete h1 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.15;
}

/* La pastille d'un module, à côté de son titre. */
.pastille {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 48px;
  height: 48px;
  background: var(--accent-doux);
  border-radius: 16px;
  font-size: 1.6rem;
  transform: rotate(-6deg);
  view-transition-name: pastille; /* voir « Transitions entre les pages » */
}

.sous-titre {
  margin: 6px 0 0;
  color: var(--texte-2);
}

.retour {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: 6px;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.contenu {
  display: grid;
  gap: 16px;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
}

.carte {
  margin: 0;
  padding: 18px 16px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
}

@media (prefers-color-scheme: dark) {
  .carte {
    border-color: var(--bord);
  }
}

.carte h2 {
  margin: 0 0 12px;
  font-size: 1.2rem;
}

/* --- Accueil --- */

.salut {
  margin: 0;
  font-family: var(--police-titre);
  font-size: clamp(1.6rem, 7.5vw, 2.1rem);
  font-weight: 800;
  line-height: 1.15;
}

.entete-ligne {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: 52px;
  height: 52px;
  overflow: hidden;
  background: var(--accent);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--accent-ombre);
  color: var(--accent-texte);
  font-family: var(--police-titre);
  font-size: 1.3rem;
  font-weight: 800;
  text-decoration: none;
}

.avatar:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--accent-ombre);
}

.avatar .portrait {
  width: 100%;
  height: 100%;
  font-size: 1.3rem;
}

/* Le visage d'un membre : sa photo, ou son initiale sur sa couleur (portrait() dans commun.js). */
.portrait {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: var(--taille, 28px);
  height: var(--taille, 28px);
  overflow: hidden;
  background: var(--fond-portrait, var(--accent));
  border-radius: 999px;
  color: #fff;
  font-family: var(--police-titre);
  font-size: calc(var(--taille, 28px) * 0.46);
  font-weight: 800;
  line-height: 1;
}

.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Plusieurs visages qui se chevauchent un peu, comme sur l'iPhone. */
.visages {
  display: flex;
  align-items: center;
}

.visages .portrait {
  box-shadow: 0 0 0 2px var(--surface);
}

.visages .portrait + .portrait {
  margin-left: -8px;
}

/* Les tuiles : une mosaïque colorée, la première (Rappels) sur toute la largeur. */
.tuiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 640px) {
  .tuiles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.tuiles > li:first-child {
  grid-column: 1 / -1;
}

/* Sur deux colonnes, une tuile seule sur la dernière ligne prend toute la largeur, comme la première. */
@media (max-width: 639px) {
  .tuiles > li:last-child:nth-child(even) {
    grid-column: 1 / -1;
  }

  .tuiles > li:last-child:nth-child(even) .tuile {
    grid-template-columns: auto 1fr;
    align-items: center;
    min-height: 0;
  }
}

.tuile {
  display: grid;
  align-content: space-between;
  gap: 14px;
  height: 100%;
  min-height: 148px;
  padding: 16px;
  background: var(--accent-doux);
  border-radius: 26px;
  box-shadow: var(--ombre);
  color: var(--texte);
  text-decoration: none;
  transition: transform 0.12s ease;
}

.tuiles > li:first-child .tuile {
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 0;
}

.tuile:active {
  transform: scale(0.97) rotate(-0.5deg);
}

.tuile-icone {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: 0 3px 0 color-mix(in srgb, var(--accent-vif) 45%, transparent);
  font-size: 2rem;
  transform: rotate(-7deg);
}

.tuiles > li:nth-child(even) .tuile-icone {
  transform: rotate(6deg);
}

.tuile-texte strong {
  display: block;
  font-family: var(--police-titre);
  font-size: 1.2rem;
  font-weight: 800;
}

.tuile-texte span {
  display: block;
  margin-top: 2px;
  color: var(--texte-2);
  font-size: 0.92rem;
  line-height: 1.3;
}

.tuile-texte .tuile-resume {
  color: var(--accent);
  font-weight: 700;
}

/* --- Boutons et champs --- */

.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 20px;
  background: var(--surface-2);
  border: 0;
  border-radius: 16px;
  color: var(--texte);
  font: inherit;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.bouton:active:not(:disabled) {
  transform: translateY(2px);
}

.bouton-principal {
  background: var(--accent);
  box-shadow: 0 4px 0 var(--accent-ombre);
  color: var(--accent-texte);
}

.bouton-principal:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--accent-ombre);
}

.bouton-accent {
  background: var(--accent-doux);
  color: var(--accent);
}

.bouton-discret {
  min-height: 40px;
  padding: 0 12px;
  background: transparent;
  font-size: 0.95rem;
}

.bouton:disabled {
  background: var(--surface-2);
  box-shadow: none;
  color: var(--texte-2);
  cursor: not-allowed;
}

/* Un bouton d'action déjà faite (« ✓ Dans la liste de courses ») : acquis, pas éteint. */
.bouton-accent:disabled {
  background: transparent;
  box-shadow: inset 0 0 0 2px var(--accent-doux);
  color: var(--accent);
  cursor: default;
}

.champ {
  display: grid;
  gap: 6px;
}

.champ > span {
  font-size: 0.95rem;
  font-weight: 700;
}

input[type="text"],
input[type="password"],
select {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  background: var(--fond);
  border: 2px solid var(--bord);
  border-radius: 14px;
  color: var(--texte);
  font: inherit;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
  border-color: var(--accent-vif);
  outline: none;
}

:is(a, button, input, select, textarea, .bouton):focus-visible {
  outline: 3px solid var(--accent-vif);
  outline-offset: 2px;
}

.message {
  min-height: 1.45em;
  margin: 12px 0 0;
}

.message.ok {
  color: var(--ok);
}

.message.erreur {
  color: var(--danger);
}

.vide {
  margin: 0;
  color: var(--texte-2);
}

.alerte {
  margin: 0;
  padding: 14px 16px;
  background: var(--accent-doux);
  border-radius: 18px;
}

[hidden] {
  display: none !important;
}

/* Bandeau hors ligne (static/commun.js) */
.bandeau-connexion {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: #7a4f00;
  color: #fff;
  font-size: 0.92rem;
  font-weight: 700;
  text-align: center;
}

/* Transitions entre les pages (View Transitions : Safari 18.2, Chrome 126). Comme sur l'iPhone, la page qui s'ouvre
   glisse depuis la droite, et revenir à l'accueil la fait repartir vers la droite. L'emoji de la tuile touchée
   s'envole jusqu'au titre de la page (accueil.js le nomme « pastille » au toucher) ; sans pendant sur l'autre page, la
   pastille arrive d'un petit bond, ou part avec sa page. Sans prise en charge, on change de page comme avant.
   Chaque page déclare aussi @view-transition dans un <style> en tête : déclarée seulement ici, la transition
   était annulée une fois sur deux (la page se mettait en forme avant l'arrivée de ce fichier). */
@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.4s;
  animation-timing-function: cubic-bezier(0.2, 0.85, 0.25, 1);
  animation-fill-mode: both;
}

::view-transition-old(root) {
  animation-name: part-a-gauche;
}

::view-transition-new(root) {
  animation-name: arrive-de-droite;
  box-shadow: 0 0 40px rgb(0 0 0 / 0.18);
}

/* Retour : vers l'accueil (data-page sur sa balise html), ou dans une page (Recettes : de la fiche à la liste). */
html[data-page="accueil"]::view-transition-old(root),
html[data-sens="retour"]::view-transition-old(root) {
  z-index: 1;
  animation-name: part-a-droite;
  box-shadow: 0 0 40px rgb(0 0 0 / 0.18);
}

html[data-page="accueil"]::view-transition-new(root),
html[data-sens="retour"]::view-transition-new(root) {
  animation-name: arrive-de-gauche;
  box-shadow: none;
}

::view-transition-group(pastille) {
  animation-duration: 0.5s;
  animation-timing-function: cubic-bezier(0.3, 1.35, 0.45, 1);
}

::view-transition-new(pastille):only-child {
  animation: pastille-arrive 0.45s 0.15s cubic-bezier(0.3, 1.6, 0.45, 1) both;
}

/* Sans pendant, l'ancienne pastille part avec sa page (translate : transform place déjà le groupe). */
::view-transition-old(pastille):only-child {
  animation: pastille-part-a-gauche 0.4s cubic-bezier(0.2, 0.85, 0.25, 1) both;
}

html[data-page="accueil"]::view-transition-old(pastille):only-child,
html[data-sens="retour"]::view-transition-old(pastille):only-child {
  animation-name: pastille-part-a-droite;
}

@keyframes part-a-gauche {
  to {
    opacity: 0.5;
    transform: translateX(-28%);
  }
}

@keyframes arrive-de-droite {
  from {
    transform: translateX(100%);
  }
}

@keyframes part-a-droite {
  to {
    transform: translateX(100%);
  }
}

@keyframes arrive-de-gauche {
  from {
    opacity: 0.5;
    transform: translateX(-28%);
  }
}

@keyframes pastille-arrive {
  from {
    opacity: 0;
    transform: scale(0.3) rotate(-30deg);
  }
}

@keyframes pastille-part-a-gauche {
  to {
    opacity: 0;
    translate: -28vw 0;
  }
}

@keyframes pastille-part-a-droite {
  to {
    translate: 100vw 0;
  }
}

/* Tirer pour actualiser (static/commun.js) : une pastille qui descend avec le doigt, retenue par un ressort. Pendant
   le geste (.glisse), elle suit le doigt ; ensuite, elle se déplace avec un léger rebond. */
.tirer {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 10px);
  left: 50%;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px 6px 6px;
  background: var(--surface);
  border: 1px solid var(--bord);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.16);
  color: var(--texte);
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -72px);
  transition: transform 0.45s cubic-bezier(0.2, 1.4, 0.4, 1), opacity 0.3s ease;
}

.tirer.glisse {
  transition: none;
}

.tirer-icone {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 999px;
  color: var(--accent-texte);
  font-size: 1.2rem;
  font-weight: 800;
}

.tirer.pret .tirer-icone {
  background: var(--soleil);
  color: #2d2019;
  animation: pop 0.3s ease-out;
}

.tirer.en-cours .tirer-icone {
  background: var(--soleil);
  color: #2d2019;
  animation: tourne 0.7s linear infinite;
}

.tirer.fini .tirer-icone {
  background: #2e8b57;
  color: #fff;
  animation: pop 0.35s ease-out;
}

.tirer.erreur .tirer-icone {
  background: #b5651d;
  color: #fff;
  animation: pop 0.35s ease-out;
}

@keyframes pop {
  50% {
    transform: scale(1.3);
  }
}

@keyframes tourne {
  to {
    transform: rotate(360deg);
  }
}

/* La petite fête quand on coche (static/commun.js, feter) */
.confetti {
  position: fixed;
  z-index: 60;
  font-size: 1.4rem;
  pointer-events: none;
  animation: envol 0.95s ease-out forwards;
}

@keyframes envol {
  from {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.5);
  }

  to {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.1) rotate(var(--rot));
  }
}

@media (prefers-reduced-motion: reduce) {
  .confetti {
    display: none;
  }

  .tirer,
  .tirer .tirer-icone {
    animation: none !important;
    transition: none;
  }

  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }

  .tuile,
  .bouton,
  .avatar {
    transition: none;
  }
}
