/* ===========================================================
   MealGen — generator page (index.php)
   Scoped under .mg. Design tokens (:root) and the shared .mg-btn
   base/primary variants live in theme.css, which loads first.
   This file adds only generator-specific layout + the ghost button.
   =========================================================== */

.mg{
  color:var(--ink);
  font-family:Arial, "Helvetica Neue", Helvetica, sans-serif;
  -webkit-font-smoothing:antialiased;
}

.mg *,
.mg *::before,
.mg *::after{ box-sizing:border-box; }

.mg-container{
  width:100%;
  max-width:var(--maxw);
  margin:0 auto;
  padding:0 20px;
}

/* ---------- Ghost button (generator-specific) ---------- */
.mg-btn--ghost{
  background-color:#fff;
  color:var(--brand-dark) !important;
  border-color:var(--line-strong);
  padding:12px 20px;
  font-size:1rem;
  white-space:nowrap;
}
.mg-btn--ghost:hover,
.mg-btn--ghost:focus{
  background-color:var(--brand-soft);
  border-color:var(--brand);
}
.mg-btn--ghost:focus-visible{ outline:none; box-shadow:var(--focus); }

/* ---------- Section heads ---------- */
.mg-section-head{ text-align:center; margin:0 auto 36px; max-width:640px; }
.mg-section-head h2{
  font-family:inherit;
  font-size:2rem;
  font-weight:800;
  line-height:1.15;
  margin:0 0 10px;
  color:var(--ink);
}
.mg-section-head p{ font-size:1.125rem; color:var(--muted); margin:0; }

/* ===========================================================
   HERO
   =========================================================== */
.mg-hero{
  background:linear-gradient(160deg, #ffffff 0%, #dcf0f3 55%, #c1e0e6 100%);
  padding:64px 0 72px;
  overflow:hidden;
}
.mg-hero__grid{
  display:grid;
  grid-template-columns:1.1fr .9fr;
  align-items:center;
  gap:40px;
}
.mg-hero__eyebrow{
  font-size:1rem;
  font-weight:700;
  color:var(--brand-dark);
  margin:0 0 12px;
  letter-spacing:.2px;
}
.mg-hero__title{
  font-family:inherit;
  font-size:clamp(2.1rem, 4.6vw, 3.3rem);
  font-weight:800;
  line-height:1.08;
  color:var(--ink);
  margin:0 0 18px;
}
.mg-hero__lead{
  font-size:1.2rem;
  line-height:1.6;
  color:#33484b;
  margin:0 0 26px;
  max-width:520px;
}
.mg-hero__lead a{ color:var(--brand-dark); font-weight:700; }

.mg-hero__actions{
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:14px 18px;
  margin-bottom:24px;
}
.mg-hero__free{ font-size:.95rem; font-weight:600; color:var(--muted); }

.mg-hero__points{
  list-style:none;
  margin:0;
  padding:0;
  display:flex;
  flex-direction:column;
  gap:8px;
}
.mg-hero__points li{
  position:relative;
  padding-left:28px;
  font-size:1rem;
  color:#33484b;
}
.mg-hero__points li::before{
  content:"✓";
  position:absolute;
  left:0;
  top:-1px;
  width:20px; height:20px;
  display:inline-flex; align-items:center; justify-content:center;
  background:var(--brand);
  color:#fff;
  font-size:.75rem;
  font-weight:800;
  border-radius:50%;
}

/* Hero visual (SVG plate) */
.mg-hero__visual{ display:flex; flex-direction:column; align-items:center; gap:16px; }
.mg-plate{
  width:min(360px, 80%);
  height:auto;
  filter:drop-shadow(0 18px 40px rgb(15 40 45 / 14%));
}
.mg-plate__legend{
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap:6px 18px;
}
.mg-plate__legend span{
  display:inline-flex;
  align-items:center;
  gap:7px;
  font-size:.9rem;
  font-weight:600;
  color:var(--ink);
}
.mg-plate__legend i{
  width:12px; height:12px; border-radius:3px; display:inline-block;
}

/* ===========================================================
   CREDIBILITY STRIP (raised trust cues, above the form)
   =========================================================== */
.mg-trustbar{
  list-style:none;
  margin:0 auto 32px;
  padding:0;
  max-width:820px;
  display:grid;
  grid-template-columns:repeat(4, 1fr);
  gap:0;
  background:var(--white);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow-sm);
  overflow:hidden;
}
.mg-trustbar li{
  display:flex;
  flex-direction:column;
  gap:4px;
  padding:16px 18px;
  border-left:1px solid var(--line);
  text-align:center;
  align-items:center;
}
.mg-trustbar li:first-child{ border-left:0; }
.mg-trustbar__k{
  font-size:.72rem;
  text-transform:uppercase;
  letter-spacing:.5px;
  font-weight:700;
  color:var(--muted);
}
.mg-trustbar__v{ font-size:1rem; font-weight:800; color:var(--ink); }
.mg-trustbar__v a{ color:var(--brand-dark); text-decoration:none; }
.mg-trustbar__v a:hover{ text-decoration:underline; }

/* ===========================================================
   GENERATOR FORM
   =========================================================== */
.mg-generator{ background:var(--bg); padding:64px 0; }

.mg-form{
  max-width:640px;
  margin:0 auto;
  background:var(--white);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow-lg);
  padding:32px;
}

/* ---------- Wizard: progress indicator ---------- */
.mg-progress{
  display:none;                 /* revealed by JS when the wizard is active */
  list-style:none;
  margin:0 0 28px;
  padding:0;
  counter-reset:none;
}
.mg-wizard-on .mg-progress{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
}
.mg-progress__step{
  position:relative;
  flex:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:8px;
  text-align:center;
}
/* connector line between dots */
.mg-progress__step::before{
  content:"";
  position:absolute;
  top:15px;
  left:-50%;
  width:100%;
  height:2px;
  background:var(--line-strong);
  z-index:0;
}
.mg-progress__step:first-child::before{ display:none; }
.mg-progress__dot{
  position:relative;
  z-index:1;
  width:32px; height:32px;
  display:inline-flex; align-items:center; justify-content:center;
  border-radius:50%;
  background:#fff;
  border:2px solid var(--line-strong);
  color:var(--muted);
  font-size:.9rem;
  font-weight:800;
  transition:background-color .2s ease, border-color .2s ease, color .2s ease;
}
.mg-progress__label{
  font-size:.85rem;
  font-weight:700;
  color:var(--muted);
  transition:color .2s ease;
}
.mg-progress__step.is-active .mg-progress__dot{
  background:var(--brand);
  border-color:var(--brand);
  color:#fff;
  box-shadow:var(--focus);
}
.mg-progress__step.is-active .mg-progress__label{ color:var(--brand-dark); }
.mg-progress__step.is-done .mg-progress__dot{
  background:var(--brand-dark);
  border-color:var(--brand-dark);
  color:#fff;
}
.mg-progress__step.is-done .mg-progress__dot::after{ content:"✓"; }
.mg-progress__step.is-done .mg-progress__dot{ font-size:0; }
.mg-progress__step.is-done .mg-progress__dot::after{ font-size:.95rem; }
.mg-progress__step.is-done::before{ background:var(--brand-dark); }
.mg-progress__step.is-active::before{ background:var(--brand-dark); }

/* ---------- Wizard: step visibility ---------- */
.mg-step{
  border:0;
  padding:0;
  margin:0 0 32px;
}
.mg-step:last-of-type{ margin-bottom:24px; }
/* When the wizard is active, only the current step shows.
   Hidden steps also get [hidden] so their required fields aren't validated. */
.mg-wizard-on .mg-step{ margin-bottom:8px; }
.mg-wizard-on .mg-step[hidden]{ display:none; }

.mg-step__legend{
  display:flex;
  align-items:center;
  gap:12px;
  width:100%;
  font-size:1.25rem;
  font-weight:800;
  color:var(--ink);
  padding:0 0 14px;
  margin:0 0 20px;
  border-bottom:1px solid var(--line);
}
.mg-step__num{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:30px;
  height:30px;
  border-radius:50%;
  background:var(--brand);
  color:#fff;
  font-size:.95rem;
  font-weight:800;
  flex:0 0 auto;
}

.mg-field{ margin-bottom:20px; }
.mg-field:last-child{ margin-bottom:0; }

.mg-grid-2{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:20px;
  margin-bottom:20px;
}
.mg-grid-2 .mg-field{ margin-bottom:0; }

.mg-label{
  display:block;
  font-size:.95rem;
  font-weight:700;
  color:var(--ink);
  margin-bottom:8px;
}
.mg-req{ color:#e05252; }

.mg-hint{
  font-size:.85rem;
  color:var(--muted);
  margin:8px 0 0;
  line-height:1.4;
}
.mg-hint--center{ text-align:center; }

/* ---------- Inputs ---------- */
.mg-input{
  width:100%;
  height:48px;
  padding:0 14px;
  font-size:1rem;
  font-family:inherit;
  color:var(--ink);
  background:#fff;
  border:1px solid var(--line-strong);
  border-radius:var(--radius-sm);
  transition:border-color .15s ease, box-shadow .15s ease;
  -moz-appearance:textfield;
}
.mg-input::placeholder{ color:#9bacae; }
.mg-input:hover{ border-color:#a9bcbe; }
.mg-input:focus{
  outline:none;
  border-color:var(--brand);
  box-shadow:var(--focus);
}
.mg-input::-webkit-outer-spin-button,
.mg-input::-webkit-inner-spin-button{ -webkit-appearance:none; margin:0; }

.mg-input-pair{ display:flex; gap:12px; }
.mg-input-pair .mg-input-suffix{ flex:1; }

/* suffix badge (kg / cm / kcal) */
.mg-input-suffix{ position:relative; }
.mg-input-suffix .mg-input{ padding-right:52px; }
.mg-input-suffix::after{
  content:attr(data-suffix);
  position:absolute;
  right:14px;
  top:50%;
  transform:translateY(-50%);
  font-size:.9rem;
  font-weight:700;
  color:var(--muted);
  pointer-events:none;
}

.mg-input--search{ background-position:14px center; }

/* ---------- Choice cards (radios) ---------- */
.mg-choice{ display:grid; gap:10px; }
.mg-choice--2{ grid-template-columns:1fr 1fr; }
.mg-choice--stack{ grid-template-columns:1fr; }

.mg-choice__input{
  position:absolute;
  opacity:0;
  width:1px; height:1px;
  pointer-events:none;
}
.mg-choice__card{
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  gap:8px;
  min-height:48px;
  padding:12px 16px;
  font-size:.98rem;
  font-weight:600;
  color:var(--ink);
  background:#fff;
  border:1.5px solid var(--line-strong);
  border-radius:var(--radius-sm);
  cursor:pointer;
  transition:border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.mg-choice__card--wide{ justify-content:flex-start; text-align:left; }

.mg-choice__card:hover{ border-color:var(--brand); background:var(--brand-soft); }

.mg-choice__input:checked + .mg-choice__card{
  border-color:var(--brand);
  background:var(--brand-soft);
  color:var(--brand-dark);
  box-shadow:inset 0 0 0 1px var(--brand);
  font-weight:700;
}
.mg-choice__input:focus-visible + .mg-choice__card{
  box-shadow:var(--focus);
}
.mg-choice__input:checked + .mg-choice__card--wide::before{
  content:"✓";
  color:var(--brand);
  font-weight:800;
  margin-right:2px;
}

/* ---------- Calorie flow ---------- */
.mg-calorie{
  display:flex;
  align-items:flex-end;
  gap:16px;
  padding:20px;
  background:var(--brand-soft);
  border:1px solid rgb(64 176 191 / 25%);
  border-radius:var(--radius-sm);
}
.mg-calorie__result{ flex:1; margin-bottom:0; }

/* ---------- Exclusions list ---------- */
.mg-exclusions{
  list-style:none;
  margin:0;
  padding:0;
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}
/* NOTE: do NOT set `display:none` here. scripts.js toggles visibility by
   assigning li.style.display = "none" (hide) / "" (show). A CSS default of
   `none` would win when JS clears the inline style, so matched items would
   never appear. Items start hidden because zeroResults() sets them inline
   on load; when shown, the inline "" falls back to inline-block below. */
.mg-exclusions li{ display:inline-block; }
.mg-exclusions li p{
  margin:0;
  padding:8px 14px;
  font-size:.9rem;
  font-weight:600;
  color:var(--ink);
  background:#fff;
  border:1px solid var(--line-strong);
  border-radius:999px;
  cursor:pointer;
  user-select:none;
  transition:border-color .12s ease, background-color .12s ease;
}
.mg-exclusions li p:hover{ border-color:var(--brand); background:var(--brand-soft); }
/* JS sets text-decoration:line-through on excluded items */
.mg-exclusions li p[style*="line-through"]{
  background:#fdeaea;
  border-color:#e7a7a7;
  color:#b84a4a;
}

/* ---------- Wizard navigation ---------- */
.mg-nav{
  display:flex;
  align-items:stretch;         /* all three buttons share the row height */
  gap:12px;
  margin-top:20px;
}
.mg-nav__next,
.mg-nav__submit{ margin-left:auto; }        /* push forward action to the right */

/* Size the ghost "Retour" to match the --lg forward buttons on the row. */
.mg-nav__back{
  padding:16px 24px;
  font-size:1.05rem;
}

/* Default (JS OFF): plain single-page form — show submit, hide wizard nav. */
.mg-nav__back,
.mg-nav__next{ display:none; }
.mg-nav__submit{ display:inline-flex; }

/* Wizard ON: JS toggles [hidden] on the three buttons per step.
   The submit is #form-button, whose legacy rule sets display with ID
   specificity, so its visibility rules must also use the ID to win. */
.mg-wizard-on .mg-nav__back[hidden],
.mg-wizard-on .mg-nav__next[hidden]{ display:none; }
.mg-wizard-on .mg-nav__back:not([hidden]){ display:inline-flex; }
.mg-wizard-on .mg-nav__next:not([hidden]){ display:inline-flex; }
.mg-wizard-on #form-button.mg-nav__submit[hidden]{ display:none !important; }
.mg-wizard-on #form-button.mg-nav__submit:not([hidden]){ display:inline-flex !important; }

/* Invalid-field highlight during per-step validation */
.mg-input.mg-invalid,
.mg-choice.mg-invalid .mg-choice__card{
  border-color:#e05252 !important;
  box-shadow:0 0 0 3px rgb(224 82 82 / 18%);
}
.mg-step__error{
  display:none;
  margin:12px 0 0;
  padding:10px 14px;
  background:#fdeaea;
  border:1px solid #e7a7a7;
  border-radius:var(--radius-sm);
  color:#b84a4a;
  font-size:.9rem;
  font-weight:600;
}
.mg-step__error.is-shown{ display:block; }

/* ---------- Submit / disclaimer ---------- */
.mg-submit{ text-align:center; margin-top:8px; }
.mg-disclaimer-note{
  font-size:.82rem;
  color:var(--muted);
  margin:14px 0 0;
}

/* Reset the legacy #form-button (styles.css) so the "Générer mon menu"
   submit matches its .mg-btn / .mg-btn--lg wizard-nav siblings.
   The legacy rule wins on ID specificity + !important, so we override
   padding / font-size / radius / shadow explicitly here. */
.mg #form-button{
  padding:16px 30px;                 /* == .mg-btn--lg */
  font-size:1.125rem !important;     /* beats legacy responsive calc() font-size */
  line-height:1.2 !important;
  font-weight:700;
  border-radius:var(--radius-sm);
  background-color:var(--brand) !important;
  color:#fff !important;
  border:1px solid transparent !important;
  box-shadow:var(--shadow-sm);
  transition:background-color .18s ease, box-shadow .18s ease, transform .05s ease;
}
.mg #form-button:hover,
.mg #form-button:focus{
  background-color:var(--brand-dark) !important;
  box-shadow:var(--shadow);
}
.mg #form-button:active{ background-color:var(--brand-dark) !important; transform:translateY(1px); }
.mg #form-button:focus-visible{ outline:none; box-shadow:var(--focus); }

/* Override legacy #form-button-small (solid teal + !important) so the
   "Calculer" button renders as the ghost variant defined above. */
.mg #form-button-small.mg-btn--ghost{
  background-color:#fff !important;
  color:var(--brand-dark) !important;
  border-color:var(--line-strong) !important;
  box-shadow:none;
}
.mg #form-button-small.mg-btn--ghost:hover,
.mg #form-button-small.mg-btn--ghost:focus{
  background-color:var(--brand-soft) !important;
  border-color:var(--brand) !important;
}

/* ===========================================================
   FEATURES
   =========================================================== */
.mg-features{ background:#fff; padding:72px 0; }

.mg-feature-grid{
  display:grid;
  grid-template-columns:repeat(3, 1fr);
  gap:24px;
}
.mg-card{
  background:#fff;
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow-sm);
  padding:28px 24px;
  transition:box-shadow .2s ease, transform .2s ease;
}
.mg-card:hover{ box-shadow:var(--shadow); transform:translateY(-3px); }
.mg-card__icon{
  width:52px; height:52px;
  display:flex; align-items:center; justify-content:center;
  font-size:1.6rem;
  background:var(--brand-soft);
  border-radius:12px;
  margin-bottom:16px;
}
.mg-card__title{
  font-size:1.15rem;
  font-weight:800;
  color:var(--ink);
  margin:0 0 10px;
  line-height:1.25;
}
.mg-card__body{
  font-size:.98rem;
  line-height:1.55;
  color:var(--muted);
  margin:0;
}

.mg-features__cta{ text-align:center; margin-top:44px; }

/* ===========================================================
   RESPONSIVE
   =========================================================== */
@media (max-width:900px){
  .mg-hero__grid{ grid-template-columns:1fr; text-align:center; gap:28px; }
  .mg-hero__lead{ margin-left:auto; margin-right:auto; }
  .mg-hero__actions{ justify-content:center; }
  .mg-hero__points{ display:inline-flex; text-align:left; }
  .mg-hero__visual{ order:-1; }          /* plate above text on small screens */
  .mg-trustbar{ grid-template-columns:repeat(2, 1fr); }
  .mg-trustbar li:nth-child(odd){ border-left:0; }
  .mg-trustbar li:nth-child(3),
  .mg-trustbar li:nth-child(4){ border-top:1px solid var(--line); }
}

@media (max-width:768px){
  .mg-hero{ display:none; }        /* hide the entire hero on mobile */
  .mg-generator{ padding:44px 0; }
  .mg-features{ padding:52px 0; }

  .mg-form{ padding:22px; }
  .mg-grid-2{ grid-template-columns:1fr; gap:16px; }
  .mg-feature-grid{ grid-template-columns:1fr; }

  .mg-calorie{ flex-direction:column; align-items:stretch; }
  .mg-calorie .mg-btn--ghost{ width:100%; }

  .mg-progress__label{ font-size:.75rem; }

  /* Stack wizard nav; keep forward action first (visually prominent) */
  .mg-nav{ flex-wrap:wrap; }
  .mg-nav__next,
  .mg-nav__submit{ order:-1; width:100%; margin-left:0; }
  .mg-wizard-on .mg-nav__back:not([hidden]){ width:100%; }
}

@media (min-width:769px) and (max-width:991px){
  .mg-feature-grid{ grid-template-columns:repeat(2, 1fr); }
}

@media (max-width:480px){
  .mg-trustbar{ grid-template-columns:1fr; }
  .mg-trustbar li{ border-left:0 !important; border-top:1px solid var(--line); }
  .mg-trustbar li:first-child{ border-top:0; }
}

@media (max-width:420px){
  .mg-choice--2{ grid-template-columns:1fr; }
}
