/* Ajustements propres à Recette, par-dessus Pico.css qui fournit l'essentiel.
   Les couleurs viennent des variables de Pico (--pico-...) : elles suivent
   d'elles-mêmes le mode sombre du téléphone. */

/* Titres un peu plus petits que ceux de Pico, pensés pour un écran
   d'ordinateur : sur un téléphone, un titre de section ne doit pas prendre
   deux lignes. */
h1 {
  --pico-font-size: 1.75rem;
}

h2 {
  --pico-font-size: 1.35rem;
}

h3 {
  --pico-font-size: 1.1rem;
}

/* Logo et nom de l'application dans la barre de navigation. */
nav .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: bold;
  text-decoration: none;
}

nav .brand img {
  width: 2rem;
  height: 2rem;
}

/* Formulaires courts (connexion, invitation) : pas de lignes trop longues
   sur un grand écran. */
.narrow {
  max-width: 32rem;
  margin-inline: auto;
}

/* Rangée de petits boutons d'action, chacun dans son formulaire. Pico donne
   toute la largeur aux boutons d'envoi ; ici ils reprennent leur taille. */
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: var(--pico-spacing);
}

.actions form {
  margin: 0;
}

.actions button,
.actions [role="button"] {
  width: auto;
  margin: 0;
}

.success {
  color: var(--pico-ins-color);
}

.muted {
  color: var(--pico-muted-color);
}

.field-error {
  color: var(--pico-del-color);
}

/* Masqué à l'écran, mais toujours là pour le clavier et les lecteurs
   d'écran : le champ d'envoi de photos, remplacé par un bouton.
   « !important » : les règles de Pico pour les champs (toute la largeur,
   marges) sont plus précises qu'une simple classe et l'emporteraient. */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

/* Titre de page et bouton d'action sur la même ligne. */
.page-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: var(--pico-spacing);
}

.page-heading h1 {
  margin: 0;
}

.page-heading [role="button"] {
  width: auto;
}

.page-footer {
  margin-top: calc(var(--pico-spacing) * 2);
  text-align: center;
}

/* ---- Liste des recettes ---- */

/* Recherche : le champ sur toute la largeur, les filtres repliés dessous.
   L'élément <search> est récent : un navigateur plus ancien le mettrait en
   ligne, comme un mot. */
search {
  display: block;
}

.search {
  margin-bottom: var(--pico-spacing);
}

.search input[type="search"] {
  margin-bottom: 0.5rem;
}

.filters {
  margin-bottom: 0;
}

.filters summary {
  color: var(--pico-muted-color);
  font-size: 0.9rem;
}

/* Trois menus côte à côte sur un grand écran, l'un sous l'autre sur un
   téléphone, où leurs libellés seraient sinon coupés. */
.filter-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0 0.75rem;
  margin-top: 0.5rem;
}

.filter-fields select {
  margin-bottom: 0.5rem;
}

.results-summary {
  margin-bottom: 0.5rem;
  color: var(--pico-muted-color);
}

.results-summary a {
  margin-left: 0.5rem;
}

.recipe-list {
  margin: 0 0 var(--pico-spacing);
  padding: 0;
}

.recipe-list li {
  margin: 0;
  list-style: none;
}

.recipe-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--pico-muted-border-color);
  color: inherit;
  text-decoration: none;
}

.recipe-card img,
.recipe-card .no-photo {
  flex: 0 0 4.5rem;
  width: 4.5rem;
  height: 4.5rem;
  border-radius: var(--pico-border-radius);
  object-fit: cover;
}

/* Recette sans photo : sa première lettre, sur un fond de la couleur du
   site. */
.no-photo {
  display: grid;
  place-items: center;
  background: var(--pico-primary-focus);
  color: var(--pico-primary);
  font-size: 1.75rem;
  font-weight: bold;
}

.card-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Description sur deux lignes au plus, coupée par des points de
   suspension. */
.card-description {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

/* ---- Fiche recette ---- */

.recipe h1 {
  margin-bottom: 0.5rem;
}

.recipe h2 {
  margin-top: var(--pico-spacing);
}

.recipe h3 {
  --pico-font-size: 1.05rem;
  margin: var(--pico-spacing) 0 0.25rem;
}

.lead {
  color: var(--pico-muted-color);
}

/* Les photos défilent horizontalement, une à la fois (scroll-snap) ; la
   suivante dépasse un peu, pour montrer qu'il y en a d'autres. */
.gallery {
  display: flex;
  gap: 0.5rem;
  margin-bottom: var(--pico-spacing);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.gallery a {
  flex: 0 0 88%;
  scroll-snap-align: center;
}

.gallery a:only-child {
  flex-basis: 100%;
}

.gallery img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--pico-border-radius);
  object-fit: cover;
}

/* Sur un téléphone, les photos vont d'un bord à l'autre de l'écran. */
@media (max-width: 575px) {
  .gallery {
    margin-inline: calc(var(--pico-spacing) * -1);
  }

  .gallery img {
    border-radius: 0;
  }
}

.times,
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0 0 var(--pico-spacing);
  padding: 0;
}

.times li,
.tags li {
  margin: 0;
  list-style: none;
  white-space: nowrap;
}

.tags {
  gap: 0.4rem;
}

.tags li {
  border-radius: 1rem;
  background: var(--pico-primary-focus);
  font-size: 0.875rem;
}

/* Un tag est un lien vers les autres recettes qui le portent : toute la
   pastille se touche. */
.tags a {
  display: block;
  padding: 0.1rem 0.7rem;
  color: inherit;
  text-decoration: none;
}

.favorite {
  margin: 0;
}

/* Réglage des portions : − 4 personnes + */
.servings {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.servings [role="button"],
.servings button {
  display: inline-grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  font-size: 1.4rem;
  line-height: 1;
}

.original-servings {
  margin-bottom: 0.5rem;
}

/* Ingrédients sur deux colonnes : la quantité, puis l'ingrédient. Avec
   subgrid, les colonnes de toutes les lignes s'alignent sur la quantité la
   plus large. */
.ingredient-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 0.9rem;
  margin: 0;
  padding: 0;
}

.ingredient-list li {
  display: grid;
  grid-template-columns: 7rem 1fr;
  grid-column: 1 / -1;
  column-gap: 0.9rem;
  margin: 0;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--pico-muted-border-color);
  list-style: none;
}

@supports (grid-template-columns: subgrid) {
  .ingredient-list li {
    grid-template-columns: subgrid;
  }
}

.amount {
  font-weight: 600;
  white-space: nowrap;
}

/* Mode cuisine (app.js) : un peu plus grand, et un appui sur un ingrédient
   ou une étape la barre. */
.cooking-help {
  margin-top: calc(var(--pico-spacing) * -0.5);
}

.cooking .recipe-body {
  font-size: 1.1em;
}

.cooking .ingredient-list li,
.cooking .steps li,
.cooking .steps p {
  cursor: pointer;
}

.done {
  color: var(--pico-muted-color);
  text-decoration: line-through;
}

/* Boutons « Ajouter à Bring », « Copier la liste » et du panier, sous les
   ingrédients. */
.export {
  margin-top: var(--pico-spacing);
}

/* Le panier sur la fiche : le bouton, et le lien vers le panier une fois la
   recette dedans. */
.cart-button {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

.in-cart {
  font-weight: 600;
}

.steps ol,
.steps ul {
  padding-left: 1.25rem;
}

.steps li {
  margin-bottom: 0.6rem;
}

/* Sur un grand écran : ingrédients et matériel à gauche, étapes à droite. */
@media (min-width: 768px) {
  .recipe-body {
    display: grid;
    grid-template-columns: minmax(16rem, 1fr) 2fr;
    gap: 2.5rem;
    align-items: start;
  }
}

/* Lien public de la recette, en bas de la fiche. */
.share {
  margin-top: calc(var(--pico-spacing) * 2);
}

.share .actions {
  margin-top: calc(var(--pico-spacing) * -0.25);
}

.new-link button {
  width: auto;
  margin-bottom: 0.25rem;
}

.new-link small {
  display: block;
}

.recipe-meta {
  margin-top: calc(var(--pico-spacing) * 2);
  padding-top: var(--pico-spacing);
  border-top: 1px solid var(--pico-muted-border-color);
}

/* ---- Commentaires et propositions de modification ---- */

/* Encadré qui signale quelque chose à faire ou à savoir : propositions en
   attente, recette modifiée depuis une proposition. */
.notice {
  display: block;
  margin-bottom: var(--pico-spacing);
  padding: 0.75rem 1rem;
  border-left: 0.25rem solid var(--pico-primary-background);
  border-radius: var(--pico-border-radius);
  background: var(--pico-card-background-color);
  box-shadow: var(--pico-card-box-shadow);
}

.notice.warning {
  border-left-color: var(--pico-del-color);
}

.notice ul {
  margin: 0.5rem 0 0;
}

/* Pas de marge sous le dernier paragraphe : l'encadré a la sienne. Même
   chose pour le texte d'un commentaire. */
.notice > :last-child,
.comment-body > :last-child {
  margin-bottom: 0;
}

.notice li:last-child {
  margin-bottom: 0;
}

/* Le compteur de l'accueil : tout l'encadré est un lien. */
a.notice {
  font-weight: 600;
  text-decoration: none;
}

/* Message d'une proposition, réponse de l'auteur : les retours à la ligne
   saisis sont gardés. */
.message {
  white-space: pre-line;
}

.comment > header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.5rem;
}

.comment > footer {
  margin-bottom: calc(var(--pico-block-spacing-vertical) * -1);
}

/* Commentaire ou variante : les deux choix côte à côte, l'explication en
   dessous. */
.comment-kind label {
  display: inline-flex;
  align-items: center;
  margin: 0 1.5rem 0.25rem 0;
}

.comment-kind small {
  display: block;
}

.comment-form button {
  width: auto;
}

/* Différences d'une proposition : une ligne par élément, barrée si la
   proposition la retire, surlignée si elle l'ajoute. Un signe dans la marge
   (−, +, ~) le dit aussi à qui distingue mal les couleurs. */
.diff {
  margin: 0 0 var(--pico-spacing);
  padding: 0;
}

/* pre-wrap : les espaces en début de ligne restent visibles. Dans les
   étapes, ils mettent une ligne dans une sous-liste. */
.diff li {
  position: relative;
  margin: 0;
  padding: 0.35rem 0.5rem 0.35rem 1.6rem;
  border-bottom: 1px solid var(--pico-muted-border-color);
  list-style: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.diff li::before {
  position: absolute;
  left: 0.5rem;
  font-weight: bold;
}

.diff .same {
  color: var(--pico-muted-color);
}

.diff .removed {
  background: color-mix(in srgb, var(--pico-del-color) 10%, transparent);
}

.diff .removed::before {
  content: "−";
  color: var(--pico-del-color);
}

.diff .added {
  background: color-mix(in srgb, var(--pico-ins-color) 12%, transparent);
}

.diff .added::before {
  content: "+";
  color: var(--pico-ins-color);
}

.diff .changed::before {
  content: "~";
  color: var(--pico-primary);
}

.diff .skipped,
.diff .blank {
  color: var(--pico-muted-color);
  font-style: italic;
}

/* Dans une ligne retouchée, les mots changés ressortent sur leur fond. */
.diff .changed del,
.diff .changed ins {
  padding: 0 0.15em;
  border-radius: 0.2em;
}

.diff .changed del {
  background: color-mix(in srgb, var(--pico-del-color) 18%, transparent);
}

.diff .changed ins {
  background: color-mix(in srgb, var(--pico-ins-color) 22%, transparent);
}

.diff del + ins {
  margin-left: 0.25em;
}

.decision form,
.withdraw {
  margin-bottom: var(--pico-spacing);
}

.decision button,
.withdraw button {
  width: auto;
  margin-bottom: 0.25rem;
}

.decision small {
  display: block;
}

.proposal-list {
  margin: 0 0 var(--pico-spacing);
  padding: 0;
}

.proposal-list li {
  margin: 0;
  list-style: none;
}

.proposal-item {
  display: flex;
  flex-direction: column;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--pico-muted-border-color);
  color: inherit;
  text-decoration: none;
}

/* ---- Panier ---- */

.cart h2 {
  margin-top: var(--pico-spacing);
}

.cart-recipes {
  margin: 0 0 0.5rem;
  padding: 0;
}

.cart-recipes li {
  margin: 0;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--pico-muted-border-color);
  list-style: none;
}

.cart-title {
  font-weight: 600;
}

/* Sous le titre d'une recette : ses portions à gauche, « Retirer » à droite.
   Les formulaires reprennent la taille de leurs boutons. */
.cart-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-top: 0.35rem;
}

.cart-line form {
  margin: 0;
}

.cart-line .servings {
  margin: 0;
}

.cart-line button {
  margin: 0;
}

.cart-remove button {
  width: auto;
}

/* ---- Administration ---- */

/* Les deux pages de l'administration, comme des onglets. Pico.css écarte
   les éléments d'un <nav> aux deux bords : ici, ils restent groupés. */
.admin-nav {
  justify-content: flex-start;
  gap: 1.5rem;
  margin-bottom: var(--pico-spacing);
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.admin-nav a {
  margin-bottom: -1px;
  padding: 0.25rem 0;
  color: var(--pico-muted-color);
  text-decoration: none;
}

.admin-nav [aria-current="page"] {
  border-bottom: 2px solid var(--pico-primary);
  color: var(--pico-primary);
  font-weight: 600;
}

.notice.warning p {
  margin: 0.25rem 0 0;
  overflow-wrap: anywhere;
}

.backup-now {
  margin-bottom: calc(var(--pico-spacing) * 1.5);
}

.backup-now button {
  width: auto;
  margin-bottom: 0.25rem;
}

.backup-now small {
  display: block;
}

.backup-list {
  margin: 0 0 var(--pico-spacing);
  padding: 0;
}

.backup-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin: 0;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--pico-muted-border-color);
  list-style: none;
}

/* ---- Corbeille ---- */

.trashed {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.trashed form {
  margin: 0;
}

.trashed button {
  margin: 0;
}

/* ---- Formulaire d'une recette ---- */

.form-errors {
  border-left: 0.25rem solid var(--pico-del-color);
}

.form-errors ul {
  margin: 0.5rem 0 0;
}

/* Saisie rapide (phase 7) : une liste collée devient des lignes
   d'ingrédients. Repliée, elle tient sur une ligne en tête des
   ingrédients. */
.quick-entry {
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
  border: 1px dashed var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
}

.quick-entry summary {
  color: var(--pico-primary);
  font-weight: 600;
}

.quick-entry[open] summary {
  margin-bottom: 0.5rem;
}

.quick-entry textarea {
  margin-bottom: 0.5rem;
}

.quick-entry small {
  display: block;
}

.quick-entry button {
  width: auto;
  margin: 0.75rem 0 0;
}

.paste-status {
  margin: 0.5rem 0 0;
  font-weight: 600;
}

.paste-status:empty {
  display: none;
}

/* Ce que le vérificateur relève après l'enregistrement : un encadré
   ordinaire, les noms à vérifier bien lisibles. */
.check-warnings ul {
  margin-bottom: 0.5rem;
}

.check-warnings [role="button"] {
  width: auto;
  margin-top: 0.25rem;
}

/* Champs plus serrés dans les lignes répétées : sur un téléphone, une
   recette de dix ingrédients tient ainsi sur moins d'écrans. */
.rows {
  --pico-form-element-spacing-vertical: 0.5rem;
  --pico-form-element-spacing-horizontal: 0.6rem;
  display: grid;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.row {
  display: grid;
  gap: 0.4rem;
  align-items: center;
}

.row input,
.row select {
  margin: 0;
}

.row-buttons {
  display: flex;
  gap: 0.25rem;
  justify-content: flex-end;
}

.row-buttons button {
  width: 2.4rem;
  margin: 0;
  padding: 0.35rem 0;
}

.row-error {
  grid-column: 1 / -1;
  color: var(--pico-del-color);
}

/* Une ligne d'ingrédient sur un téléphone, en deux lignes :
   quantité, unité, nom / précision, boutons. */
.ingredient-row {
  grid-template-columns: 4.25rem 7.5rem 1fr auto;
  grid-template-areas:
    "quantity unit name name"
    "note note note buttons";
  padding-bottom: 0.75rem;
  border-bottom: 1px dashed var(--pico-muted-border-color);
}

.ingredient-row .quantity {
  grid-area: quantity;
}

.ingredient-row .unit {
  grid-area: unit;
}

.ingredient-row .name {
  grid-area: name;
}

.ingredient-row .note {
  grid-area: note;
}

.ingredient-row .row-buttons {
  grid-area: buttons;
}

/* Sur un grand écran, tout sur une ligne. */
@media (min-width: 768px) {
  .ingredient-row {
    grid-template-columns: 5rem 9rem 2fr 1.5fr auto;
    grid-template-areas: "quantity unit name note buttons";
  }
}

/* Titre de groupe : en gras, avec un trait de la couleur du site. */
.group-row {
  grid-template-columns: 1fr auto;
  padding-left: 0.6rem;
  border-left: 0.25rem solid var(--pico-primary-background);
}

.group-row .group {
  font-weight: 600;
}

.list-row {
  grid-template-columns: 1fr auto;
}

.servings-fields {
  display: grid;
  grid-template-columns: 5rem 1fr;
  gap: 0.5rem;
}

.servings-fields input {
  margin-bottom: 0.25rem;
}

.times-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.times-fields input {
  margin-bottom: 0.25rem;
}

/* Photos du formulaire : une grille de vignettes carrées, chacune avec ses
   boutons par-dessus. */
.photo-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  padding: 0;
}

.photo-list li {
  margin: 0;
  list-style: none;
}

.photo-item {
  position: relative;
}

.photo-item img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--pico-border-radius);
  object-fit: cover;
}

.photo-item .row-buttons {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
}

.photo-item .row-buttons button {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
}

/* La première photo est la vignette de la recette : inutile de l'avancer. */
.photo-item:first-child [data-row-action="up"] {
  display: none;
}

.photo-error {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--pico-del-color);
}

.photo-error button {
  width: 2.4rem;
  margin: 0;
  padding: 0.35rem 0;
}

.upload-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

.upload {
  position: relative;
  width: auto;
  margin-bottom: 0.5rem;
}

/* Le vrai champ est invisible : le contour du focus clavier va au bouton. */
.upload:focus-within {
  box-shadow: 0 0 0 var(--pico-outline-width) var(--pico-primary-focus);
}

/* Indicateur de chargement de HTMX : visible seulement pendant la requête.
   HTMX sait ajouter ce style lui-même, mais en l'écrivant dans la page, ce
   que la politique de sécurité interdit (voir base.html). */
.htmx-indicator {
  display: none;
}

.htmx-indicator.htmx-request {
  display: inline-block;
}

/* Boutons « Enregistrer » et « Annuler » toujours visibles en bas de
   l'écran, même au milieu d'un long formulaire. */
.form-actions {
  position: sticky;
  bottom: 0;
  z-index: 1;
  display: flex;
  gap: 0.75rem;
  margin-top: var(--pico-spacing);
  padding: 0.75rem 0;
  border-top: 1px solid var(--pico-muted-border-color);
  background: var(--pico-background-color);
}

.form-actions button,
.form-actions [role="button"] {
  flex: 1;
  margin: 0;
}

/* Le bouton d'envoi, plus large que « Annuler » : sur un téléphone,
   « Envoyer la proposition » tient ainsi sur une ligne. */
.form-actions button {
  flex: 2;
}

.delete-form {
  margin-top: calc(var(--pico-spacing) * 2);
}

.delete-form button {
  width: auto;
  margin-bottom: 0.25rem;
}

.delete-form small {
  display: block;
}

/* Message d'erreur d'une action HTMX (voir app.js). */
.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  z-index: 10;
  max-width: 32rem;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  border-radius: var(--pico-border-radius);
  background: var(--pico-del-color);
  color: #fff;
}
