/* === Page de paiement : champs de carte PayGreen alignés sur Stripe Elements (Payment Element, thème « stripe ») === */

/* Cadre de saisie (Stripe Elements et PayGreen) de largeur unique : agencement stable et identique chez les deux,
   numéro sur toute la largeur puis date et code côte à côte. Le Payment Element choisit son agencement selon la largeur
   de son cadre (mesuré, non documenté par Stripe : trois champs empilés sous ~370 px, deux lignes de ~370 à ~760 px, une
   ligne au-delà) ; 36rem le garde sur deux lignes à toutes les largeurs d'ordinateur (sans élargir la colonne de paiement
   au-delà de la page). */
.cadre-saisie-carte {
  width: 36rem;
  max-width: 100%;
  margin-inline: auto;
  container-type: inline-size;
}

/* Payment Element sur téléphone (même condition que « max-sm: », voir tailwind_build/input.css) : ses intitulés réduits
   (stripe_core.js) abaissent à ~300 px le cadre nécessaire pour garder la date et le code côte à côte. Marges resserrées
   autour du cadre pour l'atteindre avec de la marge dès 360 px d'écran ; en dessous de ~340 px, les champs restent
   empilés. Stripe Elements seulement : ses deux cadres réunissent ces identifiants et « cadre-saisie-carte » ; le cadre
   PayGreen et celui de l'ancien Stripe (même identifiant, sans cette classe) gardent leurs marges. Les deux blocs de
   paiement (TR, CB) changent ensemble : ils restent alignés. */
@media not all and (min-width: 40rem), (max-height: 500px) and (orientation: landscape) {
  :has(> #zone-carte-bancaire):has(#zone-nouvelle-carte-tr.cadre-saisie-carte, #zone-nouvelle-carte-cb.cadre-saisie-carte)
    > :is(#zone-titre-restaurant, #zone-carte-bancaire) {
    margin-inline: -0.75rem;
    padding-inline: 0.25rem;
  }

  #zone-nouvelle-carte-tr.cadre-saisie-carte,
  #zone-nouvelle-carte-cb.cadre-saisie-carte {
    padding-inline: 0.375rem;
  }
}

/* Intitulés au-dessus des champs ; numéro sur toute la largeur, puis date d'expiration et code de sécurité côte à côte.
   Mêmes fond, bordure, arrondi, hauteur et anneau de sélection que les champs Stripe (apparence de stripe_core.js). */
.champs-carte {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: end; /* champs alignés même si un intitulé passe sur deux lignes */
  gap: 0.75rem;
}

.champs-carte .champ-carte--numero {
  grid-column: 1 / -1;
}

.champ-carte__libelle {
  display: block;
  margin-bottom: 0.25rem;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 0.93rem;
  color: #30313d;
}

.champ-carte__saisie {
  height: 44px;
  padding: 4px 0.75rem;
  background-color: #f6e6d6;
  border: 1px solid #e6e6e6;
  border-radius: 5px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.03), 0 3px 6px rgba(0, 0, 0, 0.02);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.champ-carte__saisie:focus-within {
  border-color: hsla(210, 96%, 45%, 50%);
  box-shadow: 0 0 0 3px hsla(210, 96%, 45%, 25%), 0 1px 1px rgba(0, 0, 0, 0.08);
}

/* PayGreen trace sa propre bordure (de la couleur du texte) dans son cadre, sans réglage possible : elle est rognée,
   le cadre ci-dessus la remplace */
.champ-carte__fenetre {
  height: 34px;
  overflow: hidden;
}

.champ-carte__fenetre > div {
  width: calc(100% + 8px);
  margin: -2px -4px 0;
}

/* Case « mémoriser ma carte » (cadre PayGreen, tous écrans) : PayGreen dessine le contour de la case non cochée dans un
   gris très pâle, sans réglage possible (ses options de style ne changent que la case cochée et le libellé). Le cadre
   est assombri pour que ce contour ressorte nettement sur le fond beige ; la coche et le libellé, déjà foncés, restent
   lisibles. */
#paygreen-reuse-checkbox-container iframe {
  filter: brightness(0.3);
}



/* === Page de paiement sur téléphone (moins de 640 px) : montants Titre-Restaurant en 2 × 2, écran de choix === */

/* Tableau d'une ligne d'intitulés et d'une ligne de montants : chaque intitulé passe au-dessus de son montant,
   deux par ligne. Au-delà de 640 px, le tableau reste inchangé. */
@media not all and (min-width: 40rem) {
  .tableau-montants-tr tbody {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 0.5rem;
  }

  .tableau-montants-tr tr {
    display: contents;
  }

  .tableau-montants-tr td {
    display: block;
    padding: 0.125rem 0.25rem;
    white-space: normal;
  }

  .tableau-montants-tr tr:first-child td:nth-child(1) { grid-area: 1 / 1; }
  .tableau-montants-tr tr:first-child td:nth-child(2) { grid-area: 1 / 2; }
  .tableau-montants-tr tr:first-child td:nth-child(3) { grid-area: 3 / 1; }
  .tableau-montants-tr tr:first-child td:nth-child(4) { grid-area: 3 / 2; }
  .tableau-montants-tr tr:last-child td:nth-child(1) { grid-area: 2 / 1; }
  .tableau-montants-tr tr:last-child td:nth-child(2) { grid-area: 2 / 2; }
  .tableau-montants-tr tr:last-child td:nth-child(3) { grid-area: 4 / 1; }
  .tableau-montants-tr tr:last-child td:nth-child(4) { grid-area: 4 / 2; }

  /* Paiement mixte : trois colonnes, la troisième sur toute la largeur */
  .tableau-montants-tr tr td:nth-child(3):last-child {
    grid-column: 1 / -1;
  }

  /* Montant à utiliser et bouton « Max » agrandis pour le doigt */
  .tableau-montants-tr input {
    width: 4.5rem;
    height: 2.5rem;
  }

  .tableau-montants-tr .btn {
    height: 2.5rem;
  }

  /* Écran de choix en une colonne : boutons de la boutique alignés sur ceux affichés par PayGreen (marges de la
     feuille PayGreen sur « pg-payment-method », colonne PayGreen réduite de 6 px à droite) */
  #paygreen-methods-wrapper button.pg-payment-method {
    width: calc(100% - 6px);
    margin: 0 0 5px; /* même écart entre tous les boutons, d'une colonne à l'autre (marges PayGreen de 5 px) */
  }

  /* « Payer … avec la carte Mastercard •••• 4444 » (cartes enregistrées PayGreen) : un libellé sur deux lignes reste
     dans son bouton */
  #paygreen-cartes-enregistrees .btn {
    height: auto;
    min-height: 2rem;
    padding-block: 0.25rem;
  }
}



/* === Contrôle d'affichage responsive pour le lien Accueil === */

/* Masquer tout par défaut */
.emoji,
.libelle,
.ensemble {
  display: none;
}

/* Petit écran < 350px : emoji seul */
@media (max-width: 349px) {
  .emoji {
    display: inline;
  }
}

/* Écran moyen entre 350px et 500px : libellé seul */
@media (min-width: 350px) and (max-width: 499px) {
  .libelle {
    display: inline;
  }
}

/* Grand écran ≥ 500px : emoji + libellé */
@media (min-width: 500px) {
  .ensemble {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
  }
}



/* === Détail d'une commande sur téléphone (moins de 640 px) : une carte par plat === */

/* Ligne de plat : nom en entier, puis « 2 × 12,50 € = 25,00 € ». Lignes du pied (frais, remise, participation,
   montant) : libellé à gauche, montant à droite. Au-delà de 640 px, le tableau reste inchangé. */
@media not all and (min-width: 40rem) {
  .tableau-lignes,
  .tableau-lignes tbody,
  .tableau-lignes tfoot {
    display: block;
    width: 100%;
  }

  .tableau-lignes thead {
    display: none;
  }

  .tableau-lignes tbody tr {
    display: grid;
    grid-template-columns: auto 1fr auto;
    column-gap: 0.375rem;
    row-gap: 0.125rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-base-300);
  }

  /* Les cellules du tableau ne passent pas à la ligne (daisyUI) : le texte le peut ici, les montants non */
  .tableau-lignes tbody td,
  .tableau-lignes tfoot td {
    display: block;
    padding: 0;
    border: 0;
    text-align: left;
    white-space: normal;
  }

  /* Nom du plat (ou « Aucun produit ») sur toute la largeur */
  .tableau-lignes tbody td:first-child {
    grid-column: 1 / -1;
  }

  .tableau-lignes tbody td:nth-child(3)::before {
    content: "× ";
  }

  .tableau-lignes tbody td:nth-child(4) {
    text-align: right;
    font-weight: 600;
    white-space: nowrap;
  }

  .tableau-lignes tbody td:nth-child(4)::before {
    content: "= ";
  }

  .tableau-lignes tfoot tr {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.25rem 0;
  }

  .tableau-lignes tfoot td:last-child {
    text-align: right;
    white-space: nowrap;
  }
}



/* Tous écrans : un long libellé du pied (prise en charge, reste à charge du jour…) passe à la ligne au lieu d'élargir
   le tableau au-delà de son cadre (cellules daisyUI en « nowrap ») ; un libellé qui tient sur une ligne est inchangé. */
.tableau-lignes tfoot td:first-child {
  white-space: normal;
}



/* === Contrôle d'affichage responsive mobile / desktop pour l'ajout rapide au panier === */

/* Ajout rapide au panier : désactivé par défaut */
.ajout-panier {
  display: none;
}

/* Si tactile détecté → affichage */
body.has-touch .ajout-panier {
  display: flex;
}

/* Si petit écran ET survol désactivé (fallback) */
@media (max-width: 600px) {
  body:not(.has-hover) .ajout-panier {
    display: flex;
  }
}

/* Si desktop + survol : affichage uniquement au hover */
body.has-hover .group:hover .ajout-panier {
  display: flex;
}

/* Téléphone (moins de 640 px, ou à l'horizontale : 500 px de haut au plus — même condition que « max-sm: », voir
   tailwind_build/input.css) : fiche produit compacte, deux par ligne (trois à l'horizontale) — image moins haute, nom sur deux lignes au plus, prix et ajout rapide (– +) sur la même ligne, boutons de 44 px ; ajout rapide
   toujours affiché (jamais pour un produit épuisé, classe « hidden »). La quantité à ajouter vaut 1 (champ masqué). */
@media not all and (min-width: 40rem), (max-height: 500px) and (orientation: landscape) {
  .carte-produit {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto 1fr auto;
    align-items: end;
  }

  /* Allergènes sous le nom, en haut de l'espace libre (écart 7) */
  .carte-produit__allergenes {
    grid-column: 1 / -1;
    align-self: start;
    padding: 0.125rem 0.5rem 0.25rem;
    line-height: 1.1rem;
  }

  .carte-produit__image {
    grid-column: 1 / -1;
    height: 7rem;
  }

  /* Contenu texte placé directement dans la grille de la fiche */
  .carte-produit__texte {
    display: contents;
  }

  .carte-produit__entete {
    grid-column: 1 / -1;
    align-self: start;
    min-width: 0;
    padding: 0.5rem 0.5rem 0;
    margin-bottom: 0;
  }

  .carte-produit__nom {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
  }

  .carte-produit__prix {
    grid-column: 1;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 0 0 0.5rem 0.5rem;
  }

  .carte-produit__prix span {
    white-space: nowrap;
  }

  body .ajout-panier {
    grid-column: 2;
    display: flex;
    position: static;
    padding: 0 0.375rem 0.375rem 0;
    box-shadow: none;
    background: transparent;
  }

  body .ajout-panier.hidden,
  body.has-hover .group:hover .ajout-panier.hidden {
    display: none;
  }

  .ajout-panier > div {
    gap: 0.25rem;
  }

  .ajout-panier .btn-circle {
    width: 2.75rem;
    height: 2.75rem;
  }

  .ajout-panier input {
    display: none;
  }
}



/* === Grille des blocs Restaurant / Traiteur / Privatisation : 3 images maximum par ligne === */

/* Colonne d'au moins 320px et d'au moins un tiers de la largeur (gouttières déduites) :
   3 colonnes au plus sur grand écran, 2 sur tablette, 1 sur mobile.
   min(100%, …) évite tout débordement sur un écran plus étroit que 320px. */
.grille-services {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, max(320px, calc((100% - 48px) / 3))), 1fr));
  gap: 24px;
  align-items: start;
}

/* Vitrine : une longue adresse écrite dans un texte (site, Instagram) passe à la ligne au lieu de faire déborder la page.
   « break-word » d'abord : Safari avant 15.4 ignore « anywhere » et laisserait l'adresse coupée au bord de l'écran. */
.page-vitrine .prose,
.page-vitrine .grille-services,
.page-vitrine .modal-box {
  word-break: break-word;
  overflow-wrap: break-word;
  overflow-wrap: anywhere;
}

/* Liens du texte des pages (site, Instagram, téléphone, e-mail) : visibles comme tels */
.page-vitrine .prose a {
  text-decoration: underline;
}

/* Galerie photos : grille de miniatures carrées (2 par ligne sur téléphone, 3 ou 4 sur grand écran), photo entière au clic */
.galerie-grille {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(45%, 280px), 1fr));
  gap: 12px;
}

.galerie-photo {
  display: block;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

.galerie-photo img {
  width: 100%;
  height: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.galerie-photo:hover img,
.galerie-photo:focus-visible img {
  transform: scale(1.03);
}

.galerie-agrandie__cadre {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100dvh;
  padding: 0.5rem;
  pointer-events: none; /* un clic à côté de la photo ferme la fenêtre */
}

.galerie-agrandie__cadre > * {
  pointer-events: auto;
}

#galerie-agrandie-image {
  width: auto;
  height: auto;
  max-width: calc(100vw - 1rem);
  max-height: calc(100dvh - 1rem);
  object-fit: contain;
  border-radius: 8px;
}

.galerie-agrandie__bouton {
  position: absolute;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 9999px;
  background: rgba(0, 0, 128, 0.85);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.galerie-agrandie__bouton--precedente {
  left: 0.5rem;
  top: calc(50% - 1.375rem);
}

.galerie-agrandie__bouton--suivante {
  right: 0.5rem;
  top: calc(50% - 1.375rem);
}

.galerie-agrandie__bouton--fermer {
  top: 0.5rem;
  right: 0.5rem;
}



/* Fiche détaillée d'un produit sur téléphone (moins de 640 px, ou à l'horizontale) : texte à gauche (nom, catégorie,
   prix, disponibilité, description), image à droite (40 % de la largeur, carrée, coins arrondis) ; un long texte
   reprend toute la largeur sous l'image. Panier et informations complémentaires en dessous ; « – » et « + » de 44 px. */
@media not all and (min-width: 40rem), (max-height: 500px) and (orientation: landscape) {
  .fiche-produit {
    display: block;
  }

  .fiche-produit__image {
    float: right;
    width: 40%;
    max-width: 11rem; /* à l'horizontale, l'image ne prend pas la moitié de la hauteur */
    margin: 0 0 0.5rem 0.75rem;
  }

  .fiche-produit__image img,
  .fiche-produit__image > div {
    width: 100%;
    height: auto;
    max-height: none;
    aspect-ratio: 1;
    object-fit: cover;
  }

  /* Texte en flux ordinaire : il contourne l'image, puis occupe toute la largeur */
  .fiche-produit__infos,
  .fiche-produit__texte {
    display: block;
    overflow-wrap: anywhere;
  }

  .fiche-produit__texte > * + * {
    margin-top: 0.5rem;
  }

  .fiche-produit__infos > :not(.fiche-produit__texte) {
    clear: both;
  }

  .fiche-produit .btn-circle {
    width: 2.75rem;
    height: 2.75rem;
  }

  .fiche-produit input[type="number"] {
    height: 2.75rem;
  }
}



/* Téléphone à l'horizontale (500 px de haut au plus) : trois produits par ligne dans le catalogue, la largeur le permet */
@media (max-height: 500px) and (orientation: landscape) {
  .grille-produits {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}



/* === Panier : libellés du pied (tous écrans) === */

/* Les cellules de tableau daisyUI ne passent pas à la ligne : un long libellé (prise en charge, reste à charge du jour…)
   élargissait le tableau au-delà de son cadre sur ordinateur. Il passe désormais à la ligne ; un libellé qui tient sur
   une ligne est inchangé. */
.tableau-panier tfoot td:first-child {
  white-space: normal;
}



/* === Panier sur téléphone (moins de 640 px, ou à l'horizontale) : une carte par plat === */

/* Ligne de plat : nom en entier (corbeille à droite), puis « [– 2 +]  × 12,50 €  = 25,00 € ».
   Lignes du pied (frais, remise, participation, montant) : libellé à gauche, montant à droite.
   Au-delà de 640 px, le tableau reste inchangé. */
@media not all and (min-width: 40rem), (max-height: 500px) and (orientation: landscape) {
  .tableau-panier,
  .tableau-panier tbody,
  .tableau-panier tfoot {
    display: block;
    width: 100%;
  }

  .tableau-panier thead {
    display: none;
  }

  .tableau-panier tbody tr {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    column-gap: 0.5rem;
    row-gap: 0.25rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--color-base-300);
  }

  /* Les cellules du tableau ne passent pas à la ligne (daisyUI) : le texte le peut ici, les montants non */
  .tableau-panier tbody td {
    display: block;
    padding: 0;
    border: 0;
    white-space: normal;
  }

  /* Nom du plat */
  .tableau-panier tbody td:nth-child(1) {
    grid-column: 1 / 3;
    grid-row: 1;
    text-align: left;
  }

  /* Quantité et corbeille : placées directement dans la grille */
  .tableau-panier tbody td:nth-child(2) {
    display: contents;
  }

  .tableau-panier tbody td:nth-child(2) > div {
    grid-column: 1;
    grid-row: 2;
  }

  .tableau-panier tbody td:nth-child(2) > button {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
  }

  .tableau-panier tbody td:nth-child(2) .btn {
    min-width: 2.5rem;
    height: 2.5rem;
  }

  .tableau-panier tbody td:nth-child(2) input {
    width: 3rem;
  }

  /* Prix unitaire et total de la ligne */
  .tableau-panier tbody td:nth-child(3) {
    grid-column: 2;
    grid-row: 2;
    text-align: left;
    white-space: nowrap;
  }

  .tableau-panier tbody td:nth-child(3)::before {
    content: "× ";
  }

  .tableau-panier tbody td:nth-child(4) {
    grid-column: 3;
    grid-row: 2;
    text-align: right;
    font-weight: 600;
    white-space: nowrap;
  }

  .tableau-panier tbody td:nth-child(4)::before {
    content: "= ";
  }

  .tableau-panier tfoot tr {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.375rem 0;
  }

  .tableau-panier tfoot td {
    display: block;
    padding: 0;
    border: 0;
    text-align: left;
    white-space: normal;
  }

  .tableau-panier tfoot td:last-child {
    text-align: right;
    white-space: nowrap;
  }
}
