/* =============================================================
   style.css — Carte cocktails Meanwhile
   -------------------------------------------------------------
   Organisation :
   1. Variables (couleurs de la marque, tailles)
   2. Base
   3. En-tête
   4. Filtres
   5. Sections & cartes cocktail
   6. Barre du bas + ticket
   ============================================================= */

/* ---------- 1. VARIABLES ----------
   Les "custom properties" CSS (--nom) permettent de changer une couleur
   à un seul endroit. Les couleurs viennent directement du logo. */
:root {
  --navy: #223353;      /* bleu du logo */
  --navy-soft: #3a4d72;
  --red: #db314d;       /* rouge du logo */
  --red-dark: #b8233c;
  --cream: #f7f3ec;     /* fond papier, plus chaleureux que du blanc pur */
  --paper: #ffffff;
  --ink: #1a2238;
  --muted: #6b7489;
  --line: #e4ddd1;
  --mint: #2f8f6b;      /* vert pour les mocktails */

  --radius: 16px;
  --shadow: 0 1px 2px rgba(34, 51, 83, .06), 0 8px 24px rgba(34, 51, 83, .08);
  --font-title: "Fraunces", Georgia, serif;
  --font-text: "Inter", system-ui, -apple-system, sans-serif;
}

/* ---------- 2. BASE ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-text);
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
  /* espace en bas pour que la barre fixe ne cache pas la dernière carte */
  padding-bottom: 110px;
}

button { font: inherit; cursor: pointer; }

/* ---------- 3. EN-TÊTE ---------- */
.hero {
  background: var(--navy);
  color: #fff;
  text-align: center;
  padding: 40px 16px 48px;
  position: relative;
  overflow: hidden;
}

/* Le logo est bleu foncé sur fond transparent : on le pose sur une
   "pastille" blanche pour qu'il reste lisible sur le fond bleu. */
.hero__logo {
  width: min(260px, 70vw);
  background: #fff;
  padding: 14px 22px;
  border-radius: 999px;
}

.hero__kicker {
  margin: 28px 0 4px;
  text-transform: uppercase;
  letter-spacing: .18em;
  font-size: .75rem;
  color: #ffb3c0;
}

.hero__title {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: clamp(2rem, 7vw, 3.2rem); /* clamp = taille fluide min/idéale/max */
  margin: 0;
  line-height: 1.05;
}

.hero__hint {
  margin: 14px auto 0;
  max-width: 32ch;
  color: rgba(255, 255, 255, .78);
}

/* ---------- 4. FILTRES ---------- */
.filters {
  position: sticky;   /* reste collé en haut pendant le scroll */
  top: 0;
  z-index: 10;
  background: rgba(247, 243, 236, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.filters__scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;              /* défilement horizontal sur mobile */
  padding: 12px 16px;
  max-width: 900px;
  margin: 0 auto;
  scrollbar-width: none;
}
.filters__scroll::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--navy);
  padding: 8px 14px;
  min-height: 42px; /* zone tactile confortable (Apple recommande 44px) */
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.chip[aria-pressed="true"] {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

/* ---------- 5. SECTIONS & CARTES ---------- */
.menu {
  max-width: 900px;
  margin: 0 auto;
  padding: 8px 16px;
  scroll-margin-top: 60px; /* hauteur des filtres collants */
}

.section { margin-top: 32px; }

.section__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}
.section__title {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--navy);
  margin: 0;
}
.section__sub { color: var(--mint); font-weight: 600; font-size: .85rem; }

/* Grille : 1 colonne sur mobile, 2 dès que l'écran est assez large.
   auto-fill + minmax fait ça tout seul, sans media query. */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  gap: 14px;
  align-items: center;
  border: 2px solid transparent;
  transition: border-color .15s, transform .15s;
}
/* Quand le cocktail est dans le ticket, on le met en évidence */
.card.is-selected { border-color: var(--red); }

.card__body { flex: 1; min-width: 0; }

.card__name {
  font-family: var(--font-title);
  font-weight: 500;
  font-size: 1.15rem;
  margin: 0 0 4px;
  color: var(--navy);
}
.card__ingredients {
  margin: 0;
  font-size: .88rem;
  color: var(--muted);
  line-height: 1.45;
}
.badge {
  display: inline-block;
  margin-top: 8px;
  font-size: .72rem;
  font-weight: 600;
  color: var(--mint);
  background: #e6f4ee;
  padding: 3px 8px;
  border-radius: 999px;
}

/* Le compteur − 0 + */
.qty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.qty__btn {
  width: 40px; height: 40px;   /* 40px minimum : facile à toucher au doigt */
  border-radius: 50%;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  display: grid;
  place-items: center;
}
.qty__btn--add { background: var(--red); color: #fff; }
.qty__btn--add:active { background: var(--red-dark); }
.qty__btn--remove { background: #eef0f5; color: var(--navy); }
.qty__btn:disabled { opacity: .35; cursor: default; }
.qty__value { font-weight: 600; min-width: 2ch; text-align: center; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}

.foot {
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
  padding: 40px 16px 0;
}

/* ---------- 6. BARRE DU BAS + TICKET ---------- */
.cartbar {
  position: fixed;
  left: 16px; right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom)); /* évite l'encoche iPhone */
  max-width: 520px;
  margin: 0 auto;
  background: var(--red);
  color: #fff;
  border-radius: 999px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 30px rgba(219, 49, 77, .35);
  border: none;
  text-align: left;
  font-size: 1rem;
  font-weight: 600;
  z-index: 20;
  animation: pop .25s ease-out;
}
/* L'attribut [hidden] doit gagner sur display:flex */
.cartbar[hidden] { display: none; }

.cartbar__count {
  background: #fff;
  color: var(--red);
  border-radius: 999px;
  min-width: 28px; height: 28px;
  display: grid; place-items: center;
  font-size: .9rem;
}
.cartbar__label { flex: 1; }

@keyframes pop {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* Le <dialog> natif */
.ticket {
  border: none;
  padding: 0;
  background: transparent;
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  /* dvh = "dynamic viewport height" : tient compte de la barre d'adresse
     qui apparaît/disparaît sur mobile. Les vieux navigateurs gardent vh. */
  max-height: calc(100dvh - 32px);
  overflow-y: auto; /* si le ticket est plus haut que l'écran (paysage), on peut défiler */
  overscroll-behavior: contain; /* le scroll ne "fuit" pas vers la page derrière */
}
.ticket::backdrop { background: rgba(26, 34, 56, .6); }

.ticket__paper {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 28px 22px 22px;
  text-align: center;
  position: relative;
  border-top: 6px solid var(--red); /* rappel du rouge de la marque */
}
.ticket__close {
  position: absolute; top: 6px; right: 6px;
  width: 44px; height: 44px; /* la croix reste petite, mais la zone cliquable est grande */
  border: none; background: none;
  font-size: 1.8rem; color: var(--muted);
}

/* Téléphone en paysage : peu de hauteur, on compacte le ticket */
@media (max-height: 500px) {
  .ticket__paper { padding: 16px 18px; }
  .ticket__logo { width: 80px; }
  .ticket__kicker { margin-top: 6px; }
  .ticket__name { font-size: 1.4rem; }
  .ticket__list li { padding: 8px 0; font-size: 1.1rem; }
}
.ticket__logo { width: 120px; }
.ticket__kicker {
  margin: 14px 0 4px;
  text-transform: uppercase;
  letter-spacing: .15em;
  font-size: .72rem;
  color: var(--muted);
}
.ticket__name {
  width: 100%;
  font-family: var(--font-title);
  font-size: 1.8rem;
  text-align: center;
  border: none;
  border-bottom: 2px dashed var(--line);
  padding: 4px 0 8px;
  color: var(--navy);
  outline: none;
}
.ticket__name:focus { border-bottom-color: var(--red); }

.ticket__list {
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
  text-align: left;
}
.ticket__list li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--line);
  /* gros texte : le barman doit pouvoir lire de loin */
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--navy);
}
.ticket__list .q { color: var(--red); min-width: 2.2ch; }
.ticket__list .tag { margin-left: auto; font-size: .75rem; color: var(--mint); }

.ticket__total { margin: 14px 0 0; color: var(--muted); }

.ticket__status { min-height: 1.4em; margin: 10px 0; font-weight: 600; }
.ticket__status.is-error { color: var(--red); }
.ticket__status.is-ok { color: var(--mint); }

.btn {
  display: block;
  width: 100%;
  margin-top: 10px;
}
.btn[hidden] { display: none; } /* sinon display:block l'emporte sur hidden */
.btn--primary {
  border: none;
  background: var(--red);
  color: #fff;
  font-weight: 600;
  font-size: 1.05rem;
  padding: 14px 18px;
  border-radius: 999px;
}
.btn--primary:active { background: var(--red-dark); }
.btn--primary:disabled { opacity: .5; cursor: default; }

/* Écran de confirmation après envoi */
.ticket__done { padding: 10px 0 4px; }
.ticket__done-icon { font-size: 3rem; }
.ticket__done-title {
  font-family: var(--font-title);
  font-size: 1.6rem;
  color: var(--navy);
  margin: 6px 0;
}
.ticket__done-text { color: var(--muted); margin: 0 0 10px; }

.btn--ghost {
  border: 1px solid var(--line);
  background: none;
  color: var(--muted);
  padding: 10px 18px;
  border-radius: 999px;
}

/* Accessibilité : si l'utilisateur a demandé moins d'animations */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* =============================================================
   7. MODE OPEN BAR
   body[data-mode="openbar"] est posé par applyMode() dans app.js :
   un seul attribut sur <body> suffit à changer l'apparence de toute la page.
   ============================================================= */
.openbar-banner {
  background: linear-gradient(90deg, var(--red), #e8576f);
  color: #fff;
  text-align: center;
  padding: 14px 16px;
  display: grid;
  gap: 2px;
  font-size: .95rem;
}
.openbar-banner[hidden] { display: none; }
.openbar-banner strong { font-size: 1.1rem; }

/* En open bar, la carte entière est cliquable */
body[data-mode="openbar"] .card { cursor: pointer; }
body[data-mode="openbar"] .card:active { transform: scale(.98); }

.recipe-btn {
  flex: none;
  border: 2px solid var(--red);
  background: #fff;
  color: var(--red);
  font-weight: 600;
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 44px;
  white-space: nowrap;
}

/* ---------- Fiche recette ---------- */
/* Elle réutilise le style du ticket (.ticket / .ticket__paper) et ajoute le sien */
.recipe .ticket__paper { text-align: left; }
.recipe .ticket__kicker { margin-top: 0; }
.recipe__name {
  font-family: var(--font-title);
  font-size: 1.9rem;
  color: var(--navy);
  margin: 4px 40px 6px 0; /* marge à droite : on ne passe pas sous la croix */
  line-height: 1.1;
}
.recipe__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 4px;
}
.recipe__meta span {
  background: var(--cream);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: .88rem;
  font-weight: 500;
  color: var(--navy);
}

/* Liste numérotée avec des pastilles rouges.
   counter-reset / counter-increment = compteur CSS : on numérote nous-mêmes
   pour pouvoir styler le numéro librement (impossible avec les puces natives). */
.recipe__steps {
  list-style: none;
  counter-reset: step;
  padding: 0;
  margin: 18px 0 0;
}
.recipe__steps li {
  counter-increment: step;
  position: relative;
  padding: 0 0 16px 44px;
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--ink);
}
.recipe__steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -2px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-size: .95rem;
}
/* Petit trait vertical qui relie les étapes */
.recipe__steps li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 14px;
  top: 32px;
  bottom: 4px;
  width: 2px;
  background: var(--line);
}
.recipe__steps strong { color: var(--red); white-space: nowrap; }

.recipe__tip {
  background: #fff4d6;
  border-radius: 12px;
  padding: 12px 14px;
  margin: 6px 0 10px;
  font-size: .92rem;
  line-height: 1.45;
}
.recipe__hint { margin: 4px 0; font-size: .82rem; color: var(--muted); }

@media (max-height: 500px) {
  .recipe__name { font-size: 1.5rem; }
  .recipe__steps li { padding-bottom: 10px; font-size: .98rem; }
}
#recipeBody:focus { outline: none; } /* reçoit le focus à l'ouverture, sans contour visible */
